blob: 687cbfd3c5155fd84d72289ba911be35e09792b3 [file] [log] [blame]
Angel Pons5f1bf2f2020-04-03 01:21:16 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01003#include <bootblock_common.h>
Vlado Cibic2bf6a302019-06-09 06:53:50 +00004#include <device/pnp_ops.h>
5#include <northbridge/intel/sandybridge/sandybridge.h>
6#include <southbridge/intel/bd82x6x/pch.h>
7
8#include <superio/nuvoton/common/nuvoton.h>
9#include <superio/nuvoton/nct6779d/nct6779d.h>
10
11#include <option.h>
12
13#include <northbridge/intel/sandybridge/raminit_native.h>
14#include <northbridge/intel/sandybridge/raminit.h>
15#include <northbridge/intel/sandybridge/pei_data.h>
16
17#define GLOBAL_DEV PNP_DEV(0x2e, 0)
18#define SERIAL_DEV PNP_DEV(0x2e, NCT6779D_SP2)
19
Vlado Cibic2bf6a302019-06-09 06:53:50 +000020const struct southbridge_usb_port mainboard_usb_ports[] = {
21 /* {enable, current, oc_pin} */
22 { 1, 2, 0 }, /* Port 0: USB3 front internal header, top */
23 { 1, 2, 0 }, /* Port 1: USB3 front internal header, bottom */
24 { 1, 2, 1 }, /* Port 2: USB3 rear, ETH top */
25 { 1, 2, 1 }, /* Port 3: USB3 rear, ETH bottom */
26 { 1, 2, 2 }, /* Port 4: USB2 rear, PS2 top */
27 { 1, 2, 2 }, /* Port 5: USB2 rear, PS2 bottom */
28 { 1, 2, 3 }, /* Port 6: USB2 internal header USB78, top */
29 { 1, 2, 3 }, /* Port 7: USB2 internal header USB78, bottom */
30 { 1, 2, 4 }, /* Port 8: USB2 internal header USB910, top */
31 { 1, 2, 4 }, /* Port 9: USB2 internal header USB910, bottom */
32 { 1, 2, 6 }, /* Port 10: USB2 internal header USB1112, top */
33 { 1, 2, 5 }, /* Port 11: USB2 internal header USB1112, bottom */
Elyes HAOUASb7da27c2020-01-11 19:21:07 +010034 { 0, 2, 5 }, /* Port 12: Unused. Asus proprietary DEBUG_PORT ??? */
35 { 0, 2, 6 } /* Port 13: Unused. Asus proprietary DEBUG_PORT ??? */
Vlado Cibic2bf6a302019-06-09 06:53:50 +000036};
37
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010038void bootblock_mainboard_early_init(void)
Vlado Cibic2bf6a302019-06-09 06:53:50 +000039{
40 /* Setup COM/UART */
41 nuvoton_pnp_enter_conf_state(GLOBAL_DEV);
42
43 /* TODO / FIXME: Setup Multifuncion/SIO pins for COM */
44
45 pnp_set_logical_device(SERIAL_DEV);
46 nuvoton_pnp_exit_conf_state(GLOBAL_DEV);
47 nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
48}
49
50void mainboard_get_spd(spd_raw_data *spd, bool id_only)
51{
52 read_spd(&spd[0], 0x50, id_only);
53 read_spd(&spd[1], 0x51, id_only);
54 read_spd(&spd[2], 0x52, id_only);
55 read_spd(&spd[3], 0x53, id_only);
56}
57
58int mainboard_should_reset_usb(int s3resume)
59{
60 return !s3resume;
61}
62
63void mainboard_fill_pei_data(struct pei_data *pei_data)
64{
65 /*
66 * USB3 mode:
67 * 0 = Disable: work always as USB 2.0(ehci)
68 * 1 = Enable: work always as USB 3.0(xhci)
69 * 2 = Auto: work as USB2.0(ehci) until OS loads USB3 xhci driver
70 * 3 = Smart Auto : same than Auto, but if OS loads USB3 driver
71 * and reboots, it will keep the USB3.0 speed
72 */
73 int usb3_mode = 1;
74 get_option(&usb3_mode, "usb3_mode");
75 usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */
76
77 /* Load USB3 pre-OS xHCI driver */
78 int usb3_drv = 1;
79 get_option(&usb3_drv, "usb3_drv");
80 usb3_drv &= 0x1; /* ensure it's 0/1 only */
81
82 /* Use USB3 xHCI streams */
83 int usb3_streams = 1;
84 get_option(&usb3_streams, "usb3_streams");
85 usb3_streams &= 0x1; /* ensure it's 0/1 only */
86
87 struct pei_data pd = {
88 .pei_version = PEI_VERSION,
89 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
90 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
91 .epbar = DEFAULT_EPBAR,
92 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
93 .smbusbar = SMBUS_IO_BASE,
94 .wdbbar = 0x4000000,
95 .wdbsize = 0x1000,
96 .hpet_address = CONFIG_HPET_ADDRESS,
97 .rcba = (uintptr_t)DEFAULT_RCBABASE,
98 .pmbase = DEFAULT_PMBASE,
99 .gpiobase = DEFAULT_GPIOBASE,
100 .thermalbase = 0xfed08000,
101 .system_type = 1, /* 0=Mobile, 1=Desktop/Server */
102 .tseg_size = CONFIG_SMM_TSEG_SIZE,
103 .spd_addresses = { 0xa0, 0xa2, 0xa4, 0xa6 }, /* SMBus mul 2 */
104 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
Elyes HAOUAS6dc9d032020-02-16 16:22:52 +0100105 .ec_present = 0, /* Asus 2203 BIOS shows XUECA016, but no EC */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000106 .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */
107 .dimm_channel0_disabled = 0, /* Both DIMM enabled */
108 .dimm_channel1_disabled = 0, /* Both DIMM enabled */
109 .max_ddr3_freq = 1600, /* 1333=Sandy; 1600=Ivy */
110 .usb_port_config = {
111 /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */
112 { 1, 0, 0x0080 }, /* USB3 front internal header */
113 { 1, 0, 0x0080 }, /* USB3 front internal header */
114 { 1, 1, 0x0080 }, /* USB3 ETH top connector */
115 { 1, 1, 0x0080 }, /* USB3 ETH botton connector */
116 { 1, 2, 0x0080 }, /* USB2 PS2 top connector */
117 { 1, 2, 0x0080 }, /* USB2 PS2 botton connector */
118 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
119 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
120 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
121 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
122 { 1, 6, 0x0080 }, /* USB2 internal header (USB1112) */
123 { 1, 5, 0x0080 }, /* USB2 internal header (USB1112) */
124 { 0, 5, 0x0080 }, /* Unused. Asus DEBUG_PORT ??? */
125 { 0, 6, 0x0080 } /* Unused. Asus DEBUG_PORT ??? */
126 },
127 .usb3 = {
128 /* 0=Disable; 1=Enable (start at USB3 speed)
129 * 2=Auto (start as USB2 speed until OS loads)
130 * 3=Smart Auto (like Auto but keep speed on reboot)
131 */
132 usb3_mode,
133 /* 4 bit switch mask. 0=not switchable, 1=switchable
134 * Means once it's loaded the OS, it can swap ports
135 * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf
136 */
137 0xf,
138 usb3_drv, /* 1=Load xHCI pre-OS drv */
139 /* 0=Don't use xHCI streams for better compatibility
140 * 1=use xHCI streams for better speed
141 */
142 usb3_streams
143 },
Paul Menzelf8976232020-03-06 12:37:06 +0100144 /* ASUS P8Z77-M PRO manual says 1.35v DIMMs are supported */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000145 .ddr3lv_support = 1,
146 /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it,
Elyes HAOUASb7da27c2020-01-11 19:21:07 +0100147 * but might cause some system instability !
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000148 */
149 .pcie_init = 1,
150 /* Command Rate. 0=Auto; 1=1N; 2=2N.
151 * Leave it always at Auto for compatibility & stability
152 */
153 .nmode = 0,
154 /* DDR refresh rate. 0=Auto based on DRAM's temperature;
155 * 1=Normal rate for speed; 2=Double rate for stability
156 */
157 .ddr_refresh_rate_config = 0
158 };
159
160 /* copy the data to output PEI */
161 *pei_data = pd;
162}