Merge tag 'ti-v2020.07-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-ti
[oweals/u-boot.git] / drivers / ddr / fsl / options.c
index 85ec48c28e38814bbaaf171088118996bc9e8051..c000a45f8ea83e18cd053cb116eed652a7157455 100644 (file)
@@ -1,13 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2008, 2010-2016 Freescale Semiconductor, Inc.
  * Copyright 2017-2018 NXP Semiconductor
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <env.h>
 #include <hwconfig.h>
 #include <fsl_ddr_sdram.h>
+#include <log.h>
 
 #include <fsl_ddr.h>
 #if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3) || \
  */
 
 /* Board-specific functions defined in each board's ddr.c */
-extern void fsl_ddr_board_options(memctl_options_t *popts,
-               dimm_params_t *pdimm,
-               unsigned int ctrl_num);
+void __weak fsl_ddr_board_options(memctl_options_t *popts,
+                                 dimm_params_t *pdimm,
+                                 unsigned int ctrl_num)
+{
+       return;
+}
 
 struct dynamic_odt {
        unsigned int odt_rd_cfg;
@@ -743,8 +747,7 @@ unsigned int populate_memctl_options(const common_timing_params_t *common_dimm,
                        unsigned int ctrl_num)
 {
        unsigned int i;
-       char buffer[HWCONFIG_BUFFER_SIZE];
-       char *buf = NULL;
+       char buf[HWCONFIG_BUFFER_SIZE];
 #if defined(CONFIG_SYS_FSL_DDR3) || \
        defined(CONFIG_SYS_FSL_DDR2) || \
        defined(CONFIG_SYS_FSL_DDR4)
@@ -758,8 +761,8 @@ unsigned int populate_memctl_options(const common_timing_params_t *common_dimm,
         * Extract hwconfig from environment since we have not properly setup
         * the environment but need it for ddr config params
         */
-       if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
-               buf = buffer;
+       if (env_get_f("hwconfig", buf, sizeof(buf)) < 0)
+               buf[0] = '\0';
 
 #if defined(CONFIG_SYS_FSL_DDR3) || \
        defined(CONFIG_SYS_FSL_DDR2) || \
@@ -1399,15 +1402,14 @@ int fsl_use_spd(void)
        int use_spd = 0;
 
 #ifdef CONFIG_DDR_SPD
-       char buffer[HWCONFIG_BUFFER_SIZE];
-       char *buf = NULL;
+       char buf[HWCONFIG_BUFFER_SIZE];
 
        /*
         * Extract hwconfig from environment since we have not properly setup
         * the environment but need it for ddr config params
         */
-       if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
-               buf = buffer;
+       if (env_get_f("hwconfig", buf, sizeof(buf)) < 0)
+               buf[0] = '\0';
 
        /* if hwconfig is not enabled, or "sdram" is not defined, use spd */
        if (hwconfig_sub_f("fsl_ddr", "sdram", buf)) {