Angel Pons | d32b6de | 2020-04-03 01:23:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <string.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 5 | #include <arch/io.h> |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 6 | #include <bootblock_common.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 7 | #include <cbfs.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 8 | #include <console/console.h> |
Kyösti Mälkki | e3ddee0 | 2014-05-03 10:45:28 +0300 | [diff] [blame] | 9 | #include <bootmode.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 10 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 11 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 12 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 13 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 14 | #include <southbridge/intel/common/gpio.h> |
Edward O'Callaghan | 74834e0 | 2015-01-04 04:17:35 +1100 | [diff] [blame] | 15 | #include <superio/smsc/lpc47n207/lpc47n207.h> |
Matt DeVillier | 2b297d9 | 2019-11-24 17:36:38 -0600 | [diff] [blame] | 16 | #include "option_table.h" |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 17 | |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 18 | void bootblock_mainboard_early_init(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 19 | { |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 20 | if (CONFIG(DRIVERS_UART_8250IO)) |
| 21 | try_enabling_LPC47N207_uart(); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 22 | } |
| 23 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 24 | void mainboard_late_rcba_config(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 25 | { |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 26 | /* |
| 27 | * GFX INTA -> PIRQA (MSI) |
| 28 | * D28IP_P1IP WLAN INTA -> PIRQB |
| 29 | * D28IP_P4IP ETH0 INTB -> PIRQC (MSI) |
| 30 | * D29IP_E1P EHCI1 INTA -> PIRQD |
| 31 | * D26IP_E2P EHCI2 INTA -> PIRQB |
| 32 | * D31IP_SIP SATA INTA -> PIRQA (MSI) |
| 33 | * D31IP_SMIP SMBUS INTC -> PIRQH |
| 34 | * D31IP_TTIP THRT INTB -> PIRQG |
| 35 | * D27IP_ZIP HDA INTA -> PIRQG (MSI) |
| 36 | * |
| 37 | * LIGHTSENSOR -> PIRQE (Edge Triggered) |
| 38 | * TRACKPAD -> PIRQF (Edge Triggered) |
| 39 | */ |
| 40 | |
| 41 | /* Device interrupt pin register (board specific) */ |
| 42 | RCBA32(D31IP) = (INTB << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 43 | (INTC << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 44 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 45 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 46 | RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) | |
| 47 | (INTB << D28IP_P4IP); |
| 48 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 49 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 50 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 51 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 52 | |
| 53 | /* Device interrupt route registers */ |
| 54 | DIR_ROUTE(D31IR, PIRQA, PIRQG, PIRQH, PIRQB); |
| 55 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQG, PIRQH); |
| 56 | DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE); |
| 57 | DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB); |
| 58 | DIR_ROUTE(D26IR, PIRQB, PIRQC, PIRQD, PIRQA); |
| 59 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 60 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 61 | } |
| 62 | |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 63 | static const uint8_t *locate_spd(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 64 | { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 65 | typedef const uint8_t spd_blob[256]; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 66 | spd_blob *spd_data; |
Vladimir Serbinenko | 1287416 | 2014-01-12 14:12:15 +0100 | [diff] [blame] | 67 | size_t spd_file_len; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 68 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 69 | u32 gp_lvl2 = inl(DEFAULT_GPIOBASE + 0x38); |
| 70 | u8 gpio33, gpio41, gpio49; |
| 71 | gpio33 = (gp_lvl2 >> (33-32)) & 1; |
| 72 | gpio41 = (gp_lvl2 >> (41-32)) & 1; |
| 73 | gpio49 = (gp_lvl2 >> (49-32)) & 1; |
| 74 | printk(BIOS_DEBUG, "Memory Straps:\n"); |
| 75 | printk(BIOS_DEBUG, " - memory capacity %dGB\n", |
| 76 | gpio33 ? 2 : 1); |
| 77 | printk(BIOS_DEBUG, " - die revision %d\n", |
| 78 | gpio41 ? 2 : 1); |
| 79 | printk(BIOS_DEBUG, " - vendor %s\n", |
| 80 | gpio49 ? "Samsung" : "Other"); |
| 81 | |
| 82 | int spd_index = 0; |
| 83 | |
| 84 | switch ((gpio49 << 2) | (gpio41 << 1) | gpio33) { |
| 85 | case 0: // Other 1G Rev 1 |
| 86 | spd_index = 0; |
| 87 | break; |
| 88 | case 2: // Other 1G Rev 2 |
| 89 | spd_index = 1; |
| 90 | break; |
| 91 | case 1: // Other 2G Rev 1 |
| 92 | case 3: // Other 2G Rev 2 |
| 93 | spd_index = 2; |
| 94 | break; |
| 95 | case 4: // Samsung 1G Rev 1 |
| 96 | spd_index = 3; |
| 97 | break; |
| 98 | case 6: // Samsung 1G Rev 2 |
| 99 | spd_index = 4; |
| 100 | break; |
| 101 | case 5: // Samsung 2G Rev 1 |
| 102 | case 7: // Samsung 2G Rev 2 |
| 103 | spd_index = 5; |
| 104 | break; |
| 105 | } |
| 106 | |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 107 | spd_data = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, |
| 108 | &spd_file_len); |
Vladimir Serbinenko | 1287416 | 2014-01-12 14:12:15 +0100 | [diff] [blame] | 109 | if (!spd_data) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 110 | die("SPD data not found."); |
Vladimir Serbinenko | 1287416 | 2014-01-12 14:12:15 +0100 | [diff] [blame] | 111 | if (spd_file_len < (spd_index + 1) * 256) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 112 | die("Missing SPD data."); |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 113 | return spd_data[spd_index]; |
| 114 | } |
| 115 | |
| 116 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
| 117 | { |
| 118 | struct pei_data pei_data_template = { |
| 119 | .pei_version = PEI_VERSION, |
Angel Pons | c802745 | 2020-09-14 16:36:28 +0200 | [diff] [blame^] | 120 | .mchbar = DEFAULT_MCHBAR, |
| 121 | .dmibar = DEFAULT_DMIBAR, |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 122 | .epbar = DEFAULT_EPBAR, |
| 123 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
Angel Pons | b21bffa | 2020-07-03 01:02:28 +0200 | [diff] [blame] | 124 | .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE, |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 125 | .wdbbar = 0x4000000, |
| 126 | .wdbsize = 0x1000, |
| 127 | .hpet_address = CONFIG_HPET_ADDRESS, |
Angel Pons | 92717ff | 2020-09-14 16:22:22 +0200 | [diff] [blame] | 128 | .rcba = (uintptr_t)DEFAULT_RCBA, |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 129 | .pmbase = DEFAULT_PMBASE, |
| 130 | .gpiobase = DEFAULT_GPIOBASE, |
| 131 | .thermalbase = 0xfed08000, |
| 132 | .system_type = 0, // 0 Mobile, 1 Desktop/Server |
| 133 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 134 | .spd_addresses = { 0xa0, 0x00,0x00,0x00 }, |
| 135 | .ts_addresses = { 0x30, 0x00, 0x00, 0x00 }, |
| 136 | .ec_present = 1, |
| 137 | // 0 = leave channel enabled |
| 138 | // 1 = disable dimm 0 on channel |
| 139 | // 2 = disable dimm 1 on channel |
| 140 | // 3 = disable dimm 0+1 on channel |
| 141 | .dimm_channel0_disabled = 2, |
| 142 | .dimm_channel1_disabled = 2, |
| 143 | .max_ddr3_freq = 1333, |
| 144 | .usb_port_config = { |
| 145 | { 1, 0, 0x0080 }, /* P0: Port 0 (OC0) */ |
| 146 | { 1, 1, 0x0080 }, /* P1: Port 1 (OC1) */ |
| 147 | { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */ |
| 148 | { 1, 0, 0x0040 }, /* P3: MMC (no OC) */ |
| 149 | { 0, 0, 0x0000 }, /* P4: Empty */ |
| 150 | { 0, 0, 0x0000 }, /* P5: Empty */ |
| 151 | { 0, 0, 0x0000 }, /* P6: Empty */ |
| 152 | { 0, 0, 0x0000 }, /* P7: Empty */ |
| 153 | { 1, 4, 0x0040 }, /* P8: MINIPCIE2 (no OC) */ |
| 154 | { 0, 4, 0x0000 }, /* P9: Empty */ |
| 155 | { 0, 4, 0x0000 }, /* P10: Empty */ |
| 156 | { 1, 4, 0x0040 }, /* P11: Camera (no OC) */ |
| 157 | { 0, 4, 0x0000 }, /* P12: Empty */ |
| 158 | { 0, 4, 0x0000 }, /* P13: Empty */ |
| 159 | }, |
| 160 | }; |
| 161 | *pei_data = pei_data_template; |
Patrick Rudolph | 59b4255 | 2019-05-08 12:44:15 +0200 | [diff] [blame] | 162 | memcpy(pei_data->spd_data[2], locate_spd(), 256); |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 166 | /* enabled power USB oc pin */ |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 167 | { 1, 1, 0 }, /* P0: Port 0 (OC0) */ |
| 168 | { 1, 1, 1 }, /* P1: Port 1 (OC1) */ |
| 169 | { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */ |
| 170 | { 1, 0, -1 }, /* P3: MMC (no OC) */ |
| 171 | { 0, 0, -1 }, /* P4: Empty */ |
| 172 | { 0, 0, -1 }, /* P5: Empty */ |
| 173 | { 0, 0, -1 }, /* P6: Empty */ |
| 174 | { 0, 0, -1 }, /* P7: Empty */ |
| 175 | { 1, 0, -1 }, /* P8: MINIPCIE2 (no OC) */ |
| 176 | { 0, 0, -1 }, /* P9: Empty */ |
| 177 | { 0, 0, -1 }, /* P10: Empty */ |
| 178 | { 1, 0, -1 }, /* P11: Camera (no OC) */ |
| 179 | { 0, 0, -1 }, /* P12: Empty */ |
| 180 | { 0, 0, -1 }, /* P13: Empty */ |
| 181 | }; |
| 182 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 183 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 184 | { |
Patrick Rudolph | 2585209 | 2016-04-07 18:51:12 +0200 | [diff] [blame] | 185 | /* get onboard dimm spd */ |
Kyösti Mälkki | 38ab6f2 | 2016-10-01 12:54:01 +0300 | [diff] [blame] | 186 | memcpy(&spd[2], locate_spd(), 256); |
Patrick Rudolph | 2585209 | 2016-04-07 18:51:12 +0200 | [diff] [blame] | 187 | /* read removable dimm spd */ |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 188 | read_spd(&spd[0], 0x50, id_only); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 189 | } |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 190 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 191 | void mainboard_early_init(int s3resume) |
| 192 | { |
| 193 | init_bootmode_straps(); |
| 194 | } |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 195 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 196 | int mainboard_should_reset_usb(int s3resume) |
| 197 | { |
| 198 | return !s3resume; |
| 199 | } |