blob: 6690c6863c58e8cd67c8dab61f75c433ecd37516 [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>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020018#include <device/pci_ops.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070019#include <device/pci_def.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070020#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030021#include <arch/acpi.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070022#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110023#include <northbridge/intel/sandybridge/sandybridge.h>
24#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +010025#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010027#include <southbridge/intel/common/gpio.h>
Kyösti Mälkki926a8d12014-04-27 22:17:22 +030028#include <bootmode.h>
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070029#include <ec/quanta/it8518/ec.h>
30#include "ec.h"
31#include "onboard.h"
32
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010033void pch_enable_lpc(void)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070034{
35 /*
36 * Enable:
37 * EC Decode Range Port62/66
38 * SuperIO Port2E/2F
39 * PS/2 Keyboard/Mouse Port60/64
40 * FDD Port3F0h-3F5h and Port3F7h
41 */
42 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN |
43 CNF1_LPC_EN | FDD_LPC_EN);
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070044}
45
Nico Huberff4025c2018-01-14 12:34:43 +010046void mainboard_rcba_config(void)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070047{
48 u32 reg32;
49
Kyösti Mälkki6f499062015-06-06 11:52:24 +030050 /*
51 * GFX INTA -> PIRQA (MSI)
52 * D20IP_XHCI XHCI INTA -> PIRQD (MSI)
53 * D26IP_E2P EHCI #2 INTA -> PIRQF
54 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
55 * D28IP_P2IP WLAN INTA -> PIRQD
56 * D28IP_P3IP Card Reader INTB -> PIRQE
57 * D28IP_P6IP LAN INTC -> PIRQB
58 * D29IP_E1P EHCI #1 INTA -> PIRQD
59 * D31IP_SIP SATA INTA -> PIRQB (MSI)
60 * D31IP_SMIP SMBUS INTB -> PIRQH
61 */
62
63 /* Device interrupt pin register (board specific) */
64 RCBA32(D31IP) = (NOINT << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
65 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
66 RCBA32(D30IP) = (NOINT << D30IP_PIP);
67 RCBA32(D29IP) = (INTA << D29IP_E1P);
68 RCBA32(D28IP) = (NOINT << D28IP_P1IP) | (INTA << D28IP_P2IP) |
69 (INTB << D28IP_P3IP) | (NOINT << D28IP_P4IP) |
70 (NOINT << D28IP_P5IP) | (INTC << D28IP_P6IP) |
71 (NOINT << D28IP_P7IP) | (NOINT << D28IP_P8IP);
72 RCBA32(D27IP) = (INTA << D27IP_ZIP);
73 RCBA32(D26IP) = (INTA << D26IP_E2P);
74 RCBA32(D25IP) = (NOINT << D25IP_LIP);
75 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
76 RCBA32(D20IP) = (INTA << D20IP_XHCIIP);
77
78 /* Device interrupt route registers */
79 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
80 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
81 DIR_ROUTE(D28IR, PIRQD, PIRQE, PIRQB, PIRQC);
82 DIR_ROUTE(D27IR, PIRQA, PIRQB, PIRQC, PIRQD);
83 DIR_ROUTE(D26IR, PIRQF, PIRQB, PIRQC, PIRQD);
84 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
85 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
86 DIR_ROUTE(D20IR, PIRQD, PIRQE, PIRQF, PIRQG);
87
88 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020089 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030090 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +020091 (void) RCBA16(OIC);
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070092
93 /* Disable unused devices (board specific) */
94 reg32 = RCBA32(FD);
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -070095 /* Disable PCI bridge so MRC does not probe this bus */
96 reg32 |= PCH_DISABLE_P2P;
97 RCBA32(FD) = reg32;
98}
99
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700100 /*
101 * The Stout EC needs to be reset to RW mode. It is important that
102 * the RTC_PWR_STS is not set until ramstage EC init.
103 */
104static void early_ec_init(void)
105{
106 u8 ec_status = ec_read(EC_STATUS_REG);
Furquan Shaikh0325dc62016-07-25 13:02:36 -0700107 int rec_mode = get_recovery_mode_switch();
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700108
109 if (((ec_status & 0x3) == EC_IN_RO_MODE) ||
110 ((ec_status & 0x3) == EC_IN_RECOVERY_MODE)) {
111
112 printk(BIOS_DEBUG, "EC Cold Boot Detected\n");
113 if (!rec_mode) {
114 /*
115 * Tell EC to exit RO mode
116 */
117 printk(BIOS_DEBUG, "EC will exit RO mode and boot normally\n");
118 ec_write_cmd(EC_CMD_EXIT_BOOT_BLOCK);
119 die("wait for ec to reset");
120 }
121 } else {
122 printk(BIOS_DEBUG, "EC Warm Boot Detected\n");
123 ec_write_cmd(EC_CMD_WARM_RESET);
124 }
125}
126
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200127void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100128{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200129 read_spd(&spd[0], 0x50, id_only);
130 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100131}
132
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100133void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700134{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100135 struct pei_data pei_data_template = {
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100136 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800137 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
138 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100139 .epbar = DEFAULT_EPBAR,
140 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
141 .smbusbar = SMBUS_IO_BASE,
142 .wdbbar = 0x4000000,
143 .wdbsize = 0x1000,
144 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800145 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100146 .pmbase = DEFAULT_PMBASE,
147 .gpiobase = DEFAULT_GPIOBASE,
148 .thermalbase = 0xfed08000,
149 .system_type = 0, // 0 Mobile, 1 Desktop/Server
150 .tseg_size = CONFIG_SMM_TSEG_SIZE,
151 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
152 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
153 .ec_present = 1,
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700154 // 0 = leave channel enabled
155 // 1 = disable dimm 0 on channel
156 // 2 = disable dimm 1 on channel
157 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100158 .dimm_channel0_disabled = 2,
159 .dimm_channel1_disabled = 2,
160 .max_ddr3_freq = 1600,
161 .usb_port_config = {
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700162 /* enabled usb oc pin length */
163 { 1, 0, 0x0040 }, /* P0: USB 3.0 1 (OC0) */
164 { 1, 0, 0x0040 }, /* P1: USB 3.0 2 (OC0) */
165 { 0, 1, 0x0000 }, /* P2: Empty */
166 { 1, 1, 0x0040 }, /* P3: Camera (no OC) */
167 { 1, 1, 0x0040 }, /* P4: WLAN (no OC) */
168 { 1, 1, 0x0040 }, /* P5: WWAN (no OC) */
169 { 0, 1, 0x0000 }, /* P6: Empty */
170 { 0, 1, 0x0000 }, /* P7: Empty */
171 { 0, 5, 0x0000 }, /* P8: Empty */
172 { 1, 4, 0x0040 }, /* P9: USB 2.0 (AUO4) (OC4) */
173 { 0, 5, 0x0000 }, /* P10: Empty */
174 { 0, 5, 0x0000 }, /* P11: Empty */
175 { 0, 5, 0x0000 }, /* P12: Empty */
176 { 1, 5, 0x0040 }, /* P13: Bluetooth (no OC) */
177 },
Edward O'Callaghan77896c12014-10-28 10:03:47 +1100178 .usb3 = {
179 .mode = XHCI_MODE,
180 .hs_port_switch_mask = XHCI_PORTS,
181 .preboot_support = XHCI_PREBOOT,
182 .xhci_streams = XHCI_STREAMS,
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700183 },
184 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100185 *pei_data = pei_data_template;
186}
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700187
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100188void mainboard_early_init(int s3resume)
189{
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700190 /* Do ec reset as early as possible, but skip it on S3 resume */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100191 if (!s3resume) {
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700192 early_ec_init();
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700193 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100194}
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200195
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100196int mainboard_should_reset_usb(int s3resume)
197{
198 return !s3resume;
199}
200
201void mainboard_config_superio(void)
202{
Stefan Reinauerb7ecf6d2013-03-13 17:13:32 -0700203}
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100204
205const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS48a01292016-09-29 18:57:56 +0200206 /* enabled usb oc pin length */
207 {1, 0, 0}, /* P0: USB 3.0 1 (OC0) */
208 {1, 0, 0}, /* P1: USB 3.0 2 (OC0) */
209 {0, 0, 0}, /* P2: Empty */
210 {1, 0, -1}, /* P3: Camera (no OC) */
211 {1, 0, -1}, /* P4: WLAN (no OC) */
212 {1, 0, -1}, /* P5: WWAN (no OC) */
213 {0, 0, 0}, /* P6: Empty */
214 {0, 0, 0}, /* P7: Empty */
215 {0, 0, 0}, /* P8: Empty */
216 {1, 0, 4}, /* P9: USB 2.0 (AUO4) (OC4) */
217 {0, 0, 0}, /* P10: Empty */
218 {0, 0, 0}, /* P11: Empty */
219 {0, 0, 0}, /* P12: Empty */
220 {1, 0, -1}, /* P13: Bluetooth (no OC) */
Vladimir Serbinenkof004b6b2016-02-10 02:42:16 +0100221};