blob: 0e2bb4f026fbfbcd24db23113a41d086382288d5 [file] [log] [blame]
Angel Ponsfeedf232020-04-05 13:22:01 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer49428d82013-02-21 15:48:37 -08002
3#include <stdint.h>
4#include <string.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07006#include <acpi/acpi.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -08007#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +11008#include <northbridge/intel/sandybridge/sandybridge.h>
9#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010010#include <northbridge/intel/sandybridge/raminit_native.h>
Patrick Rudolphda9302a2019-03-24 17:01:41 +010011#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010012#include <southbridge/intel/common/gpio.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -080013#include "ec/google/chromeec/ec.h"
Stefan Reinauer49428d82013-02-21 15:48:37 -080014#include <cbfs.h>
15
16#include <southbridge/intel/bd82x6x/chip.h>
17
Arthur Heymans2b28a162019-11-12 17:21:08 +010018void mainboard_pch_lpc_setup(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080019{
Nico Hubere036aae2019-11-17 01:24:44 +010020 /* Enable additional 0x200..0x207 for EC */
21 pci_or_config16(PCH_LPC_DEV, LPC_EN, GAMEL_LPC_EN);
Stefan Reinauer49428d82013-02-21 15:48:37 -080022}
23
Arthur Heymans9c538342019-11-12 16:42:33 +010024void mainboard_late_rcba_config(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080025{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030026 /*
27 * GFX INTA -> PIRQA (MSI)
28 * D28IP_P3IP WLAN INTA -> PIRQB
29 * D29IP_E1P EHCI1 INTA -> PIRQD
30 * D26IP_E2P EHCI2 INTA -> PIRQF
31 * D31IP_SIP SATA INTA -> PIRQF (MSI)
32 * D31IP_SMIP SMBUS INTB -> PIRQH
33 * D31IP_TTIP THRT INTC -> PIRQA
34 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
35 *
36 * TRACKPAD -> PIRQE (Edge Triggered)
37 * TOUCHSCREEN -> PIRQG (Edge Triggered)
38 */
39
40 /* Device interrupt pin register (board specific) */
41 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
42 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
43 RCBA32(D30IP) = (NOINT << D30IP_PIP);
44 RCBA32(D29IP) = (INTA << D29IP_E1P);
45 RCBA32(D28IP) = (INTA << D28IP_P3IP);
46 RCBA32(D27IP) = (INTA << D27IP_ZIP);
47 RCBA32(D26IP) = (INTA << D26IP_E2P);
48 RCBA32(D25IP) = (NOINT << D25IP_LIP);
49 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
50
51 /* Device interrupt route registers */
52 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
53 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
54 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
55 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
56 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
57 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
58 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
Stefan Reinauer49428d82013-02-21 15:48:37 -080059}
60
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010061static uint8_t *locate_spd(void)
Stefan Reinauer49428d82013-02-21 15:48:37 -080062{
63 const int gpio_vector[] = {41, 42, 43, 10, -1};
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010064 uint8_t *spd_file;
Vladimir Serbinenko12874162014-01-12 14:12:15 +010065 size_t spd_file_len;
Stefan Reinauer49428d82013-02-21 15:48:37 -080066 int spd_index = get_gpios(gpio_vector);
67
68 printk(BIOS_DEBUG, "spd index %d\n", spd_index);
Julius Werner834b3ec2020-03-04 16:52:08 -080069 spd_file = cbfs_map("spd.bin", &spd_file_len);
Stefan Reinauer49428d82013-02-21 15:48:37 -080070 if (!spd_file)
71 die("SPD data not found.");
72
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010073 if (spd_file_len < ((spd_index + 1) * 256)) {
Stefan Reinauer49428d82013-02-21 15:48:37 -080074 printk(BIOS_ERR, "spd index override to 0 - old hardware?\n");
75 spd_index = 0;
76 }
77
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010078 if (spd_file_len < 256)
Stefan Reinauer49428d82013-02-21 15:48:37 -080079 die("Missing SPD data.");
80
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010081 return spd_file + spd_index * 256;
Stefan Reinauer49428d82013-02-21 15:48:37 -080082}
83
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010084void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer49428d82013-02-21 15:48:37 -080085{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010086 struct pei_data pei_data_template = {
Edward O'Callaghan6cec8242014-05-24 04:16:57 +100087 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010088 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
89 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
90 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070091 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020092 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +100093 .wdbbar = 0x4000000,
94 .wdbsize = 0x1000,
95 .hpet_address = CONFIG_HPET_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020096 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +100097 .pmbase = DEFAULT_PMBASE,
98 .gpiobase = DEFAULT_GPIOBASE,
99 .thermalbase = 0xfed08000,
100 .system_type = 0, // 0 Mobile, 1 Desktop/Server
101 .tseg_size = CONFIG_SMM_TSEG_SIZE,
102 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
103 .ec_present = 1,
104 .ddr3lv_support = 1,
Edward O'Callaghan6cec8242014-05-24 04:16:57 +1000105 .max_ddr3_freq = 1600,
106 .usb_port_config = {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800107 /* Empty and onboard Ports 0-7, set to un-used pin OC3 */
108 { 0, 3, 0x0000 }, /* P0: Empty */
109 { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */
110 { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */
111 { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */
112 { 0, 3, 0x0000 }, /* P4: Empty */
113 { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */
114 { 0, 3, 0x0000 }, /* P6: Empty */
115 { 0, 3, 0x0000 }, /* P7: Empty */
116 /* Empty and onboard Ports 8-13, set to un-used pin OC4 */
117 { 1, 4, 0x0040 }, /* P8: Camera (no OC) */
118 { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */
119 { 0, 4, 0x0000 }, /* P10: Empty */
120 { 0, 4, 0x0000 }, /* P11: Empty */
121 { 0, 4, 0x0000 }, /* P12: Empty */
122 { 0, 4, 0x0000 }, /* P13: Empty */
123 },
124 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100125 *pei_data = pei_data_template;
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500126 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
127 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100128 memcpy(pei_data->spd_data[0], locate_spd(),
129 sizeof(pei_data->spd_data[0]));
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500130 memcpy(pei_data->spd_data[2], pei_data->spd_data[0],
131 sizeof(pei_data->spd_data[0]));
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100132}
133
134const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100135 /* enabled power USB oc pin */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100136 { 0, 0, -1 }, /* P0: Empty */
137 { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
138 { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
139 { 1, 0, -1 }, /* P3: SDCARD (no OC) */
140 { 0, 0, -1 }, /* P4: Empty */
141 { 1, 0, -1 }, /* P5: WWAN (no OC) */
142 { 0, 0, -1 }, /* P6: Empty */
143 { 0, 0, -1 }, /* P7: Empty */
144 { 1, 0, -1 }, /* P8: Camera (no OC) */
145 { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
146 { 0, 0, -1 }, /* P10: Empty */
147 { 0, 0, -1 }, /* P11: Empty */
148 { 0, 0, -1 }, /* P12: Empty */
149 { 0, 0, -1 }, /* P13: Empty */
150};
151
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100152void mainboard_get_spd(spd_raw_data *spd, bool id_only)
153{
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500154 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
155 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100156 memcpy(&spd[0], locate_spd(), 128);
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500157 memcpy(&spd[2], &spd[0], 128);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100158}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800159
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100160void mainboard_early_init(int s3resume)
161{
162 if (!s3resume) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800163 /* This is the fastest way to let users know
164 * the Intel CPU is now alive.
165 */
166 google_chromeec_kbbacklight(100);
167 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100168}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800169
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100170int mainboard_should_reset_usb(int s3resume)
171{
172 return !s3resume;
173}