Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 2 | |
Elyes HAOUAS | 0afc41e | 2018-11-27 11:25:19 +0100 | [diff] [blame] | 3 | #include <commonlib/helpers.h> |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 4 | #include <device/pci_def.h> |
| 5 | #include <device/device.h> |
| 6 | |
| 7 | /* warning: Porting.h includes an open #pragma pack(1) */ |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 8 | #include <Porting.h> |
| 9 | #include <AGESA.h> |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 10 | #include "chip.h" |
| 11 | |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 12 | #include <northbridge/amd/pi/dimmSpd.h> |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 13 | |
Elyes Haouas | f9b535e | 2022-07-16 09:47:42 +0200 | [diff] [blame] | 14 | AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info) |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 15 | { |
Kyösti Mälkki | c5cc9f2 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 16 | int spdAddress; |
Kyösti Mälkki | 33ff44c | 2018-05-22 01:15:22 +0300 | [diff] [blame] | 17 | DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); |
Jacob Garber | 42660cd | 2019-03-21 14:20:21 -0600 | [diff] [blame] | 18 | |
| 19 | if (dev == NULL) |
| 20 | return AGESA_ERROR; |
| 21 | |
Aaron Durbin | e4d7abc | 2017-04-16 22:05:36 -0500 | [diff] [blame] | 22 | DEVTREE_CONST struct northbridge_amd_pi_00730F01_config *config = dev->chip_info; |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 23 | |
Jacob Garber | 42660cd | 2019-03-21 14:20:21 -0600 | [diff] [blame] | 24 | if (config == NULL) |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 25 | return AGESA_ERROR; |
| 26 | |
Elyes HAOUAS | 0afc41e | 2018-11-27 11:25:19 +0100 | [diff] [blame] | 27 | if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 28 | return AGESA_ERROR; |
Elyes HAOUAS | 0afc41e | 2018-11-27 11:25:19 +0100 | [diff] [blame] | 29 | if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0])) |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 30 | return AGESA_ERROR; |
Elyes HAOUAS | 0afc41e | 2018-11-27 11:25:19 +0100 | [diff] [blame] | 31 | if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0])) |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 32 | return AGESA_ERROR; |
| 33 | |
| 34 | spdAddress = config->spdAddrLookup |
| 35 | [info->SocketId] [info->MemChannelId] [info->DimmId]; |
| 36 | |
Kyösti Mälkki | c5cc9f2 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 37 | if (spdAddress == 0) |
| 38 | return AGESA_ERROR; |
| 39 | |
Elyes Haouas | f9b535e | 2022-07-16 09:47:42 +0200 | [diff] [blame] | 40 | int err = hudson_readSpd(spdAddress, (void *)info->Buffer, 128); |
Kyösti Mälkki | c5cc9f2 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 41 | if (err) |
| 42 | return AGESA_ERROR; |
| 43 | return AGESA_SUCCESS; |
Bruce Griffith | 27ed80b | 2014-08-15 11:46:25 -0600 | [diff] [blame] | 44 | } |