blob: 8254bc2df13c37293de5f5263286fab9aa7c4791 [file] [log] [blame]
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2012 Google Inc.
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.
15 */
16
17#include <stdint.h>
18#include <stdlib.h>
19#include <string.h>
20#include <cbfs.h>
21#include <console/console.h>
22#include <cpu/intel/haswell/haswell.h>
23#include <northbridge/intel/haswell/haswell.h>
24#include <northbridge/intel/haswell/raminit.h>
25#include <southbridge/intel/lynxpoint/pch.h>
26#include <southbridge/intel/lynxpoint/lp_gpio.h>
27#include <variant/gpio.h>
28#include "../../variant.h"
29
30const struct rcba_config_instruction rcba_config[] = {
31
32 /*
33 * GFX INTA -> PIRQA (MSI)
34 * D28IP_P1IP PCIE INTA -> PIRQA
35 * D29IP_E1P EHCI INTA -> PIRQD
36 * D20IP_XHCI XHCI INTA -> PIRQC (MSI)
37 * D31IP_SIP SATA INTA -> PIRQF (MSI)
38 * D31IP_SMIP SMBUS INTB -> PIRQG
39 * D31IP_TTIP THRT INTC -> PIRQA
40 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
41 */
42
43 /* Device interrupt pin register (board specific) */
44 RCBA_SET_REG_32(D31IP, (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
45 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP)),
46 RCBA_SET_REG_32(D29IP, (INTA << D29IP_E1P)),
47 RCBA_SET_REG_32(D28IP, (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
48 (INTB << D28IP_P4IP)),
49 RCBA_SET_REG_32(D27IP, (INTA << D27IP_ZIP)),
50 RCBA_SET_REG_32(D26IP, (INTA << D26IP_E2P)),
51 RCBA_SET_REG_32(D22IP, (NOINT << D22IP_MEI1IP)),
52 RCBA_SET_REG_32(D20IP, (INTA << D20IP_XHCI)),
53
54 /* Device interrupt route registers */
55 RCBA_SET_REG_32(D31IR, DIR_ROUTE(PIRQG, PIRQC, PIRQB, PIRQA)),/* LPC */
56 RCBA_SET_REG_32(D29IR, DIR_ROUTE(PIRQD, PIRQD, PIRQD, PIRQD)),/* EHCI */
57 RCBA_SET_REG_32(D28IR, DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD)),/* PCIE */
58 RCBA_SET_REG_32(D27IR, DIR_ROUTE(PIRQG, PIRQG, PIRQG, PIRQG)),/* HDA */
59 RCBA_SET_REG_32(D22IR, DIR_ROUTE(PIRQA, PIRQA, PIRQA, PIRQA)),/* ME */
60 RCBA_SET_REG_32(D21IR, DIR_ROUTE(PIRQE, PIRQF, PIRQF, PIRQF)),/* SIO */
61 RCBA_SET_REG_32(D20IR, DIR_ROUTE(PIRQC, PIRQC, PIRQC, PIRQC)),/* XHCI */
62 RCBA_SET_REG_32(D23IR, DIR_ROUTE(PIRQH, PIRQH, PIRQH, PIRQH)),/* SDIO */
63
64 /* Disable unused devices (board specific) */
65 RCBA_RMW_REG_32(FD, ~0, PCH_DISABLE_ALWAYS),
66
67 RCBA_END_CONFIG,
68};
69
70/* Copy SPD data for on-board memory */
71static void copy_spd(struct pei_data *peid)
72{
73 const int gpio_vector[] = {13, 9, 47, -1};
74 int spd_index = get_gpios(gpio_vector);
75 char *spd_file;
76 size_t spd_file_len;
77
78 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
79 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
80 &spd_file_len);
81 if (!spd_file)
82 die("SPD data not found.");
83
84 if (spd_file_len <
85 ((spd_index + 1) * sizeof(peid->spd_data[0]))) {
86 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
87 spd_index = 0;
88 }
89
90 if (spd_file_len < sizeof(peid->spd_data[0]))
91 die("Missing SPD data.");
92
93 /* Index 0-2,6 are 4GB config with both CH0 and CH1
94 * Index 3-5,7 are 2GB config with CH0 only
95 */
96 switch (spd_index) {
97 case 3: case 4: case 5: case 7:
98 peid->dimm_channel1_disabled = 3;
99 }
100
101 memcpy(peid->spd_data[0],
102 spd_file +
103 spd_index * sizeof(peid->spd_data[0]),
104 sizeof(peid->spd_data[0]));
105}
106
107void variant_romstage_entry(unsigned long bist)
108{
109 struct pei_data pei_data = {
110 .pei_version = PEI_VERSION,
111 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
112 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
113 .epbar = DEFAULT_EPBAR,
114 .pciexbar = DEFAULT_PCIEXBAR,
115 .smbusbar = SMBUS_IO_BASE,
116 .wdbbar = 0x4000000,
117 .wdbsize = 0x1000,
118 .hpet_address = HPET_ADDR,
119 .rcba = (uintptr_t)DEFAULT_RCBA,
120 .pmbase = DEFAULT_PMBASE,
121 .gpiobase = DEFAULT_GPIOBASE,
122 .temp_mmio_base = 0xfed08000,
123 .system_type = 5, /* ULT */
124 .tseg_size = CONFIG_SMM_TSEG_SIZE,
125 .spd_addresses = { 0xff, 0x00, 0xff, 0x00 },
126 .ec_present = 1,
127 // 0 = leave channel enabled
128 // 1 = disable dimm 0 on channel
129 // 2 = disable dimm 1 on channel
130 // 3 = disable dimm 0+1 on channel
131 .dimm_channel0_disabled = 2,
132 .dimm_channel1_disabled = 2,
133 // Enable 2x refresh mode
134 .ddr_refresh_2x = 1,
135 .max_ddr3_freq = 1600,
136 .usb_xhci_on_resume = 1,
137 .usb2_ports = {
138 /* Length, Enable, OCn#, Location */
139 { 0x0064, 1, 0, /* P0: Port A, CN8 */
140 USB_PORT_BACK_PANEL },
141 { 0x0052, 1, 0, /* P1: Port B, CN9 */
142 USB_PORT_BACK_PANEL },
143 { 0x0040, 1, USB_OC_PIN_SKIP, /* P2: CCD */
144 USB_PORT_INTERNAL },
145 { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */
146 USB_PORT_INTERNAL },
147 { 0x0040, 1, USB_OC_PIN_SKIP, /* P4: LTE */
148 USB_PORT_INTERNAL },
149 { 0x0040, 1, USB_OC_PIN_SKIP, /* P5: TOUCH */
150 USB_PORT_INTERNAL },
151 { 0x0040, 1, USB_OC_PIN_SKIP, /* P6: SD Card */
152 USB_PORT_INTERNAL },
153 { 0x0123, 1, 3, /* P7: USB2 Port */
154 USB_PORT_INTERNAL },
155 },
156 .usb3_ports = {
157 /* Enable, OCn# */
158 { 1, 0 }, /* P1; Port A, CN8 */
159 { 1, 0 }, /* P2; Port B, CN9 */
160 { 0, USB_OC_PIN_SKIP }, /* P3; */
161 { 0, USB_OC_PIN_SKIP }, /* P4; */
162 },
163 };
164
165 struct romstage_params romstage_params = {
166 .pei_data = &pei_data,
167 .gpio_map = &mainboard_gpio_map,
168 .rcba_config = &rcba_config[0],
169 .bist = bist,
170 .copy_spd = copy_spd,
171 };
172
173 /* Call into the real romstage main with this board's attributes. */
174 romstage_common(&romstage_params);
175}