blob: 0249c3bc5649b6ce2e506cd8e0ba1b1f0d2bea72 [file] [log] [blame]
Stefan Reinauer155e9b52012-04-27 23:19:58 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer155e9b52012-04-27 23:19:58 +020015 */
16
17#include <stdint.h>
18#include <string.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020019#include <arch/io.h>
Nico Huber25128a72019-11-17 01:24:44 +010020#include <bootblock_common.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020021#include <cpu/x86/lapic.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020022#include <cbfs.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020023#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +030024#include <bootmode.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110025#include <northbridge/intel/sandybridge/sandybridge.h>
26#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010027#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110028#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010029#include <southbridge/intel/common/gpio.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110030#include <superio/smsc/lpc47n207/lpc47n207.h>
Matt DeVillier2b297d92019-11-24 17:36:38 -060031#include "option_table.h"
Stefan Reinauer155e9b52012-04-27 23:19:58 +020032
Nico Huber25128a72019-11-17 01:24:44 +010033void bootblock_mainboard_early_init(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020034{
Nico Huber25128a72019-11-17 01:24:44 +010035 if (CONFIG(DRIVERS_UART_8250IO))
36 try_enabling_LPC47N207_uart();
Stefan Reinauer155e9b52012-04-27 23:19:58 +020037}
38
Arthur Heymans9c538342019-11-12 16:42:33 +010039void mainboard_late_rcba_config(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020040{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030041 /*
42 * GFX INTA -> PIRQA (MSI)
43 * D28IP_P1IP WLAN INTA -> PIRQB
44 * D28IP_P4IP ETH0 INTB -> PIRQC (MSI)
45 * D29IP_E1P EHCI1 INTA -> PIRQD
46 * D26IP_E2P EHCI2 INTA -> PIRQB
47 * D31IP_SIP SATA INTA -> PIRQA (MSI)
48 * D31IP_SMIP SMBUS INTC -> PIRQH
49 * D31IP_TTIP THRT INTB -> PIRQG
50 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
51 *
52 * LIGHTSENSOR -> PIRQE (Edge Triggered)
53 * TRACKPAD -> PIRQF (Edge Triggered)
54 */
55
56 /* Device interrupt pin register (board specific) */
57 RCBA32(D31IP) = (INTB << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
58 (INTC << D31IP_SMIP) | (INTA << D31IP_SIP);
59 RCBA32(D30IP) = (NOINT << D30IP_PIP);
60 RCBA32(D29IP) = (INTA << D29IP_E1P);
61 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
62 (INTB << D28IP_P4IP);
63 RCBA32(D27IP) = (INTA << D27IP_ZIP);
64 RCBA32(D26IP) = (INTA << D26IP_E2P);
65 RCBA32(D25IP) = (NOINT << D25IP_LIP);
66 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
67
68 /* Device interrupt route registers */
69 DIR_ROUTE(D31IR, PIRQA, PIRQG, PIRQH, PIRQB);
70 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQG, PIRQH);
71 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
72 DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB);
73 DIR_ROUTE(D26IR, PIRQB, PIRQC, PIRQD, PIRQA);
74 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
75 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020076}
77
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +010078static const uint8_t *locate_spd(void)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020079{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020080 typedef const uint8_t spd_blob[256];
Stefan Reinauer155e9b52012-04-27 23:19:58 +020081 spd_blob *spd_data;
Vladimir Serbinenko12874162014-01-12 14:12:15 +010082 size_t spd_file_len;
Stefan Reinauer155e9b52012-04-27 23:19:58 +020083
Stefan Reinauer155e9b52012-04-27 23:19:58 +020084 u32 gp_lvl2 = inl(DEFAULT_GPIOBASE + 0x38);
85 u8 gpio33, gpio41, gpio49;
86 gpio33 = (gp_lvl2 >> (33-32)) & 1;
87 gpio41 = (gp_lvl2 >> (41-32)) & 1;
88 gpio49 = (gp_lvl2 >> (49-32)) & 1;
89 printk(BIOS_DEBUG, "Memory Straps:\n");
90 printk(BIOS_DEBUG, " - memory capacity %dGB\n",
91 gpio33 ? 2 : 1);
92 printk(BIOS_DEBUG, " - die revision %d\n",
93 gpio41 ? 2 : 1);
94 printk(BIOS_DEBUG, " - vendor %s\n",
95 gpio49 ? "Samsung" : "Other");
96
97 int spd_index = 0;
98
99 switch ((gpio49 << 2) | (gpio41 << 1) | gpio33) {
100 case 0: // Other 1G Rev 1
101 spd_index = 0;
102 break;
103 case 2: // Other 1G Rev 2
104 spd_index = 1;
105 break;
106 case 1: // Other 2G Rev 1
107 case 3: // Other 2G Rev 2
108 spd_index = 2;
109 break;
110 case 4: // Samsung 1G Rev 1
111 spd_index = 3;
112 break;
113 case 6: // Samsung 1G Rev 2
114 spd_index = 4;
115 break;
116 case 5: // Samsung 2G Rev 1
117 case 7: // Samsung 2G Rev 2
118 spd_index = 5;
119 break;
120 }
121
Aaron Durbin899d13d2015-05-15 23:39:23 -0500122 spd_data = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
123 &spd_file_len);
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100124 if (!spd_data)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200125 die("SPD data not found.");
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100126 if (spd_file_len < (spd_index + 1) * 256)
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200127 die("Missing SPD data.");
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100128 return spd_data[spd_index];
129}
130
131void mainboard_fill_pei_data(struct pei_data *pei_data)
132{
133 struct pei_data pei_data_template = {
134 .pei_version = PEI_VERSION,
135 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
136 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
137 .epbar = DEFAULT_EPBAR,
138 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
139 .smbusbar = SMBUS_IO_BASE,
140 .wdbbar = 0x4000000,
141 .wdbsize = 0x1000,
142 .hpet_address = CONFIG_HPET_ADDRESS,
143 .rcba = (uintptr_t)DEFAULT_RCBABASE,
144 .pmbase = DEFAULT_PMBASE,
145 .gpiobase = DEFAULT_GPIOBASE,
146 .thermalbase = 0xfed08000,
147 .system_type = 0, // 0 Mobile, 1 Desktop/Server
148 .tseg_size = CONFIG_SMM_TSEG_SIZE,
149 .spd_addresses = { 0xa0, 0x00,0x00,0x00 },
150 .ts_addresses = { 0x30, 0x00, 0x00, 0x00 },
151 .ec_present = 1,
152 // 0 = leave channel enabled
153 // 1 = disable dimm 0 on channel
154 // 2 = disable dimm 1 on channel
155 // 3 = disable dimm 0+1 on channel
156 .dimm_channel0_disabled = 2,
157 .dimm_channel1_disabled = 2,
158 .max_ddr3_freq = 1333,
159 .usb_port_config = {
160 { 1, 0, 0x0080 }, /* P0: Port 0 (OC0) */
161 { 1, 1, 0x0080 }, /* P1: Port 1 (OC1) */
162 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
163 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
164 { 0, 0, 0x0000 }, /* P4: Empty */
165 { 0, 0, 0x0000 }, /* P5: Empty */
166 { 0, 0, 0x0000 }, /* P6: Empty */
167 { 0, 0, 0x0000 }, /* P7: Empty */
168 { 1, 4, 0x0040 }, /* P8: MINIPCIE2 (no OC) */
169 { 0, 4, 0x0000 }, /* P9: Empty */
170 { 0, 4, 0x0000 }, /* P10: Empty */
171 { 1, 4, 0x0040 }, /* P11: Camera (no OC) */
172 { 0, 4, 0x0000 }, /* P12: Empty */
173 { 0, 4, 0x0000 }, /* P13: Empty */
174 },
175 };
176 *pei_data = pei_data_template;
Patrick Rudolph59b42552019-05-08 12:44:15 +0200177 memcpy(pei_data->spd_data[2], locate_spd(), 256);
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100178}
179
180const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100181 /* enabled power USB oc pin */
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100182 { 1, 1, 0 }, /* P0: Port 0 (OC0) */
183 { 1, 1, 1 }, /* P1: Port 1 (OC1) */
184 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
185 { 1, 0, -1 }, /* P3: MMC (no OC) */
186 { 0, 0, -1 }, /* P4: Empty */
187 { 0, 0, -1 }, /* P5: Empty */
188 { 0, 0, -1 }, /* P6: Empty */
189 { 0, 0, -1 }, /* P7: Empty */
190 { 1, 0, -1 }, /* P8: MINIPCIE2 (no OC) */
191 { 0, 0, -1 }, /* P9: Empty */
192 { 0, 0, -1 }, /* P10: Empty */
193 { 1, 0, -1 }, /* P11: Camera (no OC) */
194 { 0, 0, -1 }, /* P12: Empty */
195 { 0, 0, -1 }, /* P13: Empty */
196};
197
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200198void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenko0a07c5c2016-02-10 03:01:37 +0100199{
Patrick Rudolph25852092016-04-07 18:51:12 +0200200 /* get onboard dimm spd */
Kyösti Mälkki38ab6f22016-10-01 12:54:01 +0300201 memcpy(&spd[2], locate_spd(), 256);
Patrick Rudolph25852092016-04-07 18:51:12 +0200202 /* read removable dimm spd */
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200203 read_spd(&spd[0], 0x50, id_only);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100204}
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200205
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100206void mainboard_early_init(int s3resume)
207{
208 init_bootmode_straps();
209}
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200210
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100211int mainboard_should_reset_usb(int s3resume)
212{
213 return !s3resume;
214}