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 <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/27448
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
Patrick Rudolph 2018-07-12 11:47:37 +02:00 committed by Patrick Rudolph
parent 8247f3df67
commit de8e68917f
3 changed files with 26 additions and 18 deletions

View File

@ -11,6 +11,7 @@ config SOC_CAVIUM_CN81XX
select HAVE_MONOTONIC_TIMER select HAVE_MONOTONIC_TIMER
select UART_OVERRIDE_REFCLK select UART_OVERRIDE_REFCLK
select SOC_CAVIUM_COMMON select SOC_CAVIUM_COMMON
select CAVIUM_BDK_DDR_TUNE_HW_OFFSETS
if SOC_CAVIUM_CN81XX if SOC_CAVIUM_CN81XX

View File

@ -65,6 +65,27 @@ config CAVIUM_BDK_VERBOSE_PHY
depends on CAVIUM_BDK depends on CAVIUM_BDK
help help
Build Cavium's BDK with verbose PHY code. 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 endmenu
endif endif

View File

@ -149,23 +149,16 @@ static void bdk_dram_disable_ecc_reporting(bdk_node_t node)
static int bdk_libdram_tune_node(int node) static int bdk_libdram_tune_node(int node)
{ {
int errs, tot_errs; int errs, tot_errs;
int do_dllro_hw = 0; // default to NO int do_dllro_hw = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_HW_OFFSETS);
int do_dllwo = 0; // default to NO int do_dllwo = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_WRITE_OFFSETS);
int do_eccdll = 0; // default to NO int do_eccdll = IS_ENABLED(CONFIG_CAVIUM_BDK_DDR_TUNE_ECC_ENABLE);
const char *str;
BDK_CSR_INIT(lmc_config, node, BDK_LMCX_CONFIG(0)); // FIXME: probe LMC0 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 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 // Automatically tune the data byte DLL read offsets
// always done by default, but allow use of HW-assist // always done by default, but allow use of HW-assist
// NOTE: HW-assist will also tune the ECC byte // 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); BDK_TRACE(DRAM, "N%d: Starting DLL Read Offset Tuning for LMCs\n", node);
if (!do_dllro_hw || (lmc_config.s.mode32b != 0)) { if (!do_dllro_hw || (lmc_config.s.mode32b != 0)) {
errs = perform_dll_offset_tuning(node, 2, /* tune */1); 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? // disabled by default for now, does not seem to be needed?
// Automatically tune the data byte DLL write offsets // Automatically tune the data byte DLL write offsets
// allow override of default setting // allow override of default setting
str = getenv("ddr_tune_write_offsets");
str = NULL;
if (str)
do_dllwo = !!strtoul(str, NULL, 0);
if (do_dllwo) { if (do_dllwo) {
BDK_TRACE(DRAM, "N%d: Starting DLL Write Offset Tuning for LMCs\n", node); BDK_TRACE(DRAM, "N%d: Starting DLL Write Offset Tuning for LMCs\n", node);
errs = perform_dll_offset_tuning(node, /* write */1, /* tune */1); 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 // Automatically tune the ECC byte DLL read offsets
// FIXME? allow override of the filtering // FIXME? allow override of the filtering
// FIXME? allow programmatic override, not via envvar? // 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 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); 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 */); errs = perform_HW_dll_offset_tuning(node, 2, 8/* ECC bytelane */);