blob: d76e9c184ce44c439ee0fe03faf84f12b0d154c0 [file] [log] [blame]
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -07001/*
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 Reinauerb7ecf6d2013-03-13 17:13:32 -070015 */
16
17#include <stdint.h>
18#include <string.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070020#include <device/pci_def.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070021#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030022#include <arch/acpi.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070023#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <northbridge/intel/sandybridge/sandybridge.h>
25#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +010026#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110027#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010028#include <southbridge/intel/common/gpio.h>
Kyösti Mälkki926a8d12014-04-27 22:17:22 +030029#include <bootmode.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070030#include <ec/quanta/it8518/ec.h>
31#include "ec.h"
32#include "onboard.h"
33
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010034void pch_enable_lpc(void)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070035{
36 /*
37 * Enable:
38 * EC Decode Range Port62/66
39 * SuperIO Port2E/2F
40 * PS/2 Keyboard/Mouse Port60/64
41 * FDD Port3F0h-3F5h and Port3F7h
42 */
43 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN |
44 CNF1_LPC_EN | FDD_LPC_EN);
45
46 /* Stout EC Decode Range Port68/6C */
47 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (0x68 | 0x40001));
48}
49
Nico Huberff4025c2018-01-14 12:34:43 +010050void mainboard_rcba_config(void)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070051{
52 u32 reg32;
53
Kyösti Mälkki6f499062015-06-06 11:52:24 +030054 /*
55 * GFX INTA -> PIRQA (MSI)
56 * D20IP_XHCI XHCI INTA -> PIRQD (MSI)
57 * D26IP_E2P EHCI #2 INTA -> PIRQF
58 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
59 * D28IP_P2IP WLAN INTA -> PIRQD
60 * D28IP_P3IP Card Reader INTB -> PIRQE
61 * D28IP_P6IP LAN INTC -> PIRQB
62 * D29IP_E1P EHCI #1 INTA -> PIRQD
63 * D31IP_SIP SATA INTA -> PIRQB (MSI)
64 * D31IP_SMIP SMBUS INTB -> PIRQH
65 */
66
67 /* Device interrupt pin register (board specific) */
68 RCBA32(D31IP) = (NOINT << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
69 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
70 RCBA32(D30IP) = (NOINT << D30IP_PIP);
71 RCBA32(D29IP) = (INTA << D29IP_E1P);
72 RCBA32(D28IP) = (NOINT << D28IP_P1IP) | (INTA << D28IP_P2IP) |
73 (INTB << D28IP_P3IP) | (NOINT << D28IP_P4IP) |
74 (NOINT << D28IP_P5IP) | (INTC << D28IP_P6IP) |
75 (NOINT << D28IP_P7IP) | (NOINT << D28IP_P8IP);
76 RCBA32(D27IP) = (INTA << D27IP_ZIP);
77 RCBA32(D26IP) = (INTA << D26IP_E2P);
78 RCBA32(D25IP) = (NOINT << D25IP_LIP);
79 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
80 RCBA32(D20IP) = (INTA << D20IP_XHCIIP);
81
82 /* Device interrupt route registers */
83 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
84 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
85 DIR_ROUTE(D28IR, PIRQD, PIRQE, PIRQB, PIRQC);
86 DIR_ROUTE(D27IR, PIRQA, PIRQB, PIRQC, PIRQD);
87 DIR_ROUTE(D26IR, PIRQF, PIRQB, PIRQC, PIRQD);
88 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
89 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
90 DIR_ROUTE(D20IR, PIRQD, PIRQE, PIRQF, PIRQG);
91
92 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020093 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030094 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +020095 (void) RCBA16(OIC);
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070096
97 /* Disable unused devices (board specific) */
98 reg32 = RCBA32(FD);
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070099 /* Disable PCI bridge so MRC does not probe this bus */
100 reg32 |= PCH_DISABLE_P2P;
101 RCBA32(FD) = reg32;
102}
103
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700104 /*
105 * The Stout EC needs to be reset to RW mode. It is important that
106 * the RTC_PWR_STS is not set until ramstage EC init.
107 */
108static void early_ec_init(void)
109{
110 u8 ec_status = ec_read(EC_STATUS_REG);
Furquan Shaikh0325dc62016-07-25 13:02:36 -0700111 int rec_mode = get_recovery_mode_switch();
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700112
113 if (((ec_status & 0x3) == EC_IN_RO_MODE) ||
114 ((ec_status & 0x3) == EC_IN_RECOVERY_MODE)) {
115
116 printk(BIOS_DEBUG, "EC Cold Boot Detected\n");
117 if (!rec_mode) {
118 /*
119 * Tell EC to exit RO mode
120 */
121 printk(BIOS_DEBUG, "EC will exit RO mode and boot normally\n");
122 ec_write_cmd(EC_CMD_EXIT_BOOT_BLOCK);
123 die("wait for ec to reset");
124 }
125 } else {
126 printk(BIOS_DEBUG, "EC Warm Boot Detected\n");
127 ec_write_cmd(EC_CMD_WARM_RESET);
128 }
129}
130
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200131void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100132{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200133 read_spd(&spd[0], 0x50, id_only);
134 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100135}
136
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100137void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700138{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100139 struct pei_data pei_data_template = {
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100140 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800141 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
142 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100143 .epbar = DEFAULT_EPBAR,
144 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
145 .smbusbar = SMBUS_IO_BASE,
146 .wdbbar = 0x4000000,
147 .wdbsize = 0x1000,
148 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800149 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100150 .pmbase = DEFAULT_PMBASE,
151 .gpiobase = DEFAULT_GPIOBASE,
152 .thermalbase = 0xfed08000,
153 .system_type = 0, // 0 Mobile, 1 Desktop/Server
154 .tseg_size = CONFIG_SMM_TSEG_SIZE,
155 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
156 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
157 .ec_present = 1,
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700158 // 0 = leave channel enabled
159 // 1 = disable dimm 0 on channel
160 // 2 = disable dimm 1 on channel
161 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100162 .dimm_channel0_disabled = 2,
163 .dimm_channel1_disabled = 2,
164 .max_ddr3_freq = 1600,
165 .usb_port_config = {
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700166 /* enabled usb oc pin length */
167 { 1, 0, 0x0040 }, /* P0: USB 3.0 1 (OC0) */
168 { 1, 0, 0x0040 }, /* P1: USB 3.0 2 (OC0) */
169 { 0, 1, 0x0000 }, /* P2: Empty */
170 { 1, 1, 0x0040 }, /* P3: Camera (no OC) */
171 { 1, 1, 0x0040 }, /* P4: WLAN (no OC) */
172 { 1, 1, 0x0040 }, /* P5: WWAN (no OC) */
173 { 0, 1, 0x0000 }, /* P6: Empty */
174 { 0, 1, 0x0000 }, /* P7: Empty */
175 { 0, 5, 0x0000 }, /* P8: Empty */
176 { 1, 4, 0x0040 }, /* P9: USB 2.0 (AUO4) (OC4) */
177 { 0, 5, 0x0000 }, /* P10: Empty */
178 { 0, 5, 0x0000 }, /* P11: Empty */
179 { 0, 5, 0x0000 }, /* P12: Empty */
180 { 1, 5, 0x0040 }, /* P13: Bluetooth (no OC) */
181 },
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100182 .usb3 = {
183 .mode = XHCI_MODE,
184 .hs_port_switch_mask = XHCI_PORTS,
185 .preboot_support = XHCI_PREBOOT,
186 .xhci_streams = XHCI_STREAMS,
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700187 },
188 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100189 *pei_data = pei_data_template;
190}
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700191
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100192void mainboard_early_init(int s3resume)
193{
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700194 /* Do ec reset as early as possible, but skip it on S3 resume */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100195 if (!s3resume) {
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700196 early_ec_init();
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700197 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100198}
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200199
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100200int mainboard_should_reset_usb(int s3resume)
201{
202 return !s3resume;
203}
204
205void mainboard_config_superio(void)
206{
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700207}
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100208
209const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS48a01292016-09-29 18:57:56 +0200210 /* enabled usb oc pin length */
211 {1, 0, 0}, /* P0: USB 3.0 1 (OC0) */
212 {1, 0, 0}, /* P1: USB 3.0 2 (OC0) */
213 {0, 0, 0}, /* P2: Empty */
214 {1, 0, -1}, /* P3: Camera (no OC) */
215 {1, 0, -1}, /* P4: WLAN (no OC) */
216 {1, 0, -1}, /* P5: WWAN (no OC) */
217 {0, 0, 0}, /* P6: Empty */
218 {0, 0, 0}, /* P7: Empty */
219 {0, 0, 0}, /* P8: Empty */
220 {1, 0, 4}, /* P9: USB 2.0 (AUO4) (OC4) */
221 {0, 0, 0}, /* P10: Empty */
222 {0, 0, 0}, /* P11: Empty */
223 {0, 0, 0}, /* P12: Empty */
224 {1, 0, -1}, /* P13: Bluetooth (no OC) */
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100225};