]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx: ventana: convert U-Boot to OF_CONTROL using FIT image
authorTim Harvey <tharvey@gateworks.com>
Mon, 1 Mar 2021 22:33:32 +0000 (14:33 -0800)
committerStefano Babic <sbabic@denx.de>
Thu, 8 Apr 2021 18:29:53 +0000 (20:29 +0200)
In preparation for dm conversion convert to OF_CONTROL by adding FIT image
support and multi dtb.

Add a board_fit_config_name_match to match the dtb based off of EEPROM
model.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
board/gateworks/gw_ventana/gsc.c
board/gateworks/gw_ventana/gsc.h
board/gateworks/gw_ventana/gw_ventana.c
board/gateworks/gw_ventana/gw_ventana_spl.c
configs/gwventana_emmc_defconfig
configs/gwventana_gw5904_defconfig
configs/gwventana_nand_defconfig

index bcb6bca3462da47950476f8580a3a49c50b606bc..ffed6b5fc8b8f7670cb5ffb7786b6734b72ce612 100644 (file)
@@ -14,6 +14,8 @@
 #include <i2c.h>
 #include <linux/ctype.h>
 
+#include <asm/arch/sys_proto.h>
+
 #include "ventana_eeprom.h"
 #include "gsc.h"
 
@@ -179,6 +181,92 @@ int gsc_boot_wd_disable(void)
        return 1;
 }
 
+/* determine BOM revision from model */
+int get_bom_rev(const char *str)
+{
+       int  rev_bom = 0;
+       int i;
+
+       for (i = strlen(str) - 1; i > 0; i--) {
+               if (str[i] == '-')
+                       break;
+               if (str[i] >= '1' && str[i] <= '9') {
+                       rev_bom = str[i] - '0';
+                       break;
+               }
+       }
+       return rev_bom;
+}
+
+/* determine PCB revision from model */
+char get_pcb_rev(const char *str)
+{
+       char rev_pcb = 'A';
+       int i;
+
+       for (i = strlen(str) - 1; i > 0; i--) {
+               if (str[i] == '-')
+                       break;
+               if (str[i] >= 'A') {
+                       rev_pcb = str[i];
+                       break;
+               }
+       }
+       return rev_pcb;
+}
+
+/*
+ * get dt name based on model and detail level:
+ */
+const char *gsc_get_dtb_name(int level, char *buf, int sz)
+{
+       const char *model = (const char *)ventana_info.model;
+       const char *pre = is_mx6dq() ? "imx6q-" : "imx6dl-";
+       int modelno, rev_pcb, rev_bom;
+
+       /* a few board models are dt equivalents to other models */
+       if (strncasecmp(model, "gw5906", 6) == 0)
+               model = "gw552x-d";
+       else if (strncasecmp(model, "gw5908", 6) == 0)
+               model = "gw53xx-f";
+       else if (strncasecmp(model, "gw5905", 6) == 0)
+               model = "gw5904-a";
+
+       modelno = ((model[2] - '0') * 1000)
+                 + ((model[3] - '0') * 100)
+                 + ((model[4] - '0') * 10)
+                 + (model[5] - '0');
+       rev_pcb = tolower(get_pcb_rev(model));
+       rev_bom = get_bom_rev(model);
+
+       /* compare model/rev/bom in order of most specific to least */
+       snprintf(buf, sz, "%s%04d", pre, modelno);
+       switch (level) {
+       case 0: /* full model first (ie gw5400-a1) */
+               if (rev_bom) {
+                       snprintf(buf, sz, "%sgw%04d-%c%d", pre, modelno, rev_pcb, rev_bom);
+                       break;
+               }
+               fallthrough;
+       case 1: /* don't care about bom rev (ie gw5400-a) */
+               snprintf(buf, sz, "%sgw%04d-%c", pre, modelno, rev_pcb);
+               break;
+       case 2: /* don't care about the pcb rev (ie gw5400) */
+               snprintf(buf, sz, "%sgw%04d", pre, modelno);
+               break;
+       case 3: /* look for generic model (ie gw540x) */
+               snprintf(buf, sz, "%sgw%03dx", pre, modelno / 10);
+               break;
+       case 4: /* look for more generic model (ie gw54xx) */
+               snprintf(buf, sz, "%sgw%02dxx", pre, modelno / 100);
+               break;
+       default: /* give up */
+               return NULL;
+       }
+
+       return buf;
+}
+
 #if defined(CONFIG_CMD_GSC) && !defined(CONFIG_SPL_BUILD)
 static int do_gsc_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
                        char *const argv[])
index 6dcaafadf37630a93d02593161744b43e2174756..29d375b3a71b32d5a46bef988bd2173c0c89a78a 100644 (file)
@@ -67,5 +67,6 @@ int gsc_i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len);
 int gsc_i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len);
 int gsc_info(int verbose);
 int gsc_boot_wd_disable(void);
+const char *gsc_get_dtb_name(int level, char *buf, int sz);
 #endif
 
index 71de80c1b91c51d1326626693706f7aabf371a36..fb745ccceee65c79dcd3ebc2610d66f8b99b257b 100644 (file)
@@ -56,7 +56,6 @@ DECLARE_GLOBAL_DATA_PTR;
  * read it once.
  */
 struct ventana_board_info ventana_info;
-
 static int board_type;
 
 /* ENET */
@@ -677,6 +676,25 @@ int board_init(void)
        return 0;
 }
 
+int board_fit_config_name_match(const char *name)
+{
+       static char init;
+       const char *dtb;
+       char buf[32];
+       int i = 0;
+
+       do {
+               dtb = gsc_get_dtb_name(i++, buf, sizeof(buf));
+               if (dtb && !strcmp(dtb, name)) {
+                       if (!init++)
+                               printf("DTB:   %s\n", name);
+                       return 0;
+               }
+       } while (dtb);
+
+       return -1;
+}
+
 #if defined(CONFIG_DISPLAY_BOARDINFO_LATE)
 /*
  * called during late init (after relocation and after board_init())
index e0e4bac16126da49edc92bb21e0e30500584717e..a4f64395a17efadca25fb70789c7d295e62f3364 100644 (file)
@@ -731,8 +731,16 @@ void board_boot_order(u32 *spl_boot_list)
 /* its our chance to print info about boot device */
 void spl_board_init(void)
 {
+       u32 boot_device;
+       int board_type;
+
        /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 */
-       u32 boot_device = spl_boot_device();
+       boot_device = spl_boot_device();
+
+       /* read eeprom again now that we have gd */
+       board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
+       if (board_type == GW_UNKNOWN)
+               hang();
 
        switch (boot_device) {
        case BOOT_DEVICE_MMC1:
index 41e190bf1e803ee0513b0f957fe862892f26449c..453c80dd4c44dd6863617d3e0b28c7854e592fa8 100644 (file)
@@ -18,8 +18,12 @@ CONFIG_SPL_STACK_R_ADDR=0x18000000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0xD1400
 CONFIG_CMD_HDMIDETECT=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
+# CONFIG_LEGACY_IMAGE_FORMAT is not set
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
@@ -31,6 +35,7 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_DMA=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
@@ -62,6 +67,9 @@ CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=nand:16m(uboot),1m(env),-(rootfs)"
 CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIST="imx6q-gw51xx imx6dl-gw51xx imx6q-gw52xx imx6dl-gw52xx imx6q-gw53xx imx6dl-gw53xx imx6q-gw54xx imx6dl-gw54xx imx6q-gw551x imx6dl-gw551x imx6q-gw552x imx6dl-gw552x imx6q-gw553x imx6dl-gw553x imx6q-gw560x imx6dl-gw560x imx6q-gw5903 imx6dl-gw5903 imx6q-gw5904 imx6dl-gw5904 imx6q-gw5907 imx6dl-gw5907 imx6q-gw5910 imx6dl-gw5910 imx6q-gw5912 imx6dl-gw5912 imx6q-gw5913 imx6dl-gw5913"
+CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
@@ -79,6 +87,7 @@ CONFIG_PHYLIB=y
 CONFIG_E1000=y
 CONFIG_MII=y
 CONFIG_PCI=y
+CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
@@ -107,5 +116,4 @@ CONFIG_DM_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 # CONFIG_PANEL is not set
 CONFIG_VIDEO_IPUV3=y
-CONFIG_OF_LIBFDT=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
index 66b044197828ec435cbe971757758053e2802d2c..4dc636637f7d550e42b10f5a2eba3e8ad35114d1 100644 (file)
@@ -18,8 +18,12 @@ CONFIG_SPL_STACK_R_ADDR=0x18000000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0xD1400
 CONFIG_CMD_HDMIDETECT=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
+# CONFIG_LEGACY_IMAGE_FORMAT is not set
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
@@ -31,6 +35,7 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_DMA=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
@@ -62,6 +67,9 @@ CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=nand:16m(uboot),1m(env),-(rootfs)"
 CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIST="imx6q-gw51xx imx6dl-gw51xx imx6q-gw52xx imx6dl-gw52xx imx6q-gw53xx imx6dl-gw53xx imx6q-gw54xx imx6dl-gw54xx imx6q-gw551x imx6dl-gw551x imx6q-gw552x imx6dl-gw552x imx6q-gw553x imx6dl-gw553x imx6q-gw560x imx6dl-gw560x imx6q-gw5903 imx6dl-gw5903 imx6q-gw5904 imx6dl-gw5904 imx6q-gw5907 imx6dl-gw5907 imx6q-gw5910 imx6dl-gw5910 imx6q-gw5912 imx6dl-gw5912 imx6q-gw5913 imx6dl-gw5913"
+CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
@@ -83,6 +91,7 @@ CONFIG_MV88E61XX_FIXED_PORTS=0x0
 CONFIG_E1000=y
 CONFIG_MII=y
 CONFIG_PCI=y
+CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
@@ -111,5 +120,4 @@ CONFIG_DM_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 # CONFIG_PANEL is not set
 CONFIG_VIDEO_IPUV3=y
-CONFIG_OF_LIBFDT=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
index 9022f350d13f8f3807f7467e226b54d0a7ddb82e..bd8434030807ded30e307366e7ef808201176308 100644 (file)
@@ -18,8 +18,12 @@ CONFIG_SPL_STACK_R_ADDR=0x18000000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x1080000
 CONFIG_CMD_HDMIDETECT=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
+# CONFIG_LEGACY_IMAGE_FORMAT is not set
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
@@ -31,6 +35,7 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_DMA=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_NAND_SUPPORT=y
@@ -65,6 +70,9 @@ CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=nand:16m(uboot),1m(env),-(rootfs)"
 CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIST="imx6q-gw51xx imx6dl-gw51xx imx6q-gw52xx imx6dl-gw52xx imx6q-gw53xx imx6dl-gw53xx imx6q-gw54xx imx6dl-gw54xx imx6q-gw551x imx6dl-gw551x imx6q-gw552x imx6dl-gw552x imx6q-gw553x imx6dl-gw553x imx6q-gw560x imx6dl-gw560x imx6q-gw5903 imx6dl-gw5903 imx6q-gw5904 imx6dl-gw5904 imx6q-gw5907 imx6dl-gw5907 imx6q-gw5910 imx6dl-gw5910 imx6q-gw5912 imx6dl-gw5912 imx6q-gw5913 imx6dl-gw5913"
+CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
@@ -83,6 +91,7 @@ CONFIG_PHYLIB=y
 CONFIG_E1000=y
 CONFIG_MII=y
 CONFIG_PCI=y
+CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
@@ -111,5 +120,4 @@ CONFIG_DM_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 # CONFIG_PANEL is not set
 CONFIG_VIDEO_IPUV3=y
-CONFIG_OF_LIBFDT=y
 CONFIG_FDT_FIXUP_PARTITIONS=y