coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dimmSpd.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/pci_def.h>
4 #include <device/device.h>
5 
6 /* warning: Porting.h includes an open #pragma pack(1) */
7 #include <Porting.h>
8 #include <AGESA.h>
9 #include "chip.h"
10 
12 
13 /**
14  * Gets the SMBus address for an SPD from the array in devicetree.cb
15  * then read the SPD into the supplied buffer.
16  */
17 AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
18 {
19  UINT8 spdAddress;
20 
21  DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2);
22  if (dev == NULL)
23  return AGESA_ERROR;
24 
26  if (config == NULL)
27  return AGESA_ERROR;
28 
29  if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup))
30  return AGESA_ERROR;
31  if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0]))
32  return AGESA_ERROR;
33  if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0]))
34  return AGESA_ERROR;
35 
36  spdAddress = config->spdAddrLookup
37  [info->SocketId][info->MemChannelId][info->DimmId];
38 
39  if (spdAddress == 0)
40  return AGESA_ERROR;
41 
42  int err = hudson_readSpd(spdAddress, (void *) info->Buffer, DDR3_SPD_SIZE);
43  if (err)
44  return AGESA_ERROR;
45  return AGESA_SUCCESS;
46 }
#define AGESA_SUCCESS
Definition: Amd.h:38
unsigned int AGESA_STATUS
Definition: Amd.h:36
#define AGESA_ERROR
Definition: Amd.h:42
int hudson_readSpd(int spdAddress, char *buf, size_t len)
Definition: smbus_spd.c:124
AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
Gets the SMBus address for an SPD from the array in devicetree.cb then read the SPD into the supplied...
Definition: dimmSpd.c:18
#define ARRAY_SIZE(a)
Definition: helpers.h:12
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
static struct smmstore_params_info info
Definition: ramstage.c:12
enum board_config config
Definition: memory.c:448
#define NULL
Definition: stddef.h:19
#define DEVTREE_CONST
Definition: stddef.h:30
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164