@@ -138,8 +138,6 @@ source "drivers/staging/netlogic/Kconfig"
source "drivers/staging/mt29f_spinand/Kconfig"
-source "drivers/staging/dwc2/Kconfig"
-
source "drivers/staging/lustre/Kconfig"
source "drivers/staging/btmtk_usb/Kconfig"
@@ -106,6 +106,8 @@ endif
source "drivers/usb/musb/Kconfig"
+source "drivers/usb/dwc2/Kconfig"
+
source "drivers/usb/dwc3/Kconfig"
source "drivers/usb/chipidea/Kconfig"
@@ -6,6 +6,7 @@
obj-$(CONFIG_USB) += core/
+obj-$(CONFIG_USB_DWC2) += dwc2/
obj-$(CONFIG_USB_DWC3) += dwc3/
obj-$(CONFIG_USB_MON) += mon/
similarity index 69%
rename from drivers/staging/dwc2/Kconfig
rename to drivers/usb/dwc2/Kconfig
@@ -20,6 +20,35 @@ config USB_DWC2
if USB_DWC2
+choice
+ bool "DWC2 Mode Selection"
+ default USB_DWC2_DUAL_ROLE if (USB && USB_GADGET)
+ default USB_DWC2_HOST if (USB && !USB_GADGET)
+ default USB_DWC2_GADGET if (!USB && USB_GADGET)
+
+config USB_DWC2_HOST
+ bool "Host only mode"
+ depends on USB=y || USB=USB_DWC2
+ help
+ Select this when you want to use DWC2 in host mode only,
+ thereby the gadget feature will be regressed.
+
+config USB_DWC2_GADGET
+ bool "Gadget only mode"
+ depends on USB_GADGET=y || USB_GADGET=USB_DWC2
+ help
+ Select this when you want to use DWC2 in gadget mode only,
+ thereby the host feature will be regressed.
+
+config USB_DWC2_DUAL_ROLE
+ bool "Dual Role mode"
+ depends on ((USB=y || USB=USB_DWC2) && (USB_GADGET=y || USB_GADGET=USB_DWC2))
+ help
+ This is the default mode of working of DWC2 controller where
+ both host and gadget features are enabled.
+
+endchoice
+
config USB_DWC2_DEBUG
bool "Enable Debugging Messages"
help
similarity index 100%
rename from drivers/staging/dwc2/Makefile
rename to drivers/usb/dwc2/Makefile
similarity index 100%
rename from drivers/staging/dwc2/core.c
rename to drivers/usb/dwc2/core.c
similarity index 100%
rename from drivers/staging/dwc2/core.h
rename to drivers/usb/dwc2/core.h
similarity index 100%
rename from drivers/staging/dwc2/core_intr.c
rename to drivers/usb/dwc2/core_intr.c
similarity index 100%
rename from drivers/staging/dwc2/hcd.c
rename to drivers/usb/dwc2/hcd.c
similarity index 100%
rename from drivers/staging/dwc2/hcd.h
rename to drivers/usb/dwc2/hcd.h
similarity index 100%
rename from drivers/staging/dwc2/hcd_ddma.c
rename to drivers/usb/dwc2/hcd_ddma.c
similarity index 100%
rename from drivers/staging/dwc2/hcd_intr.c
rename to drivers/usb/dwc2/hcd_intr.c
similarity index 100%
rename from drivers/staging/dwc2/hcd_queue.c
rename to drivers/usb/dwc2/hcd_queue.c
similarity index 97%
rename from drivers/staging/dwc2/hw.h
rename to drivers/usb/dwc2/hw.h
@@ -109,6 +109,7 @@
#define GUSBCFG_FSINTF (1 << 5)
#define GUSBCFG_ULPI_UTMI_SEL (1 << 4)
#define GUSBCFG_PHYIF16 (1 << 3)
+#define GUSBCFG_PHYIF8 (0 << 3)
#define GUSBCFG_TOUTCAL_MASK (0x7 << 0)
#define GUSBCFG_TOUTCAL_SHIFT 0
#define GUSBCFG_TOUTCAL_LIMIT 0x7
@@ -151,7 +152,7 @@
#define GINTSTS_ENUMDONE (1 << 13)
#define GINTSTS_USBRST (1 << 12)
#define GINTSTS_USBSUSP (1 << 11)
-#define GINTSTS_ERLYSUSP (1 << 10)
+#define GINTSTS_EARLYSUSP (1 << 10)
#define GINTSTS_I2CINT (1 << 9)
#define GINTSTS_ULPI_CK_INT (1 << 8)
#define GINTSTS_GOUTNAKEFF (1 << 7)
@@ -169,14 +170,14 @@
#define GRXSTS_FN_SHIFT 25
#define GRXSTS_PKTSTS_MASK (0xf << 17)
#define GRXSTS_PKTSTS_SHIFT 17
-#define GRXSTS_PKTSTS_GLOBALOUTNAK 1
-#define GRXSTS_PKTSTS_OUTRX 2
+#define GRXSTS_PKTSTS_GLOBALOUTNAK (0x1 << 17)
+#define GRXSTS_PKTSTS_OUTRX (0x2 << 17)
#define GRXSTS_PKTSTS_HCHIN 2
-#define GRXSTS_PKTSTS_OUTDONE 3
+#define GRXSTS_PKTSTS_OUTDONE (0x3 << 17)
#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3
-#define GRXSTS_PKTSTS_SETUPDONE 4
+#define GRXSTS_PKTSTS_SETUPDONE (0x4 << 17)
#define GRXSTS_PKTSTS_DATATOGGLEERR 5
-#define GRXSTS_PKTSTS_SETUPRX 6
+#define GRXSTS_PKTSTS_SETUPRX (0x6 << 17)
#define GRXSTS_PKTSTS_HCHHALTED 7
#define GRXSTS_HCHNUM_MASK (0xf << 0)
#define GRXSTS_HCHNUM_SHIFT 0
@@ -403,6 +404,9 @@
#define FIFOSIZE_DEPTH_SHIFT 16
#define FIFOSIZE_STARTADDR_MASK (0xffff << 0)
#define FIFOSIZE_STARTADDR_SHIFT 0
+#define DPTXFSIZN_DPTXFSIZE_GET(_v) (((_v) >> 16) & 0xffff)
+#define DPTXFSIZN_DPTXFSIZE(_x) ((_x) << 16)
+#define DPTXFSIZN_DPTXFADDR(_x) ((_x) << 0)
/* Device mode registers */
@@ -520,10 +524,11 @@
#define DXEPCTL_SNP (1 << 20)
#define DXEPCTL_EPTYPE_MASK (0x3 << 18)
#define DXEPCTL_EPTYPE_SHIFT 18
-#define DXEPCTL_EPTYPE_CONTROL 0
-#define DXEPCTL_EPTYPE_ISO 1
-#define DXEPCTL_EPTYPE_BULK 2
-#define DXEPCTL_EPTYPE_INTTERUPT 3
+#define DXEPCTL_EPTYPE_CONTROL (0x0 << 18)
+#define DXEPCTL_EPTYPE_ISO (0x1 << 18)
+#define DXEPCTL_EPTYPE_BULK (0x2 << 18)
+#define DXEPCTL_EPTYPE_INTERRUPT (0x3 << 18)
+
#define DXEPCTL_NAKSTS (1 << 17)
#define DXEPCTL_DPID (1 << 16)
#define DXEPCTL_EOFRNUM (1 << 16)