blob: a4127f14d8f800badd06e3210ffdb46bf3747a99 [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
Felix Held972d9f22022-02-23 16:32:20 +01003#include <arch/hpet.h>
Stefan Reinauer49428d82013-02-21 15:48:37 -08004#include <stdint.h>
5#include <string.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.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{
Keith Hui7039edd2023-07-21 10:12:05 -040086 /* TODO: Confirm if nortbridge_fill_pei_data() gets .system_type right (should be 0) */
87
Matt DeVillier4af1fe22019-08-24 23:54:41 -050088 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
89 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010090 memcpy(pei_data->spd_data[0], locate_spd(),
91 sizeof(pei_data->spd_data[0]));
Matt DeVillier4af1fe22019-08-24 23:54:41 -050092 memcpy(pei_data->spd_data[2], pei_data->spd_data[0],
93 sizeof(pei_data->spd_data[0]));
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010094}
95
96const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +010097 /* enabled power USB oc pin */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +010098 { 0, 0, -1 }, /* P0: Empty */
99 { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
100 { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
101 { 1, 0, -1 }, /* P3: SDCARD (no OC) */
102 { 0, 0, -1 }, /* P4: Empty */
103 { 1, 0, -1 }, /* P5: WWAN (no OC) */
104 { 0, 0, -1 }, /* P6: Empty */
105 { 0, 0, -1 }, /* P7: Empty */
106 { 1, 0, -1 }, /* P8: Camera (no OC) */
107 { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
108 { 0, 0, -1 }, /* P10: Empty */
109 { 0, 0, -1 }, /* P11: Empty */
110 { 0, 0, -1 }, /* P12: Empty */
111 { 0, 0, -1 }, /* P13: Empty */
112};
113
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100114void mainboard_get_spd(spd_raw_data *spd, bool id_only)
115{
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500116 /* LINK has 2 channels of memory down, so spd_data[0] and [2]
117 both need to be populated */
Vladimir Serbinenkob2ad8102016-02-10 03:07:42 +0100118 memcpy(&spd[0], locate_spd(), 128);
Matt DeVillier4af1fe22019-08-24 23:54:41 -0500119 memcpy(&spd[2], &spd[0], 128);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100120}
Stefan Reinauer49428d82013-02-21 15:48:37 -0800121
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100122void mainboard_early_init(int s3resume)
123{
124 if (!s3resume) {
Stefan Reinauer49428d82013-02-21 15:48:37 -0800125 /* This is the fastest way to let users know
126 * the Intel CPU is now alive.
127 */
128 google_chromeec_kbbacklight(100);
129 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100130}