toradex: common: create a place for common functionality
authorStefan Agner <stefan.agner@toradex.com>
Fri, 1 May 2015 15:21:35 +0000 (17:21 +0200)
committerStefan Agner <stefan.agner@toradex.com>
Mon, 4 May 2015 15:52:56 +0000 (17:52 +0200)
Some functionality is repetitve accross the boards. This creates
a common place for U-Boot functions which need to be implemented
similarly for all Toradex modules.

15 files changed:
board/toradex/apalis_imx6/apalis_imx6.c
board/toradex/apalis_t30/apalis_t30.c
board/toradex/colibri_imx6/colibri_imx6.c
board/toradex/colibri_t20/colibri_t20.c
board/toradex/colibri_t30/colibri_t30.c
board/toradex/colibri_vf/colibri_vf.c
board/toradex/common/common.c [new file with mode: 0644]
board/toradex/common/common.h [new file with mode: 0644]
board/toradex/common/common.mk
board/toradex/common/configblock.c
board/toradex/common/configblock.h
include/configs/apalis_t30.h
include/configs/colibri_t20.h
include/configs/colibri_t30.h
include/configs/colibri_vf.h

index 52ab253bd0cb811555fb1666fee81be954518eb0..81ac092404bfc2f7628eebe7c803f904b901e670 100644 (file)
@@ -29,7 +29,6 @@
 #include <netdev.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/mxc_hdmi.h>
-#include <g_dnl.h>
 #include <i2c.h>
 
 #include "../common/configblock.h"
@@ -806,37 +805,11 @@ int board_late_init(void)
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
-       printf("Model: Toradex Apalis iMX6 %s\n", (gd->ram_size == 0x80000000)?"2GB":(gd->ram_size == 0x40000000)?"1GB":"512MB");
-       return 0;
-}
-
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short prodnr = 0;
-       unsigned short usb_pid;
-       /* assume a maximum 64bit serial */
-       char serialnr[21];
-
-       get_board_product_number(&prodnr);
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       usb_pid = prodnr + 0x100;
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       get_board_serial_char(serialnr);
-       g_dnl_set_serialnumber(serialnr);
-
+       printf("Model: Toradex Apalis iMX6 %s\n",
+               (gd->ram_size == 0x80000000) ? "2GB" :
+               (gd->ram_size == 0x40000000) ? "1GB" : "512MB");
        return 0;
 }
 
index a743f00febafe34089f9c452a441580b90556c24..9f9731af498a6643d17d6817dee40758a3f7e1d1 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <dm.h>
-#include <g_dnl.h>
 #include <i2c.h>
 #include <netdev.h>
 
@@ -54,43 +53,13 @@ int arch_misc_init(void)
        return 0;
 }
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
        printf("Model: Toradex Apalis T30 %dGB\n", (gd->ram_size == 0x40000000)?1:2);
 
        return 0;
 }
 
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short prodnr = 0;
-       unsigned short usb_pid;
-
-       get_board_product_number(&prodnr);
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       if (prodnr != 31)
-               if (gd->ram_size == 0x40000000)
-                       usb_pid = CONFIG_TRDX_PID_APALIS_T30_1G;
-               else
-                       usb_pid = CONFIG_TRDX_PID_APALIS_T30_2G;
-       else
-               usb_pid = CONFIG_TRDX_PID_APALIS_T30_1G_IT;
-
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       return 0;
-}
-
 /*
  * Routine: pinmux_init
  * Description: Do individual peripheral pinmux configs
index a0809eefa5f06329ff10dce8459f8bd0eb67614a..ea250267653ae986cf1e60434ae8323c8ba50b03 100644 (file)
@@ -552,37 +552,10 @@ int board_late_init(void)
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
-       printf("Model: Toradex Colibri iMX6 %sMB\n", (gd->ram_size == 0x20000000)?"512":"256");
-       return 0;
-}
-
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short prodnr = 0;
-       unsigned short usb_pid;
-       /* assume a maximum 64bit serial */
-       char serialnr[21];
-
-       get_board_product_number(&prodnr);
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       usb_pid = prodnr + 0x100;
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       get_board_serial_char(serialnr);
-       g_dnl_set_serialnumber(serialnr);
-
+       printf("Model: Toradex Colibri iMX6 %sMB\n",
+               (gd->ram_size == 0x20000000) ? "512" : "256");
        return 0;
 }
 
index e20004e4cf3aedee9a5d13c8e231a35fdd8b2b2d..00ed533cbccd4c67b08fb9bd377fd9ff190774e1 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/arch-tegra/board.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <g_dnl.h>
 #include <i2c.h>
 #include <nand.h>
 
@@ -119,16 +118,8 @@ int arch_misc_init(void)
        return 0;
 }
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
        printf("Model: Toradex Colibri T20 %dMB V%s\n",
               (gd->ram_size == 0x10000000)?256:512, (nand_info[0].erasesize >> 10
                == 512)?((gd->ram_size == 0x10000000)?"1.1B":"1.1C"):"1.2A");
@@ -136,31 +127,6 @@ int checkboard(void)
        return 0;
 }
 
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short prodnr = 0;
-       unsigned short usb_pid;
-
-       get_board_product_number(&prodnr);
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       if ((prodnr != 22) && (prodnr != 24))
-               if (gd->ram_size == 0x10000000)
-                       usb_pid = CONFIG_TRDX_PID_COLIBRI_T20_256;
-               else
-                       usb_pid = CONFIG_TRDX_PID_COLIBRI_T20_512;
-       else
-               if (gd->ram_size == 0x10000000)
-                       usb_pid = CONFIG_TRDX_PID_COLIBRI_T20_256_IT;
-               else
-                       usb_pid = CONFIG_TRDX_PID_COLIBRI_T20_512_IT;
-
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       return 0;
-}
-
 #ifdef CONFIG_TEGRA_MMC
 /*
  * Routine: pin_mux_mmc
index a7ce04b66f922aa71a184581ffa6b27beff16499..2a5ddd71ee73c3a4601795bc19f73f5b8724ef3b 100644 (file)
@@ -11,7 +11,6 @@
 #include <asm/arch-tegra/tegra.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <g_dnl.h>
 #include <i2c.h>
 
 #include "pinmux-config-colibri_t30.h"
@@ -28,40 +27,13 @@ int arch_misc_init(void)
        return 0;
 }
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
        printf("Model: Toradex Colibri T30 1GB\n");
 
        return 0;
 }
 
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short prodnr = 0;
-       unsigned short usb_pid;
-
-       get_board_product_number(&prodnr);
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       if (prodnr != 30)
-               usb_pid = CONFIG_TRDX_PID_COLIBRI_T30;
-       else
-               usb_pid = CONFIG_TRDX_PID_COLIBRI_T30_IT;
-
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       return 0;
-}
-
 /*
  * Routine: pinmux_init
  * Description: Do individual peripheral pinmux configs
index e973e8e32f8a308c2a859409bf6d7e21497952d9..696eb105bd121f18e8b1b774e1c53bf59ea84df0 100644 (file)
@@ -22,7 +22,6 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <i2c.h>
-#include <g_dnl.h>
 #include <asm/gpio.h>
 
 #include "../common/configblock.h"
@@ -464,16 +463,8 @@ int board_init(void)
        return 0;
 }
 
-int checkboard(void)
+int checkboard_fallback(void)
 {
-#ifdef CONFIG_TRDX_CFG_BLOCK
-       if (read_trdx_cfg_block())
-               printf("Missing Toradex config block\n");
-       else {
-               display_board_info();
-               return 0;
-       }
-#endif
        if (is_colibri_vf61())
                puts("Model: Toradex Colibri VF61 256MB\n");
        else
@@ -482,22 +473,6 @@ int checkboard(void)
        return 0;
 }
 
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-       unsigned short usb_pid;
-
-       put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
-
-       if (is_colibri_vf61())
-               usb_pid = CONFIG_TRDX_PID_COLIBRI_VF61IT;
-       else
-               usb_pid = CONFIG_TRDX_PID_COLIBRI_VF50IT;
-
-       put_unaligned(usb_pid, &dev->idProduct);
-
-       return 0;
-}
-
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
diff --git a/board/toradex/common/common.c b/board/toradex/common/common.c
new file mode 100644 (file)
index 0000000..30c8ebf
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2015 Toradex, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "configblock.h"
+#include <common.h>
+#include <g_dnl.h>
+
+__weak int checkboard_fallback(void)
+{
+       return 0;
+}
+
+#ifdef CONFIG_REVISION_TAG
+#ifdef CONFIG_TRDX_CFG_BLOCK
+u32 get_board_rev(void)
+{
+       /* Check validity */
+       if (!trdx_hw_tag.ver_major)
+               return 0;
+
+       return ((trdx_hw_tag.ver_major & 0xff) << 8) |
+               ((trdx_hw_tag.ver_minor & 0xf) << 4) |
+               ((trdx_hw_tag.ver_assembly & 0xf) + 0xa);
+}
+#else
+u32 get_board_rev(void)
+{
+       return 0;
+}
+#endif /* CONFIG_TRDX_CFG_BLOCK */
+#endif /* CONFIG_REVISION_TAG */
+
+#ifdef CONFIG_SERIAL_TAG
+#ifdef CONFIG_TRDX_CFG_BLOCK
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+       int array[8];
+       unsigned int serial = trdx_serial;
+       int i;
+
+       serialnr->low = 0;
+       serialnr->high = 0;
+
+       /* Check validity */
+       if (serial) {
+               /*
+                * Convert to Linux serial number format (hexadecimal coded
+                * decimal)
+                */
+               i = 7;
+               while (serial) {
+                       array[i--] = serial % 10;
+                       serial /= 10;
+               }
+               while (i >= 0)
+                       array[i--] = 0;
+               serial = array[0];
+               for (i = 1; i < 8; i++) {
+                       serial *= 16;
+                       serial += array[i];
+               }
+
+               serialnr->low = serial;
+       }
+}
+#else
+u32 get_board_rev(void)
+{
+       return 0;
+}
+#endif /* CONFIG_TRDX_CFG_BLOCK */
+#endif /* CONFIG_SERIAL_TAG */
+
+int checkboard(void)
+{
+#ifdef CONFIG_TRDX_CFG_BLOCK
+       if (read_trdx_cfg_block()) {
+               printf("Missing Toradex config block\n");
+               checkboard_fallback();
+               return 0;
+       }
+
+       printf("Model: Toradex %s V%d.%d%c\n",
+               toradex_modules[trdx_hw_tag.prodid],
+               trdx_hw_tag.ver_major,
+               trdx_hw_tag.ver_minor,
+               (char)trdx_hw_tag.ver_assembly + 'A');
+#else
+       checkboard_fallback();
+#endif
+       return 0;
+}
+
+#ifdef CONFIG_USBDOWNLOAD_GADGET
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+       unsigned short usb_pid = 0xffff;
+
+#ifdef CONFIG_TRDX_CONFIGBLOCK
+       usb_pid = 0x4000 + trdx_hw_tag.prodid;
+#endif
+       put_unaligned(usb_pid, &dev->idProduct);
+
+       return 0;
+}
+#endif /* CONFIG_USBDOWNLOAD_GADGET */
diff --git a/board/toradex/common/common.h b/board/toradex/common/common.h
new file mode 100644 (file)
index 0000000..998c479
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2015 Toradex, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _TRDX_COMMON_H
+#define _TRDX_COMMON_H
+
+#define TRDX_USB_VID                   0x1B67
+
+
+#endif /* _TRDX_COMMON_H */
index e94ebbce4f755568f50b24bb46c809498827d83c..469189a315f845ad10230723dba8f74eed05c66d 100644 (file)
@@ -4,4 +4,5 @@ ifeq ($(CONFIG_SPL_BUILD),y)
 obj- := __dummy__.o
 else
 obj-$(CONFIG_TRDX_CFG_BLOCK) += ../common/configblock.o
+obj-y += ../common/common.o
 endif
index 3575295dca3e317261c55226c952279b5a4eb7a7..f7bfee62bd560eb00ccd26896935a0085487d5c8 100644 (file)
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#include "configblock.h"
 #include <common.h>
 
 #include <cli.h>
@@ -33,54 +34,12 @@ struct toradex_tag {
        u32 id : 16;
 };
 
-struct toradex_hw {
-       u16 ver_major;
-       u16 ver_minor;
-       u16 ver_assembly;
-       u16 prodid;
-};
-
-struct toradex_eth_addr {
-       u32 oui : 24;
-       u32 nic : 24;
-} __attribute__((__packed__));
-
 bool valid_cfgblock;
-struct toradex_hw toradex_hw_tag;
-struct toradex_eth_addr eth_addr;
-u32 toradex_serial;
-
-enum {
-       COLIBRI_PXA320 = 3,
-       COLIBRI_PXA300,
-       COLIBRI_PXA310,
-       COLIBRI_PXA320_IT,
-       COLIBRI_PXA300_XT,
-       COLIBRI_PXA270_312MHZ,
-       COLIBRI_PXA270_520MHZ,
-       COLIBRI_VF50, /* not currently on sale */
-       COLIBRI_VF61,
-       COLIBRI_VF61_IT,
-       COLIBRI_VF50_IT,
-       COLIBRI_IMX6S,
-       COLIBRI_IMX6DL,
-       COLIBRI_IMX6S_IT,
-       COLIBRI_IMX6DL_IT,
-       COLIBRI_T20_256MB = 20,
-       COLIBRI_T20_512MB,
-       COLIBRI_T20_512MB_IT,
-       COLIBRI_T30,
-       COLIBRI_T20_256MB_IT,
-       APALIS_T30_2GB,
-       APALIS_T30_1GB,
-       APALIS_IMX6Q,
-       APALIS_IMX6Q_IT,
-       APALIS_IMX6D,
-       COLIBRI_T30_IT,
-       APALIS_T30_IT,
-};
+struct toradex_hw trdx_hw_tag;
+struct toradex_eth_addr trdx_eth_addr;
+u32 trdx_serial;
 
-static const char* const toradex_modules[] = {
+const char* const toradex_modules[] = {
         [1] = "Colibri PXA270 312MHz",
         [2] = "Colibri PXA270 520MHz",
         [3] = "Colibri PXA320 806MHz",
@@ -112,53 +71,6 @@ static const char* const toradex_modules[] = {
        [31] = "Apalis T30 1GB IT",
 };
 
-#ifdef CONFIG_REVISION_TAG
-u32 get_board_rev(void)
-{
-       /* Check validity */
-       if (!toradex_hw_tag.ver_major)
-               return 0;
-
-       return ((toradex_hw_tag.ver_major & 0xff) << 8) |
-               ((toradex_hw_tag.ver_minor & 0xf) << 4) |
-               ((toradex_hw_tag.ver_assembly & 0xf) + 0xa);
-}
-#endif /* CONFIG_REVISION_TAG */
-
-#ifdef CONFIG_SERIAL_TAG
-void get_board_serial(struct tag_serialnr *serialnr)
-{
-       int array[8];
-       unsigned int serial = toradex_serial;
-       int i;
-
-       serialnr->low = 0;
-       serialnr->high = 0;
-
-       /* Check validity */
-       if (serial) {
-               /*
-                * Convert to Linux serial number format (hexadecimal coded
-                * decimal)
-                */
-               i = 7;
-               while (serial) {
-                       array[i--] = serial % 10;
-                       serial /= 10;
-               }
-               while (i >= 0)
-                       array[i--] = 0;
-               serial = array[0];
-               for (i = 1; i < 8; i++) {
-                       serial *= 16;
-                       serial += array[i];
-               }
-
-               serialnr->low = serial;
-       }
-}
-#endif /* CONFIG_SERIAL_TAG */
-
 #ifdef CONFIG_TRDX_CFG_BLOCK_IS_IN_MMC
 static int trdx_cfg_block_mmc_storage(u8 *config_block, int write)
 {
@@ -281,13 +193,13 @@ int read_trdx_cfg_block(void)
                switch (tag->id)
                {
                case TAG_MAC:
-                       memcpy(&eth_addr, config_block + offset, 6);
+                       memcpy(&trdx_eth_addr, config_block + offset, 6);
 
                        /* NIC part of MAC address is serial number */
-                       toradex_serial = ntohl(eth_addr.nic) >> 8;
+                       trdx_serial = ntohl(trdx_eth_addr.nic) >> 8;
 
                        /* board serial-number */
-                       sprintf(serial, "%08u", toradex_serial);
+                       sprintf(serial, "%08u", trdx_serial);
                        setenv("serial#", serial);
 
                        /*
@@ -295,7 +207,7 @@ int read_trdx_cfg_block(void)
                         * set the one from config block if not
                         */
                        if (!eth_getenv_enetaddr("ethaddr", ethaddr))
-                               eth_setenv_enetaddr("ethaddr", (u8 *)&eth_addr);
+                               eth_setenv_enetaddr("ethaddr", (u8 *)&trdx_eth_addr);
 
 #ifdef CONFIG_TRDX_CFG_BLOCK_2ND_ETHADDR
                        if (!eth_getenv_enetaddr("eth1addr", ethaddr)) {
@@ -303,14 +215,14 @@ int read_trdx_cfg_block(void)
                                 * Secondary MAC address is allocated from block
                                 * 0x100000 higher then the first MAC address
                                 */
-                               memcpy(ethaddr, &eth_addr, 6);
+                               memcpy(ethaddr, &trdx_eth_addr, 6);
                                ethaddr[3] += 0x10;
                                eth_setenv_enetaddr("eth1addr", ethaddr);
                        }
 #endif
                        break;
                case TAG_HW:
-                       memcpy(&toradex_hw_tag, config_block + offset, 8);
+                       memcpy(&trdx_hw_tag, config_block + offset, 8);
                        break;
                }
 
@@ -323,30 +235,6 @@ out:
        return ret;
 }
 
-void display_board_info(void)
-{
-       printf("Model: Toradex %s V%d.%d%c\n",
-               toradex_modules[toradex_hw_tag.prodid],
-               toradex_hw_tag.ver_major,
-               toradex_hw_tag.ver_minor,
-               (char)toradex_hw_tag.ver_assembly + 'A');
-}
-
-void get_board_serial_char(char *serialnr)
-{
-       if (!toradex_serial) {
-               strcpy(serialnr, "UNKNOWN");
-               return;
-       }
-
-       sprintf(serialnr, "%u", toradex_serial);
-}
-
-void get_board_product_number(unsigned short *prodnr)
-{
-       *prodnr = toradex_hw_tag.prodid;
-}
-
 static int get_cfgblock_interactive(void)
 {
        char message[CONFIG_SYS_CBSIZE];
@@ -365,41 +253,41 @@ static int get_cfgblock_interactive(void)
        } else if (!strcmp("tegra20", soc)) {
                if (it == 'y' || it == 'Y')
                        if (gd->ram_size == 0x10000000)
-                               toradex_hw_tag.prodid = COLIBRI_T20_256MB_IT;
+                               trdx_hw_tag.prodid = COLIBRI_T20_256MB_IT;
                        else
-                               toradex_hw_tag.prodid = COLIBRI_T20_512MB_IT;
+                               trdx_hw_tag.prodid = COLIBRI_T20_512MB_IT;
                else
                        if (gd->ram_size == 0x10000000)
-                               toradex_hw_tag.prodid = COLIBRI_T20_256MB;
+                               trdx_hw_tag.prodid = COLIBRI_T20_256MB;
                        else
-                               toradex_hw_tag.prodid = COLIBRI_T20_512MB;
+                               trdx_hw_tag.prodid = COLIBRI_T20_512MB;
 #ifdef CONFIG_MACH_TYPE
        } else if (!strcmp("tegra30", soc)) {
                if (CONFIG_MACH_TYPE == MACH_TYPE_APALIS_T30) {
                        if (it == 'y' || it == 'Y')
-                               toradex_hw_tag.prodid = APALIS_T30_IT;
+                               trdx_hw_tag.prodid = APALIS_T30_IT;
                        else
                                if (gd->ram_size == 0x40000000)
-                                       toradex_hw_tag.prodid = APALIS_T30_1GB;
+                                       trdx_hw_tag.prodid = APALIS_T30_1GB;
                                else
-                                       toradex_hw_tag.prodid = APALIS_T30_2GB;
+                                       trdx_hw_tag.prodid = APALIS_T30_2GB;
                } else {
                        if (it == 'y' || it == 'Y')
-                               toradex_hw_tag.prodid = COLIBRI_T30_IT;
+                               trdx_hw_tag.prodid = COLIBRI_T30_IT;
                        else
-                               toradex_hw_tag.prodid = COLIBRI_T30;
+                               trdx_hw_tag.prodid = COLIBRI_T30;
                }
 #endif /* CONFIG_MACH_TYPE */
        } else if (!strcmp("vf500", soc)) {
                if (it == 'y' || it == 'Y')
-                       toradex_hw_tag.prodid = COLIBRI_VF50_IT;
+                       trdx_hw_tag.prodid = COLIBRI_VF50_IT;
                else
-                       toradex_hw_tag.prodid = COLIBRI_VF50;
+                       trdx_hw_tag.prodid = COLIBRI_VF50;
        } else if (!strcmp("vf610", soc)) {
                if (it == 'y' || it == 'Y')
-                       toradex_hw_tag.prodid = COLIBRI_VF61_IT;
+                       trdx_hw_tag.prodid = COLIBRI_VF61_IT;
                else
-                       toradex_hw_tag.prodid = COLIBRI_VF61;
+                       trdx_hw_tag.prodid = COLIBRI_VF61;
        } else {
                printf("Module type not detectable due to unknown SoC\n");
                return -1;
@@ -410,16 +298,16 @@ static int get_cfgblock_interactive(void)
                len = cli_readline(message);
        }
 
-       toradex_hw_tag.ver_major = console_buffer[0] - '0';
-       toradex_hw_tag.ver_minor = console_buffer[2] - '0';
-       toradex_hw_tag.ver_assembly = console_buffer[3] - 'A';
+       trdx_hw_tag.ver_major = console_buffer[0] - '0';
+       trdx_hw_tag.ver_minor = console_buffer[2] - '0';
+       trdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
 
        while (len < 8) {
                sprintf(message, "Enter module serial number: ");
                len = cli_readline(message);
        }
 
-       toradex_serial = simple_strtoul(console_buffer, NULL, 10);
+       trdx_serial = simple_strtoul(console_buffer, NULL, 10);
 
        return 0;
 }
@@ -432,16 +320,16 @@ static int get_cfgblock_barcode(char *barcode)
        }
 
        /* Get hardware information from the first 8 digits */
-       toradex_hw_tag.ver_major = barcode[4] - '0';
-       toradex_hw_tag.ver_minor = barcode[5] - '0';
-       toradex_hw_tag.ver_assembly = barcode[7] - '0';
+       trdx_hw_tag.ver_major = barcode[4] - '0';
+       trdx_hw_tag.ver_minor = barcode[5] - '0';
+       trdx_hw_tag.ver_assembly = barcode[7] - '0';
 
        barcode[4] = '\0';
-       toradex_hw_tag.prodid = simple_strtoul(barcode, NULL, 10);
+       trdx_hw_tag.prodid = simple_strtoul(barcode, NULL, 10);
 
        /* Parse second part of the barcode (serial number */
        barcode += 8;
-       toradex_serial = simple_strtoul(barcode, NULL, 10);
+       trdx_serial = simple_strtoul(barcode, NULL, 10);
 
        return 0;
 }
@@ -503,8 +391,8 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
                goto out;
 
        /* Convert serial number to MAC address (the storage format) */
-       eth_addr.oui = htonl(0x00142dUL << 8);
-       eth_addr.nic = htonl(toradex_serial << 8);
+       trdx_eth_addr.oui = htonl(0x00142dUL << 8);
+       trdx_eth_addr.nic = htonl(trdx_serial << 8);
 
        /* Valid Tag */
        tag = (struct toradex_tag *)config_block;
@@ -520,7 +408,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
        tag->len = 2;
        offset += 4;
 
-       memcpy(config_block + offset, &toradex_hw_tag, 8);
+       memcpy(config_block + offset, &trdx_hw_tag, 8);
        offset += 8;
 
        /* MAC Tag */
@@ -530,7 +418,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
        tag->len = 2;
        offset += 4;
 
-       memcpy(config_block + offset, &eth_addr, 6);
+       memcpy(config_block + offset, &trdx_eth_addr, 6);
        offset +=6;
        memset(config_block + offset, 0, 32 - offset);
 
index bd6c28648a9ba919897cbc8e162a8ff01cb92dc7..cce61ac89e10f5b6f143446d4819358ea7bbbe62 100644 (file)
@@ -7,9 +7,56 @@
 #ifndef _TRDX_CONFIGBLOCK_H
 #define _TRDX_CONFIGBLOCK_H
 
+#include <common.h>
+
+struct toradex_hw {
+       u16 ver_major;
+       u16 ver_minor;
+       u16 ver_assembly;
+       u16 prodid;
+};
+
+struct toradex_eth_addr {
+       u32 oui : 24;
+       u32 nic : 24;
+} __attribute__((__packed__));
+
+enum {
+       COLIBRI_PXA320 = 3,
+       COLIBRI_PXA300,
+       COLIBRI_PXA310,
+       COLIBRI_PXA320_IT,
+       COLIBRI_PXA300_XT,
+       COLIBRI_PXA270_312MHZ,
+       COLIBRI_PXA270_520MHZ,
+       COLIBRI_VF50, /* not currently on sale */
+       COLIBRI_VF61,
+       COLIBRI_VF61_IT,
+       COLIBRI_VF50_IT,
+       COLIBRI_IMX6S,
+       COLIBRI_IMX6DL,
+       COLIBRI_IMX6S_IT,
+       COLIBRI_IMX6DL_IT,
+       COLIBRI_T20_256MB = 20,
+       COLIBRI_T20_512MB,
+       COLIBRI_T20_512MB_IT,
+       COLIBRI_T30,
+       COLIBRI_T20_256MB_IT,
+       APALIS_T30_2GB,
+       APALIS_T30_1GB,
+       APALIS_IMX6Q,
+       APALIS_IMX6Q_IT,
+       APALIS_IMX6D,
+       COLIBRI_T30_IT,
+       APALIS_T30_IT,
+};
+
+extern const char* const toradex_modules[];
+extern bool valid_cfgblock;
+extern struct toradex_hw trdx_hw_tag;
+extern struct toradex_eth_addr trdx_eth_addr;
+extern u32 trdx_serial;
+
 int read_trdx_cfg_block(void);
-void display_board_info(void);
-void get_board_serial_char(char *serialnr);
-void get_board_product_number(unsigned short *prodnr);
 
 #endif /* _TRDX_CONFIGBLOCK_H */
index 0adf8c856a1cf1327ce967e81df12d81cc818bd0..a64e9fb99f6aceb6dbf89f2e7bdffc3ff1a39f07 100644 (file)
 #define CONFIG_SYS_MMC_ENV_PART                2
 
 /* USB client support */
-#define CONFIG_TRDX_VID                                0x1B67
-/* TBD */
-#define CONFIG_TRDX_PID_APALIS_T30_1G          0x001A
-#define CONFIG_TRDX_PID_APALIS_T30_2G          0x001B
-#define CONFIG_TRDX_PID_APALIS_T30_1G_IT       0x001C
-#define CONFIG_TRDX_PID_APALIS_T30_2G_IT       0x001D
-#define CONFIG_G_DNL_MANUFACTURER              "Toradex"
-#define CONFIG_G_DNL_VENDOR_NUM                        CONFIG_TRDX_VID
-#define CONFIG_G_DNL_PRODUCT_NUM               CONFIG_TRDX_PID_APALIS_T30_1G
+#define CONFIG_G_DNL_MANUFACTURER      "Toradex"
+#define CONFIG_G_DNL_VENDOR_NUM                0x1b67
+#define CONFIG_G_DNL_PRODUCT_NUM       0xffff /* Fallback, set using fixup */
 
 /* USB host support */
 #define CONFIG_USB_EHCI
index 279342f0e8f5fdd0a919501ed537a6400e2bcb0b..c566c751788f122d840f5afc507521a647f2d2f5 100644 (file)
 #define CONFIG_CMD_MMC
 
 /* USB client support */
-#define CONFIG_TRDX_VID                                0x1B67
-/* TBD */
-#define CONFIG_TRDX_PID_COLIBRI_T20_256                0x0020
-#define CONFIG_TRDX_PID_COLIBRI_T20_512                0x0021
-#define CONFIG_TRDX_PID_COLIBRI_T20_256_IT     0x0022
-#define CONFIG_TRDX_PID_COLIBRI_T20_512_IT     0x0023
-#define CONFIG_G_DNL_MANUFACTURER              "Toradex"
-#define CONFIG_G_DNL_VENDOR_NUM                        CONFIG_TRDX_VID
-#define CONFIG_G_DNL_PRODUCT_NUM               CONFIG_TRDX_PID_COLIBRI_T20_256
+#define CONFIG_G_DNL_MANUFACTURER      "Toradex"
+#define CONFIG_G_DNL_VENDOR_NUM                0x1b67
+#define CONFIG_G_DNL_PRODUCT_NUM       0xffff /* Fallback, set using fixup */
 
 /* USB DFU */
 #define CONFIG_DFU_NAND
index 5c3c09bba75b3f44c4337c0566228db2d4281429..a5997f3f076bf88a168946992702585d28aaaf2e 100644 (file)
 #define CONFIG_SYS_MMC_ENV_PART                2
 
 /* USB client support */
-#define CONFIG_TRDX_VID                                0x1B67
-/* TBD */
-#define CONFIG_TRDX_PID_COLIBRI_T30            0x001E
-#define CONFIG_TRDX_PID_COLIBRI_T30_IT         0x001F
-#define CONFIG_G_DNL_MANUFACTURER              "Toradex"
-#define CONFIG_G_DNL_VENDOR_NUM                        CONFIG_TRDX_VID
-#define CONFIG_G_DNL_PRODUCT_NUM               CONFIG_TRDX_PID_COLIBRI_T30
+#define CONFIG_G_DNL_MANUFACTURER      "Toradex"
+#define CONFIG_G_DNL_VENDOR_NUM                0x1b67
+#define CONFIG_G_DNL_PRODUCT_NUM       0xffff /* Fallback, set using fixup */
 
 /* USB host support */
 #define CONFIG_USB_EHCI
index 60f0103cb1dc835683881845a83b089e8b027d3f..3fcf2f8ece6017763203ac69adf9bf75edd239b0 100644 (file)
 #define CONFIG_CI_UDC
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW    2
-#define CONFIG_TRDX_VID                        0x1B67
-#define CONFIG_TRDX_PID_COLIBRI_VF50   0x0016
-#define CONFIG_TRDX_PID_COLIBRI_VF61   0x0017
-#define CONFIG_TRDX_PID_COLIBRI_VF61IT 0x0018
-#define CONFIG_TRDX_PID_COLIBRI_VF50IT 0x0019
 #define CONFIG_G_DNL_MANUFACTURER      "Toradex"
-#define CONFIG_G_DNL_VENDOR_NUM                CONFIG_TRDX_VID
-#define CONFIG_G_DNL_PRODUCT_NUM       CONFIG_TRDX_PID_COLIBRI_VF50
+#define CONFIG_G_DNL_VENDOR_NUM                0x1b67
+#define CONFIG_G_DNL_PRODUCT_NUM       0xffff /* Fallback, set using fixup */
 
 /* USB DFU */
 #define CONFIG_USBDOWNLOAD_GADGET