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 <commonlib/helpers.h>
4 #include <device/pci_def.h>
5 #include <device/device.h>
6 
7 /* warning: Porting.h includes an open #pragma pack(1) */
8 #include <Porting.h>
9 #include <AGESA.h>
10 #include "chip.h"
11 
13 
14 AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
15 {
16  int spdAddress;
17  DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2);
18 
19  if (dev == NULL)
20  return AGESA_ERROR;
21 
23 
24  if (config == NULL)
25  return AGESA_ERROR;
26 
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;
33 
34  spdAddress = config->spdAddrLookup
35  [info->SocketId] [info->MemChannelId] [info->DimmId];
36 
37  if (spdAddress == 0)
38  return AGESA_ERROR;
39 
40  int err = hudson_readSpd(spdAddress, (void *) info->Buffer, 128);
41  if (err)
42  return AGESA_ERROR;
43  return AGESA_SUCCESS;
44 }
#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