public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/4] usb: dwc3: fix kconfig
Date: Thu, 19 May 2016 17:15:46 +0300	[thread overview]
Message-ID: <573DCA92.6070900@ti.com> (raw)
In-Reply-To: <1463141873-10604-2-git-send-email-rogerq@ti.com>

DWC3 can be used as host or as gadget controller and the actual mode
is determined at runtime so USB_DWC3_DUAL_ROLE must be the default
mode when both host and gadget drivers are available.

As DWC3 core implements an XHCI host controller, we use USB_XHCI_HCD to
check if host driver is available.

USB_DWC3_HOST and USB_DWC3_GADGET are only set if a particular mode
needs to be forced or if both host and gadget drivers are not available.

Build the dwc3 gadget drivers only if gadget mode can be used at runtime.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
v2:
- don't depend on USB as dwc3/kconfig already depends on that
- use USB_XHCI_HCD to decide whether host operation is available.
- Add USB_DWC3_DUAL_ROLE, which means that controller can operate
either in host or gadget mode. The actual mode is decided at runtime
based on dwc3->dr_mode.

 drivers/usb/dwc3/Kconfig  | 18 +++++++++++++-----
 drivers/usb/dwc3/Makefile |  4 +++-
 drivers/usb/dwc3/core.h   |  4 ++--
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index e93398f..0db536e 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -1,19 +1,20 @@
 config USB_DWC3
 	bool "DesignWare USB3 DRD Core Support"
-	depends on (USB && USB_GADGET)
-	select USB_GADGET_DUALSPEED
+	select USB_GADGET_DUALSPEED if USB_GADGET
 	help
-	  Say Y here if your system has a Dual Role SuperSpeed
-	  USB controller based on the DesignWare USB3 IP Core.
+	  Say Y here if your system has DesignWare USB3 IP Core.
 
 if USB_DWC3
 
 choice
 	bool "DWC3 Mode Selection"
+	default USB_DWC3_DUAL_ROLE if (USB_GADGET && USB_XHCI_HCD)
+	default USB_DWC3_HOST if (!USB_GADGET && USB_XHCI_HCD)
+	default USB_DWC3_GADGET if (USB_GADGET && !USB_XHCI_HCD)
 
 config USB_DWC3_HOST
 	bool "Host only mode"
-	depends on USB
+	depends on USB_XHCI_HCD
 	help
 	  Select this when you want to use DWC3 in host mode only,
 	  thereby the gadget feature will be regressed.
@@ -25,6 +26,13 @@ config USB_DWC3_GADGET
 	  Select this when you want to use DWC3 in gadget mode only,
 	  thereby the host feature will be regressed.
 
+config USB_DWC3_DUAL_ROLE
+	bool "Dual role mode"
+	depends on (USB_XHCI_HCD && USB_GADGET)
+	help
+	 This is the default mode of working of DWC3 controller where
+	 both host and gadget features are enabled.
+
 endchoice
 
 comment "Platform Glue Driver Support"
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 0cd7302..d2ad2e9 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -6,7 +6,9 @@ obj-$(CONFIG_USB_DWC3)			+= dwc3.o
 
 dwc3-y					:= core.o
 
-dwc3-y					+= gadget.o ep0.o
+ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) $(CONFIG_USB_DWC3_DUAL_ROLE)),)
+dwc3-yi					+= gadget.o ep0.o
+endif
 
 obj-$(CONFIG_USB_DWC3_OMAP)		+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_PHY_OMAP)		+= ti_usb_phy.o
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 72d2fcd..faf0c0f 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -989,7 +989,7 @@ struct dwc3_gadget_ep_cmd_params {
 /* prototypes */
 int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
 
-#ifdef CONFIG_USB_DWC3_HOST
+#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
 int dwc3_host_init(struct dwc3 *dwc);
 void dwc3_host_exit(struct dwc3 *dwc);
 #else
@@ -999,7 +999,7 @@ static inline void dwc3_host_exit(struct dwc3 *dwc)
 { }
 #endif
 
-#ifdef CONFIG_USB_DWC3_GADGET
+#if IS_ENABLED(CONFIG_USB_DWC3_GADGET) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
 int dwc3_gadget_init(struct dwc3 *dwc);
 void dwc3_gadget_exit(struct dwc3 *dwc);
 int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode);
-- 
2.7.4

  parent reply	other threads:[~2016-05-19 14:15 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 12:17 [U-Boot] [PATCH 0/4] am57xx: beagle-x15: get usb host working Roger Quadros
2016-05-13 12:17 ` [U-Boot] [PATCH 1/4] usb: dwc3: fix kconfig Roger Quadros
2016-05-13 12:23   ` Marek Vasut
2016-05-13 12:27     ` Roger Quadros
2016-05-13 12:43       ` Marek Vasut
2016-05-17 10:37     ` Masahiro Yamada
2016-05-17 10:33   ` Masahiro Yamada
2016-05-18 12:47     ` Roger Quadros
2016-05-18 12:52       ` Marek Vasut
2016-05-19 14:15   ` Roger Quadros [this message]
2016-05-13 12:17 ` [U-Boot] [PATCH 2/4] board: ti: am57xx: Fix USB configuration Roger Quadros
2016-05-13 12:23   ` Marek Vasut
2016-05-13 12:36   ` [U-Boot] [PATCH v2 " Roger Quadros
2016-05-13 12:45     ` Marek Vasut
2016-05-16  9:06       ` Roger Quadros
2016-05-16  9:26         ` Roger Quadros
2016-05-16  9:49           ` Roger Quadros
2016-05-16 10:03             ` Kishon Vijay Abraham I
2016-05-16 10:31               ` Roger Quadros
2016-05-16 11:10                 ` Kishon Vijay Abraham I
2016-05-16 13:51                   ` Roger Quadros
2016-05-20 22:32   ` [U-Boot] [U-Boot,2/4] " Tom Rini
2016-05-13 12:17 ` [U-Boot] [PATCH 3/4] usb: dwc3: Makefile: Don't build gadget code if USB_GADGET is disabled Roger Quadros
2016-05-13 12:24   ` Marek Vasut
2016-05-30 17:58   ` [U-Boot] [U-Boot, " Tom Rini
2016-05-13 12:17 ` [U-Boot] [PATCH 4/4] usb: gadget: udc: Build on USB_GADGET Roger Quadros
2016-05-13 12:24   ` Marek Vasut
2016-05-13 12:29     ` Roger Quadros
2016-05-13 12:47       ` Marek Vasut
2016-05-16  9:03         ` Roger Quadros
2016-05-13 12:22 ` [U-Boot] [PATCH 0/4] am57xx: beagle-x15: get usb host working Marek Vasut
2016-05-13 12:39 ` Roger Quadros
2016-05-13 12:47   ` Marek Vasut
2016-05-18 14:27     ` Roger Quadros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=573DCA92.6070900@ti.com \
    --to=rogerq@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox