blob: ddac440e5c455842a7916ccec1b3a43d6b278f27 [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 */
Angel Pons88dcb312021-04-26 17:10:28 +020072 unsigned int usb3_mode = get_uint_option("usb3_mode", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000073 usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */
74
75 /* Load USB3 pre-OS xHCI driver */
Angel Pons88dcb312021-04-26 17:10:28 +020076 unsigned int usb3_drv = get_uint_option("usb3_drv", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000077 usb3_drv &= 0x1; /* ensure it's 0/1 only */
78
79 /* Use USB3 xHCI streams */
Angel Pons88dcb312021-04-26 17:10:28 +020080 unsigned int usb3_streams = get_uint_option("usb3_streams", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000081 usb3_streams &= 0x1; /* ensure it's 0/1 only */
82
83 struct pei_data pd = {
84 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010085 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
86 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
87 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070088 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020089 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Vlado Cibic2bf6a302019-06-09 06:53:50 +000090 .wdbbar = 0x4000000,
91 .wdbsize = 0x1000,
92 .hpet_address = CONFIG_HPET_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020093 .rcba = (uintptr_t)DEFAULT_RCBA,
Vlado Cibic2bf6a302019-06-09 06:53:50 +000094 .pmbase = DEFAULT_PMBASE,
95 .gpiobase = DEFAULT_GPIOBASE,
96 .thermalbase = 0xfed08000,
97 .system_type = 1, /* 0=Mobile, 1=Desktop/Server */
98 .tseg_size = CONFIG_SMM_TSEG_SIZE,
99 .spd_addresses = { 0xa0, 0xa2, 0xa4, 0xa6 }, /* SMBus mul 2 */
100 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
Elyes HAOUAS6dc9d032020-02-16 16:22:52 +0100101 .ec_present = 0, /* Asus 2203 BIOS shows XUECA016, but no EC */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000102 .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000103 .max_ddr3_freq = 1600, /* 1333=Sandy; 1600=Ivy */
104 .usb_port_config = {
105 /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */
106 { 1, 0, 0x0080 }, /* USB3 front internal header */
107 { 1, 0, 0x0080 }, /* USB3 front internal header */
108 { 1, 1, 0x0080 }, /* USB3 ETH top connector */
Martin Roth50863da2021-10-01 14:37:30 -0600109 { 1, 1, 0x0080 }, /* USB3 ETH bottom connector */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000110 { 1, 2, 0x0080 }, /* USB2 PS2 top connector */
Martin Roth50863da2021-10-01 14:37:30 -0600111 { 1, 2, 0x0080 }, /* USB2 PS2 bottom connector */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000112 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
113 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
114 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
115 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
116 { 1, 6, 0x0080 }, /* USB2 internal header (USB1112) */
117 { 1, 5, 0x0080 }, /* USB2 internal header (USB1112) */
118 { 0, 5, 0x0080 }, /* Unused. Asus DEBUG_PORT ??? */
119 { 0, 6, 0x0080 } /* Unused. Asus DEBUG_PORT ??? */
120 },
121 .usb3 = {
122 /* 0=Disable; 1=Enable (start at USB3 speed)
123 * 2=Auto (start as USB2 speed until OS loads)
124 * 3=Smart Auto (like Auto but keep speed on reboot)
125 */
126 usb3_mode,
127 /* 4 bit switch mask. 0=not switchable, 1=switchable
128 * Means once it's loaded the OS, it can swap ports
129 * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf
130 */
131 0xf,
132 usb3_drv, /* 1=Load xHCI pre-OS drv */
133 /* 0=Don't use xHCI streams for better compatibility
134 * 1=use xHCI streams for better speed
135 */
136 usb3_streams
137 },
Paul Menzelf8976232020-03-06 12:37:06 +0100138 /* ASUS P8Z77-M PRO manual says 1.35v DIMMs are supported */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000139 .ddr3lv_support = 1,
140 /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it,
Elyes HAOUASb7da27c2020-01-11 19:21:07 +0100141 * but might cause some system instability !
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000142 */
143 .pcie_init = 1,
144 /* Command Rate. 0=Auto; 1=1N; 2=2N.
145 * Leave it always at Auto for compatibility & stability
146 */
147 .nmode = 0,
148 /* DDR refresh rate. 0=Auto based on DRAM's temperature;
149 * 1=Normal rate for speed; 2=Double rate for stability
150 */
151 .ddr_refresh_rate_config = 0
152 };
153
154 /* copy the data to output PEI */
155 *pei_data = pd;
156}