blob: 516b26c9c51c51bf6baa939ba8231d0bb3530ad0 [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
Elyes HAOUAS282171c2019-06-30 00:16:40 +02003#include <stddef.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 <northbridge/intel/haswell/haswell.h>
9#include <northbridge/intel/haswell/raminit.h>
10#include <southbridge/intel/lynxpoint/pch.h>
11#include <southbridge/intel/lynxpoint/lp_gpio.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060012#include "../../variant.h"
13
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060014/* Copy SPD data for on-board memory */
Angel Pons6eea1912020-07-03 14:14:30 +020015void copy_spd(struct pei_data *peid)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060016{
17 const int gpio_vector[] = {13, 9, 47, -1};
18 int spd_index = get_gpios(gpio_vector);
19 char *spd_file;
20 size_t spd_file_len;
Matt DeVilliercadd7c72017-05-29 19:10:57 -050021 size_t spd_len = sizeof(peid->spd_data[0]);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060022
23 printk(BIOS_DEBUG, "SPD index %d\n", spd_index);
Julius Werner834b3ec2020-03-04 16:52:08 -080024 spd_file = cbfs_map("spd.bin", &spd_file_len);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060025 if (!spd_file)
26 die("SPD data not found.");
27
Matt DeVilliercadd7c72017-05-29 19:10:57 -050028 if (spd_file_len < ((spd_index + 1) * spd_len)) {
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060029 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
30 spd_index = 0;
31 }
32
Matt DeVilliercadd7c72017-05-29 19:10:57 -050033 if (spd_file_len < spd_len)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060034 die("Missing SPD data.");
35
Matt DeVilliercadd7c72017-05-29 19:10:57 -050036 memcpy(peid->spd_data[0], spd_file + (spd_index * spd_len), spd_len);
37
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060038 /* Index 0-2,6 are 4GB config with both CH0 and CH1
39 * Index 3-5,7 are 2GB config with CH0 only
40 */
41 switch (spd_index) {
Matt DeVilliercadd7c72017-05-29 19:10:57 -050042 case 0: case 1: case 2: case 6:
43 memcpy(peid->spd_data[1],
44 spd_file + (spd_index * spd_len), spd_len);
45 break;
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060046 case 3: case 4: case 5: case 7:
47 peid->dimm_channel1_disabled = 3;
48 }
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060049}
50
Angel Pons14c4f4f2020-07-03 14:22:20 +020051void variant_romstage_entry(struct pei_data *pei_data)
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060052{
Angel Pons8d3bc492020-07-03 01:43:04 +020053 struct usb2_port_setting usb2_ports[MAX_USB2_PORTS] = {
54 /* Length, Enable, OCn#, Location */
55 { 0x0064, 1, 0, /* P0: Port A, CN8 */
56 USB_PORT_BACK_PANEL },
57 { 0x0052, 1, 0, /* P1: Port B, CN9 */
58 USB_PORT_BACK_PANEL },
59 { 0x0040, 1, USB_OC_PIN_SKIP, /* P2: CCD */
60 USB_PORT_INTERNAL },
61 { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */
62 USB_PORT_INTERNAL },
63 { 0x0040, 1, USB_OC_PIN_SKIP, /* P4: LTE */
64 USB_PORT_INTERNAL },
65 { 0x0040, 1, USB_OC_PIN_SKIP, /* P5: TOUCH */
66 USB_PORT_INTERNAL },
67 { 0x0040, 1, USB_OC_PIN_SKIP, /* P6: SD Card */
68 USB_PORT_INTERNAL },
69 { 0x0123, 1, 3, /* P7: USB2 Port */
70 USB_PORT_INTERNAL },
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060071 };
72
Angel Pons8d3bc492020-07-03 01:43:04 +020073 struct usb3_port_setting usb3_ports[MAX_USB3_PORTS] = {
74 /* Enable, OCn# */
75 { 1, 0 }, /* P1; Port A, CN8 */
76 { 1, 0 }, /* P2; Port B, CN9 */
77 { 0, USB_OC_PIN_SKIP }, /* P3; */
78 { 0, USB_OC_PIN_SKIP }, /* P4; */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060079 };
80
Angel Pons14c4f4f2020-07-03 14:22:20 +020081 memcpy(pei_data->usb2_ports, usb2_ports, sizeof(usb2_ports));
82 memcpy(pei_data->usb3_ports, usb3_ports, sizeof(usb3_ports));
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060083}