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-or-later */
2 
3 #include <bootblock_common.h>
8 
11 
12 #include <option.h>
13 
14 #define SERIAL_DEV PNP_DEV(0x2e, NCT6779D_SP1)
15 
17  /* {enable, current, oc_pin} */
18  {1, 2, 0}, /* Port 0: USB3 front internal header, top */
19  {1, 2, 0}, /* Port 1: USB3 front internal header, bottom */
20  {1, 2, 1}, /* Port 2: USB3 rear, top */
21  {1, 2, 1}, /* Port 3: USB3 rear, bottom */
22  {1, 2, 2}, /* Port 4: USB2 rear, PS2 top */
23  {1, 2, 2}, /* Port 5: USB2 rear, PS2 bottom */
24  {1, 2, 3}, /* Port 6: USB2 rear, ETH, top */
25  {1, 2, 3}, /* Port 7: USB2 rear, ETH, bottom */
26  {1, 2, 4}, /* Port 8: USB2 internal header USB910, top */
27  {1, 2, 4}, /* Port 9: USB2 internal header USB910, bottom */
28  {1, 2, 6}, /* Port 10: USB2 internal header USB1112, top */
29  {1, 2, 5}, /* Port 11: USB2 internal header USB1112, bottom */
30  {1, 2, 5}, /* Port 12: USB2 internal header USB1314, top */
31  {1, 2, 6} /* Port 13: USB2 internal header USB1314, bottom */
32 };
33 
35 {
36  nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
37 
38  /*
39  * TODO: Put PCIe root port 7 (00:1c.6) into subtractive decode and have it accept I/O
40  * cycles. This should allow a POST card in the PCI slot, connected via an ASM1083
41  * bridge to this port, to receive POST codes.
42  */
43 }
44 
45 void mainboard_get_spd(spd_raw_data *spd, bool id_only)
46 {
47  read_spd(&spd[0], 0x50, id_only);
48  read_spd(&spd[1], 0x51, id_only);
49  read_spd(&spd[2], 0x52, id_only);
50  read_spd(&spd[3], 0x53, id_only);
51 }
52 
53 int mainboard_should_reset_usb(int s3resume)
54 {
55  return !s3resume;
56 }
57 
59 {
60  uint8_t spdaddr[] = {0xa0, 0xa2, 0xa4, 0xa6}; /* SMBus mul 2 */
61  uint16_t usbcfg[16][3] = {
62  /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */
63  {1, 0, 0x0080}, {1, 0, 0x0080}, {1, 1, 0x0080}, {1, 1, 0x0080}, {1, 2, 0x0080},
64  {1, 2, 0x0080}, {1, 3, 0x0080}, {1, 3, 0x0080}, {1, 4, 0x0080}, {1, 4, 0x0080},
65  {1, 6, 0x0080}, {1, 5, 0x0080}, {1, 5, 0x0080}, {1, 6, 0x0080}
66  };
67 
68  memcpy(pei->spd_addresses, &spdaddr, sizeof(spdaddr));
69 
70  pei->gbe_enable = 0; /* Board uses no Intel GbE but a RTL8111F */
71  pei->max_ddr3_freq = 1600; /* 1333=Sandy; 1600=Ivy */
72 
73  memcpy(pei->usb_port_config, &usbcfg, sizeof(usbcfg));
74 
75  /* ASUS P8Z77-M manual lists some supported DIMMs down to 1.25v */
76  pei->ddr3lv_support = 1;
77  /*
78  * PCIe 3.0 support. As we use Ivy Bridge, let's enable it,
79  * but might cause some system instability!
80  */
81  pei->pcie_init = 1;
82  /*
83  * 4 bit switch mask. 0=not switchable, 1=switchable
84  * Means once it's loaded the OS, it can swap ports
85  * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf
86  */
87  pei->usb3.hs_port_switch_mask = 0xf;
88  /*
89  * USB 3 mode settings.
90  * These are obtained from option table then bit masked to keep within range.
91  */
92  /*
93  * 0 = Disable: work always as USB 2.0(ehci)
94  * 1 = Enable: work always as USB 3.0(xhci)
95  * 2 = Auto: work as USB2.0(ehci) until OS loads USB3 xhci driver
96  * 3 = Smart Auto : same than Auto, but if OS loads USB3 driver
97  * and reboots, it will keep the USB3.0 speed
98  */
99  pei->usb3.mode = get_uint_option("usb3_mode", 1) & 0x3;
100  /* 1=Load xHCI pre-OS drv */
101  pei->usb3.preboot_support = get_uint_option("usb3_drv", 1) & 0x1;
102  /*
103  * 0=Don't use xHCI streams for better compatibility
104  * 1=use xHCI streams for better speed
105  */
106  pei->usb3.xhci_streams = get_uint_option("usb3_streams", 1) & 0x1;
107 }
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
u8 spd_raw_data[256]
Definition: ddr3.h:156
void bootblock_mainboard_early_init(void)
Definition: early_init.c:11
void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Definition: early_init.c:25
const struct southbridge_usb_port mainboard_usb_ports[]
Definition: early_init.c:8
void mainboard_fill_pei_data(struct pei_data *pei)
Definition: early_init.c:58
#define SERIAL_DEV
Definition: early_init.c:14
int mainboard_should_reset_usb(int s3resume)
Definition: early_init.c:53
void read_spd(spd_raw_data *spd, u8 addr, bool id_only)
Definition: raminit.c:138
void nuvoton_enable_serial(pnp_devfn_t dev, u16 iobase)
Definition: early_serial.c:48
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:8
int ddr3lv_support
Definition: pei_data.h:91
uint8_t spd_addresses[4]
Definition: pei_data.h:60
int pcie_init
Definition: pei_data.h:97
int gbe_enable
Definition: pei_data.h:63
pch_usb3_controller_settings usb3
Definition: pei_data.h:83
uint16_t usb_port_config[16][3]
Definition: pei_data.h:81
uint32_t max_ddr3_freq
Definition: pei_data.h:80