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