Skip to content

Commit 72246da

Browse files
Felipe Balbigregkh
authored andcommitted
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly configurable IP Core which can be instantiated as Dual-Role Device (DRD), Peripheral Only and Host Only (XHCI) configurations. Several other parameters can be configured like amount of FIFO space, amount of TX and RX endpoints, amount of Host Interrupters, etc. The current driver has been validated with a virtual model of version 1.73a of that core and with an FPGA burned with version 1.83a of the DRD core. We have support for PCIe bus, which is used on FPGA prototyping, and for the OMAP5, more adaptation (or glue) layers can be easily added and the driver is half prepared to handle any possible configuration the HW engineer has chosen considering we have the information on one of the GHWPARAMS registers to do runtime checking of certain features. More runtime checks can, and should, be added in order to make this driver even more flexible with regards to number of endpoints, FIFO sizes, transfer types, etc. While this supports only the device side, for now, we will add support for Host side (xHCI - see the updated series Sebastian has sent [1]) and OTG after we have it all stabilized. [1] http://marc.info/?l=linux-usb&m=131341992020339&w=2 Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 500fdf8 commit 72246da

File tree

16 files changed

+5712
-0
lines changed

16 files changed

+5712
-0
lines changed

Documentation/usb/dwc3.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
TODO
3+
~~~~~~
4+
Please pick something while reading :)
5+
6+
- Implement streaming support for BULK endpoints
7+
Tatyana's patch "usb: Add streams support to the gadget framework"
8+
introduces streaming support for the gadget driver.
9+
Every usb_request has new field called stream_id which holds its id.
10+
Every usb_ep has a field num_supported_strms which describes the max
11+
number of streams supported (for this ep).
12+
UAS is AFAIK the only gadget with streaming support.
13+
14+
- Convert interrupt handler to per-ep-thread-irq
15+
16+
As it turns out some DWC3-commands ~1ms to complete. Currently we spin
17+
until the command completes which is bad.
18+
19+
Implementation idea:
20+
- dwc core implements a demultiplexing irq chip for interrupts per
21+
endpoint. The interrupt numbers are allocated during probe and belong
22+
to the device. If MSI provides per-endpoint interrupt this dummy
23+
interrupt chip can be replaced with "real" interrupts.
24+
- interrupts are requested / allocated on usb_ep_enable() and removed on
25+
usb_ep_disable(). Worst case are 32 interrupts, the lower limit is two
26+
for ep0/1.
27+
- dwc3_send_gadget_ep_cmd() will sleep in wait_for_completion_timeout()
28+
until the command completes.
29+
- the interrupt handler is split into the following pieces:
30+
- primary handler of the device
31+
goes through every event and calls generic_handle_irq() for event
32+
it. On return from generic_handle_irq() in acknowledges the event
33+
counter so interrupt goes away (eventually).
34+
35+
- threaded handler of the device
36+
none
37+
38+
- primary handler of the EP-interrupt
39+
reads the event and tries to process it. Everything that requries
40+
sleeping is handed over to the Thread. The event is saved in an
41+
per-endpoint data-structure.
42+
We probably have to pay attention not to process events once we
43+
handed something to thread so we don't process event X prio Y
44+
where X > Y.
45+
46+
- threaded handler of the EP-interrupt
47+
handles the remaining EP work which might sleep such as waiting
48+
for command completion.
49+
50+
Latency:
51+
There should be no increase in latency since the interrupt-thread has a
52+
high priority and will be run before an average task in user land
53+
(except the user changed priorities).

drivers/usb/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ config USB
111111

112112
source "drivers/usb/core/Kconfig"
113113

114+
source "drivers/usb/dwc3/Kconfig"
115+
114116
source "drivers/usb/mon/Kconfig"
115117

116118
source "drivers/usb/wusbcore/Kconfig"

drivers/usb/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
obj-$(CONFIG_USB) += core/
88

9+
obj-$(CONFIG_USB_DWC3) += dwc3/
10+
911
obj-$(CONFIG_USB_MON) += mon/
1012

1113
obj-$(CONFIG_PCI) += host/

drivers/usb/dwc3/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
config USB_DWC3
2+
tristate "DesignWare USB3 DRD Core Support"
3+
depends on (USB || USB_GADGET)
4+
select USB_OTG_UTILS
5+
help
6+
Say Y or M here if your system has a Dual Role SuperSpeed
7+
USB controller based on the DesignWare USB3 IP Core.
8+
9+
If you choose to build this driver is a dynamically linked
10+
module, the module will be called dwc3.ko.
11+
12+
if USB_DWC3
13+
14+
config USB_DWC3_DEBUG
15+
bool "Enable Debugging Messages"
16+
help
17+
Say Y here to enable debugging messages on DWC3 Driver.
18+
19+
config USB_DWC3_VERBOSE
20+
bool "Enable Verbose Debugging Messages"
21+
depends on USB_DWC3_DEBUG
22+
help
23+
Say Y here to enable verbose debugging messages on DWC3 Driver.
24+
25+
endif

drivers/usb/dwc3/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG
2+
ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG
3+
4+
obj-$(CONFIG_USB_DWC3) += dwc3.o
5+
6+
dwc3-y := core.o
7+
8+
ifneq ($(CONFIG_USB_GADGET_DWC3),)
9+
dwc3-y += gadget.o ep0.o
10+
endif
11+
12+
ifneq ($(CONFIG_DEBUG_FS),)
13+
dwc3-y += debugfs.o
14+
endif
15+
16+
##
17+
# Platform-specific glue layers go here
18+
#
19+
# NOTICE: Make sure your glue layer doesn't depend on anything
20+
# which is arch-specific and that it compiles on all situations.
21+
#
22+
# We want to keep this requirement in order to be able to compile
23+
# the entire driver (with all its glue layers) on several architectures
24+
# and make sure it compiles fine. This will also help with allmodconfig
25+
# and allyesconfig builds.
26+
#
27+
# The only exception is the PCI glue layer, but that's only because
28+
# PCI doesn't provide nops if CONFIG_PCI isn't enabled.
29+
##
30+
31+
obj-$(CONFIG_USB_DWC3) += dwc3-omap.o
32+
33+
ifneq ($(CONFIG_PCI),)
34+
obj-$(CONFIG_USB_DWC3) += dwc3-pci.o
35+
endif
36+

0 commit comments

Comments
 (0)