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 #include <OEM.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 /**
15  * Gets the SMBus address for an SPD from the array in devicetree.cb
16  * then read the SPD into the supplied buffer.
17  */
18 AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
19 {
20  UINT8 spdAddress;
21 
22  DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2);
23  if (dev == NULL)
24  return AGESA_ERROR;
25 
27  if (config == NULL)
28  return AGESA_ERROR;
29 
30  if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup))
31  return AGESA_ERROR;
32  if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0]))
33  return AGESA_ERROR;
34  if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0]))
35  return AGESA_ERROR;
36 
37  spdAddress = config->spdAddrLookup
38  [info->SocketId][info->MemChannelId][info->DimmId];
39 
40  if (spdAddress == 0)
41  return AGESA_ERROR;
42 
43  int err = smbus_readSpd(spdAddress, (void *) info->Buffer, DDR3_SPD_SIZE);
44  if (err)
45  return AGESA_ERROR;
46  return AGESA_SUCCESS;
47 }
#define AGESA_SUCCESS
Definition: Amd.h:38
unsigned int AGESA_STATUS
Definition: Amd.h:36
#define AGESA_ERROR
Definition: Amd.h:42
int smbus_readSpd(int spdAddress, char *buf, size_t len)
Definition: smbus_spd.c:101
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