summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2014-12-19 13:54:40 +0100
committerStefan Agner <stefan.agner@toradex.com>2014-12-19 13:54:40 +0100
commitf7e57f71da1eecbf1ac28339868d15492c929925 (patch)
treec7b6cf430f5bbc893a5f230f6695a387c536062f
parentd69e7bbceb14e09f0af2cddeb68ee5734a1c2d45 (diff)
Set USB vendor and product ID of the module when using DFU. This allows to identify the module over USB and act accordingly if necessary (e.g. flash different version or root filesystem or similar use cases). Also the serial number of the USB device is visible by using the lsusb utility: $ lsusb -d 1b67: -v Bus 002 Device 092: ID 1b67:0018 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 2 Communications bDeviceSubClass 2 Abstract (modem) bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x1b67 idProduct 0x0018 bcdDevice 2.21 iManufacturer 1 Toradex iProduct 2 USB download gadget iSerial 3 4799890 ...
-rw-r--r--board/toradex/colibri_vf/colibri_vf.c41
-rw-r--r--board/toradex/common/configblock.c29
-rw-r--r--board/toradex/common/configblock.h2
-rw-r--r--include/configs/colibri_vf.h11
4 files changed, 80 insertions, 3 deletions
diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index 92af6370cd..0740a264e5 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -19,6 +19,7 @@
#include <miiphy.h>
#include <netdev.h>
#include <i2c.h>
+#include <g_dnl.h>
#include "../common/configblock.h"
@@ -336,3 +337,43 @@ int checkboard(void)
return 0;
}
+
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+ char serialnr[64];
+ unsigned short prodnr;
+ unsigned short usb_pid;
+
+#ifdef CONFIG_TRDX_CFG_BLOCK
+ get_board_serial_char(serialnr);
+ get_board_product_number(&prodnr);
+#endif
+
+ put_unaligned(CONFIG_TRDX_VID, &dev->idVendor);
+
+ switch (prodnr) {
+ case 10:
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF50;
+ break;
+ case 11:
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF61;
+ break;
+ case 12:
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF61IT;
+ break;
+ case 13:
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF50IT;
+ break;
+ default:
+ if (is_colibri_vf61())
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF61IT;
+ else
+ usb_pid = CONFIG_TRDX_PID_COLIBRI_VF50;
+ break;
+ }
+
+ put_unaligned(usb_pid, &dev->idProduct);
+ g_dnl_set_serialnumber((char *)serialnr);
+
+ return 0;
+}
diff --git a/board/toradex/common/configblock.c b/board/toradex/common/configblock.c
index 0d333d5a67..7843e0aa8b 100644
--- a/board/toradex/common/configblock.c
+++ b/board/toradex/common/configblock.c
@@ -186,4 +186,33 @@ err:
config_block = NULL;
return err;
}
+
+void get_board_serial_char(char *serialnr)
+{
+ unsigned int serial = 0;
+ unsigned int serial_offset = 11;
+
+ if (config_block == NULL) {
+ strcpy(serialnr, "UNKNOWN");
+ return;
+ }
+
+ /* Get MAC address from config block */
+ memcpy(&serial, config_block + serial_offset, 3);
+ serial = ntohl(serial);
+ serial >>= 8;
+
+ sprintf(serialnr, "%u", serial);
+}
+
+void get_board_product_number(unsigned short *prodnr)
+{
+ unsigned int prodnr_offset = 25;
+
+ if (config_block == NULL)
+ return;
+
+ memcpy(prodnr, config_block + prodnr_offset, 2);
+ *prodnr = ntohs(*prodnr);
+}
#endif /* CONFIG_TRDX_CFG_BLOCK */
diff --git a/board/toradex/common/configblock.h b/board/toradex/common/configblock.h
index 5b204812b5..a2324c4d7c 100644
--- a/board/toradex/common/configblock.h
+++ b/board/toradex/common/configblock.h
@@ -6,4 +6,6 @@
#ifdef CONFIG_TRDX_CFG_BLOCK
int read_trdx_cfg_block(void);
+void get_board_serial_char(char *serialnr);
+void get_board_product_number(unsigned short *prodnr);
#endif
diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h
index c5b288d1b4..98ff456d71 100644
--- a/include/configs/colibri_vf.h
+++ b/include/configs/colibri_vf.h
@@ -257,9 +257,14 @@
#define CONFIG_CI_UDC
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_USB_GADGET_VBUS_DRAW 2
-#define CONFIG_G_DNL_MANUFACTURER "Freescale"
-#define CONFIG_G_DNL_PRODUCT_NUM 0x006A
-#define CONFIG_G_DNL_VENDOR_NUM 0x15A2
+#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
/* USB DFU */
#define CONFIG_USBDOWNLOAD_GADGET