blob: 628e2a00526a39a8039036cdc5cad2770c249947 [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{
Stefan Reinauer49428d82013-02-21 15:48:37 -080037 /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */
38 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | \
39 GAMEL_LPC_EN | COMA_LPC_EN);
Stefan Reinauer49428d82013-02-21 15:48:37 -080040}
41
Arthur Heymans9c538342019-11-12 16:42:33 +010042void mainboard_late_rcba_config(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080043{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030044 /*
45 * GFX INTA -> PIRQA (MSI)
46 * D28IP_P3IP WLAN INTA -> PIRQB
47 * D29IP_E1P EHCI1 INTA -> PIRQD
48 * D26IP_E2P EHCI2 INTA -> PIRQF
49 * D31IP_SIP SATA INTA -> PIRQF (MSI)
50 * D31IP_SMIP SMBUS INTB -> PIRQH
51 * D31IP_TTIP THRT INTC -> PIRQA
52 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
53 *
54 * TRACKPAD -> PIRQE (Edge Triggered)
55 * TOUCHSCREEN -> PIRQG (Edge Triggered)
56 */
57
58 /* Device interrupt pin register (board specific) */
59 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
60 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
61 RCBA32(D30IP) = (NOINT << D30IP_PIP);
62 RCBA32(D29IP) = (INTA << D29IP_E1P);
63 RCBA32(D28IP) = (INTA << D28IP_P3IP);
64 RCBA32(D27IP) = (INTA << D27IP_ZIP);
65 RCBA32(D26IP) = (INTA << D26IP_E2P);
66 RCBA32(D25IP) = (NOINT << D25IP_LIP);
67 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
68
69 /* Device interrupt route registers */
70 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
71 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
72 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
73 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
74 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
75 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
76 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
77
78 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020079 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030080 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +020081 (void) RCBA16(OIC);
Stefan Reinauer49428d82013-02-21 15:48:37 -080082}
83
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010084static uint8_t *locate_spd(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080085{
86 const int gpio_vector[] = {41, 42, 43, 10, -1};
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010087 uint8_t *spd_file;
Vladimir Serbinenko12874162014-01-12 14:12:15 +010088 size_t spd_file_len;
Stefan Reinauer49428d82013-02-21 15:48:37 -080089 int spd_index = get_gpios(gpio_vector);
90
91 printk(BIOS_DEBUG, "spd index %d\n", spd_index);
Aaron Durbin899d13d2015-05-15 23:39:23 -050092 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
93 &spd_file_len);
Stefan Reinauer49428d82013-02-21 15:48:37 -080094 if (!spd_file)
95 die("SPD data not found.");
96
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010097 if (spd_file_len < ((spd_index + 1) * 256)) {
Stefan Reinauer49428d82013-02-21 15:48:37 -080098 printk(BIOS_ERR, "spd index override to 0 - old hardware?\n");
99 spd_index = 0;
100 }
101
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100102 if (spd_file_len < 256)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800103 die("Missing SPD data.");
104
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100105 return spd_file + spd_index * 256;
Stefan Reinauer49428d82013-02-21 15:48:37 -0800106}
107
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100108void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer49428d82013-02-21 15:48:37 -0800109{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100110 struct pei_data pei_data_template = {
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000111 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800112 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
113 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000114 .epbar = DEFAULT_EPBAR,
115 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
116 .smbusbar = SMBUS_IO_BASE,
117 .wdbbar = 0x4000000,
118 .wdbsize = 0x1000,
119 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800120 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000121 .pmbase = DEFAULT_PMBASE,
122 .gpiobase = DEFAULT_GPIOBASE,
123 .thermalbase = 0xfed08000,
124 .system_type = 0, // 0 Mobile, 1 Desktop/Server
125 .tseg_size = CONFIG_SMM_TSEG_SIZE,
126 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
127 .ec_present = 1,
128 .ddr3lv_support = 1,
Stefan Reinauer49428d82013-02-21 15:48:37 -0800129 // 0 = leave channel enabled
130 // 1 = disable dimm 0 on channel
131 // 2 = disable dimm 1 on channel
132 // 3 = disable dimm 0+1 on channel
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000133 .dimm_channel0_disabled = 2,
134 .dimm_channel1_disabled = 2,
135 .max_ddr3_freq = 1600,
136 .usb_port_config = {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800137 /* Empty and onboard Ports 0-7, set to un-used pin OC3 */
138 { 0, 3, 0x0000 }, /* P0: Empty */
139 { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */
140 { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */
141 { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */
142 { 0, 3, 0x0000 }, /* P4: Empty */
143 { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */
144 { 0, 3, 0x0000 }, /* P6: Empty */
145 { 0, 3, 0x0000 }, /* P7: Empty */
146 /* Empty and onboard Ports 8-13, set to un-used pin OC4 */
147 { 1, 4, 0x0040 }, /* P8: Camera (no OC) */
148 { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */
149 { 0, 4, 0x0000 }, /* P10: Empty */
150 { 0, 4, 0x0000 }, /* P11: Empty */
151 { 0, 4, 0x0000 }, /* P12: Empty */
152 { 0, 4, 0x0000 }, /* P13: Empty */
153 },
154 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100155 *pei_data = pei_data_template;
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500156 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
157 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100158 memcpy(pei_data->spd_data[0], locate_spd(),
159 sizeof(pei_data->spd_data[0]));
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500160 memcpy(pei_data->spd_data[2], pei_data->spd_data[0],
161 sizeof(pei_data->spd_data[0]));
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100162}
163
164const struct southbridge_usb_port mainboard_usb_ports[] = {
165 /* enabled power usb oc pin */
166 { 0, 0, -1 }, /* P0: Empty */
167 { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
168 { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
169 { 1, 0, -1 }, /* P3: SDCARD (no OC) */
170 { 0, 0, -1 }, /* P4: Empty */
171 { 1, 0, -1 }, /* P5: WWAN (no OC) */
172 { 0, 0, -1 }, /* P6: Empty */
173 { 0, 0, -1 }, /* P7: Empty */
174 { 1, 0, -1 }, /* P8: Camera (no OC) */
175 { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
176 { 0, 0, -1 }, /* P10: Empty */
177 { 0, 0, -1 }, /* P11: Empty */
178 { 0, 0, -1 }, /* P12: Empty */
179 { 0, 0, -1 }, /* P13: Empty */
180};
181
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100182void mainboard_get_spd(spd_raw_data *spd, bool id_only)
183{
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500184 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
185 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100186 memcpy(&spd[0], locate_spd(), 128);
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500187 memcpy(&spd[2], &spd[0], 128);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100188}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800189
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100190void mainboard_early_init(int s3resume)
191{
192 if (!s3resume) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800193 /* This is the fastest way to let users know
194 * the Intel CPU is now alive.
195 */
196 google_chromeec_kbbacklight(100);
197 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100198}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800199
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100200int mainboard_should_reset_usb(int s3resume)
201{
202 return !s3resume;
203}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800204
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100205void mainboard_config_superio(void)
206{
Stefan Reinauer49428d82013-02-21 15:48:37 -0800207}