Angel Pons | 89ab250 | 2020-04-03 01:22:28 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <string.h> |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 5 | #include <console/console.h> |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 6 | #include <northbridge/intel/sandybridge/raminit_native.h> |
| 7 | #include <southbridge/intel/bd82x6x/pch.h> |
| 8 | #include <southbridge/intel/common/gpio.h> |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 9 | #include <cbfs.h> |
| 10 | |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 11 | const 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 | |
| 29 | static 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 Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame^] | 35 | spd_file = cbfs_map("spd.bin", &spd_file_len); |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 36 | 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 Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 45 | void 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 Couzens | 532e8a9 | 2018-08-01 18:59:50 +0200 | [diff] [blame] | 53 | |
| 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 Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * GPIO45 GPIO25 |
| 63 | * 0 0 elpida |
| 64 | * 0 1 hynix |
| 65 | * 1 0 samsung |
| 66 | * 1 1 reserved |
| 67 | */ |
| 68 | |
Alexander Couzens | 532e8a9 | 2018-08-01 18:59:50 +0200 | [diff] [blame] | 69 | if (spd_index == 3) |
| 70 | die("Unsupported Memory. (detected 'reserved' memory configuration)."); |
Alexander Couzens | db50856 | 2016-10-12 04:44:19 +0200 | [diff] [blame] | 71 | |
| 72 | memory = get_spd_data(spd_index); |
| 73 | memcpy(&spd[0], memory, 256); |
| 74 | memcpy(&spd[2], memory, 256); |
| 75 | } |