From: Dinh Nguyen <dingu...@altera.com>

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 then dynamic linked modules are selected for Host mode. For
peripheral mode only dwc2_gadget.ko will get built.

Signed-off-by: Dinh Nguyen <dingu...@altera.com>
Tested-by: Jingoo Han <jg1....@samsung.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: Paul Zimmerman <pa...@synopsys.com>
Cc: Felipe Balbi <ba...@ti.com>
Cc: Ben Dooks <ben-li...@fluff.org>
Cc: Matt Porter <mpor...@linaro.org>
Cc: Kukjin Kim <kgene....@samsung.com>
Cc: Stephen Warren <swar...@wwwdotorg.org>
Cc: Matthijs Kooijman <matth...@stdin.nl>
Cc: Sachin Kamat <sachin.ka...@linaro.org>
Cc: Robert Baldyga <r.bald...@samsung.com>
---
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..e85e6e1 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 || USB_GADGET=y) && !USB_DWC2_HOST
+       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.8.3.2

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

Reply via email to