[U-Boot] [PATCH v4 10/15] usb: dwc3: Kconfig: get rid of obsolete mode selection

Jean-Jacques Hiblot jjhiblot at ti.com
Wed Sep 11 09:33:53 UTC 2019


The mode selection for the DWC3 is kind of obsolete. The driver does not
have to be host only or gadget only. This choice is confusing.
All the remaining callers of dwc3_uboot_init() explicitly set dr_mode
before calling the function, so none rely on a default behavior.

Remove the choice menu and keep only the USB_DWC3_GADGET option. Enable it
by default if USB_GADGET and USB_DWC3 are enabled.
It must be disabled for the evb-rk3328 as it uses DWC2 for the gadget and
DWC3 for the host.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>

---

Changes in v4:
- update more defconfigs (u200, sei510, rock64-rk332 and odroid-n2)
- Fix the test of the USB_DWC3_GADGET option. IS_ENABLED() requires the
  whole option name including the 'CONFIG_' prefix

Changes in v3: None
Changes in v2:
Select USB_GADGET_DUALSPEED if USB_DWC3_GADGET is selected

 configs/evb-rk3328_defconfig    |  1 +
 configs/odroid-n2_defconfig     |  1 +
 configs/rock64-rk3328_defconfig |  1 +
 configs/sei510_defconfig        |  1 +
 configs/u200_defconfig          |  1 +
 drivers/usb/dwc3/Kconfig        | 18 ++----------------
 drivers/usb/dwc3/core.c         |  4 ++--
 7 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig
index 37610774c1..f161c40ae7 100644
--- a/configs/evb-rk3328_defconfig
+++ b/configs/evb-rk3328_defconfig
@@ -86,6 +86,7 @@ CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Rockchip"
 CONFIG_USB_GADGET_VENDOR_NUM=0x2207
diff --git a/configs/odroid-n2_defconfig b/configs/odroid-n2_defconfig
index abd945a975..1caa391320 100644
--- a/configs/odroid-n2_defconfig
+++ b/configs/odroid-n2_defconfig
@@ -44,6 +44,7 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_DWC3_MESON_G12A=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
diff --git a/configs/rock64-rk3328_defconfig b/configs/rock64-rk3328_defconfig
index 3ab0af1158..60a0d1473c 100644
--- a/configs/rock64-rk3328_defconfig
+++ b/configs/rock64-rk3328_defconfig
@@ -88,6 +88,7 @@ CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Rockchip"
 CONFIG_USB_GADGET_VENDOR_NUM=0x2207
diff --git a/configs/sei510_defconfig b/configs/sei510_defconfig
index 5aea81d873..7c34d0cab3 100644
--- a/configs/sei510_defconfig
+++ b/configs/sei510_defconfig
@@ -54,6 +54,7 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_DWC3_MESON_G12A=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x18d1
diff --git a/configs/u200_defconfig b/configs/u200_defconfig
index ced6ca84b6..009d564d6a 100644
--- a/configs/u200_defconfig
+++ b/configs/u200_defconfig
@@ -44,6 +44,7 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
 CONFIG_USB_DWC3_MESON_G12A=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 25e1a38aee..c302486291 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -7,25 +7,11 @@ config USB_DWC3
 
 if USB_DWC3
 
-choice
-	bool "DWC3 Mode Selection"
-
-config USB_DWC3_HOST
-	bool "Host only mode"
-	depends on USB
-	help
-	  Select this when you want to use DWC3 in host mode only,
-	  thereby the gadget feature will be regressed.
-
 config USB_DWC3_GADGET
-	bool "Gadget only mode"
+	bool "USB Gadget support for DWC3"
+	default y
 	depends on USB_GADGET
 	select USB_GADGET_DUALSPEED
-	help
-	  Select this when you want to use DWC3 in gadget mode only,
-	  thereby the host feature will be regressed.
-
-endchoice
 
 comment "Platform Glue Driver Support"
 
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 1baad39796..10b3f837f2 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -707,9 +707,9 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)
 		return -ENOMEM;
 	}
 
-	if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
+	if (!IS_ENABLED(CONFIG_USB_DWC3_GADGET))
 		dwc->dr_mode = USB_DR_MODE_HOST;
-	else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
+	else if (!IS_ENABLED(CONFIG_USB_HOST))
 		dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
 
 	if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
-- 
2.17.1



More information about the U-Boot mailing list