blob: d2a92a8789796d2c1d2092febe44fc5e6ec6c770 [file] [log] [blame]
Angel Ponsd28443e2020-04-05 13:22:44 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06003
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06004#include <stdint.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06005#include <string.h>
6#include <cbfs.h>
7#include <console/console.h>
8#include <cpu/intel/haswell/haswell.h>
9#include "ec/google/chromeec/ec.h"
10#include <northbridge/intel/haswell/haswell.h>
11#include <northbridge/intel/haswell/raminit.h>
12#include <southbridge/intel/lynxpoint/pch.h>
13#include <southbridge/intel/lynxpoint/lp_gpio.h>
14#include <variant/gpio.h>
15#include "../../onboard.h"
16#include "../../variant.h"
17
18const struct rcba_config_instruction rcba_config[] = {
19
20 /*
21 * GFX INTA -> PIRQA (MSI)
22 * D28IP_P1IP PCIE INTA -> PIRQA
23 * D29IP_E1P EHCI INTA -> PIRQD
24 * D20IP_XHCI XHCI INTA -> PIRQC (MSI)
25 * D31IP_SIP SATA INTA -> PIRQF (MSI)
26 * D31IP_SMIP SMBUS INTB -> PIRQG
27 * D31IP_TTIP THRT INTC -> PIRQA
28 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
29 */
30
31 /* Device interrupt pin register (board specific) */
32 RCBA_SET_REG_32(D31IP, (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
33 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP)),
34 RCBA_SET_REG_32(D29IP, (INTA << D29IP_E1P)),
35 RCBA_SET_REG_32(D28IP, (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
36 (INTB << D28IP_P4IP)),
37 RCBA_SET_REG_32(D27IP, (INTA << D27IP_ZIP)),
38 RCBA_SET_REG_32(D26IP, (INTA << D26IP_E2P)),
39 RCBA_SET_REG_32(D22IP, (NOINT << D22IP_MEI1IP)),
40 RCBA_SET_REG_32(D20IP, (INTA << D20IP_XHCI)),
41
42 /* Device interrupt route registers */
43 RCBA_SET_REG_32(D31IR, DIR_ROUTE(PIRQG, PIRQC, PIRQB, PIRQA)),/* LPC */
44 RCBA_SET_REG_32(D29IR, DIR_ROUTE(PIRQD, PIRQD, PIRQD, PIRQD)),/* EHCI */
45 RCBA_SET_REG_32(D28IR, DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD)),/* PCIE */
46 RCBA_SET_REG_32(D27IR, DIR_ROUTE(PIRQG, PIRQG, PIRQG, PIRQG)),/* HDA */
47 RCBA_SET_REG_32(D22IR, DIR_ROUTE(PIRQA, PIRQA, PIRQA, PIRQA)),/* ME */
48 RCBA_SET_REG_32(D21IR, DIR_ROUTE(PIRQE, PIRQF, PIRQF, PIRQF)),/* SIO */
49 RCBA_SET_REG_32(D20IR, DIR_ROUTE(PIRQC, PIRQC, PIRQC, PIRQC)),/* XHCI */
50 RCBA_SET_REG_32(D23IR, DIR_ROUTE(PIRQH, PIRQH, PIRQH, PIRQH)),/* SDIO */
51
52 /* Disable unused devices (board specific) */
53 RCBA_RMW_REG_32(FD, ~0, PCH_DISABLE_ALWAYS),
54
55 RCBA_END_CONFIG,
56};
57
58/* Copy SPD data for on-board memory */
59static void copy_spd(struct pei_data *peid)
60{
61 const int gpio_vector[] = {13, 9, 47, -1};
62 int spd_index = get_gpios(gpio_vector);
63 char *spd_file;
64 size_t spd_file_len;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050065 size_t spd_len = sizeof(peid->spd_data[0]);
Karthikeyan Ramasubramanianc80ff842018-09-17 16:19:34 -060066 uint32_t board_version = PEPPY_BOARD_VERSION_PROTO;
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060067
68 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
69 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
70 &spd_file_len);
71 if (!spd_file)
72 die("SPD data not found.");
73
Matt DeVilliercadd7c72017-05-29 19:10:57 -050074 if (spd_file_len < ((spd_index + 1) * sizeof(peid->spd_data[0]))) {
75 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
76 spd_index = 0;
77 }
78
79 if (spd_file_len < spd_len)
80 die("Missing SPD data.");
81
82 memcpy(peid->spd_data[0], spd_file + (spd_index * spd_len), spd_len);
83
Karthikeyan Ramasubramanianc80ff842018-09-17 16:19:34 -060084 google_chromeec_get_board_version(&board_version);
85 switch (board_version) {
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060086 case PEPPY_BOARD_VERSION_PROTO:
87 /* Index 0 is 2GB config with CH0 only. */
88 if (spd_index == 0)
89 peid->dimm_channel1_disabled = 3;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050090 else
91 memcpy(peid->spd_data[1],
92 spd_file + (spd_index * spd_len), spd_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060093 break;
94
95 case PEPPY_BOARD_VERSION_EVT:
96 default:
Matt DeVillierf41eea42019-12-26 20:10:32 -060097 /* Index 0-3 are 4GB config with both CH0 and CH1.
98 * Index 4-7 are 2GB config with CH0 only. */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060099 if (spd_index > 3)
100 peid->dimm_channel1_disabled = 3;
Matt DeVilliercadd7c72017-05-29 19:10:57 -0500101 else
102 memcpy(peid->spd_data[1],
103 spd_file + (spd_index * spd_len), spd_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -0600104 break;
105 }
Matt DeVillierc12e5ae2016-11-27 02:19:02 -0600106}
107
Kyösti Mälkki157b1892019-08-16 14:02:25 +0300108void variant_romstage_entry(void)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -0600109{
110 struct pei_data pei_data = {
111 .pei_version = PEI_VERSION,
112 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
113 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
114 .epbar = DEFAULT_EPBAR,
Kyösti Mälkki503d3242019-03-05 07:54:28 +0200115 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
Matt DeVillierc12e5ae2016-11-27 02:19:02 -0600116 .smbusbar = SMBUS_IO_BASE,
117 .wdbbar = 0x4000000,
118 .wdbsize = 0x1000,
119 .hpet_address = HPET_ADDR,
120 .rcba = (uintptr_t)DEFAULT_RCBA,
121 .pmbase = DEFAULT_PMBASE,
122 .gpiobase = DEFAULT_GPIOBASE,
123 .temp_mmio_base = 0xfed08000,
124 .system_type = 5, /* ULT */
125 .tseg_size = CONFIG_SMM_TSEG_SIZE,
126 .spd_addresses = { 0xff, 0x00, 0xff, 0x00 },
127 .ec_present = 1,
128 // 0 = leave channel enabled
129 // 1 = disable dimm 0 on channel
130 // 2 = disable dimm 1 on channel
131 // 3 = disable dimm 0+1 on channel
132 .dimm_channel0_disabled = 2,
133 .dimm_channel1_disabled = 2,
134 .max_ddr3_freq = 1600,
135 .usb_xhci_on_resume = 1,
136 .usb2_ports = {
137 /* Length, Enable, OCn#, Location */
138 { 0x0150, 1, USB_OC_PIN_SKIP, /* P0: LTE */
139 USB_PORT_MINI_PCIE },
140 { 0x0040, 1, 0, /* P1: Port A, CN10 */
141 USB_PORT_BACK_PANEL },
142 { 0x0080, 1, USB_OC_PIN_SKIP, /* P2: CCD */
143 USB_PORT_INTERNAL },
144 { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */
145 USB_PORT_MINI_PCIE },
146 { 0x0040, 1, 2, /* P4: Port B, CN6 */
147 USB_PORT_BACK_PANEL },
148 { 0x0000, 0, USB_OC_PIN_SKIP, /* P5: EMPTY */
149 USB_PORT_SKIP },
150 { 0x0150, 1, USB_OC_PIN_SKIP, /* P6: SD Card */
151 USB_PORT_FLEX },
152 { 0x0000, 0, USB_OC_PIN_SKIP, /* P7: EMPTY */
153 USB_PORT_SKIP },
154 },
155 .usb3_ports = {
156 /* Enable, OCn# */
157 { 1, 0 }, /* P1; Port A, CN6 */
158 { 0, USB_OC_PIN_SKIP }, /* P2; */
159 { 0, USB_OC_PIN_SKIP }, /* P3; */
160 { 0, USB_OC_PIN_SKIP }, /* P4; */
161 },
162 };
163
164 struct romstage_params romstage_params = {
165 .pei_data = &pei_data,
166 .gpio_map = &mainboard_gpio_map,
167 .rcba_config = &rcba_config[0],
Matt DeVillierc12e5ae2016-11-27 02:19:02 -0600168 .copy_spd = copy_spd,
169 };
170
171 /* Call into the real romstage main with this board's attributes. */
172 romstage_common(&romstage_params);
173}