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> |
Julius Werner | a9b44f4 | 2021-02-05 17:27:45 -0800 | [diff] [blame] | 7 | #include <string.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 8 | #include <variant/gpio.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 9 | #include <amdblocks/dimm_spd.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 10 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 11 | uint8_t __weak variant_memory_sku(void) |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 12 | { |
| 13 | gpio_t pads[] = { |
| 14 | [3] = MEM_CONFIG3, |
| 15 | [2] = MEM_CONFIG2, |
| 16 | [1] = MEM_CONFIG1, |
| 17 | [0] = MEM_CONFIG0, |
| 18 | }; |
| 19 | |
Martin Roth | 1cdb6f2 | 2017-11-17 09:25:02 -0700 | [diff] [blame] | 20 | return gpio_base2_value(pads, ARRAY_SIZE(pads)); |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 21 | } |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 22 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 23 | int __weak variant_mainboard_read_spd(uint8_t spdAddress, |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 24 | char *buf, size_t len) |
| 25 | { |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 26 | u8 spd_index = variant_memory_sku(); |
| 27 | |
| 28 | printk(BIOS_INFO, "%s SPD index %d\n", __func__, spd_index); |
| 29 | |
Julius Werner | a9b44f4 | 2021-02-05 17:27:45 -0800 | [diff] [blame] | 30 | void *spd = (void *)spd_cbfs_map(spd_index); |
| 31 | if (!spd) { |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame^] | 32 | printk(BIOS_ERR, "spd.bin not found\n"); |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 33 | return -1; |
| 34 | } |
| 35 | |
Julius Werner | a9b44f4 | 2021-02-05 17:27:45 -0800 | [diff] [blame] | 36 | if (len != CONFIG_DIMM_SPD_SIZE) { |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame^] | 37 | printk(BIOS_ERR, "spd.bin is not the correct size\n"); |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 38 | return -1; |
| 39 | } |
| 40 | |
Julius Werner | a9b44f4 | 2021-02-05 17:27:45 -0800 | [diff] [blame] | 41 | memcpy(buf, spd, len); |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame] | 42 | |
| 43 | return 0; |
| 44 | } |