command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / board / toradex / common / tdx-cfg-block.c
index 9c86230595b9131d8e50efa6c3c0cdc0bcdc8f1c..75216ecf6d3979acf14ad5e67e54e32872f77d92 100644 (file)
@@ -1,15 +1,20 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (c) 2016-2019 Toradex, Inc.
+ * Copyright (c) 2016-2020 Toradex
  */
 
 #include <common.h>
 #include "tdx-cfg-block.h"
+#include <command.h>
+#include <asm/cache.h>
 
 #if defined(CONFIG_TARGET_APALIS_IMX6) || \
        defined(CONFIG_TARGET_APALIS_IMX8) || \
+       defined(CONFIG_TARGET_APALIS_IMX8X) || \
        defined(CONFIG_TARGET_COLIBRI_IMX6) || \
-       defined(CONFIG_TARGET_COLIBRI_IMX8X)
+       defined(CONFIG_TARGET_COLIBRI_IMX8X) || \
+       defined(CONFIG_TARGET_VERDIN_IMX8MM) || \
+       defined(CONFIG_TARGET_VERDIN_IMX8MN)
 #include <asm/arch/sys_proto.h>
 #else
 #define is_cpu_type(cpu) (0)
@@ -112,6 +117,11 @@ const char * const toradex_modules[] = {
        [50] = "Colibri iMX8 QuadXPlus 2GB IT",
        [51] = "Colibri iMX8 DualX 1GB Wi-Fi / Bluetooth",
        [52] = "Colibri iMX8 DualX 1GB",
+       [53] = "Apalis iMX8 QuadXPlus 2GB ECC IT",
+       [54] = "Apalis iMX8 DualXPlus 1GB",
+       [55] = "Verdin iMX8M Mini Quad 2GB Wi-Fi / BT IT",
+       [56] = "Verdin iMX8M Nano SoloLite 1GB", /* not currently on sale */
+       [57] = "Verdin iMX8M Mini DualLite 1GB",
 };
 
 #ifdef CONFIG_TDX_CFG_BLOCK_IS_IN_MMC
@@ -294,19 +304,27 @@ static int get_cfgblock_interactive(void)
        char *soc;
        char it = 'n';
        char wb = 'n';
-       int len;
+       int len = 0;
 
        /* Unknown module by default */
        tdx_hw_tag.prodid = 0;
 
        if (cpu_is_pxa27x())
                sprintf(message, "Is the module the 312 MHz version? [y/N] ");
+#if !defined(CONFIG_TARGET_VERDIN_IMX8MM) || !defined(CONFIG_TARGET_VERDIN_IMX8MN)
        else
                sprintf(message, "Is the module an IT version? [y/N] ");
+
        len = cli_readline(message);
        it = console_buffer[0];
+#else
+       else
+               it = 'y';
+#endif
+
 
 #if defined(CONFIG_TARGET_APALIS_IMX8) || \
+               defined(CONFIG_TARGET_APALIS_IMX8X) || \
                defined(CONFIG_TARGET_COLIBRI_IMX6ULL) || \
                defined(CONFIG_TARGET_COLIBRI_IMX8X)
        sprintf(message, "Does the module have Wi-Fi / Bluetooth? [y/N] ");
@@ -357,6 +375,12 @@ static int get_cfgblock_interactive(void)
                tdx_hw_tag.prodid = COLIBRI_IMX7D;
        else if (!strcmp("imx7s", soc))
                tdx_hw_tag.prodid = COLIBRI_IMX7S;
+       else if (is_cpu_type(MXC_CPU_IMX8MM))
+               tdx_hw_tag.prodid = VERDIN_IMX8MMQ_WIFI_BT_IT;
+       else if (is_cpu_type(MXC_CPU_IMX8MMDL))
+               tdx_hw_tag.prodid = VERDIN_IMX8MMDL;
+       else if (is_cpu_type(MXC_CPU_IMX8MN))
+               tdx_hw_tag.prodid = VERDIN_IMX8MNSL;
        else if (is_cpu_type(MXC_CPU_IMX8QM)) {
                if (it == 'y' || it == 'Y') {
                        if (wb == 'y' || wb == 'Y')
@@ -370,6 +394,16 @@ static int get_cfgblock_interactive(void)
                                tdx_hw_tag.prodid = APALIS_IMX8QP;
                }
        } else if (is_cpu_type(MXC_CPU_IMX8QXP)) {
+#ifdef CONFIG_TARGET_APALIS_IMX8X
+               if (it == 'y' || it == 'Y' || wb == 'y' || wb == 'Y') {
+                               tdx_hw_tag.prodid = APALIS_IMX8QXP_WIFI_BT_IT;
+               } else {
+                       if (gd->ram_size == 0x40000000)
+                               tdx_hw_tag.prodid = APALIS_IMX8DXP;
+                       else
+                               tdx_hw_tag.prodid = APALIS_IMX8QXP;
+               }
+#elif CONFIG_TARGET_COLIBRI_IMX8X
                if (it == 'y' || it == 'Y') {
                        if (wb == 'y' || wb == 'Y')
                                tdx_hw_tag.prodid = COLIBRI_IMX8QXP_WIFI_BT_IT;
@@ -381,6 +415,7 @@ static int get_cfgblock_interactive(void)
                        else
                                tdx_hw_tag.prodid = COLIBRI_IMX8DX;
                }
+#endif
        } else if (!strcmp("tegra20", soc)) {
                if (it == 'y' || it == 'Y')
                        if (gd->ram_size == 0x10000000)
@@ -480,8 +515,8 @@ static int get_cfgblock_barcode(char *barcode)
        return 0;
 }
 
-static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
-                             char * const argv[])
+static int do_cfgblock_create(struct cmd_tbl *cmdtp, int flag, int argc,
+                             char *const argv[])
 {
        u8 *config_block;
        struct toradex_tag *tag;
@@ -609,8 +644,8 @@ out:
        return ret;
 }
 
-static int do_cfgblock(cmd_tbl_t *cmdtp, int flag, int argc,
-                      char * const argv[])
+static int do_cfgblock(struct cmd_tbl *cmdtp, int flag, int argc,
+                      char *const argv[])
 {
        int ret;