blob: 817fce9d52cdd105e3e0160ba89648fae1d65443 [file] [log] [blame]
Duncan Laurie3ece50d2013-06-24 14:57:40 -07001/*
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.
Duncan Laurie3ece50d2013-06-24 14:57:40 -070015 */
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 "gpio.h"
28
29const struct rcba_config_instruction rcba_config[] = {
30
31 /*
32 * GFX INTA -> PIRQA (MSI)
33 * D28IP_P1IP PCIE INTA -> PIRQA
34 * D29IP_E1P EHCI INTA -> PIRQD
35 * D20IP_XHCI XHCI INTA -> PIRQC (MSI)
36 * D31IP_SIP SATA INTA -> PIRQF (MSI)
37 * D31IP_SMIP SMBUS INTB -> PIRQG
38 * D31IP_TTIP THRT INTC -> PIRQA
39 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
40 */
41
42 /* Device interrupt pin register (board specific) */
43 RCBA_SET_REG_32(D31IP, (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
44 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP)),
45 RCBA_SET_REG_32(D29IP, (INTA << D29IP_E1P)),
46 RCBA_SET_REG_32(D28IP, (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
47 (INTB << D28IP_P4IP)),
48 RCBA_SET_REG_32(D27IP, (INTA << D27IP_ZIP)),
49 RCBA_SET_REG_32(D26IP, (INTA << D26IP_E2P)),
50 RCBA_SET_REG_32(D22IP, (NOINT << D22IP_MEI1IP)),
51 RCBA_SET_REG_32(D20IP, (INTA << D20IP_XHCI)),
52
53 /* Device interrupt route registers */
54 RCBA_SET_REG_32(D31IR, DIR_ROUTE(PIRQG, PIRQC, PIRQB, PIRQA)),/* LPC */
55 RCBA_SET_REG_32(D29IR, DIR_ROUTE(PIRQD, PIRQD, PIRQD, PIRQD)),/* EHCI */
56 RCBA_SET_REG_32(D28IR, DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD)),/* PCIE */
57 RCBA_SET_REG_32(D27IR, DIR_ROUTE(PIRQG, PIRQG, PIRQG, PIRQG)),/* HDA */
58 RCBA_SET_REG_32(D22IR, DIR_ROUTE(PIRQA, PIRQA, PIRQA, PIRQA)),/* ME */
59 RCBA_SET_REG_32(D21IR, DIR_ROUTE(PIRQE, PIRQF, PIRQF, PIRQF)),/* SIO */
60 RCBA_SET_REG_32(D20IR, DIR_ROUTE(PIRQC, PIRQC, PIRQC, PIRQC)),/* XHCI */
61 RCBA_SET_REG_32(D23IR, DIR_ROUTE(PIRQH, PIRQH, PIRQH, PIRQH)),/* SDIO */
62
63 /* Disable unused devices (board specific) */
64 RCBA_RMW_REG_32(FD, ~0, PCH_DISABLE_ALWAYS),
65
66 RCBA_END_CONFIG,
67};
68
69/* Copy SPD data for on-board memory */
70static void copy_spd(struct pei_data *peid)
71{
Vladimir Serbinenko12874162014-01-12 14:12:15 +010072 char *spd_file;
73 size_t spd_file_len;
Duncan Laurie3ece50d2013-06-24 14:57:40 -070074 int spd_index = 0; /* No GPIO selection, force index 0 for now */
75
76 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
Aaron Durbin899d13d2015-05-15 23:39:23 -050077 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
78 &spd_file_len);
Duncan Laurie3ece50d2013-06-24 14:57:40 -070079 if (!spd_file)
80 die("SPD data not found.");
81
Vladimir Serbinenko12874162014-01-12 14:12:15 +010082 if (spd_file_len <
Duncan Laurie3ece50d2013-06-24 14:57:40 -070083 ((spd_index + 1) * sizeof(peid->spd_data[0]))) {
84 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
85 spd_index = 0;
86 }
87
Vladimir Serbinenko12874162014-01-12 14:12:15 +010088 if (spd_file_len < sizeof(peid->spd_data[0]))
Duncan Laurie3ece50d2013-06-24 14:57:40 -070089 die("Missing SPD data.");
90
91 memcpy(peid->spd_data[0],
Vladimir Serbinenko12874162014-01-12 14:12:15 +010092 spd_file +
Duncan Laurie3ece50d2013-06-24 14:57:40 -070093 spd_index * sizeof(peid->spd_data[0]),
94 sizeof(peid->spd_data[0]));
95}
96
97void mainboard_romstage_entry(unsigned long bist)
98{
99 struct pei_data pei_data = {
Edward O'Callaghan6224c312014-05-25 09:49:37 +1000100 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800101 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
102 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan6224c312014-05-25 09:49:37 +1000103 .epbar = DEFAULT_EPBAR,
104 .pciexbar = DEFAULT_PCIEXBAR,
105 .smbusbar = SMBUS_IO_BASE,
106 .wdbbar = 0x4000000,
107 .wdbsize = 0x1000,
108 .hpet_address = HPET_ADDR,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800109 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghan6224c312014-05-25 09:49:37 +1000110 .pmbase = DEFAULT_PMBASE,
111 .gpiobase = DEFAULT_GPIOBASE,
112 .temp_mmio_base = 0xfed08000,
113 .system_type = 5, /* ULT */
114 .tseg_size = CONFIG_SMM_TSEG_SIZE,
115 .spd_addresses = { 0xff, 0x00, 0xff, 0x00 },
116 .ec_present = 1,
Duncan Laurie3ece50d2013-06-24 14:57:40 -0700117 // 0 = leave channel enabled
118 // 1 = disable dimm 0 on channel
119 // 2 = disable dimm 1 on channel
120 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan6224c312014-05-25 09:49:37 +1000121 .dimm_channel0_disabled = 2,
122 .dimm_channel1_disabled = 2,
123 .max_ddr3_freq = 1600,
124 .usb2_ports = {
Duncan Laurie3ece50d2013-06-24 14:57:40 -0700125 /* Length, Enable, OCn#, Location */
126 /* P0: HOST PORT - J7 */
127 { 0x0040, 1, 0, USB_PORT_BACK_PANEL },
128 /* P1: HOST PORT - J6 */
129 { 0x0040, 1, 1, USB_PORT_BACK_PANEL },
130 /* P2: EMPTY */
131 { 0x0000, 0, USB_OC_PIN_SKIP, USB_PORT_SKIP },
132 /* P3: SD CARD */
133 { 0x0040, 1, USB_OC_PIN_SKIP, USB_PORT_FLEX },
134 /* P4: EMPTY */
135 { 0x0000, 0, USB_OC_PIN_SKIP, USB_PORT_SKIP },
136 /* P5: WWAN */
137 { 0x0040, 1, USB_OC_PIN_SKIP, USB_PORT_MINI_PCIE },
138 /* P6: CAMERA */
139 { 0x0040, 1, USB_OC_PIN_SKIP, USB_PORT_FLEX },
140 /* P7: BT */
141 { 0x0040, 1, USB_OC_PIN_SKIP, USB_PORT_MINI_PCIE },
142 },
Edward O'Callaghan6224c312014-05-25 09:49:37 +1000143 .usb3_ports = {
Duncan Laurie3ece50d2013-06-24 14:57:40 -0700144 /* Enable, OCn# */
145 { 1, 0 }, /* P1: HOST PORT - J7 */
146 { 1, 1 }, /* P2: HOST PORT - J6 */
147 { 0, USB_OC_PIN_SKIP }, /* P3: EMPTY */
148 { 0, USB_OC_PIN_SKIP }, /* P4: EMPTY */
149 },
150 };
151
152 struct romstage_params romstage_params = {
153 .pei_data = &pei_data,
154 .gpio_map = &mainboard_gpio_map,
155 .rcba_config = &rcba_config[0],
156 .bist = bist,
157 .copy_spd = copy_spd,
158 };
159
160 /* Call into the real romstage main with this board's attributes. */
161 romstage_common(&romstage_params);
162}