diff options
author | Marc Jones <marcj303@gmail.com> | 2017-11-16 18:47:36 -0700 |
---|---|---|
committer | Marc Jones <marc@marcjonesconsulting.com> | 2017-11-29 23:58:06 +0000 |
commit | a9f72776bd5af067abf8bfc4bcdd44ec805c9e76 (patch) | |
tree | fbd68137175f80b5c183494e5ba80e9084542617 /src/soc/amd/stoneyridge | |
parent | fede56bf811972cd16e5b36c39c819b88fa74941 (diff) | |
download | coreboot-a9f72776bd5af067abf8bfc4bcdd44ec805c9e76.tar.xz |
soc/amd/stoneyridge: Add mainboard call for SPD values
Add a mainboard function call to write the AGESA SPD buffer.
Removes the unneccesary dimm_spd.c file.
BUG=b:67845441
Change-Id: Id42622008b49b4559e648a7fa1bfd9f26e1f56a4
Signed-off-by: Marc Jones <marcj303@gmail.com>
Reviewed-on: https://review.coreboot.org/22485
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Diffstat (limited to 'src/soc/amd/stoneyridge')
-rw-r--r-- | src/soc/amd/stoneyridge/BiosCallOuts.c | 69 | ||||
-rw-r--r-- | src/soc/amd/stoneyridge/Makefile.inc | 1 | ||||
-rw-r--r-- | src/soc/amd/stoneyridge/dimm_spd.c | 48 |
3 files changed, 51 insertions, 67 deletions
diff --git a/src/soc/amd/stoneyridge/BiosCallOuts.c b/src/soc/amd/stoneyridge/BiosCallOuts.c index 2c68f38d9e..87eccaa345 100644 --- a/src/soc/amd/stoneyridge/BiosCallOuts.c +++ b/src/soc/amd/stoneyridge/BiosCallOuts.c @@ -1,7 +1,7 @@ /* * This file is part of the coreboot project. * - * Copyright (C) 2011 Advanced Micro Devices, Inc. + * Copyright (C) 2011, 2017 Advanced Micro Devices, Inc. * Copyright (C) 2013 Sage Electronic Engineering, LLC * Copyright (C) 2017 Google Inc. * @@ -15,13 +15,17 @@ * GNU General Public License for more details. */ +#include <device/device.h> #include <device/pci_def.h> #include <BiosCallOuts.h> #include <soc/southbridge.h> +#include <soc/pci_devs.h> +#include <stdlib.h> #include <agesawrapper.h> #include <amdlib.h> #include <amdblocks/dimm_spd.h> +#include "chip.h" AGESA_STATUS agesa_fch_initreset(UINT32 Func, UINTN FchData, VOID *ConfigPtr) { @@ -91,24 +95,53 @@ AGESA_STATUS agesa_fch_initenv(UINT32 Func, UINTN FchData, VOID *ConfigPtr) AGESA_STATUS agesa_ReadSpd(UINT32 Func, UINTN Data, VOID *ConfigPtr) { - AGESA_STATUS Status = AGESA_UNSUPPORTED; + uint8_t spd_address; + int err; + DEVTREE_CONST struct device *dev; + DEVTREE_CONST struct soc_amd_stoneyridge_config *conf; + AGESA_READ_SPD_PARAMS *info = ConfigPtr; if (!ENV_ROMSTAGE) - return Status; - - if (IS_ENABLED(CONFIG_GENERIC_SPD_BIN)) { - AGESA_READ_SPD_PARAMS *info = ConfigPtr; - if (info->MemChannelId > 0) - return AGESA_UNSUPPORTED; - if (info->SocketId != 0) - return AGESA_UNSUPPORTED; - if (info->DimmId > 1) - return AGESA_UNSUPPORTED; - - die("SPD in cbfs not yet supported.\n"); - } else { - Status = AmdMemoryReadSPD(Func, Data, ConfigPtr); - } + return AGESA_UNSUPPORTED; + + dev = dev_find_slot(0, DCT_DEVFN); + if (dev == NULL) + return AGESA_ERROR; + + conf = dev->chip_info; + if (conf == NULL) + return AGESA_ERROR; + + if (info->SocketId >= ARRAY_SIZE(conf->spd_addr_lookup)) + return AGESA_ERROR; + if (info->MemChannelId >= ARRAY_SIZE(conf->spd_addr_lookup[0])) + return AGESA_ERROR; + if (info->DimmId >= ARRAY_SIZE(conf->spd_addr_lookup[0][0])) + return AGESA_ERROR; + + spd_address = conf->spd_addr_lookup + [info->SocketId][info->MemChannelId][info->DimmId]; + if (spd_address == 0) + return AGESA_ERROR; + + err = mainboard_read_spd(spd_address, (void *)info->Buffer, + CONFIG_DIMM_SPD_SIZE); - return Status; + /* Read the SPD if the mainboard didn't fill the buffer */ + if (err || (*info->Buffer == 0)) + err = sb_read_spd(spd_address, (void *)info->Buffer, + CONFIG_DIMM_SPD_SIZE); + + if (err) + return AGESA_ERROR; + + return AGESA_SUCCESS; +} + +/* Allow mainboards to fill the SPD buffer */ +__attribute__((weak)) int mainboard_read_spd(uint8_t spdAddress, char *buf, + size_t len) +{ + printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); + return -1; /* SPD not read */ } diff --git a/src/soc/amd/stoneyridge/Makefile.inc b/src/soc/amd/stoneyridge/Makefile.inc index a50511d36f..d2a0db48d9 100644 --- a/src/soc/amd/stoneyridge/Makefile.inc +++ b/src/soc/amd/stoneyridge/Makefile.inc @@ -47,7 +47,6 @@ bootblock-y += tsc_freq.c romstage-y += BiosCallOuts.c romstage-y += romstage.c romstage-y += early_setup.c -romstage-y += dimm_spd.c romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += enable_usbdebug.c romstage-y += gpio.c romstage-$(CONFIG_STONEYRIDGE_IMC_FWM) += imc.c diff --git a/src/soc/amd/stoneyridge/dimm_spd.c b/src/soc/amd/stoneyridge/dimm_spd.c deleted file mode 100644 index d9f6355da0..0000000000 --- a/src/soc/amd/stoneyridge/dimm_spd.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2015 - 2017 Advanced Micro Devices, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <agesawrapper.h> -#include <device/pci_def.h> -#include <device/device.h> -#include <soc/pci_devs.h> -#include <stdlib.h> -#include "chip.h" -#include <amdblocks/dimm_spd.h> - -AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, - AGESA_READ_SPD_PARAMS *info) -{ - uint8_t spd_address; - DEVTREE_CONST struct device *dev = dev_find_slot(0, DCT_DEVFN); - DEVTREE_CONST struct soc_amd_stoneyridge_config *conf = dev->chip_info; - - if ((dev == 0) || (conf == 0)) - return AGESA_ERROR; - if (info->SocketId >= ARRAY_SIZE(conf->spd_addr_lookup)) - return AGESA_ERROR; - if (info->MemChannelId >= ARRAY_SIZE(conf->spd_addr_lookup[0])) - return AGESA_ERROR; - if (info->DimmId >= ARRAY_SIZE(conf->spd_addr_lookup[0][0])) - return AGESA_ERROR; - spd_address = conf->spd_addr_lookup - [info->SocketId][info->MemChannelId][info->DimmId]; - if (spd_address == 0) - return AGESA_ERROR; - int err = sb_read_spd(spd_address, (void *)info->Buffer, - CONFIG_DIMM_SPD_SIZE); - if (err) - return AGESA_ERROR; - return AGESA_SUCCESS; -} |