commonlib: Refactor CSE sync eventLog
[coreboot2.git] / src / northbridge / amd / pi / 00730F01 / dimmSpd.c
blobc24466efe9c54fc806bdf20bde170b034718f36a
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <commonlib/helpers.h>
4 #include <device/pci_def.h>
5 #include <device/device.h>
7 /* warning: Porting.h includes an open #pragma pack(1) */
8 #include <Porting.h>
9 #include <AGESA.h>
10 #include "chip.h"
12 #include <northbridge/amd/pi/dimmSpd.h>
14 AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
16 int spdAddress;
17 DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2);
19 if (dev == NULL)
20 return AGESA_ERROR;
22 DEVTREE_CONST struct northbridge_amd_pi_00730F01_config *config = dev->chip_info;
24 if (config == NULL)
25 return AGESA_ERROR;
27 if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup))
28 return AGESA_ERROR;
29 if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0]))
30 return AGESA_ERROR;
31 if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0]))
32 return AGESA_ERROR;
34 spdAddress = config->spdAddrLookup
35 [info->SocketId] [info->MemChannelId] [info->DimmId];
37 if (spdAddress == 0)
38 return AGESA_ERROR;
40 int err = hudson_readSpd(spdAddress, (void *)info->Buffer, 128);
41 if (err)
42 return AGESA_ERROR;
43 return AGESA_SUCCESS;