blob: a885f5b2a154e7f67cf5478aeee5338003abae7e [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 <cbfs.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02008#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +03009#include <bootmode.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110010#include <northbridge/intel/sandybridge/sandybridge.h>
11#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010012#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110013#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010014#include <southbridge/intel/common/gpio.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110015#include <superio/smsc/lpc47n207/lpc47n207.h>
Matt DeVillier2b297d92019-11-24 17:36:38 -060016#include "option_table.h"
Stefan Reinauer155e9b52012-04-27 23:19:58 +020017
Nico Huber25128a72019-11-17 01:24:44 +010018void bootblock_mainboard_early_init(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020019{
Nico Huber25128a72019-11-17 01:24:44 +010020 if (CONFIG(DRIVERS_UART_8250IO))
21 try_enabling_LPC47N207_uart();
Stefan Reinauer155e9b52012-04-27 23:19:58 +020022}
23
Arthur Heymans9c538342019-11-12 16:42:33 +010024void mainboard_late_rcba_config(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020025{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030026 /*
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 Reinauer155e9b52012-04-27 23:19:58 +020061}
62
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010063static const uint8_t *locate_spd(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020064{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020065 typedef const uint8_t spd_blob[256];
Stefan Reinauer155e9b52012-04-27 23:19:58 +020066 spd_blob *spd_data;
Vladimir Serbinenko12874162014-01-12 14:12:15 +010067 size_t spd_file_len;
Stefan Reinauer155e9b52012-04-27 23:19:58 +020068
Stefan Reinauer155e9b52012-04-27 23:19:58 +020069 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
Julius Werner834b3ec2020-03-04 16:52:08 -0800107 spd_data = cbfs_map("spd.bin", &spd_file_len);
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100108 if (!spd_data)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200109 die("SPD data not found.");
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100110 if (spd_file_len < (spd_index + 1) * 256)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200111 die("Missing SPD data.");
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100112 return spd_data[spd_index];
113}
114
115void mainboard_fill_pei_data(struct pei_data *pei_data)
116{
117 struct pei_data pei_data_template = {
118 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +0100119 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
120 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
121 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -0700122 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +0200123 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100124 .wdbbar = 0x4000000,
125 .wdbsize = 0x1000,
126 .hpet_address = CONFIG_HPET_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +0200127 .rcba = (uintptr_t)DEFAULT_RCBA,
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100128 .pmbase = DEFAULT_PMBASE,
129 .gpiobase = DEFAULT_GPIOBASE,
130 .thermalbase = 0xfed08000,
131 .system_type = 0, // 0 Mobile, 1 Desktop/Server
132 .tseg_size = CONFIG_SMM_TSEG_SIZE,
133 .spd_addresses = { 0xa0, 0x00,0x00,0x00 },
134 .ts_addresses = { 0x30, 0x00, 0x00, 0x00 },
135 .ec_present = 1,
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100136 .max_ddr3_freq = 1333,
137 .usb_port_config = {
138 { 1, 0, 0x0080 }, /* P0: Port 0 (OC0) */
139 { 1, 1, 0x0080 }, /* P1: Port 1 (OC1) */
140 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
141 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
142 { 0, 0, 0x0000 }, /* P4: Empty */
143 { 0, 0, 0x0000 }, /* P5: Empty */
144 { 0, 0, 0x0000 }, /* P6: Empty */
145 { 0, 0, 0x0000 }, /* P7: Empty */
146 { 1, 4, 0x0040 }, /* P8: MINIPCIE2 (no OC) */
147 { 0, 4, 0x0000 }, /* P9: Empty */
148 { 0, 4, 0x0000 }, /* P10: Empty */
149 { 1, 4, 0x0040 }, /* P11: Camera (no OC) */
150 { 0, 4, 0x0000 }, /* P12: Empty */
151 { 0, 4, 0x0000 }, /* P13: Empty */
152 },
153 };
154 *pei_data = pei_data_template;
Patrick Rudolph59b42552019-05-08 12:44:15 +0200155 memcpy(pei_data->spd_data[2], locate_spd(), 256);
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100156}
157
158const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100159 /* enabled power USB oc pin */
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100160 { 1, 1, 0 }, /* P0: Port 0 (OC0) */
161 { 1, 1, 1 }, /* P1: Port 1 (OC1) */
162 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
163 { 1, 0, -1 }, /* P3: MMC (no OC) */
164 { 0, 0, -1 }, /* P4: Empty */
165 { 0, 0, -1 }, /* P5: Empty */
166 { 0, 0, -1 }, /* P6: Empty */
167 { 0, 0, -1 }, /* P7: Empty */
168 { 1, 0, -1 }, /* P8: MINIPCIE2 (no OC) */
169 { 0, 0, -1 }, /* P9: Empty */
170 { 0, 0, -1 }, /* P10: Empty */
171 { 1, 0, -1 }, /* P11: Camera (no OC) */
172 { 0, 0, -1 }, /* P12: Empty */
173 { 0, 0, -1 }, /* P13: Empty */
174};
175
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200176void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100177{
Patrick Rudolph25852092016-04-07 18:51:12 +0200178 /* get onboard dimm spd */
Kyösti Mälkki38ab6f22016-10-01 12:54:01 +0300179 memcpy(&spd[2], locate_spd(), 256);
Patrick Rudolph25852092016-04-07 18:51:12 +0200180 /* read removable dimm spd */
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200181 read_spd(&spd[0], 0x50, id_only);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100182}
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200183
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100184void mainboard_early_init(int s3resume)
185{
186 init_bootmode_straps();
187}
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200188
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100189int mainboard_should_reset_usb(int s3resume)
190{
191 return !s3resume;
192}