]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
kernel: usb: kmod-usb-dwc3: add gadget and dual-role modes support
authorThomas Richard <thomas.richard@bootlin.com>
Fri, 27 Jun 2025 08:28:08 +0000 (10:28 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Fri, 8 Aug 2025 16:06:51 +0000 (18:06 +0200)
Build DWC3 driver in the right mode:
- host mode if kernel have usb host support only.
- gadget mode if kernel have usbgadget support only.
- dual-role mode if kernel have both usb host and usbgadget support.

Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Link: https://github.com/openwrt/openwrt/pull/19246
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/kernel/linux/modules/usb.mk

index d3b37311bc78709f40539e83ec52e35f88b85199..af9346775ef56e47b245baeabae4b1b85332366f 100644 (file)
@@ -508,17 +508,28 @@ $(eval $(call KernelPackage,usb-cdns3))
 
 
 define KernelPackage/usb-dwc3
+  SUBMENU:=$(USB_MENU)
   TITLE:=DWC3 USB controller driver
+  DEPENDS:=+USB_GADGET_SUPPORT:kmod-usb-gadget \
+          +USB_SUPPORT:kmod-usb-core \
+          +kmod-usb-roles
   KCONFIG:= \
        CONFIG_USB_DWC3 \
-       CONFIG_USB_DWC3_HOST=y \
-       CONFIG_USB_DWC3_GADGET=n \
-       CONFIG_USB_DWC3_DUAL_ROLE=n \
        CONFIG_USB_DWC3_DEBUG=n \
        CONFIG_USB_DWC3_VERBOSE=n
+ifeq ($(CONFIG_USB_SUPPORT)$(CONFIG_USB_GADGET_SUPPORT),yy)
+  KCONFIG+= \
+       CONFIG_USB_DWC3_HOST=n \
+       CONFIG_USB_DWC3_GADGET=n \
+       CONFIG_USB_DWC3_DUAL_ROLE=y
+else
+  KCONFIG+= \
+       CONFIG_USB_DWC3_HOST=$(if $(CONFIG_USB_SUPPORT),y,n) \
+       CONFIG_USB_DWC3_GADGET=$(if $(CONFIG_USB_GADGET_SUPPORT),y,n) \
+       CONFIG_USB_DWC3_DUAL_ROLE=n
+endif
   FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3.ko
   AUTOLOAD:=$(call AutoLoad,54,dwc3,1)
-  $(call AddDepends/usb)
 endef
 
 define KernelPackage/usb-dwc3/description