[PATCHv5 4/4] usb: dwc2: Edit the Kconfig and Makefile to build dwc2_gadget driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dinh Nguyen <dinguyen@xxxxxxxxxx>

Modify the dwc2 Kconfig and Makefile so that it will build the dwc2_gadget
driver when peripheral only mode is selected. The dwc_platform.ko and dwc2.ko
will get built when dynamic linked modules are selected for Host mode. For
peripheral mode only dwc2_gadget.ko will get built.

NOTE: You can build both host and peripheral as a dynamically linked module,
but be aware that if you insmod dwc2_gadget, then rmmod it, then insmod
dwc2 and dwc2_platform for host mode, this will not work. As the step to
rmmod dwc2_gadget.ko will turn off the clock to the USB IP. The dwc2 host
driver currently does not look to turn on a clock yet. A patch to fix that
will be coming soon.

Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
Tested-by: Jingoo Han <jg1.han@xxxxxxxxxxx>
Tested-by: Paul Zimmerman <paulz@xxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Felipe Balbi <balbi@xxxxxx>
Cc: Ben Dooks <ben-linux@xxxxxxxxx>
Cc: Matt Porter <mporter@xxxxxxxxxx>
Cc: Kukjin Kim <kgene.kim@xxxxxxxxxxx>
Cc: Stephen Warren <swarren@xxxxxxxxxxxxx>
Cc: Matthijs Kooijman <matthijs@xxxxxxxx>
Cc: Sachin Kamat <sachin.kamat@xxxxxxxxxx>
Cc: Robert Baldyga <r.baldyga@xxxxxxxxxxx>
Cc: Federico Vaga <federico.vaga@xxxxxxxxx>
---
v5: Remove condition that only host or peripheral can be built at the same time.
v4: Remove PCI dependency for USB_DWC2_PLATFORM
v3: Created
v2: none
---
 drivers/usb/dwc2/Kconfig    |   36 +++++++++++++++++++++++++++++-------
 drivers/usb/dwc2/Makefile   |   27 +++++++++++++++------------
 drivers/usb/gadget/Kconfig  |    7 -------
 drivers/usb/gadget/Makefile |    1 -
 4 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index be947d6..1f57d9a 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -5,21 +5,43 @@ config USB_DWC2
 	  Say Y or M here if your system has a Dual Role HighSpeed
 	  USB controller based on the DesignWare HSOTG IP Core.
 
-	  If you choose to build this driver as dynamically linked
-	  modules, the core module will be called dwc2.ko, the
+	  For host mode, if you choose to build this driver as dynamically
+	  linked modules, the core module will be called dwc2.ko, the
 	  PCI bus interface module (if you have a PCI bus system)
 	  will be called dwc2_pci.ko and the platform interface module
 	  (for controllers directly connected to the CPU) will be called
-	  dwc2_platform.ko.
+	  dwc2_platform.ko. For gadget, it will be only be dwc2_gadget.ko.
 
-	  NOTE: This driver at present only implements the Host mode
-	  of the controller. The existing s3c-hsotg driver supports
-	  Peripheral mode, but only for the Samsung S3C platforms.
-	  There are plans to merge the s3c-hsotg driver with this
+	  NOTE: The s3c-hsotg is now renamed as dwc2_gadget. The host
+	  and gadget driver are still currently separate drivers. There
+	  are plans to merge the dwc2_gadget driver with the dwc2 host
 	  driver in the near future to create a dual-role driver.
 
 if USB_DWC2
 
+config USB_DWC2_HOST
+	bool "Host only mode"
+	depends on USB=y || USB=USB_DWC2
+	default y
+	help
+	  Select this when you want to use DWC2 in host mode only,
+	  thereby the gadget feature will be regressed.
+
+config USB_DWC2_PERIPHERAL
+	depends on ARM
+	tristate "Gadget only mode"
+	help
+	  The Designware USB2.0 high-speed gadget controller
+	  integrated into many SoCs.
+
+config USB_DWC2_PLATFORM
+	depends on USB_DWC2_HOST
+	tristate "DWC2 Platform"
+	default y
+	help
+	  The Designware USB2.0 platform interface module for controllers
+	  directly connected to the CPU. This is only used for Host mode.
+
 config USB_DWC2_DEBUG
 	bool "Enable Debugging Messages"
 	help
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index 11529d3..1509032 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -1,25 +1,28 @@
 ccflags-$(CONFIG_USB_DWC2_DEBUG)	+= -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE)	+= -DVERBOSE_DEBUG
 
+ifeq ($(CONFIG_USB_DWC2_HOST),y)
 obj-$(CONFIG_USB_DWC2)			+= dwc2.o
-
 dwc2-y					+= core.o core_intr.o
-
-# NOTE: This driver at present only implements the Host mode
-# of the controller. The existing s3c-hsotg driver supports
-# Peripheral mode, but only for the Samsung S3C platforms.
-# There are plans to merge the s3c-hsotg driver with this
-# driver in the near future to create a dual-role driver. Once
-# that is done, Host mode will become an optional feature that
-# is selected with a config option.
-
 dwc2-y					+= hcd.o hcd_intr.o
 dwc2-y					+= hcd_queue.o hcd_ddma.o
+endif
+obj-$(CONFIG_USB_DWC2_PERIPHERAL)	+= dwc2_gadget.o
+dwc2_gadget-objs			+= gadget.o
+
+# NOTE: The previous s3c-hsotg peripheral mode only driver has been moved to
+# this location and renamed gadget.c. When building for dynamically linked
+# modules, dwc2_gadget.ko will get built for peripheral mode. For host mode,
+# the core module will be dwc2.ko, the PCI bus interface module will called
+# dwc2_pci.ko and the platform interface module will be called dwc2_platform.ko.
+# At present the host and gadget driver will be separate drivers, but there
+# are plans in the near future to create a dual-role driver.
 
 ifneq ($(CONFIG_PCI),)
 	obj-$(CONFIG_USB_DWC2)		+= dwc2_pci.o
 endif
-obj-$(CONFIG_USB_DWC2)			+= dwc2_platform.o
 
-dwc2_pci-y				+= pci.o
+obj-$(CONFIG_USB_DWC2_PLATFORM)		+= dwc2_platform.o
 dwc2_platform-y				+= platform.o
+
+dwc2_pci-y				+= pci.o
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 8154165..ca04ae6 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -300,13 +300,6 @@ config USB_PXA27X
 	   dynamically linked module called "pxa27x_udc" and force all
 	   gadget drivers to also be dynamically linked.
 
-config USB_S3C_HSOTG
-	depends on ARM
-	tristate "Designware/S3C HS/OtG USB Device controller"
-	help
-	  The Designware USB2.0 high-speed gadget controller
-	  integrated into many SoCs.
-
 config USB_S3C2410
 	tristate "S3C2410 USB Device Controller"
 	depends on ARCH_S3C24XX
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 5f150bc..49514ea 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -26,7 +26,6 @@ fsl_usb2_udc-$(CONFIG_ARCH_MXC)	+= fsl_mxc_udc.o
 obj-$(CONFIG_USB_M66592)	+= m66592-udc.o
 obj-$(CONFIG_USB_R8A66597)	+= r8a66597-udc.o
 obj-$(CONFIG_USB_FSL_QE)	+= fsl_qe_udc.o
-obj-$(CONFIG_USB_S3C_HSOTG)	+= s3c-hsotg.o
 obj-$(CONFIG_USB_S3C_HSUDC)	+= s3c-hsudc.o
 obj-$(CONFIG_USB_LPC32XX)	+= lpc32xx_udc.o
 obj-$(CONFIG_USB_EG20T)		+= pch_udc.o
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux