From a9f72776bd5af067abf8bfc4bcdd44ec805c9e76 Mon Sep 17 00:00:00 2001 From: Marc Jones Date: Thu, 16 Nov 2017 18:47:36 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/22485 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Marshall Dawson --- .../amd/common/block/include/amdblocks/dimm_spd.h | 10 ++-- src/soc/amd/stoneyridge/BiosCallOuts.c | 69 ++++++++++++++++------ src/soc/amd/stoneyridge/Makefile.inc | 1 - src/soc/amd/stoneyridge/dimm_spd.c | 48 --------------- 4 files changed, 57 insertions(+), 71 deletions(-) delete mode 100644 src/soc/amd/stoneyridge/dimm_spd.c diff --git a/src/soc/amd/common/block/include/amdblocks/dimm_spd.h b/src/soc/amd/common/block/include/amdblocks/dimm_spd.h index dce5494f40..e29edc59b7 100644 --- a/src/soc/amd/common/block/include/amdblocks/dimm_spd.h +++ b/src/soc/amd/common/block/include/amdblocks/dimm_spd.h @@ -20,10 +20,12 @@ #include #include -AGESA_STATUS -AmdMemoryReadSPD(IN UINT32 Func, IN UINTN Data, - IN OUT AGESA_READ_SPD_PARAMS *SpdData); - +/* + * Fill the buf and returns 0 on success. + * Return -1 on failure and the the caller tries sb_read_spd() + * to get the SPD from I2C. + */ +int mainboard_read_spd(uint8_t spdAddress, char *buf, size_t len); int sb_read_spd(uint8_t spdAddress, char *buf, size_t len); #endif 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 #include #include #include +#include +#include #include #include #include +#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 -#include -#include -#include -#include -#include "chip.h" -#include - -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; -} -- cgit v1.2.3