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 <console/console.h> |
Kyösti Mälkki | e3ddee0 | 2014-05-03 10:45:28 +0300 | [diff] [blame] | 8 | #include <bootmode.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 9 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 10 | #include <northbridge/intel/sandybridge/raminit.h> |
| 11 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 12 | #include <southbridge/intel/common/gpio.h> |
Edward O'Callaghan | 74834e0 | 2015-01-04 04:17:35 +1100 | [diff] [blame] | 13 | #include <superio/smsc/lpc47n207/lpc47n207.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 14 | |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 15 | void bootblock_mainboard_early_init(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 16 | { |
Nico Huber | 25128a7 | 2019-11-17 01:24:44 +0100 | [diff] [blame] | 17 | if (CONFIG(DRIVERS_UART_8250IO)) |
| 18 | try_enabling_LPC47N207_uart(); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 19 | } |
| 20 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 21 | void mainboard_late_rcba_config(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 22 | { |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 23 | /* |
| 24 | * GFX INTA -> PIRQA (MSI) |
| 25 | * D28IP_P1IP WLAN INTA -> PIRQB |
| 26 | * D28IP_P4IP ETH0 INTB -> PIRQC (MSI) |
| 27 | * D29IP_E1P EHCI1 INTA -> PIRQD |
| 28 | * D26IP_E2P EHCI2 INTA -> PIRQB |
| 29 | * D31IP_SIP SATA INTA -> PIRQA (MSI) |
| 30 | * D31IP_SMIP SMBUS INTC -> PIRQH |
| 31 | * D31IP_TTIP THRT INTB -> PIRQG |
| 32 | * D27IP_ZIP HDA INTA -> PIRQG (MSI) |
| 33 | * |
| 34 | * LIGHTSENSOR -> PIRQE (Edge Triggered) |
| 35 | * TRACKPAD -> PIRQF (Edge Triggered) |
| 36 | */ |
| 37 | |
| 38 | /* Device interrupt pin register (board specific) */ |
| 39 | RCBA32(D31IP) = (INTB << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 40 | (INTC << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 41 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 42 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 43 | RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) | |
| 44 | (INTB << D28IP_P4IP); |
| 45 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 46 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 47 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 48 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 49 | |
| 50 | /* Device interrupt route registers */ |
| 51 | DIR_ROUTE(D31IR, PIRQA, PIRQG, PIRQH, PIRQB); |
| 52 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQG, PIRQH); |
| 53 | DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE); |
| 54 | DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB); |
| 55 | DIR_ROUTE(D26IR, PIRQB, PIRQC, PIRQD, PIRQA); |
| 56 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 57 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 60 | static unsigned int get_spd_index(void) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 61 | { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 62 | u32 gp_lvl2 = inl(DEFAULT_GPIOBASE + 0x38); |
| 63 | u8 gpio33, gpio41, gpio49; |
| 64 | gpio33 = (gp_lvl2 >> (33-32)) & 1; |
| 65 | gpio41 = (gp_lvl2 >> (41-32)) & 1; |
| 66 | gpio49 = (gp_lvl2 >> (49-32)) & 1; |
| 67 | printk(BIOS_DEBUG, "Memory Straps:\n"); |
| 68 | printk(BIOS_DEBUG, " - memory capacity %dGB\n", |
| 69 | gpio33 ? 2 : 1); |
| 70 | printk(BIOS_DEBUG, " - die revision %d\n", |
| 71 | gpio41 ? 2 : 1); |
| 72 | printk(BIOS_DEBUG, " - vendor %s\n", |
| 73 | gpio49 ? "Samsung" : "Other"); |
| 74 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 75 | unsigned int spd_index = 0; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 76 | |
| 77 | switch ((gpio49 << 2) | (gpio41 << 1) | gpio33) { |
| 78 | case 0: // Other 1G Rev 1 |
| 79 | spd_index = 0; |
| 80 | break; |
| 81 | case 2: // Other 1G Rev 2 |
| 82 | spd_index = 1; |
| 83 | break; |
| 84 | case 1: // Other 2G Rev 1 |
| 85 | case 3: // Other 2G Rev 2 |
| 86 | spd_index = 2; |
| 87 | break; |
| 88 | case 4: // Samsung 1G Rev 1 |
| 89 | spd_index = 3; |
| 90 | break; |
| 91 | case 6: // Samsung 1G Rev 2 |
| 92 | spd_index = 4; |
| 93 | break; |
| 94 | case 5: // Samsung 2G Rev 1 |
| 95 | case 7: // Samsung 2G Rev 2 |
| 96 | spd_index = 5; |
| 97 | break; |
| 98 | } |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 99 | return spd_index; |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
| 103 | { |
Keith Hui | 7039edd | 2023-07-21 10:12:05 -0400 | [diff] [blame] | 104 | const uint8_t tsaddr[] = {0x30, 0x00, 0x00, 0x00}; |
| 105 | |
| 106 | /* TODO: Confirm if nortbridge_fill_pei_data() gets .system_type right (should be 0) */ |
Keith Hui | 7039edd | 2023-07-21 10:12:05 -0400 | [diff] [blame] | 107 | /* Only this board uses .ts_addresses. Fill here to allow removal from devicetree. */ |
| 108 | memcpy(pei_data->ts_addresses, &tsaddr, sizeof(pei_data->ts_addresses)); |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 109 | } |
| 110 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 111 | void mb_get_spd_map(struct spd_info *spdi) |
Vladimir Serbinenko | 0a07c5c | 2016-02-10 03:01:37 +0100 | [diff] [blame] | 112 | { |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 113 | spdi->addresses[0] = 0x50; |
| 114 | spdi->addresses[2] = SPD_MEMORY_DOWN; |
| 115 | spdi->spd_index = get_spd_index(); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 116 | } |