coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_init.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <
stdint.h
>
4
#include <
string.h
>
5
#include <
console/console.h
>
6
#include <
northbridge/intel/sandybridge/raminit_native.h
>
7
#include <
southbridge/intel/bd82x6x/pch.h
>
8
#include <
southbridge/intel/common/gpio.h
>
9
#include <
cbfs.h
>
10
11
const
struct
southbridge_usb_port
mainboard_usb_ports
[] = {
12
/* enabled, current, OC pin */
13
{ 0, 3, 0 },
/* P00 disconnected */
14
{ 1, 1, 1 },
/* P01 left or right */
15
{ 0, 1, 3 },
/* P02 disconnected */
16
{ 1, 3, -1 },
/* P03 WWAN */
17
{ 0, 1, 2 },
/* P04 disconnected */
18
{ 0, 1, -1 },
/* P05 disconnected */
19
{ 0, 1, -1 },
/* P06 disconnected */
20
{ 0, 2, -1 },
/* P07 disconnected */
21
{ 0, 1, -1 },
/* P08 disconnected */
22
{ 1, 2, 5 },
/* P09 left or right */
23
{ 1, 3, -1 },
/* P10 FPR */
24
{ 1, 3, -1 },
/* P11 Bluetooth */
25
{ 1, 1, -1 },
/* P12 WLAN */
26
{ 1, 1, -1 },
/* P13 Camera */
27
};
28
29
static
uint8_t
*
get_spd_data
(
int
spd_index
)
30
{
31
uint8_t
*spd_file;
32
size_t
spd_file_len;
33
34
printk
(
BIOS_DEBUG
,
"spd index %d\n"
,
spd_index
);
35
spd_file =
cbfs_map
(
"spd.bin"
, &spd_file_len);
36
if
(!spd_file)
37
die
(
"SPD data not found."
);
38
39
if
(spd_file_len <
spd_index
* 256)
40
die
(
"Missing SPD data."
);
41
42
return
spd_file +
spd_index
* 256;
43
}
44
45
void
mainboard_get_spd
(
spd_raw_data
*spd,
bool
id_only)
46
{
47
uint8_t
*
memory
;
48
const
int
spd_gpio_vector[] = {25, 45, -1};
49
int
spd_index
=
get_gpios
(spd_gpio_vector);
50
51
/* 4gb model = 0, 8gb model = 1 */
52
/* int extended_memory_version = get_gpio(44); */
53
54
/*
55
* So far there is no need to parse gpio 44, as the 4GiB use
56
* the hynix or elpida memory and 8 GiB versions use samsung.
57
* All version use both channels.
58
* But we might miss some versions.
59
*/
60
61
/*
62
* GPIO45 GPIO25
63
* 0 0 elpida
64
* 0 1 hynix
65
* 1 0 samsung
66
* 1 1 reserved
67
*/
68
69
if
(
spd_index
== 3)
70
die
(
"Unsupported Memory. (detected 'reserved' memory configuration)."
);
71
72
memory
=
get_spd_data
(
spd_index
);
73
memcpy
(&spd[0],
memory
, 256);
74
memcpy
(&spd[2],
memory
, 256);
75
}
memcpy
void * memcpy(void *dest, const void *src, size_t n)
Definition:
memcpy.c:7
cbfs.h
cbfs_map
static void * cbfs_map(const char *name, size_t *size_out)
Definition:
cbfs.h:246
printk
#define printk(level,...)
Definition:
stdlib.h:16
die
void __noreturn die(const char *fmt,...)
Definition:
die.c:17
console.h
spd_raw_data
u8 spd_raw_data[256]
Definition:
ddr3.h:156
BIOS_DEBUG
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition:
loglevel.h:128
mainboard_get_spd
void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Definition:
early_init.c:25
mainboard_usb_ports
const struct southbridge_usb_port mainboard_usb_ports[]
Definition:
early_init.c:8
spd_index
static const int spd_index[32]
Definition:
memory.c:10
get_spd_data
static uint8_t * get_spd_data(int spd_index)
Definition:
early_init.c:29
memory
static const PCI_SUBCLASS memory[]
Definition:
pci_class.c:66
raminit_native.h
pch.h
get_gpios
unsigned int get_gpios(const int *gpio_num_array)
Definition:
gpio.c:107
gpio.h
stdint.h
uint8_t
unsigned char uint8_t
Definition:
stdint.h:8
string.h
southbridge_usb_port
Definition:
pch.h:56
src
mainboard
lenovo
x1_carbon_gen1
early_init.c
Generated by
1.9.1