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 | |
Felix Held | 972d9f2 | 2022-02-23 16:32:20 +0100 | [diff] [blame] | 3 | #include <arch/hpet.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | #include <string.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 6 | #include <arch/io.h> |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 7 | #include <bootblock_common.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 8 | #include <cbfs.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 9 | #include <console/console.h> |
Kyösti Mälkki | e3ddee0 | 2014-05-03 10:45:28 +0300 | [diff] [blame] | 10 | #include <bootmode.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 11 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 12 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 13 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 14 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 15 | #include <southbridge/intel/common/gpio.h> |
Edward O'Callaghan | 74834e0 | 2015-01-04 04:17:35 +1100 | [diff] [blame] | 16 | #include <superio/smsc/lpc47n207/lpc47n207.h> |
Matt DeVillier | 2b297d9 | 2019-11-24 17:36:38 -0600 | [diff] [blame] | 17 | #include "option_table.h" |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 18 | |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 19 | void bootblock_mainboard_early_init(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 20 | { |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 21 | if (CONFIG(DRIVERS_UART_8250IO)) |
| 22 | try_enabling_LPC47N207_uart(); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 23 | } |
| 24 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 25 | void mainboard_late_rcba_config(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 26 | { |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 27 | /* |
| 28 | * GFX INTA -> PIRQA (MSI) |
| 29 | * D28IP_P1IP WLAN INTA -> PIRQB |
| 30 | * D28IP_P4IP ETH0 INTB -> PIRQC (MSI) |
| 31 | * D29IP_E1P EHCI1 INTA -> PIRQD |
| 32 | * D26IP_E2P EHCI2 INTA -> PIRQB |
| 33 | * D31IP_SIP SATA INTA -> PIRQA (MSI) |
| 34 | * D31IP_SMIP SMBUS INTC -> PIRQH |
| 35 | * D31IP_TTIP THRT INTB -> PIRQG |
| 36 | * D27IP_ZIP HDA INTA -> PIRQG (MSI) |
| 37 | * |
| 38 | * LIGHTSENSOR -> PIRQE (Edge Triggered) |
| 39 | * TRACKPAD -> PIRQF (Edge Triggered) |
| 40 | */ |
| 41 | |
| 42 | /* Device interrupt pin register (board specific) */ |
| 43 | RCBA32(D31IP) = (INTB << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 44 | (INTC << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 45 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 46 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 47 | RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) | |
| 48 | (INTB << D28IP_P4IP); |
| 49 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 50 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 51 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 52 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 53 | |
| 54 | /* Device interrupt route registers */ |
| 55 | DIR_ROUTE(D31IR, PIRQA, PIRQG, PIRQH, PIRQB); |
| 56 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQG, PIRQH); |
| 57 | DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE); |
| 58 | DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB); |
| 59 | DIR_ROUTE(D26IR, PIRQB, PIRQC, PIRQD, PIRQA); |
| 60 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 61 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 62 | } |
| 63 | |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 64 | static const uint8_t *locate_spd(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 65 | { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 66 | typedef const uint8_t spd_blob[256]; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 67 | spd_blob *spd_data; |
Vladimir Serbinenko | 1287416 | 2014-01-12 14:12:15 +0100 | [diff] [blame] | 68 | size_t spd_file_len; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 69 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 70 | u32 gp_lvl2 = inl(DEFAULT_GPIOBASE + 0x38); |
| 71 | u8 gpio33, gpio41, gpio49; |
| 72 | gpio33 = (gp_lvl2 >> (33-32)) & 1; |
| 73 | gpio41 = (gp_lvl2 >> (41-32)) & 1; |
| 74 | gpio49 = (gp_lvl2 >> (49-32)) & 1; |
| 75 | printk(BIOS_DEBUG, "Memory Straps:\n"); |
| 76 | printk(BIOS_DEBUG, " - memory capacity %dGB\n", |
| 77 | gpio33 ? 2 : 1); |
| 78 | printk(BIOS_DEBUG, " - die revision %d\n", |
| 79 | gpio41 ? 2 : 1); |
| 80 | printk(BIOS_DEBUG, " - vendor %s\n", |
| 81 | gpio49 ? "Samsung" : "Other"); |
| 82 | |
| 83 | int spd_index = 0; |
| 84 | |
| 85 | switch ((gpio49 << 2) | (gpio41 << 1) | gpio33) { |
| 86 | case 0: // Other 1G Rev 1 |
| 87 | spd_index = 0; |
| 88 | break; |
| 89 | case 2: // Other 1G Rev 2 |
| 90 | spd_index = 1; |
| 91 | break; |
| 92 | case 1: // Other 2G Rev 1 |
| 93 | case 3: // Other 2G Rev 2 |
| 94 | spd_index = 2; |
| 95 | break; |
| 96 | case 4: // Samsung 1G Rev 1 |
| 97 | spd_index = 3; |
| 98 | break; |
| 99 | case 6: // Samsung 1G Rev 2 |
| 100 | spd_index = 4; |
| 101 | break; |
| 102 | case 5: // Samsung 2G Rev 1 |
| 103 | case 7: // Samsung 2G Rev 2 |
| 104 | spd_index = 5; |
| 105 | break; |
| 106 | } |
| 107 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 108 | spd_data = cbfs_map("spd.bin", &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 | d9e58dc | 2021-01-20 01:22:20 +0100 | [diff] [blame] | 120 | .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE, |
| 121 | .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE, |
| 122 | .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE, |
Shelley Chen | 4e9bb33 | 2021-10-20 15:43:45 -0700 | [diff] [blame] | 123 | .pciexbar = CONFIG_ECAM_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, |
Felix Held | 972d9f2 | 2022-02-23 16:32:20 +0100 | [diff] [blame] | 127 | .hpet_address = HPET_BASE_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, |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 137 | .max_ddr3_freq = 1333, |
| 138 | .usb_port_config = { |
| 139 | { 1, 0, 0x0080 }, /* P0: Port 0 (OC0) */ |
| 140 | { 1, 1, 0x0080 }, /* P1: Port 1 (OC1) */ |
| 141 | { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */ |
| 142 | { 1, 0, 0x0040 }, /* P3: MMC (no OC) */ |
| 143 | { 0, 0, 0x0000 }, /* P4: Empty */ |
| 144 | { 0, 0, 0x0000 }, /* P5: Empty */ |
| 145 | { 0, 0, 0x0000 }, /* P6: Empty */ |
| 146 | { 0, 0, 0x0000 }, /* P7: Empty */ |
| 147 | { 1, 4, 0x0040 }, /* P8: MINIPCIE2 (no OC) */ |
| 148 | { 0, 4, 0x0000 }, /* P9: Empty */ |
| 149 | { 0, 4, 0x0000 }, /* P10: Empty */ |
| 150 | { 1, 4, 0x0040 }, /* P11: Camera (no OC) */ |
| 151 | { 0, 4, 0x0000 }, /* P12: Empty */ |
| 152 | { 0, 4, 0x0000 }, /* P13: Empty */ |
| 153 | }, |
| 154 | }; |
| 155 | *pei_data = pei_data_template; |
Patrick Rudolph | 59b4255 | 2019-05-08 12:44:15 +0200 | [diff] [blame] | 156 | memcpy(pei_data->spd_data[2], locate_spd(), 256); |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 160 | /* enabled power USB oc pin */ |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 161 | { 1, 1, 0 }, /* P0: Port 0 (OC0) */ |
| 162 | { 1, 1, 1 }, /* P1: Port 1 (OC1) */ |
| 163 | { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */ |
| 164 | { 1, 0, -1 }, /* P3: MMC (no OC) */ |
| 165 | { 0, 0, -1 }, /* P4: Empty */ |
| 166 | { 0, 0, -1 }, /* P5: Empty */ |
| 167 | { 0, 0, -1 }, /* P6: Empty */ |
| 168 | { 0, 0, -1 }, /* P7: Empty */ |
| 169 | { 1, 0, -1 }, /* P8: MINIPCIE2 (no OC) */ |
| 170 | { 0, 0, -1 }, /* P9: Empty */ |
| 171 | { 0, 0, -1 }, /* P10: Empty */ |
| 172 | { 1, 0, -1 }, /* P11: Camera (no OC) */ |
| 173 | { 0, 0, -1 }, /* P12: Empty */ |
| 174 | { 0, 0, -1 }, /* P13: Empty */ |
| 175 | }; |
| 176 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 177 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 178 | { |
Patrick Rudolph | 2585209 | 2016-04-07 18:51:12 +0200 | [diff] [blame] | 179 | /* get onboard dimm spd */ |
Kyösti Mälkki | 38ab6f2 | 2016-10-01 12:54:01 +0300 | [diff] [blame] | 180 | memcpy(&spd[2], locate_spd(), 256); |
Patrick Rudolph | 2585209 | 2016-04-07 18:51:12 +0200 | [diff] [blame] | 181 | /* read removable dimm spd */ |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 182 | read_spd(&spd[0], 0x50, id_only); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 183 | } |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 184 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 185 | int mainboard_should_reset_usb(int s3resume) |
| 186 | { |
| 187 | return !s3resume; |
| 188 | } |