blob: 73d33a3a12a9ec2b7441600b19cd20c4ad83bcfc [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>
Stefan Reinauer49428d82013-02-21 15:48:37 -080019#include <timestamp.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080020#include <arch/io.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080021#include <device/pci.h>
22#include <device/pci_def.h>
23#include <device/pnp_def.h>
24#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030025#include <arch/acpi.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080026#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110027#include <northbridge/intel/sandybridge/sandybridge.h>
28#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010029#include <northbridge/intel/sandybridge/raminit_native.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010030#include <southbridge/intel/common/gpio.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080031#include "ec/google/chromeec/ec.h"
Patrick Georgibd79c5e2014-11-28 22:35:36 +010032#include <halt.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080033#include <cbfs.h>
34
35#include <southbridge/intel/bd82x6x/chip.h>
36
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010037void pch_enable_lpc(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080038{
39 const struct device *lpc;
40 const struct southbridge_intel_bd82x6x_config *config = NULL;
41
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030042 lpc = pcidev_on_root(0x1f, 0);
Stefan Reinauer49428d82013-02-21 15:48:37 -080043 if (!lpc)
44 return;
45 if (lpc->chip_info)
46 config = lpc->chip_info;
47 if (!config)
48 return;
49
50 /* Set COM1/COM2 decode range */
51 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
52
53 /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */
54 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | \
55 GAMEL_LPC_EN | COMA_LPC_EN);
56
57 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec);
58 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec);
59 pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec);
60 pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec);
61}
62
Nico Huberff4025c2018-01-14 12:34:43 +010063void mainboard_rcba_config(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080064{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030065 /*
66 * GFX INTA -> PIRQA (MSI)
67 * D28IP_P3IP WLAN INTA -> PIRQB
68 * D29IP_E1P EHCI1 INTA -> PIRQD
69 * D26IP_E2P EHCI2 INTA -> PIRQF
70 * D31IP_SIP SATA INTA -> PIRQF (MSI)
71 * D31IP_SMIP SMBUS INTB -> PIRQH
72 * D31IP_TTIP THRT INTC -> PIRQA
73 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
74 *
75 * TRACKPAD -> PIRQE (Edge Triggered)
76 * TOUCHSCREEN -> PIRQG (Edge Triggered)
77 */
78
79 /* Device interrupt pin register (board specific) */
80 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
81 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
82 RCBA32(D30IP) = (NOINT << D30IP_PIP);
83 RCBA32(D29IP) = (INTA << D29IP_E1P);
84 RCBA32(D28IP) = (INTA << D28IP_P3IP);
85 RCBA32(D27IP) = (INTA << D27IP_ZIP);
86 RCBA32(D26IP) = (INTA << D26IP_E2P);
87 RCBA32(D25IP) = (NOINT << D25IP_LIP);
88 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
89
90 /* Device interrupt route registers */
91 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
92 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
93 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
94 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
95 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
96 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
97 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
98
99 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +0200100 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +0300101 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +0200102 (void) RCBA16(OIC);
Stefan Reinauer49428d82013-02-21 15:48:37 -0800103}
104
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100105static uint8_t *locate_spd(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800106{
107 const int gpio_vector[] = {41, 42, 43, 10, -1};
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100108 uint8_t *spd_file;
Vladimir Serbinenko12874162014-01-12 14:12:15 +0100109 size_t spd_file_len;
Stefan Reinauer49428d82013-02-21 15:48:37 -0800110 int spd_index = get_gpios(gpio_vector);
111
112 printk(BIOS_DEBUG, "spd index %d\n", spd_index);
Aaron Durbin899d13d2015-05-15 23:39:23 -0500113 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
114 &spd_file_len);
Stefan Reinauer49428d82013-02-21 15:48:37 -0800115 if (!spd_file)
116 die("SPD data not found.");
117
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100118 if (spd_file_len < ((spd_index + 1) * 256)) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800119 printk(BIOS_ERR, "spd index override to 0 - old hardware?\n");
120 spd_index = 0;
121 }
122
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100123 if (spd_file_len < 256)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800124 die("Missing SPD data.");
125
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100126 return spd_file + spd_index * 256;
Stefan Reinauer49428d82013-02-21 15:48:37 -0800127}
128
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100129void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800130{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100131 struct pei_data pei_data_template = {
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000132 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800133 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
134 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000135 .epbar = DEFAULT_EPBAR,
136 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
137 .smbusbar = SMBUS_IO_BASE,
138 .wdbbar = 0x4000000,
139 .wdbsize = 0x1000,
140 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800141 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000142 .pmbase = DEFAULT_PMBASE,
143 .gpiobase = DEFAULT_GPIOBASE,
144 .thermalbase = 0xfed08000,
145 .system_type = 0, // 0 Mobile, 1 Desktop/Server
146 .tseg_size = CONFIG_SMM_TSEG_SIZE,
147 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
148 .ec_present = 1,
149 .ddr3lv_support = 1,
Stefan Reinauer49428d82013-02-21 15:48:37 -0800150 // 0 = leave channel enabled
151 // 1 = disable dimm 0 on channel
152 // 2 = disable dimm 1 on channel
153 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000154 .dimm_channel0_disabled = 2,
155 .dimm_channel1_disabled = 2,
156 .max_ddr3_freq = 1600,
157 .usb_port_config = {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800158 /* Empty and onboard Ports 0-7, set to un-used pin OC3 */
159 { 0, 3, 0x0000 }, /* P0: Empty */
160 { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */
161 { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */
162 { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */
163 { 0, 3, 0x0000 }, /* P4: Empty */
164 { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */
165 { 0, 3, 0x0000 }, /* P6: Empty */
166 { 0, 3, 0x0000 }, /* P7: Empty */
167 /* Empty and onboard Ports 8-13, set to un-used pin OC4 */
168 { 1, 4, 0x0040 }, /* P8: Camera (no OC) */
169 { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */
170 { 0, 4, 0x0000 }, /* P10: Empty */
171 { 0, 4, 0x0000 }, /* P11: Empty */
172 { 0, 4, 0x0000 }, /* P12: Empty */
173 { 0, 4, 0x0000 }, /* P13: Empty */
174 },
175 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100176 *pei_data = pei_data_template;
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100177 memcpy(pei_data->spd_data[0], locate_spd(),
178 sizeof(pei_data->spd_data[0]));
179}
180
181const struct southbridge_usb_port mainboard_usb_ports[] = {
182 /* enabled power usb oc pin */
183 { 0, 0, -1 }, /* P0: Empty */
184 { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
185 { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
186 { 1, 0, -1 }, /* P3: SDCARD (no OC) */
187 { 0, 0, -1 }, /* P4: Empty */
188 { 1, 0, -1 }, /* P5: WWAN (no OC) */
189 { 0, 0, -1 }, /* P6: Empty */
190 { 0, 0, -1 }, /* P7: Empty */
191 { 1, 0, -1 }, /* P8: Camera (no OC) */
192 { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
193 { 0, 0, -1 }, /* P10: Empty */
194 { 0, 0, -1 }, /* P11: Empty */
195 { 0, 0, -1 }, /* P12: Empty */
196 { 0, 0, -1 }, /* P13: Empty */
197};
198
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200199void mainboard_get_spd(spd_raw_data *spd, bool id_only) {
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100200 memcpy(&spd[0], locate_spd(), 128);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100201}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800202
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100203void mainboard_early_init(int s3resume)
204{
205 if (!s3resume) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800206 /* This is the fastest way to let users know
207 * the Intel CPU is now alive.
208 */
209 google_chromeec_kbbacklight(100);
210 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100211}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800212
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100213int mainboard_should_reset_usb(int s3resume)
214{
215 return !s3resume;
216}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800217
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100218void mainboard_config_superio(void)
219{
Stefan Reinauer49428d82013-02-21 15:48:37 -0800220}