blob: 92e1e8dd5e049ee95448daada57e29a990ac27cc [file] [log] [blame]
Angel Ponsd28443e2020-04-05 13:22:44 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06002
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06003#include <stdint.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06004#include <string.h>
5#include <cbfs.h>
6#include <console/console.h>
7#include <cpu/intel/haswell/haswell.h>
8#include "ec/google/chromeec/ec.h"
9#include <northbridge/intel/haswell/haswell.h>
10#include <northbridge/intel/haswell/raminit.h>
11#include <southbridge/intel/lynxpoint/pch.h>
12#include <southbridge/intel/lynxpoint/lp_gpio.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060013#include "../../onboard.h"
14#include "../../variant.h"
15
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060016/* Copy SPD data for on-board memory */
Angel Pons6eea1912020-07-03 14:14:30 +020017void copy_spd(struct pei_data *peid)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060018{
19 const int gpio_vector[] = {13, 9, 47, -1};
20 int spd_index = get_gpios(gpio_vector);
21 char *spd_file;
22 size_t spd_file_len;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050023 size_t spd_len = sizeof(peid->spd_data[0]);
Karthikeyan Ramasubramanianc80ff842018-09-17 16:19:34 -060024 uint32_t board_version = PEPPY_BOARD_VERSION_PROTO;
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060025
26 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
Julius Werner834b3ec2020-03-04 16:52:08 -080027 spd_file = cbfs_map("spd.bin", &spd_file_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060028 if (!spd_file)
29 die("SPD data not found.");
30
Matt DeVilliercadd7c72017-05-29 19:10:57 -050031 if (spd_file_len < ((spd_index + 1) * sizeof(peid->spd_data[0]))) {
32 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
33 spd_index = 0;
34 }
35
36 if (spd_file_len < spd_len)
37 die("Missing SPD data.");
38
39 memcpy(peid->spd_data[0], spd_file + (spd_index * spd_len), spd_len);
40
Karthikeyan Ramasubramanianc80ff842018-09-17 16:19:34 -060041 google_chromeec_get_board_version(&board_version);
42 switch (board_version) {
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060043 case PEPPY_BOARD_VERSION_PROTO:
44 /* Index 0 is 2GB config with CH0 only. */
45 if (spd_index == 0)
46 peid->dimm_channel1_disabled = 3;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050047 else
48 memcpy(peid->spd_data[1],
49 spd_file + (spd_index * spd_len), spd_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060050 break;
51
52 case PEPPY_BOARD_VERSION_EVT:
53 default:
Matt DeVillierf41eea42019-12-26 20:10:32 -060054 /* Index 0-3 are 4GB config with both CH0 and CH1.
55 * Index 4-7 are 2GB config with CH0 only. */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060056 if (spd_index > 3)
57 peid->dimm_channel1_disabled = 3;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050058 else
59 memcpy(peid->spd_data[1],
60 spd_file + (spd_index * spd_len), spd_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060061 break;
62 }
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060063}
64
Angel Pons14c4f4f2020-07-03 14:22:20 +020065void variant_romstage_entry(struct pei_data *pei_data)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060066{
Angel Pons8d3bc492020-07-03 01:43:04 +020067 struct usb2_port_setting usb2_ports[MAX_USB2_PORTS] = {
68 /* Length, Enable, OCn#, Location */
69 { 0x0150, 1, USB_OC_PIN_SKIP, /* P0: LTE */
70 USB_PORT_MINI_PCIE },
71 { 0x0040, 1, 0, /* P1: Port A, CN10 */
72 USB_PORT_BACK_PANEL },
73 { 0x0080, 1, USB_OC_PIN_SKIP, /* P2: CCD */
74 USB_PORT_INTERNAL },
75 { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */
76 USB_PORT_MINI_PCIE },
77 { 0x0040, 1, 2, /* P4: Port B, CN6 */
78 USB_PORT_BACK_PANEL },
79 { 0x0000, 0, USB_OC_PIN_SKIP, /* P5: EMPTY */
80 USB_PORT_SKIP },
81 { 0x0150, 1, USB_OC_PIN_SKIP, /* P6: SD Card */
82 USB_PORT_FLEX },
83 { 0x0000, 0, USB_OC_PIN_SKIP, /* P7: EMPTY */
84 USB_PORT_SKIP },
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060085 };
86
Angel Pons8d3bc492020-07-03 01:43:04 +020087 struct usb3_port_setting usb3_ports[MAX_USB3_PORTS] = {
88 /* Enable, OCn# */
89 { 1, 0 }, /* P1; Port A, CN6 */
90 { 0, USB_OC_PIN_SKIP }, /* P2; */
91 { 0, USB_OC_PIN_SKIP }, /* P3; */
92 { 0, USB_OC_PIN_SKIP }, /* P4; */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060093 };
94
Angel Pons14c4f4f2020-07-03 14:22:20 +020095 memcpy(pei_data->usb2_ports, usb2_ports, sizeof(usb2_ports));
96 memcpy(pei_data->usb3_ports, usb3_ports, sizeof(usb3_ports));
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060097}