blob: a93f5e942afe7203e8b0b28a66d818e2be234334 [file] [log] [blame]
Angel Pons5f1bf2f2020-04-03 01:21:16 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Felix Held972d9f22022-02-23 16:32:20 +01002
3#include <arch/hpet.h>
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01004#include <bootblock_common.h>
Vlado Cibic2bf6a302019-06-09 06:53:50 +00005#include <device/pnp_ops.h>
6#include <northbridge/intel/sandybridge/sandybridge.h>
7#include <southbridge/intel/bd82x6x/pch.h>
8
9#include <superio/nuvoton/common/nuvoton.h>
10#include <superio/nuvoton/nct6779d/nct6779d.h>
11
12#include <option.h>
13
14#include <northbridge/intel/sandybridge/raminit_native.h>
15#include <northbridge/intel/sandybridge/raminit.h>
16#include <northbridge/intel/sandybridge/pei_data.h>
17
18#define GLOBAL_DEV PNP_DEV(0x2e, 0)
19#define SERIAL_DEV PNP_DEV(0x2e, NCT6779D_SP2)
20
Vlado Cibic2bf6a302019-06-09 06:53:50 +000021const struct southbridge_usb_port mainboard_usb_ports[] = {
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 */
Elyes HAOUASb7da27c2020-01-11 19:21:07 +010035 { 0, 2, 5 }, /* Port 12: Unused. Asus proprietary DEBUG_PORT ??? */
36 { 0, 2, 6 } /* Port 13: Unused. Asus proprietary DEBUG_PORT ??? */
Vlado Cibic2bf6a302019-06-09 06:53:50 +000037};
38
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010039void bootblock_mainboard_early_init(void)
Vlado Cibic2bf6a302019-06-09 06:53:50 +000040{
41 /* Setup COM/UART */
42 nuvoton_pnp_enter_conf_state(GLOBAL_DEV);
43
44 /* TODO / FIXME: Setup Multifuncion/SIO pins for COM */
45
46 pnp_set_logical_device(SERIAL_DEV);
47 nuvoton_pnp_exit_conf_state(GLOBAL_DEV);
48 nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
49}
50
51void 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
Vlado Cibic2bf6a302019-06-09 06:53:50 +000059void mainboard_fill_pei_data(struct pei_data *pei_data)
60{
61 /*
62 * USB3 mode:
63 * 0 = Disable: work always as USB 2.0(ehci)
64 * 1 = Enable: work always as USB 3.0(xhci)
65 * 2 = Auto: work as USB2.0(ehci) until OS loads USB3 xhci driver
66 * 3 = Smart Auto : same than Auto, but if OS loads USB3 driver
67 * and reboots, it will keep the USB3.0 speed
68 */
Angel Pons88dcb312021-04-26 17:10:28 +020069 unsigned int usb3_mode = get_uint_option("usb3_mode", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000070 usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */
71
72 /* Load USB3 pre-OS xHCI driver */
Angel Pons88dcb312021-04-26 17:10:28 +020073 unsigned int usb3_drv = get_uint_option("usb3_drv", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000074 usb3_drv &= 0x1; /* ensure it's 0/1 only */
75
76 /* Use USB3 xHCI streams */
Angel Pons88dcb312021-04-26 17:10:28 +020077 unsigned int usb3_streams = get_uint_option("usb3_streams", 1);
Vlado Cibic2bf6a302019-06-09 06:53:50 +000078 usb3_streams &= 0x1; /* ensure it's 0/1 only */
79
80 struct pei_data pd = {
81 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010082 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
83 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
84 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070085 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020086 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Vlado Cibic2bf6a302019-06-09 06:53:50 +000087 .wdbbar = 0x4000000,
88 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +010089 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020090 .rcba = (uintptr_t)DEFAULT_RCBA,
Vlado Cibic2bf6a302019-06-09 06:53:50 +000091 .pmbase = DEFAULT_PMBASE,
92 .gpiobase = DEFAULT_GPIOBASE,
93 .thermalbase = 0xfed08000,
94 .system_type = 1, /* 0=Mobile, 1=Desktop/Server */
95 .tseg_size = CONFIG_SMM_TSEG_SIZE,
96 .spd_addresses = { 0xa0, 0xa2, 0xa4, 0xa6 }, /* SMBus mul 2 */
97 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
Elyes HAOUAS6dc9d032020-02-16 16:22:52 +010098 .ec_present = 0, /* Asus 2203 BIOS shows XUECA016, but no EC */
Vlado Cibic2bf6a302019-06-09 06:53:50 +000099 .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000100 .max_ddr3_freq = 1600, /* 1333=Sandy; 1600=Ivy */
101 .usb_port_config = {
102 /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */
103 { 1, 0, 0x0080 }, /* USB3 front internal header */
104 { 1, 0, 0x0080 }, /* USB3 front internal header */
105 { 1, 1, 0x0080 }, /* USB3 ETH top connector */
Martin Roth50863da2021-10-01 14:37:30 -0600106 { 1, 1, 0x0080 }, /* USB3 ETH bottom connector */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000107 { 1, 2, 0x0080 }, /* USB2 PS2 top connector */
Martin Roth50863da2021-10-01 14:37:30 -0600108 { 1, 2, 0x0080 }, /* USB2 PS2 bottom connector */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000109 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
110 { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */
111 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
112 { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */
113 { 1, 6, 0x0080 }, /* USB2 internal header (USB1112) */
114 { 1, 5, 0x0080 }, /* USB2 internal header (USB1112) */
115 { 0, 5, 0x0080 }, /* Unused. Asus DEBUG_PORT ??? */
116 { 0, 6, 0x0080 } /* Unused. Asus DEBUG_PORT ??? */
117 },
118 .usb3 = {
119 /* 0=Disable; 1=Enable (start at USB3 speed)
120 * 2=Auto (start as USB2 speed until OS loads)
121 * 3=Smart Auto (like Auto but keep speed on reboot)
122 */
123 usb3_mode,
124 /* 4 bit switch mask. 0=not switchable, 1=switchable
125 * Means once it's loaded the OS, it can swap ports
126 * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf
127 */
128 0xf,
129 usb3_drv, /* 1=Load xHCI pre-OS drv */
130 /* 0=Don't use xHCI streams for better compatibility
131 * 1=use xHCI streams for better speed
132 */
133 usb3_streams
134 },
Paul Menzelf8976232020-03-06 12:37:06 +0100135 /* ASUS P8Z77-M PRO manual says 1.35v DIMMs are supported */
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000136 .ddr3lv_support = 1,
137 /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it,
Elyes HAOUASb7da27c2020-01-11 19:21:07 +0100138 * but might cause some system instability !
Vlado Cibic2bf6a302019-06-09 06:53:50 +0000139 */
140 .pcie_init = 1,
141 /* Command Rate. 0=Auto; 1=1N; 2=2N.
142 * Leave it always at Auto for compatibility & stability
143 */
144 .nmode = 0,
145 /* DDR refresh rate. 0=Auto based on DRAM's temperature;
146 * 1=Normal rate for speed; 2=Double rate for stability
147 */
148 .ddr_refresh_rate_config = 0
149 };
150
151 /* copy the data to output PEI */
152 *pei_data = pd;
153}