From de8e68917fac12e3448cc8f3bde08d444642ce8a Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 12 Jul 2018 11:47:37 +0200 Subject: bdk: Use Kconfig options instead of getenv() * Use Kconfig options instead of unusable getenv * Select CAVIUM_BDK_DDR_TUNE_HW_OFFSETS on CN81XX * Fix Coverity CID 1393976 (DEADCODE) Tested on Cavium's cn8100_sff_evb. Change-Id: Ia16c0161b0e9cf5d06418e46556c0fb45532a5b1 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/27448 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Philipp Deppenwiese --- src/vendorcode/cavium/Kconfig | 21 +++++++++++++++++++++ src/vendorcode/cavium/bdk/libdram/libdram.c | 22 ++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src/vendorcode/cavium') diff --git a/src/vendorcode/cavium/Kconfig b/src/vendorcode/cavium/Kconfig index 80377620ae..9538d1cab2 100644 --- a/src/vendorcode/cavium/Kconfig +++ b/src/vendorcode/cavium/Kconfig @@ -65,6 +65,27 @@ config CAVIUM_BDK_VERBOSE_PHY depends on CAVIUM_BDK help Build Cavium's BDK with verbose PHY code. + +config CAVIUM_BDK_DDR_TUNE_HW_OFFSETS + bool "Hardware assisted DLL read offset tuning" + default n + depends on CAVIUM_BDK + + help + Automatically tune the data byte DLL read offsets. + Always done by default, but allow use of HW-assist. + NOTE: HW-assist will also tune the ECC byte. + +config CAVIUM_BDK_DDR_TUNE_WRITE_OFFSETS + bool "Automatically tune the data byte DLL write offsets" + default n + depends on CAVIUM_BDK + +config CAVIUM_BDK_DDR_TUNE_ECC_ENABLE + bool "Automatically tune the ECC byte DLL read offsets" + default n + depends on CAVIUM_BDK + endmenu endif diff --git a/src/vendorcode/cavium/bdk/libdram/libdram.c b/src/vendorcode/cavium/bdk/libdram/libdram.c index 551ba24c42..bebd5200f9 100644 --- a/src/vendorcode/cavium/bdk/libdram/libdram.c +++ b/src/vendorcode/cavium/bdk/libdram/libdram.c @@ -149,23 +149,16 @@ static void bdk_dram_disable_ecc_reporting(bdk_node_t node) static int bdk_libdram_tune_node(int node) { int errs, tot_errs; - int do_dllro_hw = 0; // default to NO - int do_dllwo = 0; // default to NO - int do_eccdll = 0; // default to NO - const char *str; + int do_dllro_hw = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_HW_OFFSETS); + int do_dllwo = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_WRITE_OFFSETS); + int do_eccdll = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_ECC_ENABLE); BDK_CSR_INIT(lmc_config, node, BDK_LMCX_CONFIG(0)); // FIXME: probe LMC0 do_eccdll = (lmc_config.s.ecc_ena != 0); // change to ON if ECC enabled - // FIXME!!! make 81xx always use HW-assist tuning - if (CAVIUM_IS_MODEL(CAVIUM_CN81XX)) - do_dllro_hw = 1; - // Automatically tune the data byte DLL read offsets // always done by default, but allow use of HW-assist // NOTE: HW-assist will also tune the ECC byte - str = getenv("ddr_tune_hw_offsets"); - if (str) - do_dllro_hw = !!strtoul(str, NULL, 0); + BDK_TRACE(DRAM, "N%d: Starting DLL Read Offset Tuning for LMCs\n", node); if (!do_dllro_hw || (lmc_config.s.mode32b != 0)) { errs = perform_dll_offset_tuning(node, 2, /* tune */1); @@ -179,10 +172,6 @@ static int bdk_libdram_tune_node(int node) // disabled by default for now, does not seem to be needed? // Automatically tune the data byte DLL write offsets // allow override of default setting - str = getenv("ddr_tune_write_offsets"); - str = NULL; - if (str) - do_dllwo = !!strtoul(str, NULL, 0); if (do_dllwo) { BDK_TRACE(DRAM, "N%d: Starting DLL Write Offset Tuning for LMCs\n", node); errs = perform_dll_offset_tuning(node, /* write */1, /* tune */1); @@ -195,9 +184,6 @@ static int bdk_libdram_tune_node(int node) // Automatically tune the ECC byte DLL read offsets // FIXME? allow override of the filtering // FIXME? allow programmatic override, not via envvar? - str = getenv("ddr_tune_ecc_enable"); - if (str) - do_eccdll = !!strtoul(str, NULL, 10); if (do_eccdll && !do_dllro_hw && (lmc_config.s.mode32b == 0)) { // do not do HW-assist twice for ECC BDK_TRACE(DRAM, "N%d: Starting ECC DLL Read Offset Tuning for LMCs\n", node); errs = perform_HW_dll_offset_tuning(node, 2, 8/* ECC bytelane */); -- cgit v1.2.3