blob: 3f515ec37457e7e020aef460162ef2c791311129 [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
Felix Held972d9f22022-02-23 16:32:20 +01003#include <arch/hpet.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02004#include <stdint.h>
5#include <string.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02006#include <arch/io.h>
Nico Huber25128a72019-11-17 01:24:44 +01007#include <bootblock_common.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02008#include <cbfs.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02009#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +030010#include <bootmode.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110011#include <northbridge/intel/sandybridge/sandybridge.h>
12#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010013#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110014#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010015#include <southbridge/intel/common/gpio.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110016#include <superio/smsc/lpc47n207/lpc47n207.h>
Matt DeVillier2b297d92019-11-24 17:36:38 -060017#include "option_table.h"
Stefan Reinauer155e9b52012-04-27 23:19:58 +020018
Nico Huber25128a72019-11-17 01:24:44 +010019void bootblock_mainboard_early_init(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020020{
Nico Huber25128a72019-11-17 01:24:44 +010021 if (CONFIG(DRIVERS_UART_8250IO))
22 try_enabling_LPC47N207_uart();
Stefan Reinauer155e9b52012-04-27 23:19:58 +020023}
24
Arthur Heymans9c538342019-11-12 16:42:33 +010025void mainboard_late_rcba_config(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020026{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030027 /*
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 Reinauer155e9b52012-04-27 23:19:58 +020062}
63
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010064static const uint8_t *locate_spd(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020065{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020066 typedef const uint8_t spd_blob[256];
Stefan Reinauer155e9b52012-04-27 23:19:58 +020067 spd_blob *spd_data;
Vladimir Serbinenko12874162014-01-12 14:12:15 +010068 size_t spd_file_len;
Stefan Reinauer155e9b52012-04-27 23:19:58 +020069
Stefan Reinauer155e9b52012-04-27 23:19:58 +020070 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 Werner834b3ec2020-03-04 16:52:08 -0800108 spd_data = cbfs_map("spd.bin", &spd_file_len);
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100109 if (!spd_data)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200110 die("SPD data not found.");
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100111 if (spd_file_len < (spd_index + 1) * 256)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200112 die("Missing SPD data.");
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100113 return spd_data[spd_index];
114}
115
116void mainboard_fill_pei_data(struct pei_data *pei_data)
117{
118 struct pei_data pei_data_template = {
119 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +0100120 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
121 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
122 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -0700123 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +0200124 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100125 .wdbbar = 0x4000000,
126 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +0100127 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +0200128 .rcba = (uintptr_t)DEFAULT_RCBA,
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100129 .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 Serbinenko0a07c5c2016-02-10 03:01:37 +0100137 .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 Rudolph59b42552019-05-08 12:44:15 +0200156 memcpy(pei_data->spd_data[2], locate_spd(), 256);
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100157}
158
159const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100160 /* enabled power USB oc pin */
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100161 { 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älkkie258b9a2016-11-18 19:59:23 +0200177void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100178{
Patrick Rudolph25852092016-04-07 18:51:12 +0200179 /* get onboard dimm spd */
Kyösti Mälkki38ab6f22016-10-01 12:54:01 +0300180 memcpy(&spd[2], locate_spd(), 256);
Patrick Rudolph25852092016-04-07 18:51:12 +0200181 /* read removable dimm spd */
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200182 read_spd(&spd[0], 0x50, id_only);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100183}