Angel Pons | 2e8a4b0 | 2020-04-05 13:22:54 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 4 | #include <acpi/acpi.h> |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 5 | #include <console/console.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 6 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 7 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | f004b6b | 2016-02-10 02:42:16 +0100 | [diff] [blame] | 8 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 9 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 10 | #include <southbridge/intel/common/gpio.h> |
Kyösti Mälkki | 926a8d1 | 2014-04-27 22:17:22 +0300 | [diff] [blame] | 11 | #include <bootmode.h> |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 12 | #include <ec/quanta/it8518/ec.h> |
| 13 | #include "ec.h" |
| 14 | #include "onboard.h" |
| 15 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 16 | void mainboard_late_rcba_config(void) |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 17 | { |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 18 | /* |
| 19 | * GFX INTA -> PIRQA (MSI) |
| 20 | * D20IP_XHCI XHCI INTA -> PIRQD (MSI) |
| 21 | * D26IP_E2P EHCI #2 INTA -> PIRQF |
| 22 | * D27IP_ZIP HDA INTA -> PIRQA (MSI) |
| 23 | * D28IP_P2IP WLAN INTA -> PIRQD |
| 24 | * D28IP_P3IP Card Reader INTB -> PIRQE |
| 25 | * D28IP_P6IP LAN INTC -> PIRQB |
| 26 | * D29IP_E1P EHCI #1 INTA -> PIRQD |
| 27 | * D31IP_SIP SATA INTA -> PIRQB (MSI) |
| 28 | * D31IP_SMIP SMBUS INTB -> PIRQH |
| 29 | */ |
| 30 | |
| 31 | /* Device interrupt pin register (board specific) */ |
| 32 | RCBA32(D31IP) = (NOINT << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 33 | (INTB << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 34 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 35 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 36 | RCBA32(D28IP) = (NOINT << D28IP_P1IP) | (INTA << D28IP_P2IP) | |
| 37 | (INTB << D28IP_P3IP) | (NOINT << D28IP_P4IP) | |
| 38 | (NOINT << D28IP_P5IP) | (INTC << D28IP_P6IP) | |
| 39 | (NOINT << D28IP_P7IP) | (NOINT << D28IP_P8IP); |
| 40 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 41 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 42 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 43 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 44 | RCBA32(D20IP) = (INTA << D20IP_XHCIIP); |
| 45 | |
| 46 | /* Device interrupt route registers */ |
| 47 | DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC); |
| 48 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG); |
| 49 | DIR_ROUTE(D28IR, PIRQD, PIRQE, PIRQB, PIRQC); |
| 50 | DIR_ROUTE(D27IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 51 | DIR_ROUTE(D26IR, PIRQF, PIRQB, PIRQC, PIRQD); |
| 52 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 53 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 54 | DIR_ROUTE(D20IR, PIRQD, PIRQE, PIRQF, PIRQG); |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 57 | /* |
| 58 | * The Stout EC needs to be reset to RW mode. It is important that |
| 59 | * the RTC_PWR_STS is not set until ramstage EC init. |
| 60 | */ |
| 61 | static void early_ec_init(void) |
| 62 | { |
| 63 | u8 ec_status = ec_read(EC_STATUS_REG); |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 64 | int rec_mode = get_recovery_mode_switch(); |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 65 | |
| 66 | if (((ec_status & 0x3) == EC_IN_RO_MODE) || |
| 67 | ((ec_status & 0x3) == EC_IN_RECOVERY_MODE)) { |
| 68 | |
| 69 | printk(BIOS_DEBUG, "EC Cold Boot Detected\n"); |
| 70 | if (!rec_mode) { |
| 71 | /* |
| 72 | * Tell EC to exit RO mode |
| 73 | */ |
| 74 | printk(BIOS_DEBUG, "EC will exit RO mode and boot normally\n"); |
| 75 | ec_write_cmd(EC_CMD_EXIT_BOOT_BLOCK); |
| 76 | die("wait for ec to reset"); |
| 77 | } |
| 78 | } else { |
| 79 | printk(BIOS_DEBUG, "EC Warm Boot Detected\n"); |
| 80 | ec_write_cmd(EC_CMD_WARM_RESET); |
| 81 | } |
| 82 | } |
| 83 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 84 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
Vladimir Serbinenko | f004b6b | 2016-02-10 02:42:16 +0100 | [diff] [blame] | 85 | { |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 86 | read_spd(&spd[0], 0x50, id_only); |
| 87 | read_spd(&spd[2], 0x52, id_only); |
Vladimir Serbinenko | f004b6b | 2016-02-10 02:42:16 +0100 | [diff] [blame] | 88 | } |
| 89 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 90 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 91 | { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 92 | struct pei_data pei_data_template = { |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 93 | .pei_version = PEI_VERSION, |
Angel Pons | c802745 | 2020-09-14 16:36:28 +0200 | [diff] [blame] | 94 | .mchbar = DEFAULT_MCHBAR, |
| 95 | .dmibar = DEFAULT_DMIBAR, |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 96 | .epbar = DEFAULT_EPBAR, |
| 97 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
Angel Pons | b21bffa | 2020-07-03 01:02:28 +0200 | [diff] [blame] | 98 | .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE, |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 99 | .wdbbar = 0x4000000, |
| 100 | .wdbsize = 0x1000, |
| 101 | .hpet_address = CONFIG_HPET_ADDRESS, |
Angel Pons | 92717ff | 2020-09-14 16:22:22 +0200 | [diff] [blame] | 102 | .rcba = (uintptr_t)DEFAULT_RCBA, |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 103 | .pmbase = DEFAULT_PMBASE, |
| 104 | .gpiobase = DEFAULT_GPIOBASE, |
| 105 | .thermalbase = 0xfed08000, |
| 106 | .system_type = 0, // 0 Mobile, 1 Desktop/Server |
| 107 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 108 | .spd_addresses = { 0xA0, 0x00,0xA4,0x00 }, |
| 109 | .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, |
| 110 | .ec_present = 1, |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 111 | // 0 = leave channel enabled |
| 112 | // 1 = disable dimm 0 on channel |
| 113 | // 2 = disable dimm 1 on channel |
| 114 | // 3 = disable dimm 0+1 on channel |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 115 | .dimm_channel0_disabled = 2, |
| 116 | .dimm_channel1_disabled = 2, |
| 117 | .max_ddr3_freq = 1600, |
| 118 | .usb_port_config = { |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 119 | /* enabled USB oc pin length */ |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 120 | { 1, 0, 0x0040 }, /* P0: USB 3.0 1 (OC0) */ |
| 121 | { 1, 0, 0x0040 }, /* P1: USB 3.0 2 (OC0) */ |
| 122 | { 0, 1, 0x0000 }, /* P2: Empty */ |
| 123 | { 1, 1, 0x0040 }, /* P3: Camera (no OC) */ |
| 124 | { 1, 1, 0x0040 }, /* P4: WLAN (no OC) */ |
| 125 | { 1, 1, 0x0040 }, /* P5: WWAN (no OC) */ |
| 126 | { 0, 1, 0x0000 }, /* P6: Empty */ |
| 127 | { 0, 1, 0x0000 }, /* P7: Empty */ |
| 128 | { 0, 5, 0x0000 }, /* P8: Empty */ |
| 129 | { 1, 4, 0x0040 }, /* P9: USB 2.0 (AUO4) (OC4) */ |
| 130 | { 0, 5, 0x0000 }, /* P10: Empty */ |
| 131 | { 0, 5, 0x0000 }, /* P11: Empty */ |
| 132 | { 0, 5, 0x0000 }, /* P12: Empty */ |
| 133 | { 1, 5, 0x0040 }, /* P13: Bluetooth (no OC) */ |
| 134 | }, |
Edward O'Callaghan | 77896c1 | 2014-10-28 10:03:47 +1100 | [diff] [blame] | 135 | .usb3 = { |
| 136 | .mode = XHCI_MODE, |
| 137 | .hs_port_switch_mask = XHCI_PORTS, |
| 138 | .preboot_support = XHCI_PREBOOT, |
| 139 | .xhci_streams = XHCI_STREAMS, |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 140 | }, |
| 141 | }; |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 142 | *pei_data = pei_data_template; |
| 143 | } |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 144 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 145 | void mainboard_early_init(int s3resume) |
| 146 | { |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 147 | /* Do ec reset as early as possible, but skip it on S3 resume */ |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 148 | if (!s3resume) { |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 149 | early_ec_init(); |
Stefan Reinauer | b7ecf6d | 2013-03-13 17:13:32 -0700 | [diff] [blame] | 150 | } |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 151 | } |
Vladimir Serbinenko | c845b43 | 2014-09-05 03:37:44 +0200 | [diff] [blame] | 152 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 153 | int mainboard_should_reset_usb(int s3resume) |
| 154 | { |
| 155 | return !s3resume; |
| 156 | } |
| 157 | |
Vladimir Serbinenko | f004b6b | 2016-02-10 02:42:16 +0100 | [diff] [blame] | 158 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 159 | /* enabled USB oc pin length */ |
Elyes HAOUAS | 48a0129 | 2016-09-29 18:57:56 +0200 | [diff] [blame] | 160 | {1, 0, 0}, /* P0: USB 3.0 1 (OC0) */ |
| 161 | {1, 0, 0}, /* P1: USB 3.0 2 (OC0) */ |
| 162 | {0, 0, 0}, /* P2: Empty */ |
| 163 | {1, 0, -1}, /* P3: Camera (no OC) */ |
| 164 | {1, 0, -1}, /* P4: WLAN (no OC) */ |
| 165 | {1, 0, -1}, /* P5: WWAN (no OC) */ |
| 166 | {0, 0, 0}, /* P6: Empty */ |
| 167 | {0, 0, 0}, /* P7: Empty */ |
| 168 | {0, 0, 0}, /* P8: Empty */ |
| 169 | {1, 0, 4}, /* P9: USB 2.0 (AUO4) (OC4) */ |
| 170 | {0, 0, 0}, /* P10: Empty */ |
| 171 | {0, 0, 0}, /* P11: Empty */ |
| 172 | {0, 0, 0}, /* P12: Empty */ |
| 173 | {1, 0, -1}, /* P13: Bluetooth (no OC) */ |
Vladimir Serbinenko | f004b6b | 2016-02-10 02:42:16 +0100 | [diff] [blame] | 174 | }; |