WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <device/pci_def.h> |
| 16 | #include <device/device.h> |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 17 | |
| 18 | /* warning: Porting.h includes an open #pragma pack(1) */ |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 19 | #include <Porting.h> |
| 20 | #include <AGESA.h> |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 21 | #include "chip.h" |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 22 | #include <northbridge/amd/pi/dimmSpd.h> |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 23 | |
Stefan Reinauer | 8d29dd1 | 2017-06-26 14:30:39 -0700 | [diff] [blame] | 24 | AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info) |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 25 | { |
| 26 | int spdAddress; |
Kyösti Mälkki | 33ff44c | 2018-05-22 01:15:22 +0300 | [diff] [blame] | 27 | DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); |
Jacob Garber | 42660cd | 2019-03-21 14:20:21 -0600 | [diff] [blame] | 28 | |
| 29 | if (dev == NULL) |
| 30 | return AGESA_ERROR; |
| 31 | |
Aaron Durbin | e4d7abc | 2017-04-16 22:05:36 -0500 | [diff] [blame] | 32 | DEVTREE_CONST struct northbridge_amd_pi_00660F01_config *config = dev->chip_info; |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 33 | |
Jacob Garber | 42660cd | 2019-03-21 14:20:21 -0600 | [diff] [blame] | 34 | if (config == NULL) |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 35 | return AGESA_ERROR; |
Jacob Garber | 42660cd | 2019-03-21 14:20:21 -0600 | [diff] [blame] | 36 | |
WANG Siyuan | 0563941 | 2015-05-20 14:44:32 +0800 | [diff] [blame] | 37 | if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) |
| 38 | return AGESA_ERROR; |
| 39 | if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0])) |
| 40 | return AGESA_ERROR; |
| 41 | if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0])) |
| 42 | return AGESA_ERROR; |
| 43 | spdAddress = config->spdAddrLookup |
| 44 | [info->SocketId] [info->MemChannelId] [info->DimmId]; |
| 45 | if (spdAddress == 0) |
| 46 | return AGESA_ERROR; |
| 47 | int err = hudson_readSpd(spdAddress, (void *) info->Buffer, 128); |
| 48 | if (err) |
| 49 | return AGESA_ERROR; |
| 50 | return AGESA_SUCCESS; |
| 51 | } |