blob: 6f18feee9182d7be5ac0bb669a6a359036aeac6b [file] [log] [blame]
Angel Pons89ab2502020-04-03 01:22:28 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Alexander Couzensdb508562016-10-12 04:44:19 +02002
3#include <stdint.h>
4#include <string.h>
Alexander Couzensdb508562016-10-12 04:44:19 +02005#include <console/console.h>
Alexander Couzensdb508562016-10-12 04:44:19 +02006#include <northbridge/intel/sandybridge/raminit_native.h>
7#include <southbridge/intel/bd82x6x/pch.h>
8#include <southbridge/intel/common/gpio.h>
Alexander Couzensdb508562016-10-12 04:44:19 +02009#include <cbfs.h>
10
Alexander Couzensdb508562016-10-12 04:44:19 +020011const struct southbridge_usb_port mainboard_usb_ports[] = {
12 /* enabled, current, OC pin */
13 { 0, 3, 0 }, /* P00 disconnected */
14 { 1, 1, 1 }, /* P01 left or right */
15 { 0, 1, 3 }, /* P02 disconnected */
16 { 1, 3, -1 },/* P03 WWAN */
17 { 0, 1, 2 }, /* P04 disconnected */
18 { 0, 1, -1 },/* P05 disconnected */
19 { 0, 1, -1 },/* P06 disconnected */
20 { 0, 2, -1 },/* P07 disconnected */
21 { 0, 1, -1 },/* P08 disconnected */
22 { 1, 2, 5 }, /* P09 left or right */
23 { 1, 3, -1 },/* P10 FPR */
24 { 1, 3, -1 },/* P11 Bluetooth */
25 { 1, 1, -1 },/* P12 WLAN */
26 { 1, 1, -1 },/* P13 Camera */
27};
28
29static uint8_t *get_spd_data(int spd_index)
30{
31 uint8_t *spd_file;
32 size_t spd_file_len;
33
34 printk(BIOS_DEBUG, "spd index %d\n", spd_index);
Julius Werner834b3ec2020-03-04 16:52:08 -080035 spd_file = cbfs_map("spd.bin", &spd_file_len);
Alexander Couzensdb508562016-10-12 04:44:19 +020036 if (!spd_file)
37 die("SPD data not found.");
38
39 if (spd_file_len < spd_index * 256)
40 die("Missing SPD data.");
41
42 return spd_file + spd_index * 256;
43}
44
Alexander Couzensdb508562016-10-12 04:44:19 +020045void mainboard_get_spd(spd_raw_data *spd, bool id_only)
46{
47 uint8_t *memory;
48 const int spd_gpio_vector[] = {25, 45, -1};
49 int spd_index = get_gpios(spd_gpio_vector);
50
51 /* 4gb model = 0, 8gb model = 1 */
52 /* int extended_memory_version = get_gpio(44); */
Alexander Couzens532e8a92018-08-01 18:59:50 +020053
54 /*
55 * So far there is no need to parse gpio 44, as the 4GiB use
56 * the hynix or elpida memory and 8 GiB versions use samsung.
57 * All version use both channels.
58 * But we might miss some versions.
59 */
Alexander Couzensdb508562016-10-12 04:44:19 +020060
61 /*
62 * GPIO45 GPIO25
63 * 0 0 elpida
64 * 0 1 hynix
65 * 1 0 samsung
66 * 1 1 reserved
67 */
68
Alexander Couzens532e8a92018-08-01 18:59:50 +020069 if (spd_index == 3)
70 die("Unsupported Memory. (detected 'reserved' memory configuration).");
Alexander Couzensdb508562016-10-12 04:44:19 +020071
72 memory = get_spd_data(spd_index);
73 memcpy(&spd[0], memory, 256);
74 memcpy(&spd[2], memory, 256);
75}