{mb,nb,soc}: Remove references to pci_bus_default_ops()
[coreboot.git] / src / northbridge / amd / agesa / family15tn / dimmSpd.c
blob1d77683e88030a0df609660669805c5dd9202080
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <device/pci_def.h>
17 #include <device/device.h>
18 #include <stdlib.h>
20 /* warning: Porting.h includes an open #pragma pack(1) */
21 #include "Porting.h"
22 #include "AGESA.h"
23 #include "chip.h"
25 #include <northbridge/amd/agesa/dimmSpd.h>
27 /**
28 * Gets the SMBus address for an SPD from the array in devicetree.cb
29 * then read the SPD into the supplied buffer.
31 AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
33 UINT8 spdAddress;
35 DEVTREE_CONST struct device *dev = dev_find_slot(0, PCI_DEVFN(0x18, 2));
36 if (dev == NULL)
37 return AGESA_ERROR;
39 DEVTREE_CONST struct northbridge_amd_agesa_family15tn_config *config = dev->chip_info;
40 if (config == NULL)
41 return AGESA_ERROR;
43 if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup))
44 return AGESA_ERROR;
45 if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0]))
46 return AGESA_ERROR;
47 if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0]))
48 return AGESA_ERROR;
50 spdAddress = config->spdAddrLookup
51 [info->SocketId][info->MemChannelId][info->DimmId];
53 if (spdAddress == 0)
54 return AGESA_ERROR;
56 int err = hudson_readSpd(spdAddress, (void *) info->Buffer, 128);
57 if (err)
58 return AGESA_ERROR;
59 return AGESA_SUCCESS;