summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-07-09 11:05:52 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-07-09 11:05:52 +0200
commitf44593e64ae594523e2fdba735f0a8ce2bba1758 (patch)
treee7a29e4ee90c2f3735a97ecd58dabb0cfbd1b316
parent25ce31344f2ad69f6a8566c0ae9c51d1883c2c02 (diff)
toradex: configblock: re-sync with mainline
Re-sync with mainline which fixes missing Apalis iMX8 and Colibri iMX8X SKU and their interactive handling. Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--board/toradex/common/Kconfig2
-rw-r--r--board/toradex/common/Makefile2
-rw-r--r--board/toradex/common/tdx-cfg-block.c145
-rw-r--r--board/toradex/common/tdx-cfg-block.h31
-rw-r--r--board/toradex/common/tdx-common.c38
-rw-r--r--board/toradex/common/tdx-common.h3
6 files changed, 149 insertions, 72 deletions
diff --git a/board/toradex/common/Kconfig b/board/toradex/common/Kconfig
index b33baeff84..11f4aab359 100644
--- a/board/toradex/common/Kconfig
+++ b/board/toradex/common/Kconfig
@@ -1,5 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016 Toradex, Inc.
-# SPDX-License-Identifier: GPL-2.0+
menuconfig TDX_CFG_BLOCK
bool "Enable Toradex config block support"
diff --git a/board/toradex/common/Makefile b/board/toradex/common/Makefile
index d645f5a4ad..6b9fccb6b9 100644
--- a/board/toradex/common/Makefile
+++ b/board/toradex/common/Makefile
@@ -1,5 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016 Toradex, Inc.
-# SPDX-License-Identifier: GPL-2.0+
# Common for all Toradex modules
ifeq ($(CONFIG_SPL_BUILD),y)
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 9ab946970a..e454de9abe 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -1,14 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright (c) 2016 Toradex, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0+
+ * Copyright (c) 2016-2019 Toradex, Inc.
*/
#include <common.h>
#include "tdx-cfg-block.h"
-#if defined(CONFIG_TARGET_APALIS_IMX6) || defined(CONFIG_TARGET_COLIBRI_IMX6) \
- || defined(CONFIG_TARGET_APALIS_IMX8) || defined(CONFIG_TARGET_COLIBRI_IMX8QXP)
+#if defined(CONFIG_TARGET_APALIS_IMX6) || \
+ defined(CONFIG_TARGET_APALIS_IMX8) || \
+ defined(CONFIG_TARGET_COLIBRI_IMX6) || \
+ defined(CONFIG_TARGET_COLIBRI_IMX8QXP)
#include <asm/arch/sys_proto.h>
#else
#define is_cpu_type(cpu) (0)
@@ -94,12 +95,22 @@ const char * const toradex_modules[] = {
[34] = "Apalis TK1 2GB",
[35] = "Apalis iMX6 Dual 1GB IT",
[36] = "Colibri iMX6ULL 256MB",
- [37] = "Apalis iMX8 QuadMax 4GB Wi-Fi / Bluetooth",
- [38] = "Colibri iMX8QXP 2GB WB IT",
+ [37] = "Apalis iMX8 QuadMax 4GB Wi-Fi / BT IT",
+ [38] = "Colibri iMX8 QuadXPlus 2GB Wi-Fi / BT IT",
[39] = "Colibri iMX7 Dual 1GB (eMMC)",
- [40] = "Colibri iMX6ULL 512MB Wi-Fi / Bluetooth IT",
+ [40] = "Colibri iMX6ULL 512MB Wi-Fi / BT IT",
[41] = "Colibri iMX7 Dual 512MB EPDC",
[42] = "Apalis TK1 4GB",
+ [43] = "Colibri T20 512MB IT SETEK",
+ [44] = "Colibri iMX6ULL 512MB IT",
+ [45] = "Colibri iMX6ULL 512MB Wi-Fi / Bluetooth",
+ [46] = "Apalis iMX8 QuadXPlus 2GB Wi-Fi / BT IT",
+ [47] = "Apalis iMX8 QuadMax 4GB IT",
+ [48] = "Apalis iMX8 QuadPlus 2GB Wi-Fi / BT",
+ [49] = "Apalis iMX8 QuadPlus 2GB",
+ [50] = "Colibri iMX8 QuadXPlus 2GB IT",
+ [51] = "Colibri iMX8 DualX 1GB Wi-Fi / Bluetooth",
+ [52] = "Colibri iMX8 DualX 1GB",
};
#ifdef CONFIG_TDX_CFG_BLOCK_IS_IN_MMC
@@ -162,10 +173,13 @@ out:
static int read_tdx_cfg_block_from_nand(unsigned char *config_block)
{
size_t size = TDX_CFG_BLOCK_MAX_SIZE;
+ struct mtd_info *mtd = get_nand_dev_by_index(0);
+
+ if (!mtd)
+ return -ENODEV;
/* Read production parameter config block from NAND page */
- return nand_read_skip_bad(get_nand_dev_by_index(0),
- CONFIG_TDX_CFG_BLOCK_OFFSET,
+ return nand_read_skip_bad(mtd, CONFIG_TDX_CFG_BLOCK_OFFSET,
&size, NULL, TDX_CFG_BLOCK_MAX_SIZE,
config_block);
}
@@ -264,7 +278,7 @@ int read_tdx_cfg_block(void)
}
/* Cap product id to avoid issues with a yet unknown one */
- if (tdx_hw_tag.prodid > (sizeof(toradex_modules) /
+ if (tdx_hw_tag.prodid >= (sizeof(toradex_modules) /
sizeof(toradex_modules[0])))
tdx_hw_tag.prodid = 0;
@@ -278,49 +292,95 @@ static int get_cfgblock_interactive(void)
char message[CONFIG_SYS_CBSIZE];
char *soc;
char it = 'n';
+ char wb = 'n';
int len;
+ /* Unknown module by default */
+ tdx_hw_tag.prodid = 0;
+
if (cpu_is_pxa27x())
sprintf(message, "Is the module the 312 MHz version? [y/N] ");
else
sprintf(message, "Is the module an IT version? [y/N] ");
-
len = cli_readline(message);
it = console_buffer[0];
+#if defined(CONFIG_TARGET_APALIS_IMX8) || \
+ defined(CONFIG_TARGET_COLIBRI_IMX6ULL) || \
+ defined(CONFIG_TARGET_COLIBRI_IMX8X)
+ sprintf(message, "Does the module have Wi-Fi / Bluetooth? " \
+ "[y/N] ");
+ len = cli_readline(message);
+ wb = console_buffer[0];
+#endif
+
soc = env_get("soc");
if (!strcmp("mx6", soc)) {
-#ifdef CONFIG_MACH_TYPE
- if (it == 'y' || it == 'Y')
+#ifdef CONFIG_TARGET_APALIS_IMX6
+ if (it == 'y' || it == 'Y') {
if (is_cpu_type(MXC_CPU_MX6Q))
tdx_hw_tag.prodid = APALIS_IMX6Q_IT;
else
tdx_hw_tag.prodid = APALIS_IMX6D_IT;
- else
+ } else {
if (is_cpu_type(MXC_CPU_MX6Q))
tdx_hw_tag.prodid = APALIS_IMX6Q;
else
tdx_hw_tag.prodid = APALIS_IMX6D;
-#else
- if (it == 'y' || it == 'Y')
+ }
+#elif CONFIG_TARGET_COLIBRI_IMX6
+ if (it == 'y' || it == 'Y') {
if (is_cpu_type(MXC_CPU_MX6DL))
tdx_hw_tag.prodid = COLIBRI_IMX6DL_IT;
else if (is_cpu_type(MXC_CPU_MX6SOLO))
tdx_hw_tag.prodid = COLIBRI_IMX6S_IT;
- else
- tdx_hw_tag.prodid = COLIBRI_IMX6ULL_WIFI_BT_IT;
- else
+ } else {
if (is_cpu_type(MXC_CPU_MX6DL))
tdx_hw_tag.prodid = COLIBRI_IMX6DL;
else if (is_cpu_type(MXC_CPU_MX6SOLO))
tdx_hw_tag.prodid = COLIBRI_IMX6S;
+ }
+#elif CONFIG_TARGET_COLIBRI_IMX6ULL
+ if (it == 'y' || it == 'Y') {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = COLIBRI_IMX6ULL_WIFI_BT_IT;
+ else
+ tdx_hw_tag.prodid = COLIBRI_IMX6ULL_IT;
+ } else {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = COLIBRI_IMX6ULL_WIFI_BT;
else
tdx_hw_tag.prodid = COLIBRI_IMX6ULL;
-#endif /* CONFIG_MACH_TYPE */
- } else if (!strcmp("imx7d", soc)) {
+ }
+#endif
+ } else if (!strcmp("imx7d", soc))
tdx_hw_tag.prodid = COLIBRI_IMX7D;
- } else if (!strcmp("imx7s", soc)) {
+ else if (!strcmp("imx7s", soc))
tdx_hw_tag.prodid = COLIBRI_IMX7S;
+ else if (is_cpu_type(MXC_CPU_IMX8QM)) {
+ if (it == 'y' || it == 'Y') {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = APALIS_IMX8QM_WIFI_BT_IT;
+ else
+ tdx_hw_tag.prodid = APALIS_IMX8QM_IT;
+ } else {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = APALIS_IMX8QP_WIFI_BT;
+ else
+ tdx_hw_tag.prodid = APALIS_IMX8QP;
+ }
+ } else if (is_cpu_type(MXC_CPU_IMX8QXP)) {
+ if (it == 'y' || it == 'Y') {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = COLIBRI_IMX8QXP_WIFI_BT_IT;
+ else
+ tdx_hw_tag.prodid = COLIBRI_IMX8QXP_IT;
+ } else {
+ if (wb == 'y' || wb == 'Y')
+ tdx_hw_tag.prodid = COLIBRI_IMX8DX_WIFI_BT;
+ else
+ tdx_hw_tag.prodid = COLIBRI_IMX8DX;
+ }
} else if (!strcmp("tegra20", soc)) {
if (it == 'y' || it == 'Y')
if (gd->ram_size == 0x10000000)
@@ -337,8 +397,9 @@ static int get_cfgblock_interactive(void)
tdx_hw_tag.prodid = COLIBRI_PXA270_312MHZ;
else
tdx_hw_tag.prodid = COLIBRI_PXA270_520MHZ;
+ }
#ifdef CONFIG_MACH_TYPE
- } else if (!strcmp("tegra30", soc)) {
+ else if (!strcmp("tegra30", soc)) {
if (CONFIG_MACH_TYPE == MACH_TYPE_APALIS_T30) {
if (it == 'y' || it == 'Y')
tdx_hw_tag.prodid = APALIS_T30_IT;
@@ -353,8 +414,9 @@ static int get_cfgblock_interactive(void)
else
tdx_hw_tag.prodid = COLIBRI_T30;
}
+ }
#endif /* CONFIG_MACH_TYPE */
- } else if (!strcmp("tegra124", soc)) {
+ else if (!strcmp("tegra124", soc)) {
tdx_hw_tag.prodid = APALIS_TK1_2GB;
} else if (!strcmp("vf500", soc)) {
if (it == 'y' || it == 'Y')
@@ -366,11 +428,9 @@ static int get_cfgblock_interactive(void)
tdx_hw_tag.prodid = COLIBRI_VF61_IT;
else
tdx_hw_tag.prodid = COLIBRI_VF61;
- } else if (is_cpu_type(MXC_CPU_IMX8QM)) {
- tdx_hw_tag.prodid = APALIS_IMX8QM;
- } else if (is_cpu_type(MXC_CPU_IMX8QXP)) {
- tdx_hw_tag.prodid = COLIBRI_IMX8X;
- } else {
+ }
+
+ if (!tdx_hw_tag.prodid) {
printf("Module type not detectable due to unknown SoC\n");
return -1;
}
@@ -384,7 +444,7 @@ static int get_cfgblock_interactive(void)
tdx_hw_tag.ver_minor = console_buffer[2] - '0';
tdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
- if (cpu_is_pxa27x() && (tdx_hw_tag.ver_major == 1))
+ if (cpu_is_pxa27x() && tdx_hw_tag.ver_major == 1)
tdx_hw_tag.prodid -= (COLIBRI_PXA270_312MHZ -
COLIBRI_PXA270_V1_312MHZ);
@@ -443,7 +503,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
if (argc >= 3) {
if (argv[2][0] == '-' && argv[2][1] == 'y')
force_overwrite = 1;
- }
+ }
read_tdx_cfg_block();
if (valid_cfgblock) {
@@ -452,7 +512,8 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
* On NAND devices, recreation is only allowed if the page is
* empty (config block invalid...)
*/
- printf("NAND erase block %d need to be erased before creating a Toradex config block\n",
+ printf("NAND erase block %d need to be erased before creating" \
+ " a Toradex config block\n",
CONFIG_TDX_CFG_BLOCK_OFFSET /
get_nand_dev_by_index(0)->erasesize);
goto out;
@@ -461,28 +522,32 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
* On NOR devices, recreation is only allowed if the sector is
* empty and write protection is off (config block invalid...)
*/
- printf("NOR sector at offset 0x%02x need to be erased and unprotected before creating a Toradex config block\n",
+ printf("NOR sector at offset 0x%02x need to be erased and " \
+ "unprotected before creating a Toradex config block\n",
CONFIG_TDX_CFG_BLOCK_OFFSET);
goto out;
#else
- if (!force_overwrite) {
+ if (!force_overwrite) {
char message[CONFIG_SYS_CBSIZE];
+
sprintf(message,
- "A valid Toradex config block is present, still recreate? [y/N] ");
+ "A valid Toradex config block is present, " \
+ "still recreate? [y/N] ");
if (!cli_readline(message))
goto out;
- if (console_buffer[0] != 'y' && console_buffer[0] != 'Y')
+ if (console_buffer[0] != 'y' &&
+ console_buffer[0] != 'Y')
goto out;
- }
+ }
#endif
}
/* Parse new Toradex config block data... */
- if (argc < 3 || (force_overwrite && argc < 4))
+ if (argc < 3 || (force_overwrite && argc < 4)) {
err = get_cfgblock_interactive();
- else {
+ } else {
if (force_overwrite)
err = get_cfgblock_barcode(argv[3]);
else
diff --git a/board/toradex/common/tdx-cfg-block.h b/board/toradex/common/tdx-cfg-block.h
index a0ee717e61..bfdc8b7f70 100644
--- a/board/toradex/common/tdx-cfg-block.h
+++ b/board/toradex/common/tdx-cfg-block.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (c) 2016 Toradex, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _TDX_CFG_BLOCK_H
@@ -26,7 +25,7 @@ enum {
COLIBRI_PXA270_V1_520MHZ,
COLIBRI_PXA320,
COLIBRI_PXA300,
- COLIBRI_PXA310,
+ COLIBRI_PXA310, /* 5 */
COLIBRI_PXA320_IT,
COLIBRI_PXA300_XT,
COLIBRI_PXA270_312MHZ,
@@ -36,15 +35,17 @@ enum {
COLIBRI_VF61_IT,
COLIBRI_VF50_IT,
COLIBRI_IMX6S,
- COLIBRI_IMX6DL,
+ COLIBRI_IMX6DL, /* 15 */
COLIBRI_IMX6S_IT,
- COLIBRI_IMX6DL_IT, /* 17 */
+ COLIBRI_IMX6DL_IT,
+ /* 18 */
+ /* 19 */
COLIBRI_T20_256MB = 20,
COLIBRI_T20_512MB,
COLIBRI_T20_512MB_IT,
COLIBRI_T30,
COLIBRI_T20_256MB_IT,
- APALIS_T30_2GB,
+ APALIS_T30_2GB, /* 25 */
APALIS_T30_1GB,
APALIS_IMX6Q,
APALIS_IMX6Q_IT,
@@ -54,14 +55,24 @@ enum {
COLIBRI_IMX7S,
COLIBRI_IMX7D,
APALIS_TK1_2GB,
- APALIS_IMX6D_IT,
+ APALIS_IMX6D_IT, /* 35 */
COLIBRI_IMX6ULL,
- APALIS_IMX8QM, /* 37 */
- COLIBRI_IMX8X,
+ APALIS_IMX8QM_WIFI_BT_IT,
+ COLIBRI_IMX8QXP_WIFI_BT_IT,
COLIBRI_IMX7D_EMMC,
COLIBRI_IMX6ULL_WIFI_BT_IT, /* 40 */
COLIBRI_IMX7D_EPDC,
- APALIS_TK1_4GB,
+ APALIS_TK1_4GB, /* not currently on sale */
+ COLIBRI_T20_512MB_IT_SETEK,
+ COLIBRI_IMX6ULL_IT,
+ COLIBRI_IMX6ULL_WIFI_BT, /* 45 */
+ APALIS_IMX8QXP_WIFI_BT_IT,
+ APALIS_IMX8QM_IT,
+ APALIS_IMX8QP_WIFI_BT,
+ APALIS_IMX8QP,
+ COLIBRI_IMX8QXP_IT, /* 50 */
+ COLIBRI_IMX8DX_WIFI_BT,
+ COLIBRI_IMX8DX,
};
extern const char * const toradex_modules[];
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index 6e12d279e8..2d560cceaf 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -1,10 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2016 Toradex, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <environment.h>
#include <g_dnl.h>
#include <linux/libfdt.h>
@@ -12,6 +12,8 @@
#include <asm/setup.h>
#include "tdx-common.h"
+#define TORADEX_OUI 0x00142dUL
+
#ifdef CONFIG_TDX_CFG_BLOCK
static char tdx_serial_str[9];
static char tdx_board_rev_str[6];
@@ -68,20 +70,25 @@ int show_board_info(void)
unsigned char ethaddr[6];
if (read_tdx_cfg_block()) {
- printf("Missing Toradex config block\n");
+ printf("MISSING TORADEX CONFIG BLOCK\n");
+ tdx_eth_addr.oui = htonl(TORADEX_OUI << 8);
+ tdx_eth_addr.nic = htonl(tdx_serial << 8);
checkboard();
- return 0;
+ } else {
+ sprintf(tdx_serial_str, "%08u", tdx_serial);
+ sprintf(tdx_board_rev_str, "V%1d.%1d%c",
+ tdx_hw_tag.ver_major,
+ tdx_hw_tag.ver_minor,
+ (char)tdx_hw_tag.ver_assembly + 'A');
+
+ env_set("serial#", tdx_serial_str);
+
+ printf("Model: Toradex %s %s, Serial# %s\n",
+ toradex_modules[tdx_hw_tag.prodid],
+ tdx_board_rev_str,
+ tdx_serial_str);
}
- /* board serial-number */
- sprintf(tdx_serial_str, "%08u", tdx_serial);
- sprintf(tdx_board_rev_str, "V%1d.%1d%c",
- tdx_hw_tag.ver_major,
- tdx_hw_tag.ver_minor,
- (char)tdx_hw_tag.ver_assembly + 'A');
-
- env_set("serial#", tdx_serial_str);
-
/*
* Check if environment contains a valid MAC address,
* set the one from config block if not
@@ -101,11 +108,6 @@ int show_board_info(void)
}
#endif
- printf("Model: Toradex %s %s, Serial# %s\n",
- toradex_modules[tdx_hw_tag.prodid],
- tdx_board_rev_str,
- tdx_serial_str);
-
return 0;
}
diff --git a/board/toradex/common/tdx-common.h b/board/toradex/common/tdx-common.h
index f8d78f0ed5..c537dca71e 100644
--- a/board/toradex/common/tdx-common.h
+++ b/board/toradex/common/tdx-common.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (c) 2016 Toradex, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _TDX_COMMON_H