]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - board/sunxi/board.c
env: Rename common functions related to setenv()
[people/ms/u-boot.git] / board / sunxi / board.c
index 4404edb59e0e1423ad0947ce95cab9d3b7d47b16..92fa6c897493756854a3bb7e2d03ca00ff43b5dd 100644 (file)
@@ -33,6 +33,7 @@
 #include <nand.h>
 #include <net.h>
 #include <sy8106a.h>
+#include <asm/setup.h>
 
 #if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
 /* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */
@@ -512,7 +513,6 @@ int board_mmc_init(bd_t *bis)
 void sunxi_board_init(void)
 {
        int power_failed = 0;
-       unsigned long ramsize;
 
 #ifdef CONFIG_SY8106A_POWER
        power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT);
@@ -573,9 +573,9 @@ void sunxi_board_init(void)
 #endif
 #endif
        printf("DRAM:");
-       ramsize = sunxi_dram_init();
-       printf(" %d MiB\n", (int)(ramsize >> 20));
-       if (!ramsize)
+       gd->ram_size = sunxi_dram_init();
+       printf(" %d MiB\n", (int)(gd->ram_size >> 20));
+       if (!gd->ram_size)
                hang();
 
        /*
@@ -646,7 +646,7 @@ static void parse_spl_header(const uint32_t spl_addr)
                return;
        }
        /* otherwise assume .scr format (mkimage-type script) */
-       setenv_hex("fel_scriptaddr", spl->fel_script_address);
+       env_set_hex("fel_scriptaddr", spl->fel_script_address);
 }
 
 /*
@@ -712,7 +712,7 @@ static void setup_environment(const void *fdt)
                        snprintf(serial_string, sizeof(serial_string),
                                "%08x%08x", sid[0], sid[3]);
 
-                       setenv("serial#", serial_string);
+                       env_set("serial#", serial_string);
                }
        }
 }
@@ -721,11 +721,11 @@ int misc_init_r(void)
 {
        __maybe_unused int ret;
 
-       setenv("fel_booted", NULL);
-       setenv("fel_scriptaddr", NULL);
+       env_set("fel_booted", NULL);
+       env_set("fel_scriptaddr", NULL);
        /* determine if we are running in FEL mode */
        if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */
-               setenv("fel_booted", "1");
+               env_set("fel_booted", "1");
                parse_spl_header(SPL_ADDR);
        }
 
@@ -758,3 +758,32 @@ int ft_board_setup(void *blob, bd_t *bd)
 #endif
        return 0;
 }
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+       struct boot_file_head *spl = (void *)(ulong)SPL_ADDR;
+       const char *cmp_str = (void *)(ulong)SPL_ADDR;
+
+       /* Check if there is a DT name stored in the SPL header and use that. */
+       if (spl->dt_name_offset) {
+               cmp_str += spl->dt_name_offset;
+       } else {
+#ifdef CONFIG_DEFAULT_DEVICE_TREE
+               cmp_str = CONFIG_DEFAULT_DEVICE_TREE;
+#else
+               return 0;
+#endif
+       };
+
+/* Differentiate the two Pine64 board DTs by their DRAM size. */
+       if (strstr(name, "-pine64") && strstr(cmp_str, "-pine64")) {
+               if ((gd->ram_size > 512 * 1024 * 1024))
+                       return !strstr(name, "plus");
+               else
+                       return !!strstr(name, "plus");
+       } else {
+               return strcmp(name, cmp_str);
+       }
+}
+#endif