blob: d6a0b4d3c8f0b40bc15d06f4e598d2e48f207eb4 [file] [log] [blame]
WANG Siyuan05639412015-05-20 14:44:32 +08001/*
2 * This file is part of the coreboot project.
3 *
WANG Siyuan05639412015-05-20 14:44:32 +08004 *
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 Siyuan05639412015-05-20 14:44:32 +080013 */
14
15#include <device/pci_def.h>
16#include <device/device.h>
WANG Siyuan05639412015-05-20 14:44:32 +080017
18/* warning: Porting.h includes an open #pragma pack(1) */
Elyes HAOUAS19f5ba82018-10-14 14:52:06 +020019#include <Porting.h>
20#include <AGESA.h>
WANG Siyuan05639412015-05-20 14:44:32 +080021#include "chip.h"
Elyes HAOUAS19f5ba82018-10-14 14:52:06 +020022#include <northbridge/amd/pi/dimmSpd.h>
WANG Siyuan05639412015-05-20 14:44:32 +080023
Stefan Reinauer8d29dd12017-06-26 14:30:39 -070024AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
WANG Siyuan05639412015-05-20 14:44:32 +080025{
26 int spdAddress;
Kyösti Mälkki33ff44c2018-05-22 01:15:22 +030027 DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2);
Jacob Garber42660cd2019-03-21 14:20:21 -060028
29 if (dev == NULL)
30 return AGESA_ERROR;
31
Aaron Durbine4d7abc2017-04-16 22:05:36 -050032 DEVTREE_CONST struct northbridge_amd_pi_00660F01_config *config = dev->chip_info;
WANG Siyuan05639412015-05-20 14:44:32 +080033
Jacob Garber42660cd2019-03-21 14:20:21 -060034 if (config == NULL)
WANG Siyuan05639412015-05-20 14:44:32 +080035 return AGESA_ERROR;
Jacob Garber42660cd2019-03-21 14:20:21 -060036
WANG Siyuan05639412015-05-20 14:44:32 +080037 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}