Skip to contentSkip to conversation

FHCI USB Host support patches

PATCH In review Anton Vorontsov 2 participants 6 messages Sep 24, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover FHCI USB Host support patches

Hi all,

Thanks for the comments on the previous version, here is the updated patch set, v3:

- use list_for_each*() where appropriate;
- improve error checking in the fhci_start();
- improve qe_gpio_set_dedicated patch's description.

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#1 lore raw

PATCH v3 1/4 gpiolib: make gpio_to_chip() public

We'll need this function to write platform-specific hooks to deal with pin's dedicated functions. Quite obviously this will work only for the platforms with 1-to-1 GPIO to PIN mapping.

This is stopgap solution till we think out and implement a proper api (pinlib?).

p.s. This patch actually exports gpio_desc and places gpio_to_chip into the asm-generic/gpio.h as `static inline'. This is needed to not cause function calls for this trivial translation.

Also, the patch does not export FLAG_*s... the names are too generic, and nobody is using them outside of gpiolib.c.

---
 drivers/gpio/gpiolib.c     |   16 ++--------------
 include/asm-generic/gpio.h |   17 +++++++++++++++++
 2 files changed, 19 insertions(+), 14 deletions(-)
drivers/gpio/gpiolib.c +2 -14
index 8d29405..fb36a90 100644
@@ -40,9 +40,6 @@
  */
 static DEFINE_SPINLOCK(gpio_lock);
 
-struct gpio_desc {
-	struct gpio_chip	*chip;
-	unsigned long		flags;
 /* flag symbols are bit numbers */
 #define FLAG_REQUESTED	0
 #define FLAG_IS_OUT	1
@@ -50,11 +47,8 @@ struct gpio_desc {
 #define FLAG_EXPORT	3	/* protected by sysfs_lock */
 #define FLAG_SYSFS	4	/* exported via /sys/class/gpio/control */
 
-#ifdef CONFIG_DEBUG_FS
-	const char		*label;
-#endif
-};
-static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
+struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
+EXPORT_SYMBOL_GPL(gpio_desc);
 
 static inline void desc_set_label(struct gpio_desc *d, const char *label)
 {
@@ -80,12 +74,6 @@ static void gpio_ensure_requested(struct gpio_desc *desc)
 	}
 }
 
-/* caller holds gpio_lock *OR* gpio is marked as requested */
-static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
-{
-	return gpio_desc[gpio].chip;
-}
-
 /* dynamic allocation of GPIOs, e.g. on a hotplugged device */
 static int gpiochip_find_base(int ngpio)
 {
include/asm-generic/gpio.h +17 -0
index 0f99ad3..88962f0 100644
@@ -81,6 +81,23 @@ struct gpio_chip {
 	unsigned		exported:1;
 };
 
+struct gpio_desc {
+	struct gpio_chip	*chip;
+	unsigned long		flags;
+
+#ifdef CONFIG_DEBUG_FS
+	const char		*label;
+#endif
+};
+
+extern struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
+
+/* caller holds gpio_lock *OR* gpio is marked as requested */
+static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
+{
+	return gpio_desc[gpio].chip;
+}
+
 extern const char *gpiochip_is_requested(struct gpio_chip *chip,
 			unsigned offset);
 extern int __must_check gpiochip_reserve(int start, int ngpio);
Signature · 1 line
1.5.6.3
#2 lore raw

Re: [PATCH 1/4] gpiolib: make gpio_to_chip() public

Quoted 7 lines · Anton Vorontsov

We'll need this function to write platform-specific hooks to deal with pin's dedicated functions. Quite obviously this will work only for the platforms with 1-to-1 GPIO to PIN mapping.

This is stopgap solution till we think out and implement a proper api (pinlib?).

Quoted 6 lines

p.s. This patch actually exports gpio_desc and places gpio_to_chip into the asm-generic/gpio.h as `static inline'. This is needed to not cause function calls for this trivial translation.

Also, the patch does not export FLAG_*s... the names are too generic, and nobody is using them outside of gpiolib.c.

For the record: NAK, still. The concept has problems, there is no "need" for this. I sketched a cleaner way to address the issues of the QE USB driver; I'm sure it would only take an hour or two to code, using what's already present.

And if I were to approve something like this it would be a lot simpler, not exposing internals, and with appropriate kerneldoc. Simpler such as

	struct gpio_chip *gpio_to_gpiochip(unsigned gpio)
	{
		return gpio_to_chip(gpio);
	}
	EXPORT_SYMBOL_NOTREALLY(gpio_to_gpiochip);

with a declaration in a header. It's not like THIS version would be performance-critical (unlike the one inside gpiolib).

- Dave

#3 lore raw

PATCH v3 2/4 powerpc/qe: new call to revert a gpio to a dedicated function

In reply to Anton Vorontsov

qe_gpio_set_dedicated() is a platform specific function that is used to revert a pin to a dedicated on chip peripheral function. Caller should have already obtained the gpio via gpio_request().

This is needed to support Freescale USB Host Controller.

---
 arch/powerpc/include/asm/qe.h     |    1 +
 arch/powerpc/sysdev/qe_lib/gpio.c |   46 +++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/qe.h +1 -0
index edee15d..c926147 100644
@@ -111,6 +111,7 @@ extern void __par_io_config_pin(struct qe_pio_regs __iomem *par_io, u8 pin,
 extern int par_io_config_pin(u8 port, u8 pin, int dir, int open_drain,
 			     int assignment, int has_irq);
 extern int par_io_data_set(u8 port, u8 pin, u8 val);
+extern int qe_gpio_set_dedicated(unsigned int gpio);
 
 /* QE internal API */
 int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input);
arch/powerpc/sysdev/qe_lib/gpio.c +46 -0

64 lines not on this page · raw message

Signature · 1 line
1.5.6.3
#4 lore raw

PATCH v3 3/4 USB: Protect hcd.h from multiple inclusions

In reply to Anton Vorontsov

This will let us use this header in other header files. Will be needed for the FHCI USB Host driver.

---
 drivers/usb/core/hcd.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/usb/core/hcd.h +4 -0
index e710ce0..66b64d7 100644
@@ -16,6 +16,8 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#ifndef __USB_CORE_HCD_H
+#define __USB_CORE_HCD_H
 
 #ifdef __KERNEL__
 
@@ -483,3 +485,5 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
 extern struct rw_semaphore ehci_cf_port_reset_rwsem;
 
 #endif /* __KERNEL__ */
+
+#endif /* __USB_CORE_HCD_H */
Signature · 1 line
1.5.6.3
#5 lore raw

PATCH v3 4/4 USB: driver for Freescale QUICC Engine USB Host Controller

In reply to Anton Vorontsov

This patch adds support for the FHCI USB controller, as found in the Freescale MPC836x and MPC832x processors. It can support Full or Low speed modes.

Quite a lot the hardware is doing by itself (SOF generation, CRC generation and checking), though scheduling and retransmission is on software's shoulders.

This controller does not integrate the root hub, so this driver also fakes one-port hub. External hub is required to support more than one device.

---
 drivers/usb/Makefile          |    1 +
 drivers/usb/host/Kconfig      |   17 +
 drivers/usb/host/Makefile     |    8 +
 drivers/usb/host/fhci-dbg.c   |  139 +++++++
 drivers/usb/host/fhci-hcd.c   |  793 ++++++++++++++++++++++++++++++++++++
 drivers/usb/host/fhci-hub.c   |  349 ++++++++++++++++
 drivers/usb/host/fhci-mem.c   |  112 ++++++
 drivers/usb/host/fhci-q.c     |  280 +++++++++++++
 drivers/usb/host/fhci-sched.c |  887 +++++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/fhci-tds.c   |  626 +++++++++++++++++++++++++++++
 drivers/usb/host/fhci.h       |  597 +++++++++++++++++++++++++++
 11 files changed, 3809 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/host/fhci-dbg.c
 create mode 100644 drivers/usb/host/fhci-hcd.c
 create mode 100644 drivers/usb/host/fhci-hub.c
 create mode 100644 drivers/usb/host/fhci-mem.c
 create mode 100644 drivers/usb/host/fhci-q.c
 create mode 100644 drivers/usb/host/fhci-sched.c
 create mode 100644 drivers/usb/host/fhci-tds.c
 create mode 100644 drivers/usb/host/fhci.h
drivers/usb/Makefile +1 -0
index a419c42..7b14564 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_USB_UHCI_HCD)	+= host/
 obj-$(CONFIG_USB_SL811_HCD)	+= host/
 obj-$(CONFIG_USB_U132_HCD)	+= host/
 obj-$(CONFIG_USB_R8A66597_HCD)	+= host/
+obj-$(CONFIG_USB_FHCI_HCD)	+= host/
 
 obj-$(CONFIG_USB_C67X00_HCD)	+= c67x00/
 
drivers/usb/host/Kconfig +17 -0
index 228797e..594c263 100644
@@ -305,3 +305,20 @@ config SUPERH_ON_CHIP_R8A66597
 	help
 	   This driver enables support for the on-chip R8A66597 in the
 	   SH7366 and SH7723 processors.
+
+config USB_FHCI_HCD
+	tristate "Freescale QE USB Host Controller support"
+	depends on USB && OF_GPIO && QUICC_ENGINE
+	select FSL_GTM
+	select QE_USB
+	help
+	  This driver enables support for Freescale QE USB Host Controller
+	  (as found on MPC8360 and MPC8323 processors), the driver supports
+	  Full and Low Speed USB.
+
+config FHCI_DEBUG
+	bool "Freescale QE USB Host Controller debug support"
+	depends on USB_FHCI_HCD && DEBUG_FS
+	help
+	  Say "y" to see some FHCI debug information and statistics
+	  throught debugfs.
drivers/usb/host/Makefile +8 -0
index f1edda2..2e1eaa7 100644
@@ -8,6 +8,13 @@ endif
 
 isp1760-objs := isp1760-hcd.o isp1760-if.o
 
+fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
+	     fhci-tds.o fhci-sched.o
+
+ifeq ($(CONFIG_FHCI_DEBUG),y)
+fhci-objs += fhci-dbg.o
+endif
+
 obj-$(CONFIG_PCI)		+= pci-quirks.o
 
 obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
@@ -19,3 +26,4 @@ obj-$(CONFIG_USB_SL811_CS)	+= sl811_cs.o
 obj-$(CONFIG_USB_U132_HCD)	+= u132-hcd.o
 obj-$(CONFIG_USB_R8A66597_HCD)	+= r8a66597-hcd.o
 obj-$(CONFIG_USB_ISP1760_HCD)	+= isp1760.o
+obj-$(CONFIG_USB_FHCI_HCD)	+= fhci.o
drivers/usb/host/fhci-dbg.c new file +139 -0

139 lines not on this page · raw message

drivers/usb/host/fhci-hcd.c new file +793 -0

793 lines not on this page · raw message

drivers/usb/host/fhci-hub.c new file +349 -0

349 lines not on this page · raw message

drivers/usb/host/fhci-mem.c new file +112 -0

112 lines not on this page · raw message

drivers/usb/host/fhci-q.c new file +280 -0

280 lines not on this page · raw message

drivers/usb/host/fhci-sched.c new file +887 -0

887 lines not on this page · raw message

drivers/usb/host/fhci-tds.c new file +626 -0

396 lines not on this page · raw message

drivers/usb/host/fhci.h new file +597 -0

597 lines not on this page · raw message

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

Signature · 1 line
1.5.6.3

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