blob: b82d4d3411ebf0cd94f44aafb023ff8b73824f5e [file] [log] [blame]
Angel Ponsd32b6de2020-04-03 01:23:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer155e9b52012-04-27 23:19:58 +02002
3#include <stdint.h>
4#include <string.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02005#include <arch/io.h>
Nico Huber25128a72019-11-17 01:24:44 +01006#include <bootblock_common.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02007#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +03008#include <bootmode.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +11009#include <northbridge/intel/sandybridge/sandybridge.h>
10#include <northbridge/intel/sandybridge/raminit.h>
11#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010012#include <southbridge/intel/common/gpio.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110013#include <superio/smsc/lpc47n207/lpc47n207.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020014
Nico Huber25128a72019-11-17 01:24:44 +010015void bootblock_mainboard_early_init(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020016{
Nico Huber25128a72019-11-17 01:24:44 +010017 if (CONFIG(DRIVERS_UART_8250IO))
18 try_enabling_LPC47N207_uart();
Stefan Reinauer155e9b52012-04-27 23:19:58 +020019}
20
Arthur Heymans9c538342019-11-12 16:42:33 +010021void mainboard_late_rcba_config(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020022{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030023 /*
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 Reinauer155e9b52012-04-27 23:19:58 +020058}
59
Keith Hui45e4ab42023-07-22 12:49:05 -040060static unsigned int get_spd_index(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020061{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020062 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 Hui45e4ab42023-07-22 12:49:05 -040075 unsigned int spd_index = 0;
Stefan Reinauer155e9b52012-04-27 23:19:58 +020076
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 Hui45e4ab42023-07-22 12:49:05 -040099 return spd_index;
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100100}
101
102void mainboard_fill_pei_data(struct pei_data *pei_data)
103{
Keith Hui7039edd2023-07-21 10:12:05 -0400104 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 Hui7039edd2023-07-21 10:12:05 -0400107 /* 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 Serbinenko0a07c5c2016-02-10 03:01:37 +0100109}
110
Keith Hui45e4ab42023-07-22 12:49:05 -0400111void mb_get_spd_map(struct spd_info *spdi)
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100112{
Keith Hui45e4ab42023-07-22 12:49:05 -0400113 spdi->addresses[0] = 0x50;
114 spdi->addresses[2] = SPD_MEMORY_DOWN;
115 spdi->spd_index = get_spd_index();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100116}