[PATCH 0/3] Patches to support QE USB Host Controller

Previous thread: Re: ACPI "Soft-off" power button only rebooting system, not powering off by Bodo Eggert on Thursday, September 18, 2008 - 8:04 am. (1 message)

Next thread: [PATCH] rfkill: clarify usage of rfkill_force_state() and rfkill->get_state() by Henrique de Moraes Holschuh on Thursday, September 18, 2008 - 8:19 am. (8 messages)
From: Anton Vorontsov
Date: Thursday, September 18, 2008 - 8:16 am

Hi all,

More than a month has passed since the first post. Unfortunately
David didn't comment on the "1/3" patch, and Greg said that he
have to wait for it...

(Laurent Pinchart also said that he is interested in the first
patch, so here are at least two users for that call.)

So I'm reposting this again. The first patch has changed in a way
that now it exports gpio_desc instead of just a function, this keeps
the gpiolib code optimized.

Previous patchset and discussion can be found here:

http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-08/msg03687.html


Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
--

From: Anton Vorontsov
Date: Thursday, September 18, 2008 - 8:17 am

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.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/gpio/gpiolib.c     |   16 ++--------------
 include/asm-generic/gpio.h |   17 +++++++++++++++++
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8d29405..fb36a90 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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)
 {
diff --git a/include/asm-generic/gpio.h ...
From: Anton Vorontsov
Date: Thursday, September 18, 2008 - 8:17 am

qe_gpio_set_dedicated() is a platform specific function, which is used
to revert a pin to a dedicated function. Caller should have already
obtained the gpio via gpio_request().

This is needed to support Freescale USB Host Controller.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 arch/powerpc/include/asm/qe.h     |    1 +
 arch/powerpc/sysdev/qe_lib/gpio.c |   46 +++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/qe.h b/arch/powerpc/include/asm/qe.h
index edee15d..c926147 100644
--- a/arch/powerpc/include/asm/qe.h
+++ b/arch/powerpc/include/asm/qe.h
@@ -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);
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
index 8e5a0bc..bd7278f 100644
--- a/arch/powerpc/sysdev/qe_lib/gpio.c
+++ b/arch/powerpc/sysdev/qe_lib/gpio.c
@@ -26,6 +26,9 @@ struct qe_gpio_chip {
 
 	/* shadowed data register to clear/set bits safely */
 	u32 cpdata;
+
+	/* saved_regs used to restore dedicated functions */
+	struct qe_pio_regs saved_regs;
 };
 
 static inline struct qe_gpio_chip *
@@ -40,6 +43,12 @@ static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc)
 	struct qe_pio_regs __iomem *regs = mm_gc->regs;
 
 	qe_gc->cpdata = in_be32(&regs->cpdata);
+	qe_gc->saved_regs.cpdata = qe_gc->cpdata;
+	qe_gc->saved_regs.cpdir1 = in_be32(&regs->cpdir1);
+	qe_gc->saved_regs.cpdir2 = in_be32(&regs->cpdir2);
+	qe_gc->saved_regs.cppar1 = in_be32(&regs->cppar1);
+	qe_gc->saved_regs.cppar2 = in_be32(&regs->cppar2);
+	qe_gc->saved_regs.cpodr = in_be32(&regs->cpodr);
 }
 
 static ...
From: Anton Vorontsov
Date: Thursday, September 18, 2008 - 8:17 am

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.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/usb/Makefile          |    1 +
 drivers/usb/host/Kconfig      |   17 +
 drivers/usb/host/Makefile     |    1 +
 drivers/usb/host/fhci-cq.c    |  105 +++++
 drivers/usb/host/fhci-dbg.c   |  144 +++++++
 drivers/usb/host/fhci-hcd.c   |  798 +++++++++++++++++++++++++++++++++++++
 drivers/usb/host/fhci-hub.c   |  338 ++++++++++++++++
 drivers/usb/host/fhci-mem.c   |  105 +++++
 drivers/usb/host/fhci-q.c     |  242 ++++++++++++
 drivers/usb/host/fhci-sched.c |  866 +++++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/fhci-tds.c   |  633 ++++++++++++++++++++++++++++++
 drivers/usb/host/fhci.h       |  526 +++++++++++++++++++++++++
 12 files changed, 3776 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/host/fhci-cq.c
 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

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index a419c42..7b14564 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -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/
 ...
From: Andrew Morton
Date: Friday, September 19, 2008 - 4:23 pm

On Thu, 18 Sep 2008 19:17:46 +0400




hack, gack, nack.

We know that USB likes to prevertedly #include C files all over the
place, but this doesn't mean that it's a sane, tasteful or desirable
thing to do.

I stopped looking there.  Guys - get a grip :(
--

From: Anton Vorontsov
Date: Tuesday, September 23, 2008 - 11:31 am

Heh. I changed this to kfifo, though I don't quite like it,
since it feels heavy to hold mere pointers...


Hm. I fixed this, but for lengthy drivers, where we want split the
driver in multiple logical files, this sometimes makes sense (for
example, we don't need externed functions. plus gcc automatically
might inline some of them, etc).


Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
--

From: Anton Vorontsov
Date: Tuesday, September 23, 2008 - 11:32 am

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

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/usb/core/hcd.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index e710ce0..66b64d7 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -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 */
-- 
1.5.6.3

--

From: Anton Vorontsov
Date: Tuesday, September 23, 2008 - 11:32 am

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.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 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   |  789 ++++++++++++++++++++++++++++++++++++
 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 |  889 +++++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/fhci-tds.c   |  626 +++++++++++++++++++++++++++++
 drivers/usb/host/fhci.h       |  597 +++++++++++++++++++++++++++
 11 files changed, 3807 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

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index a419c42..7b14564 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -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/
 
diff --git a/drivers/usb/host/Kconfig ...
From: Sergei Shtylyov
Date: Tuesday, September 23, 2008 - 2:32 pm

Hello.


   No one-port hubs I guess -- they are pointless. Though e.g. MUSB 
driver creates one -- I guess to impersonate a transaction translating 
high-speed hub...

WBR, Sergei


--

From: Sergei Shtylyov
Date: Tuesday, September 23, 2008 - 2:35 pm

... then the root hub emulation is completely pointless.

WBR, Sergei


--

From: Anton Vorontsov
Date: Tuesday, September 23, 2008 - 3:57 pm

On Wed, Sep 24, 2008 at 01:35:41AM +0400, Sergei Shtylyov wrote:

It isn't. We always should emulate the root hub. The root hub
is part and parcel of any USB Host. Even the one-port one.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
--

From: Sergei Shtylyov
Date: Wednesday, September 24, 2008 - 3:24 am

Hello.


   Hm, maybe that's what USB core thinks (because UHCI/OHCI/EHCI all 
have it) but e.g. MUSB doesn't have the root hub registers...
I looked at the core and figured that USB core seems to use the root hub 
interface for port PM, etc. and expects it to bee present, so it seems 
unavoidable indeed... :-/

WBR, Sergei


--

From: Sergei Shtylyov
Date: Wednesday, September 24, 2008 - 3:48 am

Oops, I stand corrected. Even USB 1.1 specifies that it must be a 
part the host...

WBR, Sergei


--

From: David Brownell
Date: Wednesday, September 24, 2008 - 11:59 am

Only the OHCI registers have bit positions matching what the USB
spec says for hub status bits.  Everything else, including musb_hdrc,

Or more fundamentally:  for enumeration.  "Unavoidable" is correct.  ;)

--

From: Sergei Shtylyov
Date: Wednesday, September 24, 2008 - 12:17 pm

Hello.



    Yes, but I thought that if there are no multiple ports, having the hub is 

    Not sure what you mean here but I guess having a root hub alows an uniform 
model of controlling the ports... anyway, USB specifies that it must be 
present in the host.

WBR, Sergei
--

Previous thread: Re: ACPI "Soft-off" power button only rebooting system, not powering off by Bodo Eggert on Thursday, September 18, 2008 - 8:04 am. (1 message)

Next thread: [PATCH] rfkill: clarify usage of rfkill_force_state() and rfkill->get_state() by Henrique de Moraes Holschuh on Thursday, September 18, 2008 - 8:19 am. (8 messages)