blob: a4cc7ece0d4efab107ded72a78d52b5b93529d32 [file] [log] [blame]
Duncan Lauriecf72d912013-04-29 15:10:31 -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 Lauriecf72d912013-04-29 15:10:31 -070015 */
16
Duncan Lauriee820a6c2013-05-01 11:11:10 -070017#include <delay.h>
Duncan Lauriecf72d912013-04-29 15:10:31 -070018#include <stdint.h>
Duncan Lauriee820a6c2013-05-01 11:11:10 -070019#include <stdlib.h>
Duncan Laurief31fcbc2013-05-02 10:40:49 -070020#include <string.h>
21#include <cbfs.h>
Duncan Lauriecf72d912013-04-29 15:10:31 -070022#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110023#include <cpu/intel/haswell/haswell.h>
24#include <northbridge/intel/haswell/haswell.h>
25#include <northbridge/intel/haswell/raminit.h>
26#include <southbridge/intel/lynxpoint/pch.h>
27#include <southbridge/intel/lynxpoint/lp_gpio.h>
Duncan Lauriecf72d912013-04-29 15:10:31 -070028#include "gpio.h"
29
30const struct rcba_config_instruction rcba_config[] = {
31
32 /*
33 * GFX INTA -> PIRQA (MSI)
Duncan Laurie90bfbfa2013-05-21 08:05:39 -070034 * D28IP_P1IP PCIE INTA -> PIRQA
35 * D29IP_E1P EHCI INTA -> PIRQD
36 * D20IP_XHCI XHCI INTA -> PIRQC (MSI)
Duncan Lauriecf72d912013-04-29 15:10:31 -070037 * D31IP_SIP SATA INTA -> PIRQF (MSI)
38 * D31IP_SMIP SMBUS INTB -> PIRQG
Duncan Laurie90bfbfa2013-05-21 08:05:39 -070039 * D31IP_TTIP THRT INTC -> PIRQA
Duncan Lauriecf72d912013-04-29 15:10:31 -070040 * 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)),
Duncan Lauriecf72d912013-04-29 15:10:31 -070051 RCBA_SET_REG_32(D22IP, (NOINT << D22IP_MEI1IP)),
Duncan Laurie90bfbfa2013-05-21 08:05:39 -070052 RCBA_SET_REG_32(D20IP, (INTA << D20IP_XHCI)),
Duncan Lauriecf72d912013-04-29 15:10:31 -070053
54 /* Device interrupt route registers */
Duncan Laurie90bfbfa2013-05-21 08:05:39 -070055 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 */
Duncan Lauriecf72d912013-04-29 15:10:31 -070063
64 /* Disable unused devices (board specific) */
65 RCBA_RMW_REG_32(FD, ~0, PCH_DISABLE_ALWAYS),
66
67 RCBA_END_CONFIG,
68};
69
Duncan Laurief31fcbc2013-05-02 10:40:49 -070070/* 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);
Vladimir Serbinenko12874162014-01-12 14:12:15 +010075 char *spd_file;
76 size_t spd_file_len;
Duncan Laurief31fcbc2013-05-02 10:40:49 -070077
78 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
Aaron Durbin899d13d2015-05-15 23:39:23 -050079 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
80 &spd_file_len);
Duncan Laurief31fcbc2013-05-02 10:40:49 -070081 if (!spd_file)
82 die("SPD data not found.");
83
Vladimir Serbinenko12874162014-01-12 14:12:15 +010084 if (spd_file_len <
Duncan Laurief31fcbc2013-05-02 10:40:49 -070085 ((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
Vladimir Serbinenko12874162014-01-12 14:12:15 +010090 if (spd_file_len < sizeof(peid->spd_data[0]))
Duncan Laurief31fcbc2013-05-02 10:40:49 -070091 die("Missing SPD data.");
92
93 memcpy(peid->spd_data[0],
Vladimir Serbinenko12874162014-01-12 14:12:15 +010094 spd_file +
Duncan Laurief31fcbc2013-05-02 10:40:49 -070095 spd_index * sizeof(peid->spd_data[0]),
96 sizeof(peid->spd_data[0]));
97}
98
Duncan Lauriee820a6c2013-05-01 11:11:10 -070099/*
100 * Power Sequencing for SanDisk i100/i110 SSD
101 *
102 * Must be sequenced in this order with specified timing.
103 *
104 * 1. VCC_IO : 30us - 100ms
105 * 2. VCC_FLASH : 70us - 10ms
106 * 3. VCCQ : 70us - 10ms
107 * 4. VDDC : 30us - 100ms
108 *
109 * There is no feedback to know if the voltage has stabilized
110 * so this implementation will use the max ramp times. That
111 * means it adds significantly to the boot time.
112 */
113static void issd_power_sequence(void)
114{
115 struct gpio_seq {
116 int gpio;
117 int wait_ms;
118 } issd_gpio_seq[] = {
119 { 49, 100 }, /* VCC_IO: GPIO 49, wait 100ms */
120 { 44, 10 }, /* VCC_FLASH: GPIO 44, wait 10ms */
121 { 17, 10 }, /* VCCQ: GPIO 17, wait 10ms */
122 { 16, 100 }, /* VDDC: GPIO 16, wait 100ms */
123 };
124 int step;
125
126 for (step = 0; step < ARRAY_SIZE(issd_gpio_seq); step++) {
127 set_gpio(issd_gpio_seq[step].gpio, 1);
128 udelay(issd_gpio_seq[step].wait_ms * 1000);
129 }
130}
131
Duncan Lauriecf72d912013-04-29 15:10:31 -0700132void mainboard_romstage_entry(unsigned long bist)
133{
134 struct pei_data pei_data = {
Edward O'Callaghan8102a9a2014-05-25 09:50:26 +1000135 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800136 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
137 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan8102a9a2014-05-25 09:50:26 +1000138 .epbar = DEFAULT_EPBAR,
139 .pciexbar = DEFAULT_PCIEXBAR,
140 .smbusbar = SMBUS_IO_BASE,
141 .wdbbar = 0x4000000,
142 .wdbsize = 0x1000,
143 .hpet_address = HPET_ADDR,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800144 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghan8102a9a2014-05-25 09:50:26 +1000145 .pmbase = DEFAULT_PMBASE,
146 .gpiobase = DEFAULT_GPIOBASE,
147 .temp_mmio_base = 0xfed08000,
148 .system_type = 5, /* ULT */
149 .tseg_size = CONFIG_SMM_TSEG_SIZE,
150 .spd_addresses = { 0xff, 0x00, 0xff, 0x00 },
151 .ec_present = 1,
Duncan Lauriecf72d912013-04-29 15:10:31 -0700152 // 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
Edward O'Callaghan8102a9a2014-05-25 09:50:26 +1000156 .dimm_channel0_disabled = 2,
157 .dimm_channel1_disabled = 2,
158 .max_ddr3_freq = 1600,
159 .usb_xhci_on_resume = 1,
160 .usb2_ports = {
Duncan Lauriebcfcfa42013-06-03 10:41:12 -0700161 /* Length, Enable, OCn#, Location */
162 { 0x0150, 1, USB_OC_PIN_SKIP, /* P0: LTE */
163 USB_PORT_MINI_PCIE },
164 { 0x0040, 1, 0, /* P1: Port A, CN10 */
165 USB_PORT_BACK_PANEL },
166 { 0x0080, 1, USB_OC_PIN_SKIP, /* P2: CCD */
167 USB_PORT_INTERNAL },
168 { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */
169 USB_PORT_MINI_PCIE },
170 { 0x0040, 1, 2, /* P4: Port B, CN6 */
171 USB_PORT_BACK_PANEL },
172 { 0x0000, 0, USB_OC_PIN_SKIP, /* P5: EMPTY */
173 USB_PORT_SKIP },
174 { 0x0150, 1, USB_OC_PIN_SKIP, /* P6: SD Card */
175 USB_PORT_FLEX },
176 { 0x0000, 0, USB_OC_PIN_SKIP, /* P7: EMPTY */
177 USB_PORT_SKIP },
Aaron Durbinb1c25e72013-05-23 15:57:46 -0500178 },
Edward O'Callaghan8102a9a2014-05-25 09:50:26 +1000179 .usb3_ports = {
Aaron Durbinb1c25e72013-05-23 15:57:46 -0500180 /* Enable, OCn# */
181 { 1, 0 }, /* P1; Port A, CN10 */
182 { 1, 2 }, /* P2; Port B, CN6 */
183 { 0, USB_OC_PIN_SKIP }, /* P3; */
184 { 0, USB_OC_PIN_SKIP }, /* P4; */
Duncan Lauriecf72d912013-04-29 15:10:31 -0700185 },
186 };
187
188 struct romstage_params romstage_params = {
189 .pei_data = &pei_data,
190 .gpio_map = &mainboard_gpio_map,
191 .rcba_config = &rcba_config[0],
192 .bist = bist,
Aaron Durbinc7633f42013-06-13 17:29:36 -0700193 .copy_spd = copy_spd,
Duncan Lauriecf72d912013-04-29 15:10:31 -0700194 };
195
196 /* Call into the real romstage main with this board's attributes. */
197 romstage_common(&romstage_params);
Duncan Lauriee820a6c2013-05-01 11:11:10 -0700198
199 /* Power sequence the iSSD module */
200 issd_power_sequence();
Duncan Lauriecf72d912013-04-29 15:10:31 -0700201}