From: Peter Mamonov
Here is a UHCI driver ported from the u-boot.
There are a few pending FIXMEs, but the driver should work.
Can anyone test it?
BINDING:
uhci: uhci@ {
compatible = "generic-uhci";
reg = <0x 0x200>;
/* specify companion EHCI controller if any */
companion = <>;
};
Signed-off-by: Peter Mamonov
---
drivers/usb/host/Kconfig|4 +
drivers/usb/host/Makefile |1 +
drivers/usb/host/uhci-hcd.c | 1336 +++
drivers/usb/host/uhci-hcd.h | 165 ++
4 files changed, 1506 insertions(+)
create mode 100644 drivers/usb/host/uhci-hcd.c
create mode 100644 drivers/usb/host/uhci-hcd.h
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 54eaf46..61d981e 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -1,3 +1,7 @@
+config USB_UHCI
+ bool "UHCI driver"
+ depends on HAS_DMA
+
config USB_EHCI
bool "EHCI driver"
depends on HAS_DMA
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 0478d34..628ba61 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_USB_UHCI) += uhci-hcd.o
obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
obj-$(CONFIG_USB_EHCI_OMAP)+= ehci-omap.o
obj-$(CONFIG_USB_EHCI_ATMEL) += ehci-atmel.o
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
new file mode 100644
index 000..cabd783
--- /dev/null
+++ b/drivers/usb/host/uhci-hcd.c
@@ -0,0 +1,1336 @@
+/*
+ * Part of this code has been derived from linux:
+ * Universal Host Controller Interface driver for USB (take II).
+ *
+ * (c) 1999-2001 Georg Acher, ac...@in.tum.de (executive slave) (base guitar)
+ * Deti Fliegl, d...@fliegl.de (executive slave) (lead voice)
+ * Thomas Sailer, sai...@ife.ee.ethz.ch (chief consultant) (cheer
+ * leader)
+ * Roman Weissgaerber, wei...@vienna.at (virt root hub) (studio
+ * porter)
+ * (c) 2000 Yggdrasil Computing, Inc. (port of new PCI interface support
+ * from usb-ohci.c by Adam Richter, a...@yggdrasil.com).
+ * (C) 2000 David Brownell, davi...@pacbell.net (usb-ohci.c)
+ *
+ * HW-initalization based on material of
+ *
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999 Johannes Erdfelt
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Gregory P. Smith
+ *
+ *
+ * Adapted for U-Boot:
+ * (C) Copyright 2001 Denis Peter, MPL AG Switzerland
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/**
+ * How it works:
+ * -
+ * The framelist / Transfer descriptor / Queue Heads are similar like
+ * in the linux usb_uhci.c.
+ *
+ * During initialization, the following skeleton is allocated in init_skel:
+ *
+ * framespecific | common chain
+ *
+ * framelist[]
+ * [ 0 ]-> TD -\
+ * [ 1 ]-> TD --> TD --> QH ---> QH ---> QH ---> NULL
+ * ...TD -/
+ * [1023]-> TD /
+ *
+ * ^^ ^^ ^^ ^^ ^^
+ * 7 TDs for 1 TD for Start ofStart ofEnd Chain
+ * INT (2-128ms) 1ms-INTCTRL Chain BULK Chain
+ *
+ *
+ * Since this is a bootloader, the isochronous transfer descriptor have been
+ * removed.
+ *
+ * Interrupt Transfers.
+ *
+ * For Interrupt transfers USB_MAX_TEMP_INT_TD Transfer descriptor are
+ * available. They will be inserted after the appropriate (depending the
+ * interval setting) skeleton TD. If an interrupt has been detected the
+ * dev->irqhandler is called. The status and number of transfered bytes is
+ * stored in dev->irq_status resp. dev->irq_act_len. If the dev->irqhandler
+ * returns 0, the interrupt TD is removed and disabled. If an 1 is returned,
the
+ * interrupt TD will be reactivated.
+ *
+ * Control Transfers
+ * -
+ * Control Transfers are issued by filling the tmp_td with the appropriate data
+ * and connect them to the qh_cntrl queue header. Before other control/bulk
+ * transfers can be issued, the programm has to wait for completion. This does
+ * not allows asynchronous data transfer.
+ *
+ * Bulk Transfers
+ * --
+ * Bulk Transfers are issued by filling the tmp_td with the appropriate data
and
+ * connect them to the qh_bulk queue header. Before other control/bulk
transfers
+ * can be issued, the programm has to wait for completion. This does not allows
+ * asynchronous data transfer.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "uhci-hcd.h"
+
+/* number of temporary TDs for bulk and control transfers */
+#define USB_MAX_TEMP_TD 128
+/* number of temporary TDs for