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

Alban Bedel alban.bedel at aerq.com
Tue Apr 19 11:20:10 CEST 2022


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 at 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,
-- 
2.32.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3627 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20220419/d4893c9e/attachment.bin>


More information about the U-Boot mailing list