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 <arch/hpet.h>
4 #include <bootblock_common.h>
5 #include <device/pnp_ops.h>
8 
11 
12 #include <option.h>
13 
17 
18 #define GLOBAL_DEV PNP_DEV(0x2e, 0)
19 #define SERIAL_DEV PNP_DEV(0x2e, NCT6779D_SP2)
20 
22  /* {enable, current, oc_pin} */
23  { 1, 2, 0 }, /* Port 0: USB3 front internal header, top */
24  { 1, 2, 0 }, /* Port 1: USB3 front internal header, bottom */
25  { 1, 2, 1 }, /* Port 2: USB3 rear, ETH top */
26  { 1, 2, 1 }, /* Port 3: USB3 rear, ETH bottom */
27  { 1, 2, 2 }, /* Port 4: USB2 rear, PS2 top */
28  { 1, 2, 2 }, /* Port 5: USB2 rear, PS2 bottom */
29  { 1, 2, 3 }, /* Port 6: USB2 internal header USB78, top */
30  { 1, 2, 3 }, /* Port 7: USB2 internal header USB78, bottom */
31  { 1, 2, 4 }, /* Port 8: USB2 internal header USB910, top */
32  { 1, 2, 4 }, /* Port 9: USB2 internal header USB910, bottom */
33  { 1, 2, 6 }, /* Port 10: USB2 internal header USB1112, top */
34  { 1, 2, 5 }, /* Port 11: USB2 internal header USB1112, bottom */
35  { 0, 2, 5 }, /* Port 12: Unused. Asus proprietary DEBUG_PORT ??? */
36  { 0, 2, 6 } /* Port 13: Unused. Asus proprietary DEBUG_PORT ??? */
37 };
38 
40 {
41  /* Setup COM/UART */
43 
44  /* TODO / FIXME: Setup Multifuncion/SIO pins for COM */
45 
48  nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
49 }
50 
51 void mainboard_get_spd(spd_raw_data *spd, bool id_only)
52 {
53  read_spd(&spd[0], 0x50, id_only);
54  read_spd(&spd[1], 0x51, id_only);
55  read_spd(&spd[2], 0x52, id_only);
56  read_spd(&spd[3], 0x53, id_only);
57 }
58 
59 int mainboard_should_reset_usb(int s3resume)
60 {
61  return !s3resume;
62 }
63 
65 {
66  /*
67  * USB3 mode:
68  * 0 = Disable: work always as USB 2.0(ehci)
69  * 1 = Enable: work always as USB 3.0(xhci)
70  * 2 = Auto: work as USB2.0(ehci) until OS loads USB3 xhci driver
71  * 3 = Smart Auto : same than Auto, but if OS loads USB3 driver
72  * and reboots, it will keep the USB3.0 speed
73  */
74  unsigned int usb3_mode = get_uint_option("usb3_mode", 1);
75  usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */
76 
77  /* Load USB3 pre-OS xHCI driver */
78  unsigned int usb3_drv = get_uint_option("usb3_drv", 1);
79  usb3_drv &= 0x1; /* ensure it's 0/1 only */
80 
81  /* Use USB3 xHCI streams */
82  unsigned int usb3_streams = get_uint_option("usb3_streams", 1);
83  usb3_streams &= 0x1; /* ensure it's 0/1 only */
84 
85  struct pei_data pd = {
87  .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
88  .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
89  .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
90  .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
91  .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
92  .wdbbar = 0x4000000,
93  .wdbsize = 0x1000,
94  .hpet_address = HPET_BASE_ADDRESS,
95  .rcba = (uintptr_t)DEFAULT_RCBA,
98  .thermalbase = 0xfed08000,
99  .system_type = 1, /* 0=Mobile, 1=Desktop/Server */
100  .tseg_size = CONFIG_SMM_TSEG_SIZE,
101  .spd_addresses = { 0xa0, 0xa2, 0xa4, 0xa6 }, /* SMBus mul 2 */
102  .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
103  .ec_present = 0, /* Asus 2203 BIOS shows XUECA016, but no EC */
104  .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */
105  .max_ddr3_freq = 1600, /* 1333=Sandy; 1600=Ivy */
106  .usb_port_config = {
107  /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */
108  { 1, 0, 0x0080 }, /* USB3 front internal header */
109  { 1, 0, 0x0080 }, /* USB3 front internal header */
110  { 1, 1, 0x0080 }, /* USB3 ETH top connector */
111  { 1, 1, 0x0080 }, /* USB3 ETH bottom connector */
112  { 1, 2, 0x0080 }, /* USB2 PS2 top connector */
113  { 1, 2, 0x0080 }, /* USB2 PS2 bottom connector */
114  { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
115  { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
116  { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
117  { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
118  { 1, 6, 0x0080 }, /* USB2 internal header (USB1112) */
119  { 1, 5, 0x0080 }, /* USB2 internal header (USB1112) */
120  { 0, 5, 0x0080 }, /* Unused. Asus DEBUG_PORT ??? */
121  { 0, 6, 0x0080 } /* Unused. Asus DEBUG_PORT ??? */
122  },
123  .usb3 = {
124  /* 0=Disable; 1=Enable (start at USB3 speed)
125  * 2=Auto (start as USB2 speed until OS loads)
126  * 3=Smart Auto (like Auto but keep speed on reboot)
127  */
128  usb3_mode,
129  /* 4 bit switch mask. 0=not switchable, 1=switchable
130  * Means once it's loaded the OS, it can swap ports
131  * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf
132  */
133  0xf,
134  usb3_drv, /* 1=Load xHCI pre-OS drv */
135  /* 0=Don't use xHCI streams for better compatibility
136  * 1=use xHCI streams for better speed
137  */
138  usb3_streams
139  },
140  /* ASUS P8Z77-M PRO manual says 1.35v DIMMs are supported */
141  .ddr3lv_support = 1,
142  /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it,
143  * but might cause some system instability !
144  */
145  .pcie_init = 1,
146  /* Command Rate. 0=Auto; 1=1N; 2=2N.
147  * Leave it always at Auto for compatibility & stability
148  */
149  .nmode = 0,
150  /* DDR refresh rate. 0=Auto based on DRAM's temperature;
151  * 1=Normal rate for speed; 2=Double rate for stability
152  */
153  .ddr_refresh_rate_config = 0
154  };
155 
156  /* copy the data to output PEI */
157  *pei_data = pd;
158 }
#define HPET_BASE_ADDRESS
Definition: hpet.h:6
u8 spd_raw_data[256]
Definition: ddr3.h:156
#define DEFAULT_PMBASE
Definition: iomap.h:14
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
int mainboard_should_reset_usb(int s3resume)
Definition: early_init.c:53
#define SERIAL_DEV
Definition: early_init.c:19
#define GLOBAL_DEV
Definition: early_init.c:18
#define PEI_VERSION
Definition: pei_data.h:9
void read_spd(spd_raw_data *spd, u8 addr, bool id_only)
Definition: raminit.c:138
void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev)
Definition: early_serial.c:33
void nuvoton_enable_serial(pnp_devfn_t dev, u16 iobase)
Definition: early_serial.c:48
void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev)
Definition: early_serial.c:41
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
void pnp_set_logical_device(struct device *dev)
Definition: pnp_device.c:59
#define DEFAULT_GPIOBASE
Definition: pch.h:22
#define DEFAULT_RCBA
Definition: rcba.h:6
static u16 pmbase
Definition: smi.c:27
unsigned long uintptr_t
Definition: stdint.h:21
uint8_t spd_addresses[4]
Definition: pei_data.h:60
uint32_t tseg_size
Definition: pei_data.h:59
uint32_t system_type
Definition: pei_data.h:58
uint32_t gpiobase
Definition: pei_data.h:55
uint32_t pei_version
Definition: pei_data.h:43
uint32_t thermalbase
Definition: pei_data.h:33