Skip to contentSkip to conversation

usb/gadget: Add driver for Aspeed SoC virtual hub

PATCH Superseded Benjamin Herrenschmidt 1 participant 1 message Jan 26, 2018

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/2 usb/gadget: Add driver for Aspeed SoC virtual hub

The Aspeed BMC SoCs support a "virtual hub" function. It provides some HW support for a top-level USB2 hub behind which sit 5 gadget "ports".

This driver adds support for the full functionality, emulating the hub standard requests and exposing 5 UDC gadget drivers corresponding to the ports.

The hub itself has HW provided dedicated EP0 and EP1 (the latter for hub interrupts). It also has dedicated EP0s for each function. For other endpoints, there's a pool of 15 "generic" endpoints that are shared among the ports.

The driver relies on my previous patch adding a "dispose" EP op to handle EP allocation between ports. EPs are allocated from the shared pool in the UDC "match_ep" callback and assigned to the UDC instance (added to the gadget ep_list).

When the composite driver gets unbound, the new hook will allow the UDC to clean things up and return those EPs to the shared pool.

---
v4. - Fix missing unlock ast_vhub_udc_wakeup() error path
- Make "irq" signed to deal with error from platform_get_irq
- Fix Makefile for module builds
- Fix a missing endian conversion

v3. - Rebased
- Add clk stuff

v2. - Cosmetic fixes
- Properly "allocate" device addresses instead of using a never reset counter
- Move .dtsi updates to a different patch

foo

goo

---
 drivers/usb/gadget/udc/Kconfig              |   2 +
 drivers/usb/gadget/udc/Makefile             |   1 +
 drivers/usb/gadget/udc/aspeed-vhub/Kconfig  |   6 +
 drivers/usb/gadget/udc/aspeed-vhub/Makefile |   3 +
 drivers/usb/gadget/udc/aspeed-vhub/core.c   | 429 ++++++++++++++
 drivers/usb/gadget/udc/aspeed-vhub/dev.c    | 580 +++++++++++++++++++
 drivers/usb/gadget/udc/aspeed-vhub/ep0.c    | 474 ++++++++++++++++
 drivers/usb/gadget/udc/aspeed-vhub/epn.c    | 840 ++++++++++++++++++++++++++++
 drivers/usb/gadget/udc/aspeed-vhub/hub.c    | 822 +++++++++++++++++++++++++++
 drivers/usb/gadget/udc/aspeed-vhub/vhub.h   | 496 ++++++++++++++++
 10 files changed, 3653 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/Kconfig
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/Makefile
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/core.c
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/dev.c
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/ep0.c
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/epn.c
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/hub.c
 create mode 100644 drivers/usb/gadget/udc/aspeed-vhub/vhub.h
drivers/usb/gadget/udc/Kconfig +2 -0
index 1e9567091d86..14cf31a2703a 100644
@@ -439,6 +439,8 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
+source "drivers/usb/gadget/udc/aspeed-vhub/Kconfig"
+
 #
 # LAST -- dummy/emulated controller
 #
drivers/usb/gadget/udc/Makefile +1 -0
index ce865b129fd6..897f648f3cf1 100644
@@ -39,4 +39,5 @@ obj-$(CONFIG_USB_MV_U3D)	+= mv_u3d_core.o
 obj-$(CONFIG_USB_GR_UDC)	+= gr_udc.o
 obj-$(CONFIG_USB_GADGET_XILINX)	+= udc-xilinx.o
 obj-$(CONFIG_USB_SNP_UDC_PLAT) += snps_udc_plat.o
+obj-$(CONFIG_USB_ASPEED_VHUB)	+= aspeed-vhub/
 obj-$(CONFIG_USB_BDC_UDC)	+= bdc/
drivers/usb/gadget/udc/aspeed-vhub/Kconfig new file +6 -0
new file mode 100644
index 000000000000..cb022c885425
@@ -0,0 +1,6 @@
+config USB_ASPEED_VHUB
+	tristate "Aspeed vHub UDC driver"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	help
+	  USB peripheral controller for the Aspeed AST2500 family
+	  SoCs supporting the "vHub" functionality and USB2.0
drivers/usb/gadget/udc/aspeed-vhub/Makefile new file +3 -0
new file mode 100644
index 000000000000..4256266c0a8a
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USB_ASPEED_VHUB)	+= aspeed-vhub.o
+aspeed-vhub-y	:= core.o ep0.o epn.o dev.o hub.o
+
drivers/usb/gadget/udc/aspeed-vhub/core.c new file +429 -0

429 lines not on this page · raw message

drivers/usb/gadget/udc/aspeed-vhub/dev.c new file +580 -0

580 lines not on this page · raw message

drivers/usb/gadget/udc/aspeed-vhub/ep0.c new file +474 -0

474 lines not on this page · raw message

drivers/usb/gadget/udc/aspeed-vhub/epn.c new file +840 -0

840 lines not on this page · raw message

drivers/usb/gadget/udc/aspeed-vhub/hub.c new file +822 -0

655 lines not on this page · raw message

drivers/usb/gadget/udc/aspeed-vhub/vhub.h new file +496 -0

496 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.