From 7341581eb4990cff3255b6451742aa1c7ec0ee44 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 1 May 2015 17:21:35 +0200 Subject: toradex: common: create a place for common functionality 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. --- board/toradex/apalis_imx6/apalis_imx6.c | 35 +----- board/toradex/apalis_t30/apalis_t30.c | 33 +----- board/toradex/colibri_imx6/colibri_imx6.c | 33 +----- board/toradex/colibri_t20/colibri_t20.c | 36 +----- board/toradex/colibri_t30/colibri_t30.c | 30 +---- board/toradex/colibri_vf/colibri_vf.c | 27 +---- board/toradex/common/common.c | 109 +++++++++++++++++ board/toradex/common/common.h | 13 +++ board/toradex/common/common.mk | 1 + board/toradex/common/configblock.c | 186 ++++++------------------------ board/toradex/common/configblock.h | 53 ++++++++- 11 files changed, 221 insertions(+), 335 deletions(-) create mode 100644 board/toradex/common/common.c create mode 100644 board/toradex/common/common.h (limited to 'board') diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c index 52ab253bd0..81ac092404 100644 --- a/board/toradex/apalis_imx6/apalis_imx6.c +++ b/board/toradex/apalis_imx6/apalis_imx6.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #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; } diff --git a/board/toradex/apalis_t30/apalis_t30.c b/board/toradex/apalis_t30/apalis_t30.c index a743f00feb..9f9731af49 100644 --- a/board/toradex/apalis_t30/apalis_t30.c +++ b/board/toradex/apalis_t30/apalis_t30.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -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 diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c index a0809eefa5..ea25026765 100644 --- a/board/toradex/colibri_imx6/colibri_imx6.c +++ b/board/toradex/colibri_imx6/colibri_imx6.c @@ -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; } diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index e20004e4cf..00ed533cbc 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -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 diff --git a/board/toradex/colibri_t30/colibri_t30.c b/board/toradex/colibri_t30/colibri_t30.c index a7ce04b66f..2a5ddd71ee 100644 --- a/board/toradex/colibri_t30/colibri_t30.c +++ b/board/toradex/colibri_t30/colibri_t30.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #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 diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c index e973e8e32f..696eb105bd 100644 --- a/board/toradex/colibri_vf/colibri_vf.c +++ b/board/toradex/colibri_vf/colibri_vf.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #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 index 0000000000..30c8ebf8bd --- /dev/null +++ b/board/toradex/common/common.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015 Toradex, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "configblock.h" +#include +#include + +__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 index 0000000000..998c479f36 --- /dev/null +++ b/board/toradex/common/common.h @@ -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 */ diff --git a/board/toradex/common/common.mk b/board/toradex/common/common.mk index e94ebbce4f..469189a315 100644 --- a/board/toradex/common/common.mk +++ b/board/toradex/common/common.mk @@ -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 diff --git a/board/toradex/common/configblock.c b/board/toradex/common/configblock.c index 3575295dca..f7bfee62bd 100644 --- a/board/toradex/common/configblock.c +++ b/board/toradex/common/configblock.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include "configblock.h" #include #include @@ -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(ð_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 *)ð_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, ð_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, ð_addr, 6); + memcpy(config_block + offset, &trdx_eth_addr, 6); offset +=6; memset(config_block + offset, 0, 32 - offset); diff --git a/board/toradex/common/configblock.h b/board/toradex/common/configblock.h index bd6c28648a..cce61ac89e 100644 --- a/board/toradex/common/configblock.h +++ b/board/toradex/common/configblock.h @@ -7,9 +7,56 @@ #ifndef _TRDX_CONFIGBLOCK_H #define _TRDX_CONFIGBLOCK_H +#include + +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 */ -- cgit v1.2.3