Angel Pons | b5a2a52 | 2020-04-05 13:21:48 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 2 | |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 3 | #include <baseboard/variants.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 4 | #include <console/console.h> |
Elyes HAOUAS | 3b3d085 | 2021-02-01 10:09:40 +0100 | [diff] [blame^] | 5 | #include <gpio.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 6 | #include <spd_bin.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 7 | #include <variant/gpio.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 8 | #include <amdblocks/dimm_spd.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 9 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 10 | uint8_t __weak variant_memory_sku(void) |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 11 | { |
| 12 | gpio_t pads[] = { |
| 13 | [3] = MEM_CONFIG3, |
| 14 | [2] = MEM_CONFIG2, |
| 15 | [1] = MEM_CONFIG1, |
| 16 | [0] = MEM_CONFIG0, |
| 17 | }; |
| 18 | |
Martin Roth | 1cdb6f2 | 2017-11-17 09:25:02 -0700 | [diff] [blame] | 19 | return gpio_base2_value(pads, ARRAY_SIZE(pads)); |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 20 | } |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 21 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 22 | int __weak variant_mainboard_read_spd(uint8_t spdAddress, |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 23 | char *buf, size_t len) |
| 24 | { |
| 25 | struct region_device spd_rdev; |
| 26 | u8 spd_index = variant_memory_sku(); |
| 27 | |
| 28 | printk(BIOS_INFO, "%s SPD index %d\n", __func__, spd_index); |
| 29 | |
| 30 | if (get_spd_cbfs_rdev(&spd_rdev, spd_index) < 0) { |
| 31 | printk(BIOS_ERR, "Error: spd.bin not found\n"); |
| 32 | return -1; |
| 33 | } |
| 34 | |
| 35 | if (len != region_device_sz(&spd_rdev)) { |
| 36 | printk(BIOS_ERR, "Error: spd.bin is not the correct size\n"); |
| 37 | return -1; |
| 38 | } |
| 39 | |
| 40 | if (rdev_readat(&spd_rdev, buf, 0, len) != len) { |
| 41 | printk(BIOS_ERR, "Error: couldn't read spd.bin\n"); |
| 42 | return -1; |
| 43 | } |
| 44 | |
| 45 | return 0; |
| 46 | } |