blob: 8da13080b3a86aba9541801a23dcc1e7a958ea79 [file] [log] [blame]
Stefan Reinauer49428d82013-02-21 15:48:37 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 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.
Stefan Reinauer49428d82013-02-21 15:48:37 -080015 */
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 Reinauer49428d82013-02-21 15:48:37 -080020#include <device/pci.h>
21#include <device/pci_def.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080022#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030023#include <arch/acpi.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080024#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110025#include <northbridge/intel/sandybridge/sandybridge.h>
26#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010027#include <northbridge/intel/sandybridge/raminit_native.h>
Patrick Rudolphda9302a2019-03-24 17:01:41 +010028#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010029#include <southbridge/intel/common/gpio.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080030#include "ec/google/chromeec/ec.h"
Stefan Reinauer49428d82013-02-21 15:48:37 -080031#include <cbfs.h>
32
33#include <southbridge/intel/bd82x6x/chip.h>
34
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010035void pch_enable_lpc(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080036{
37 const struct device *lpc;
38 const struct southbridge_intel_bd82x6x_config *config = NULL;
39
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030040 lpc = pcidev_on_root(0x1f, 0);
Stefan Reinauer49428d82013-02-21 15:48:37 -080041 if (!lpc)
42 return;
43 if (lpc->chip_info)
44 config = lpc->chip_info;
45 if (!config)
46 return;
47
48 /* Set COM1/COM2 decode range */
49 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
50
51 /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */
52 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | \
53 GAMEL_LPC_EN | COMA_LPC_EN);
54
55 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec);
56 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec);
57 pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec);
58 pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec);
59}
60
Nico Huberff4025c2018-01-14 12:34:43 +010061void mainboard_rcba_config(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080062{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030063 /*
64 * GFX INTA -> PIRQA (MSI)
65 * D28IP_P3IP WLAN INTA -> PIRQB
66 * D29IP_E1P EHCI1 INTA -> PIRQD
67 * D26IP_E2P EHCI2 INTA -> PIRQF
68 * D31IP_SIP SATA INTA -> PIRQF (MSI)
69 * D31IP_SMIP SMBUS INTB -> PIRQH
70 * D31IP_TTIP THRT INTC -> PIRQA
71 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
72 *
73 * TRACKPAD -> PIRQE (Edge Triggered)
74 * TOUCHSCREEN -> PIRQG (Edge Triggered)
75 */
76
77 /* Device interrupt pin register (board specific) */
78 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
79 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
80 RCBA32(D30IP) = (NOINT << D30IP_PIP);
81 RCBA32(D29IP) = (INTA << D29IP_E1P);
82 RCBA32(D28IP) = (INTA << D28IP_P3IP);
83 RCBA32(D27IP) = (INTA << D27IP_ZIP);
84 RCBA32(D26IP) = (INTA << D26IP_E2P);
85 RCBA32(D25IP) = (NOINT << D25IP_LIP);
86 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
87
88 /* Device interrupt route registers */
89 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
90 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
91 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
92 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
93 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
94 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
95 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
96
97 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020098 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030099 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +0200100 (void) RCBA16(OIC);
Stefan Reinauer49428d82013-02-21 15:48:37 -0800101}
102
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100103static uint8_t *locate_spd(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800104{
105 const int gpio_vector[] = {41, 42, 43, 10, -1};
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100106 uint8_t *spd_file;
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100107 size_t spd_file_len;
Stefan Reinauer49428d82013-02-21 15:48:37 -0800108 int spd_index = get_gpios(gpio_vector);
109
110 printk(BIOS_DEBUG, "spd index %d\n", spd_index);
Aaron Durbin899d13d2015-05-15 23:39:23 -0500111 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
112 &spd_file_len);
Stefan Reinauer49428d82013-02-21 15:48:37 -0800113 if (!spd_file)
114 die("SPD data not found.");
115
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100116 if (spd_file_len < ((spd_index + 1) * 256)) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800117 printk(BIOS_ERR, "spd index override to 0 - old hardware?\n");
118 spd_index = 0;
119 }
120
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100121 if (spd_file_len < 256)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800122 die("Missing SPD data.");
123
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100124 return spd_file + spd_index * 256;
Stefan Reinauer49428d82013-02-21 15:48:37 -0800125}
126
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100127void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800128{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100129 struct pei_data pei_data_template = {
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000130 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800131 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
132 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000133 .epbar = DEFAULT_EPBAR,
134 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
135 .smbusbar = SMBUS_IO_BASE,
136 .wdbbar = 0x4000000,
137 .wdbsize = 0x1000,
138 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800139 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000140 .pmbase = DEFAULT_PMBASE,
141 .gpiobase = DEFAULT_GPIOBASE,
142 .thermalbase = 0xfed08000,
143 .system_type = 0, // 0 Mobile, 1 Desktop/Server
144 .tseg_size = CONFIG_SMM_TSEG_SIZE,
145 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
146 .ec_present = 1,
147 .ddr3lv_support = 1,
Stefan Reinauer49428d82013-02-21 15:48:37 -0800148 // 0 = leave channel enabled
149 // 1 = disable dimm 0 on channel
150 // 2 = disable dimm 1 on channel
151 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000152 .dimm_channel0_disabled = 2,
153 .dimm_channel1_disabled = 2,
154 .max_ddr3_freq = 1600,
155 .usb_port_config = {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800156 /* Empty and onboard Ports 0-7, set to un-used pin OC3 */
157 { 0, 3, 0x0000 }, /* P0: Empty */
158 { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */
159 { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */
160 { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */
161 { 0, 3, 0x0000 }, /* P4: Empty */
162 { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */
163 { 0, 3, 0x0000 }, /* P6: Empty */
164 { 0, 3, 0x0000 }, /* P7: Empty */
165 /* Empty and onboard Ports 8-13, set to un-used pin OC4 */
166 { 1, 4, 0x0040 }, /* P8: Camera (no OC) */
167 { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */
168 { 0, 4, 0x0000 }, /* P10: Empty */
169 { 0, 4, 0x0000 }, /* P11: Empty */
170 { 0, 4, 0x0000 }, /* P12: Empty */
171 { 0, 4, 0x0000 }, /* P13: Empty */
172 },
173 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100174 *pei_data = pei_data_template;
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100175 memcpy(pei_data->spd_data[0], locate_spd(),
176 sizeof(pei_data->spd_data[0]));
177}
178
179const struct southbridge_usb_port mainboard_usb_ports[] = {
180 /* enabled power usb oc pin */
181 { 0, 0, -1 }, /* P0: Empty */
182 { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
183 { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
184 { 1, 0, -1 }, /* P3: SDCARD (no OC) */
185 { 0, 0, -1 }, /* P4: Empty */
186 { 1, 0, -1 }, /* P5: WWAN (no OC) */
187 { 0, 0, -1 }, /* P6: Empty */
188 { 0, 0, -1 }, /* P7: Empty */
189 { 1, 0, -1 }, /* P8: Camera (no OC) */
190 { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
191 { 0, 0, -1 }, /* P10: Empty */
192 { 0, 0, -1 }, /* P11: Empty */
193 { 0, 0, -1 }, /* P12: Empty */
194 { 0, 0, -1 }, /* P13: Empty */
195};
196
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100197void mainboard_get_spd(spd_raw_data *spd, bool id_only)
198{
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100199 memcpy(&spd[0], locate_spd(), 128);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100200}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800201
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100202void mainboard_early_init(int s3resume)
203{
204 if (!s3resume) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800205 /* This is the fastest way to let users know
206 * the Intel CPU is now alive.
207 */
208 google_chromeec_kbbacklight(100);
209 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100210}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800211
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100212int mainboard_should_reset_usb(int s3resume)
213{
214 return !s3resume;
215}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800216
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100217void mainboard_config_superio(void)
218{
Stefan Reinauer49428d82013-02-21 15:48:37 -0800219}