Angel Pons | 5f1bf2f | 2020-04-03 01:21:16 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Arthur Heymans | fa5d0f8 | 2019-11-12 19:11:50 +0100 | [diff] [blame] | 2 | #include <bootblock_common.h> |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 3 | #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 Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 19 | const 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 HAOUAS | b7da27c | 2020-01-11 19:21:07 +0100 | [diff] [blame] | 33 | { 0, 2, 5 }, /* Port 12: Unused. Asus proprietary DEBUG_PORT ??? */ |
| 34 | { 0, 2, 6 } /* Port 13: Unused. Asus proprietary DEBUG_PORT ??? */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
Arthur Heymans | fa5d0f8 | 2019-11-12 19:11:50 +0100 | [diff] [blame] | 37 | void bootblock_mainboard_early_init(void) |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 38 | { |
| 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 | |
| 49 | void 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 | |
| 57 | int mainboard_should_reset_usb(int s3resume) |
| 58 | { |
| 59 | return !s3resume; |
| 60 | } |
| 61 | |
| 62 | void 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 Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 72 | unsigned int usb3_mode = get_uint_option("usb3_mode", 1); |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 73 | usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */ |
| 74 | |
| 75 | /* Load USB3 pre-OS xHCI driver */ |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 76 | unsigned int usb3_drv = get_uint_option("usb3_drv", 1); |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 77 | usb3_drv &= 0x1; /* ensure it's 0/1 only */ |
| 78 | |
| 79 | /* Use USB3 xHCI streams */ |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 80 | unsigned int usb3_streams = get_uint_option("usb3_streams", 1); |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 81 | usb3_streams &= 0x1; /* ensure it's 0/1 only */ |
| 82 | |
| 83 | struct pei_data pd = { |
| 84 | .pei_version = PEI_VERSION, |
Angel Pons | d9e58dc | 2021-01-20 01:22:20 +0100 | [diff] [blame] | 85 | .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE, |
| 86 | .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE, |
| 87 | .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE, |
Shelley Chen | 4e9bb33 | 2021-10-20 15:43:45 -0700 | [diff] [blame] | 88 | .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS, |
Angel Pons | b21bffa | 2020-07-03 01:02:28 +0200 | [diff] [blame] | 89 | .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE, |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 90 | .wdbbar = 0x4000000, |
| 91 | .wdbsize = 0x1000, |
| 92 | .hpet_address = CONFIG_HPET_ADDRESS, |
Angel Pons | 92717ff | 2020-09-14 16:22:22 +0200 | [diff] [blame] | 93 | .rcba = (uintptr_t)DEFAULT_RCBA, |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 94 | .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 HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 101 | .ec_present = 0, /* Asus 2203 BIOS shows XUECA016, but no EC */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 102 | .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 103 | .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 Roth | 50863da | 2021-10-01 14:37:30 -0600 | [diff] [blame] | 109 | { 1, 1, 0x0080 }, /* USB3 ETH bottom connector */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 110 | { 1, 2, 0x0080 }, /* USB2 PS2 top connector */ |
Martin Roth | 50863da | 2021-10-01 14:37:30 -0600 | [diff] [blame] | 111 | { 1, 2, 0x0080 }, /* USB2 PS2 bottom connector */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 112 | { 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 Menzel | f897623 | 2020-03-06 12:37:06 +0100 | [diff] [blame] | 138 | /* ASUS P8Z77-M PRO manual says 1.35v DIMMs are supported */ |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 139 | .ddr3lv_support = 1, |
| 140 | /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it, |
Elyes HAOUAS | b7da27c | 2020-01-11 19:21:07 +0100 | [diff] [blame] | 141 | * but might cause some system instability ! |
Vlado Cibic | 2bf6a30 | 2019-06-09 06:53:50 +0000 | [diff] [blame] | 142 | */ |
| 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 | } |