[PATCH 1/2] usb: gadget: Add a config option to set the SPL product ID

It might be desirable to have a different product ID for the SPL gadget. Several boards use dubious hack to achieve this like adding an hardcoded offset to the configurable main product ID.
Add a new config option to set the product ID to use in the SPL and use it in the ethernet and download gadgets.
Signed-off-by: Alban Bedel alban.bedel@aerq.com --- common/spl/Kconfig | 6 ++++++ drivers/usb/gadget/ether.c | 2 +- drivers/usb/gadget/g_dnl.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index ac61b25a0660..196f3cfc5558 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1182,6 +1182,12 @@ config SPL_USB_GADGET
if SPL_USB_GADGET
+config SPL_USB_GADGET_PRODUCT_NUM + hex "Product ID of the SPL USB device" + default 0x0 + help + Product ID of the USB device emulated in SPL, reported to the host device. + config SPL_USB_ETHER bool "Support USB Ethernet drivers" depends on SPL_NET diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 430732865723..18195d3ee19b 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2078,7 +2078,7 @@ static int eth_bind(struct usb_gadget *gadget) device_desc.idVendor = __constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM); device_desc.idProduct = - __constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM); + __constant_cpu_to_le16(CONFIG_VAL(USB_GADGET_PRODUCT_NUM)); #else device_desc.idVendor = __constant_cpu_to_le16(RNDIS_VENDOR_NUM); diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index afb7b74f3057..85297cc0e501 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -63,7 +63,7 @@ static struct usb_device_descriptor device_desc = { .bDeviceSubClass = 0, /*0x02:CDC-modem , 0x00:CDC-serial*/
.idVendor = __constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM), + .idProduct = __constant_cpu_to_le16(CONFIG_VAL(USB_GADGET_PRODUCT_NUM)), /* .iProduct = DYNAMIC */ /* .iSerialNumber = DYNAMIC */ .bNumConfigurations = 1,

Remove the hardcoded USB product ID offset for the SPL as it doesn't work anymore for the product ID needed for iMX8 with current flashing tools. Update all the defconfig of iMX boards that have CONFIG_SPL_USB_GADGET enabled to still return the same product ID.
Signed-off-by: Alban Bedel alban.bedel@aerq.com --- arch/arm/mach-imx/spl.c | 7 ------- configs/apalis_imx6_defconfig | 1 + configs/colibri_imx6_defconfig | 1 + configs/display5_factory_defconfig | 1 + configs/ge_b1x5v2_defconfig | 1 + configs/imx6q_logic_defconfig | 1 + configs/imx7_cm_defconfig | 1 + configs/kontron-sl-mx6ul_defconfig | 1 + configs/mx6sabreauto_defconfig | 1 + configs/mx6sabresd_defconfig | 1 + configs/mx6ul_14x14_evk_defconfig | 1 + configs/pico-dwarf-imx6ul_defconfig | 1 + configs/pico-dwarf-imx7d_defconfig | 1 + configs/pico-hobbit-imx6ul_defconfig | 1 + configs/pico-hobbit-imx7d_defconfig | 1 + configs/pico-imx6_defconfig | 1 + configs/pico-imx6ul_defconfig | 1 + configs/pico-imx7d_bl33_defconfig | 1 + configs/pico-imx7d_defconfig | 1 + configs/pico-nymph-imx7d_defconfig | 1 + configs/pico-pi-imx6ul_defconfig | 1 + configs/vining_2000_defconfig | 1 + 22 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index 64ca29677212..27a2650a0ba5 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -185,13 +185,6 @@ u32 spl_boot_device(void) #endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */
#ifdef CONFIG_SPL_USB_GADGET -int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) -{ - put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM + 0xfff, &dev->idProduct); - - return 0; -} - #define SDPV_BCD_DEVICE 0x500 int g_dnl_get_board_bcd_device_number(int gcnum) { diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig index 3fa1bb58a434..5b641343cd9c 100644 --- a/configs/apalis_imx6_defconfig +++ b/configs/apalis_imx6_defconfig @@ -37,6 +37,7 @@ CONFIG_SPL_DMA=y CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0x4fff CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SYS_PROMPT="Apalis iMX6 # " # CONFIG_CMD_ELF is not set diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig index 04b73a8b9cb1..a946a772bccb 100644 --- a/configs/colibri_imx6_defconfig +++ b/configs/colibri_imx6_defconfig @@ -36,6 +36,7 @@ CONFIG_SPL_DMA=y CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0x4fff CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SYS_PROMPT="Colibri iMX6 # " # CONFIG_CMD_ELF is not set diff --git a/configs/display5_factory_defconfig b/configs/display5_factory_defconfig index 45b6b9644918..8339a7c6a09f 100644 --- a/configs/display5_factory_defconfig +++ b/configs/display5_factory_defconfig @@ -44,6 +44,7 @@ CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="display5 factory > " diff --git a/configs/ge_b1x5v2_defconfig b/configs/ge_b1x5v2_defconfig index a1cf676f3f57..bf52e0541198 100644 --- a/configs/ge_b1x5v2_defconfig +++ b/configs/ge_b1x5v2_defconfig @@ -41,6 +41,7 @@ CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x11400 CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_HUSH_PARSER=y CONFIG_CMD_BOOTZ=y diff --git a/configs/imx6q_logic_defconfig b/configs/imx6q_logic_defconfig index 0a8ac8f50ab2..34b506e72c32 100644 --- a/configs/imx6q_logic_defconfig +++ b/configs/imx6q_logic_defconfig @@ -37,6 +37,7 @@ CONFIG_SPL_FALCON_BOOT_MMCSD=y CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR=0x1000 CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_SYS_PROMPT="i.MX6 Logic # " diff --git a/configs/imx7_cm_defconfig b/configs/imx7_cm_defconfig index c22c4d570d40..18a7054b2e5d 100644 --- a/configs/imx7_cm_defconfig +++ b/configs/imx7_cm_defconfig @@ -27,6 +27,7 @@ CONFIG_DEFAULT_FDT_FILE="ask" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y # CONFIG_CMD_BOOTD is not set CONFIG_CMD_BOOTMENU=y diff --git a/configs/kontron-sl-mx6ul_defconfig b/configs/kontron-sl-mx6ul_defconfig index c4f8fdb4f5fc..65cecff52f2c 100644 --- a/configs/kontron-sl-mx6ul_defconfig +++ b/configs/kontron-sl-mx6ul_defconfig @@ -31,6 +31,7 @@ CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_WATCHDOG=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_GPIO=y diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig index 7160825f4b33..52dbd002fcc3 100644 --- a/configs/mx6sabreauto_defconfig +++ b/configs/mx6sabreauto_defconfig @@ -39,6 +39,7 @@ CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig index 6d122477e027..b61e8e1dc656 100644 --- a/configs/mx6sabresd_defconfig +++ b/configs/mx6sabresd_defconfig @@ -36,6 +36,7 @@ CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_FIT_IMAGE_TINY=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y diff --git a/configs/mx6ul_14x14_evk_defconfig b/configs/mx6ul_14x14_evk_defconfig index 1e1e799eb384..676e44e4ada0 100644 --- a/configs/mx6ul_14x14_evk_defconfig +++ b/configs/mx6ul_14x14_evk_defconfig @@ -31,6 +31,7 @@ CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y diff --git a/configs/pico-dwarf-imx6ul_defconfig b/configs/pico-dwarf-imx6ul_defconfig index 8e1c25def99e..e30e20014992 100644 --- a/configs/pico-dwarf-imx6ul_defconfig +++ b/configs/pico-dwarf-imx6ul_defconfig @@ -27,6 +27,7 @@ CONFIG_DEFAULT_FDT_FILE="imx6ul-pico-dwarf.dtb" CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_MEMTEST=y diff --git a/configs/pico-dwarf-imx7d_defconfig b/configs/pico-dwarf-imx7d_defconfig index 90b607b90dff..873312041bb1 100644 --- a/configs/pico-dwarf-imx7d_defconfig +++ b/configs/pico-dwarf-imx7d_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="imx7d-pico-dwarf.dtb" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y # CONFIG_CMD_BOOTD is not set CONFIG_CMD_BOOTMENU=y diff --git a/configs/pico-hobbit-imx6ul_defconfig b/configs/pico-hobbit-imx6ul_defconfig index 28414666851b..fb225e9d4880 100644 --- a/configs/pico-hobbit-imx6ul_defconfig +++ b/configs/pico-hobbit-imx6ul_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="imx6ul-pico-hobbit.dtb" CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_MEMTEST=y diff --git a/configs/pico-hobbit-imx7d_defconfig b/configs/pico-hobbit-imx7d_defconfig index 1342d8501171..7919e6035be6 100644 --- a/configs/pico-hobbit-imx7d_defconfig +++ b/configs/pico-hobbit-imx7d_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="imx7d-pico-hobbit.dtb" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y # CONFIG_CMD_BOOTD is not set CONFIG_CMD_BOOTMENU=y diff --git a/configs/pico-imx6_defconfig b/configs/pico-imx6_defconfig index 0bd66135d965..e6eca499e519 100644 --- a/configs/pico-imx6_defconfig +++ b/configs/pico-imx6_defconfig @@ -32,6 +32,7 @@ CONFIG_SPL_FIT_IMAGE_TINY=y CONFIG_SPL_FS_EXT4=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_CMD_BOOTMENU=y diff --git a/configs/pico-imx6ul_defconfig b/configs/pico-imx6ul_defconfig index c198a660ea33..1dc60d0f84d5 100644 --- a/configs/pico-imx6ul_defconfig +++ b/configs/pico-imx6ul_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="ask" CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_SPL=y diff --git a/configs/pico-imx7d_bl33_defconfig b/configs/pico-imx7d_bl33_defconfig index 09117e9a4ea8..cf98163d09ee 100644 --- a/configs/pico-imx7d_bl33_defconfig +++ b/configs/pico-imx7d_bl33_defconfig @@ -29,6 +29,7 @@ CONFIG_BOOTCOMMAND="run distro_bootcmd" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_BOOTD is not set diff --git a/configs/pico-imx7d_defconfig b/configs/pico-imx7d_defconfig index 6473aaaede4c..2026cd5c775f 100644 --- a/configs/pico-imx7d_defconfig +++ b/configs/pico-imx7d_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="ask" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y # CONFIG_CMD_BOOTD is not set CONFIG_CMD_BOOTMENU=y diff --git a/configs/pico-nymph-imx7d_defconfig b/configs/pico-nymph-imx7d_defconfig index 90b607b90dff..873312041bb1 100644 --- a/configs/pico-nymph-imx7d_defconfig +++ b/configs/pico-nymph-imx7d_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="imx7d-pico-dwarf.dtb" CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y # CONFIG_CMD_BOOTD is not set CONFIG_CMD_BOOTMENU=y diff --git a/configs/pico-pi-imx6ul_defconfig b/configs/pico-pi-imx6ul_defconfig index 31f37dab26fd..ce1eed9f789e 100644 --- a/configs/pico-pi-imx6ul_defconfig +++ b/configs/pico-pi-imx6ul_defconfig @@ -28,6 +28,7 @@ CONFIG_DEFAULT_FDT_FILE="imx6ul-pico-pi.dtb" CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_MEMTEST=y diff --git a/configs/vining_2000_defconfig b/configs/vining_2000_defconfig index 57fd3376bbcc..e88c836f7462 100644 --- a/configs/vining_2000_defconfig +++ b/configs/vining_2000_defconfig @@ -35,6 +35,7 @@ CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C=y CONFIG_SPL_USB_HOST=y CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4 CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y

On Tue, 2022-04-19 at 11:20 +0200, Alban Bedel wrote:
It might be desirable to have a different product ID for the SPL gadget. Several boards use dubious hack to achieve this like adding an hardcoded offset to the configurable main product ID.
Add a new config option to set the product ID to use in the SPL and use it in the ethernet and download gadgets.
Can this patch please be considered? It still apply on master.
Alban
participants (2)
-
Alban Bedel
-
Bedel, Alban