I need to implement support for the on-chip EHCI HCD on the Intel IXP46x
NPU and being on-chip, it is clearly !PCI. The existing EHCI code ties
the bus glue and core together and makes it rather difficult to add
a non-PCI HCD underneath. This patch attempts to get around this by 
creating a new ehci-pci module that hooks into the EHCI core via 
appropriate glue functions and also cleans up the debug support code
while at it. We also export the ehci_tdi_reset() function as the
IXP46x is basically a TDI implementation attached to the CPU bus
(oh and it is the wrong endianess, but we won't go there yet).

Signed-off-by: Deepak Saxena <[EMAIL PROTECTED]>

---

Greg, 

Please apply or comment on needed changes.

Index: linux-2.6-ixp2350/drivers/usb/host/Kconfig
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/Kconfig
+++ linux-2.6-ixp2350/drivers/usb/host/Kconfig
@@ -6,7 +6,7 @@ comment "USB Host Controller Drivers"
 
 config USB_EHCI_HCD
        tristate "EHCI HCD (USB 2.0) support"
-       depends on USB && PCI
+       depends on USB
        ---help---
          The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
          "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
@@ -29,6 +29,19 @@ config USB_EHCI_HCD
          To compile this driver as a module, choose M here: the
          module will be called ehci-hcd.
 
+config USB_EHCI_HCD_PCI
+       tristate "EHCI controller on PCI bus"
+       depends on USB_EHCI_HCD && PCI
+       ---help---
+         Enable this option if your USB2.0 controller is on the PCI bus.
+         This is the most common configuration found on all PCs, Apple
+         machines, and various other systems. You most probably want to
+         say yes here unless you are running an embedded system with
+         a non-PCI EHCI controller.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ehci-pci.
+
 config USB_EHCI_SPLIT_ISO
        bool "Full speed ISO transactions (EXPERIMENTAL)"
        depends on USB_EHCI_HCD && EXPERIMENTAL
Index: linux-2.6-ixp2350/drivers/usb/host/Makefile
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/Makefile
+++ linux-2.6-ixp2350/drivers/usb/host/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_PCI)              += pci-quirks.o
 
 obj-$(CONFIG_USB_EHCI_HCD)     += ehci-hcd.o
+obj-$(CONFIG_USB_EHCI_HCD_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD)     += ohci-hcd.o
 obj-$(CONFIG_USB_UHCI_HCD)     += uhci-hcd.o
Index: linux-2.6-ixp2350/drivers/usb/host/ehci-hcd.c
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/ehci-hcd.c
+++ linux-2.6-ixp2350/drivers/usb/host/ehci-hcd.c
@@ -17,17 +17,11 @@
  */
 
 #include <linux/config.h>
-
-#ifdef CONFIG_USB_DEBUG
-       #define DEBUG
-#else
-       #undef DEBUG
-#endif
-
 #include <linux/module.h>
-#include <linux/pci.h>
+#include <linux/device.h>
 #include <linux/dmapool.h>
 #include <linux/kernel.h>
+#include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/sched.h>
@@ -101,10 +95,6 @@
 #define DRIVER_AUTHOR "David Brownell"
 #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
 
-static const char      hcd_name [] = "ehci_hcd";
-
-
-#undef EHCI_VERBOSE_DEBUG
 #undef EHCI_URB_TRACE
 
 #ifdef DEBUG
@@ -178,7 +168,7 @@ static int handshake (void __iomem *ptr,
 }
 
 /* force HC to halt state from unknown (EHCI spec section 2.3) */
-static int ehci_halt (struct ehci_hcd *ehci)
+int ehci_halt (struct ehci_hcd *ehci)
 {
        u32     temp = readl (&ehci->regs->status);
 
@@ -195,7 +185,7 @@ static int ehci_halt (struct ehci_hcd *e
 }
 
 /* put TDI/ARC silicon into EHCI mode */
-static void tdi_reset (struct ehci_hcd *ehci)
+void ehci_tdi_reset (struct ehci_hcd *ehci)
 {
        u32 __iomem     *reg_ptr;
        u32             tmp;
@@ -207,13 +197,13 @@ static void tdi_reset (struct ehci_hcd *
 }
 
 /* reset a non-running (STS_HALT == 1) controller */
-static int ehci_reset (struct ehci_hcd *ehci)
+int ehci_reset (struct ehci_hcd *ehci)
 {
        int     retval;
        u32     command = readl (&ehci->regs->command);
 
        command |= CMD_RESET;
-       dbg_cmd (ehci, "reset", command);
+       ehci_dbg_cmd (ehci, "reset", command);
        writel (command, &ehci->regs->command);
        ehci_to_hcd(ehci)->state = HC_STATE_HALT;
        ehci->next_statechange = jiffies;
@@ -223,7 +213,7 @@ static int ehci_reset (struct ehci_hcd *
                return retval;
 
        if (ehci_is_TDI(ehci))
-               tdi_reset (ehci);
+               ehci_tdi_reset (ehci);
 
        return retval;
 }
@@ -262,8 +252,6 @@ static void ehci_quiesce (struct ehci_hc
 
 /*-------------------------------------------------------------------------*/
 
-static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
-
 #include "ehci-hub.c"
 #include "ehci-mem.c"
 #include "ehci-q.c"
@@ -317,7 +305,7 @@ ehci_reboot (struct notifier_block *self
        return 0;
 }
 
-static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
+void ehci_port_power (struct ehci_hcd *ehci, int is_on)
 {
        unsigned port;
 
@@ -339,7 +327,7 @@ static void ehci_port_power (struct ehci
  * ehci_work is called from some interrupts, timers, and so on.
  * it calls driver completion functions, after dropping ehci->lock.
  */
-static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
+void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
 {
        timer_action_done (ehci, TIMER_IO_WATCHDOG);
        if (ehci->reclaim_ready)
@@ -367,7 +355,7 @@ static void ehci_work (struct ehci_hcd *
                timer_action (ehci, TIMER_IO_WATCHDOG);
 }
 
-static void ehci_stop (struct usb_hcd *hcd)
+void ehci_stop (struct usb_hcd *hcd)
 {
        struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
 
@@ -408,11 +396,11 @@ static void ehci_stop (struct usb_hcd *h
                ehci->stats.complete, ehci->stats.unlink);
 #endif
 
-       dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
+       ehci_dbg_status (ehci, "ehci_stop completed", readl 
(&ehci->regs->status));
 }
 
 /* one-time init, only for memory state */
-static int ehci_init(struct usb_hcd *hcd)
+int ehci_init(struct usb_hcd *hcd)
 {
        struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        u32                     temp;
@@ -498,7 +486,7 @@ static int ehci_init(struct usb_hcd *hcd
 }
 
 /* start HC running; it's halted, ehci_init() has been run (once) */
-static int ehci_run (struct usb_hcd *hcd)
+int ehci_run (struct usb_hcd *hcd)
 {
        struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
        int                     retval;
@@ -542,7 +530,7 @@ static int ehci_run (struct usb_hcd *hcd
        ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
        ehci->command |= CMD_RUN;
        writel (ehci->command, &ehci->regs->command);
-       dbg_cmd (ehci, "init", ehci->command);
+       ehci_dbg_cmd (ehci, "init", ehci->command);
 
        /*
         * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
@@ -600,9 +588,9 @@ static irqreturn_t ehci_irq (struct usb_
        readl (&ehci->regs->command);   /* unblock posted write */
        bh = 0;
 
-#ifdef EHCI_VERBOSE_DEBUG
+#ifdef CONFIG_EHCI_VERBOSE_DEBUG
        /* unrequested/ignored: Frame List Rollover */
-       dbg_status (ehci, "irq", status);
+       ehci_dbg_status (ehci, "irq", status);
 #endif
 
        /* INT, ERR, and IAA interrupt rates can be throttled */
@@ -654,8 +642,8 @@ static irqreturn_t ehci_irq (struct usb_
        if (unlikely ((status & STS_FATAL) != 0)) {
                /* bogus "fatal" IRQs appear on some chips... why?  */
                status = readl (&ehci->regs->status);
-               dbg_cmd (ehci, "fatal", readl (&ehci->regs->command));
-               dbg_status (ehci, "fatal", status);
+               ehci_dbg_cmd (ehci, "fatal", readl (&ehci->regs->command));
+               ehci_dbg_status (ehci, "fatal", status);
                if (status & STS_HALT) {
                        ehci_err (ehci, "fatal error\n");
 dead:
@@ -888,16 +876,59 @@ static int ehci_get_frame (struct usb_hc
 
 /*-------------------------------------------------------------------------*/
 
+/*
+ * Bus glue initialization.
+ */
+void ehci_bus_glue_init(struct hc_driver *bus_glue)
+{
+       bus_glue->product_desc  = "EHCI Host Controller",
+       bus_glue->irq           = ehci_irq;
+
+
+       /*
+        * Bus might require special glue for start/stop
+        */
+       if (!bus_glue->start)
+               bus_glue->start = ehci_run;
+
+       if (!bus_glue->stop)
+               bus_glue->stop = ehci_stop;
+
+       /*
+        * managing i/o requests and associated device resources
+        */
+       bus_glue->urb_enqueue           = ehci_urb_enqueue;
+       bus_glue->urb_dequeue           = ehci_urb_dequeue;
+       bus_glue->endpoint_disable      = ehci_endpoint_disable;
+
+       /*
+        * scheduling support
+        */
+       bus_glue->get_frame_number = ehci_get_frame;
+
+       /*
+        * root hub support
+        */
+       bus_glue->hub_status_data       = ehci_hub_status_data;
+       bus_glue->hub_control           = ehci_hub_control;
+       bus_glue->bus_suspend           = ehci_bus_suspend;
+       bus_glue->bus_resume            = ehci_bus_resume;
+}
+
+/*-------------------------------------------------------------------------*/
+
+EXPORT_SYMBOL_GPL(ehci_bus_glue_init);
+EXPORT_SYMBOL_GPL(ehci_reset);
+EXPORT_SYMBOL_GPL(ehci_halt);
+EXPORT_SYMBOL_GPL(ehci_work);
+EXPORT_SYMBOL_GPL(ehci_run);
+EXPORT_SYMBOL_GPL(ehci_stop);
+EXPORT_SYMBOL_GPL(ehci_init);
+EXPORT_SYMBOL_GPL(ehci_tdi_reset);
+
 #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
 
 MODULE_DESCRIPTION (DRIVER_INFO);
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_LICENSE ("GPL");
 
-#ifdef CONFIG_PCI
-#include "ehci-pci.c"
-#endif
-
-#if !defined(CONFIG_PCI)
-#error "missing bus glue for ehci-hcd"
-#endif
Index: linux-2.6-ixp2350/drivers/usb/host/ehci-pci.c
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/ehci-pci.c
+++ linux-2.6-ixp2350/drivers/usb/host/ehci-pci.c
@@ -18,11 +18,35 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifndef CONFIG_PCI
-#error "This file is PCI bus glue.  CONFIG_PCI must be defined."
-#endif
-
-/*-------------------------------------------------------------------------*/
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/compiler.h>
+#include <linux/pci.h>
+#include <linux/dmapool.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/smp_lock.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/reboot.h>
+#include <linux/usb.h>
+#include <linux/moduleparam.h>
+#include <linux/dma-mapping.h>
+
+#include "../core/hcd.h"
+#include "ehci.h"
+
+#include <asm/byteorder.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/unaligned.h>
 
 /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
  * off the controller (maybe it can boot from highspeed USB disks).
@@ -131,8 +155,8 @@ static int ehci_pci_setup(struct usb_hcd
 
        ehci->caps = hcd->regs;
        ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
-       dbg_hcs_params(ehci, "reset");
-       dbg_hcc_params(ehci, "reset");
+       ehci_dbg_hcs_params(ehci, "reset");
+       ehci_dbg_hcc_params(ehci, "reset");
 
        /* cache this readonly data; minimize chip reads */
        ehci->hcs_params = readl(&ehci->caps->hcs_params);
@@ -152,7 +176,7 @@ static int ehci_pci_setup(struct usb_hcd
        case PCI_VENDOR_ID_TDI:
                if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
                        ehci->is_tdi_rh_tt = 1;
-                       tdi_reset(ehci);
+                       ehci_tdi_reset(ehci);
                }
                break;
        case PCI_VENDOR_ID_AMD:
@@ -335,47 +359,23 @@ restart:
 }
 #endif
 
-static const struct hc_driver ehci_pci_hc_driver = {
-       .description =          hcd_name,
-       .product_desc =         "EHCI Host Controller",
+static struct hc_driver ehci_pci_hc_driver = {
+       .description =          EHCI_HCD_NAME "_pci",
        .hcd_priv_size =        sizeof(struct ehci_hcd),
 
        /*
-        * generic hardware linkage
+        * PCI is memory-mapped and USB2
         */
-       .irq =                  ehci_irq,
        .flags =                HCD_MEMORY | HCD_USB2,
 
        /*
         * basic lifecycle operations
         */
        .reset =                ehci_pci_setup,
-       .start =                ehci_run,
 #ifdef CONFIG_PM
        .suspend =              ehci_pci_suspend,
        .resume =               ehci_pci_resume,
 #endif
-       .stop =                 ehci_stop,
-
-       /*
-        * managing i/o requests and associated device resources
-        */
-       .urb_enqueue =          ehci_urb_enqueue,
-       .urb_dequeue =          ehci_urb_dequeue,
-       .endpoint_disable =     ehci_endpoint_disable,
-
-       /*
-        * scheduling support
-        */
-       .get_frame_number =     ehci_get_frame,
-
-       /*
-        * root hub support
-        */
-       .hub_status_data =      ehci_hub_status_data,
-       .hub_control =          ehci_hub_control,
-       .bus_suspend =          ehci_bus_suspend,
-       .bus_resume =           ehci_bus_resume,
 };
 
 /*-------------------------------------------------------------------------*/
@@ -392,7 +392,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
 
 /* pci driver glue; this is a "new style" PCI driver module */
 static struct pci_driver ehci_pci_driver = {
-       .name =         (char *) hcd_name,
+       .name =         (char *) EHCI_HCD_NAME,
        .id_table =     pci_ids,
 
        .probe =        usb_hcd_pci_probe,
@@ -414,6 +414,7 @@ static int __init ehci_hcd_pci_init(void
                sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
                sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
 
+       ehci_bus_glue_init(&ehci_pci_hc_driver);
        return pci_register_driver(&ehci_pci_driver);
 }
 module_init(ehci_hcd_pci_init);
Index: linux-2.6-ixp2350/drivers/usb/host/ehci-dbg.c
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/ehci-dbg.c
+++ linux-2.6-ixp2350/drivers/usb/host/ehci-dbg.c
@@ -16,32 +16,13 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* this file is part of ehci-hcd.c */
-
-#define ehci_dbg(ehci, fmt, args...) \
-       dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
-#define ehci_err(ehci, fmt, args...) \
-       dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
-#define ehci_info(ehci, fmt, args...) \
-       dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
-#define ehci_warn(ehci, fmt, args...) \
-       dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
-
-#ifdef EHCI_VERBOSE_DEBUG
-#      define vdbg dbg
-#      define ehci_vdbg ehci_dbg
-#else
-#      define vdbg(fmt,args...) do { } while (0)
-#      define ehci_vdbg(ehci, fmt, args...) do { } while (0)
-#endif
-
-#ifdef DEBUG
+#ifdef DEBUG
 
 /* check the values in the HCSPARAMS register
  * (host controller _Structural_ parameters)
  * see EHCI spec, Table 2-4 for each value
  */
-static void dbg_hcs_params (struct ehci_hcd *ehci, char *label)
+static void ehci_dbg_hcs_params (struct ehci_hcd *ehci, char *label)
 {
        u32     params = readl (&ehci->caps->hcs_params);
 
@@ -73,19 +54,12 @@ static void dbg_hcs_params (struct ehci_
                                label, buf);
        }
 }
-#else
-
-static inline void dbg_hcs_params (struct ehci_hcd *ehci, char *label) {}
-
-#endif
-
-#ifdef DEBUG
 
 /* check the values in the HCCPARAMS register
  * (host controller _Capability_ parameters)
  * see EHCI Spec, Table 2-5 for each value
  * */
-static void dbg_hcc_params (struct ehci_hcd *ehci, char *label)
+static void ehci_dbg_hcc_params (struct ehci_hcd *ehci, char *label)
 {
        u32     params = readl (&ehci->caps->hcc_params);
 
@@ -107,16 +81,9 @@ static void dbg_hcc_params (struct ehci_
                     HCC_64BIT_ADDR (params) ? " 64 bit addr" : "");
        }
 }
-#else
-
-static inline void dbg_hcc_params (struct ehci_hcd *ehci, char *label) {}
-
-#endif
-
-#ifdef DEBUG
 
 static void __attribute__((__unused__))
-dbg_qtd (const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
+ehci_dbg_qtd (const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
 {
        ehci_dbg (ehci, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd,
                le32_to_cpup (&qtd->hw_next),
@@ -132,7 +99,7 @@ dbg_qtd (const char *label, struct ehci_
 }
 
 static void __attribute__((__unused__))
-dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
+ehci_dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
        ehci_dbg (ehci, "%s qh %p n%08x info %x %x qtd %x\n", label,
                qh, qh->hw_next, qh->hw_info1, qh->hw_info2,
@@ -141,7 +108,7 @@ dbg_qh (const char *label, struct ehci_h
 }
 
 static void __attribute__((__unused__))
-dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) 
+ehci_dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
 {
        ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n",
                label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb);
@@ -171,7 +138,7 @@ dbg_itd (const char *label, struct ehci_
 }
 
 static void __attribute__((__unused__))
-dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd) 
+ehci_dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd 
*sitd)
 {
        ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n",
                label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), 
sitd->urb);
@@ -185,7 +152,7 @@ dbg_sitd (const char *label, struct ehci
 }
 
 static int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
+ehci_dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
 {
        return scnprintf (buf, len,
                "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
@@ -204,7 +171,7 @@ dbg_status_buf (char *buf, unsigned len,
 }
 
 static int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
+ehci_dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
 {
        return scnprintf (buf, len,
                "%s%sintrenable %02x%s%s%s%s%s%s",
@@ -222,7 +189,7 @@ static const char *const fls_strings [] 
     { "1024", "512", "256", "??" };
 
 static int
-dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
+ehci_dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
 {
        return scnprintf (buf, len,
                "%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s",
@@ -241,7 +208,7 @@ dbg_command_buf (char *buf, unsigned len
 }
 
 static int
-dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
+ehci_dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 
status)
 {
        char    *sig;
 
@@ -271,57 +238,8 @@ dbg_port_buf (char *buf, unsigned len, c
            );
 }
 
-#else
-static inline void __attribute__((__unused__))
-dbg_qh (char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
-{}
-
-static inline int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
-{ return 0; }
-
-static inline int __attribute__((__unused__))
-dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
-{ return 0; }
-
-static inline int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
-{ return 0; }
-
-static inline int __attribute__((__unused__))
-dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
-{ return 0; }
-
-#endif /* DEBUG */
-
-/* functions have the "wrong" filename when they're output... */
-#define dbg_status(ehci, label, status) { \
-       char _buf [80]; \
-       dbg_status_buf (_buf, sizeof _buf, label, status); \
-       ehci_dbg (ehci, "%s\n", _buf); \
-}
-
-#define dbg_cmd(ehci, label, command) { \
-       char _buf [80]; \
-       dbg_command_buf (_buf, sizeof _buf, label, command); \
-       ehci_dbg (ehci, "%s\n", _buf); \
-}
-
-#define dbg_port(ehci, label, port, status) { \
-       char _buf [80]; \
-       dbg_port_buf (_buf, sizeof _buf, label, port, status); \
-       ehci_dbg (ehci, "%s\n", _buf); \
-}
-
 /*-------------------------------------------------------------------------*/
 
-#ifdef STUB_DEBUG_FILES
-
-static inline void create_debug_files (struct ehci_hcd *bus) { }
-static inline void remove_debug_files (struct ehci_hcd *bus) { }
-
-#else
-
 /* troubleshooting help: expose state in driverfs */
 
 #define speed_char(info1) ({ char tmp; \
@@ -800,5 +718,5 @@ static inline void remove_debug_files (s
        class_device_remove_file(cldev, &class_device_attr_registers);
 }
 
-#endif /* STUB_DEBUG_FILES */
+#endif /* DEBUG */
 
Index: linux-2.6-ixp2350/drivers/usb/host/ehci.h
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/ehci.h
+++ linux-2.6-ixp2350/drivers/usb/host/ehci.h
@@ -19,6 +19,8 @@
 #ifndef __LINUX_EHCI_HCD_H
 #define __LINUX_EHCI_HCD_H
 
+#define        EHCI_HCD_NAME   "ehci_hcd"
+
 /* definitions used for the EHCI driver */
 
 /* statistics can be kept for for tuning/monitoring */
@@ -110,6 +112,18 @@ static inline struct usb_hcd *ehci_to_hc
        return container_of ((void *) ehci, struct usb_hcd, hcd_priv);
 }
 
+/* magic numbers that can affect system performance */
+#define        EHCI_TUNE_CERR          3       /* 0-3 qtd retries; 0 == don't 
stop */
+#define        EHCI_TUNE_RL_HS         4       /* nak throttle; see 4.9 */
+#define        EHCI_TUNE_RL_TT         0
+#define        EHCI_TUNE_MULT_HS       1       /* 1-3 transactions/uframe; 
4.10.3 */
+#define        EHCI_TUNE_MULT_TT       1
+#define        EHCI_TUNE_FLS           2       /* (small) 256 frame schedule */
+
+#define EHCI_IAA_JIFFIES       (HZ/100)        /* arbitrary; ~10 msec */
+#define EHCI_IO_JIFFIES                (HZ/10)         /* io watchdog > 
irq_thresh */
+#define EHCI_ASYNC_JIFFIES     (HZ/20)         /* async idle timeout */
+#define EHCI_SHRINK_JIFFIES    (HZ/200)        /* async qh unlink delay */
 
 enum ehci_timer_action {
        TIMER_IO_WATCHDOG,
@@ -600,6 +614,21 @@ struct ehci_fstn {
 
 /*-------------------------------------------------------------------------*/
 
+/*
+ * Functions called by bus glue layers
+ */
+void ehci_bus_glue_init(struct hc_driver *bus_glue);
+int ehci_reset (struct ehci_hcd *ehci);
+int ehci_init(struct usb_hcd *hcd);
+int ehci_halt (struct ehci_hcd *ehci);
+void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
+int ehci_run (struct usb_hcd *hcd);
+void ehci_stop (struct usb_hcd *hcd);
+void ehci_port_power (struct ehci_hcd *ehci, int is_on);
+void ehci_tdi_reset (struct ehci_hcd *ehci);
+
+/*-------------------------------------------------------------------------*/
+
 #ifdef CONFIG_USB_EHCI_ROOT_HUB_TT
 
 /*
@@ -638,8 +667,78 @@ ehci_port_speed(struct ehci_hcd *ehci, u
 
 /*-------------------------------------------------------------------------*/
 
+#ifdef CONFIG_USB_DEBUG
+       #define DEBUG
+#else
+       #undef DEBUG
+#endif
+
+#define ehci_dbg(ehci, fmt, args...) \
+       dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
+#define ehci_err(ehci, fmt, args...) \
+       dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
+#define ehci_info(ehci, fmt, args...) \
+       dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
+#define ehci_warn(ehci, fmt, args...) \
+       dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
+
+#ifdef EHCI_VERBOSE_DEBUG
+#      define vdbg dbg
+#      define ehci_vdbg ehci_dbg
+#else
+#      define vdbg(fmt,args...) do { } while (0)
+#      define ehci_vdbg(ehci, fmt, args...) do { } while (0)
+#endif
+
 #ifndef DEBUG
-#define STUB_DEBUG_FILES
+
+#define create_debug_files(bus)
+#define remove_debug_files(bus)
+#define ehci_dbg_hcs_params(ehci, label)
+#define ehci_dbg_hcc_params(ehci, label)
+#define ehci_dbg_qh(label, ehci, qh)
+#define ehci_dbg_status_buf(buf, len, label, status)
+#define ehci_dbg_command_buf(buf,len,label, command)
+#define ehci_dbg_intr_buf(buf, len, label, enable)
+#define ehci_dbg_port_buf (buf,len, label, port, status)
+#define ehci_dbg_status(ehci, label, status)
+#define ehci_dbg_cmd(ehci, label, command)
+#define ehci_dbg_port(ehci, label, port, status)
+
+#else
+
+void ehci_dbg_hcs_params (struct ehci_hcd *ehci, char *label);
+void ehci_dbg_hcc_params (struct ehci_hcd *ehci, char *label);
+void __attribute__((__unused__)) ehci_dbg_qh (char *label, struct ehci_hcd 
*ehci, struct ehci_qh *qh);
+
+static int __attribute__((__unused__)) ehci_dbg_status_buf (char *buf, 
unsigned len, const char *label, u32 status);
+
+static int __attribute__((__unused__)) ehci_dbg_command_buf (char *buf, 
unsigned len, const char *label, u32 command);
+
+static int __attribute__((__unused__)) ehci_dbg_intr_buf (char *buf, unsigned 
len, const char *label, u32 enable);
+
+static int __attribute__((__unused__)) ehci_dbg_port_buf (char *buf, unsigned 
len, const char *label, int port, u32 status);
+
+/* functions have the "wrong" filename when they're output... */
+#define ehci_dbg_status(ehci, label, status) { \
+       char _buf [80]; \
+       ehci_dbg_status_buf (_buf, sizeof _buf, label, status); \
+       ehci_dbg (ehci, "%s\n", _buf); \
+}
+
+#define ehci_dbg_cmd(ehci, label, command) { \
+       char _buf [80]; \
+       ehci_dbg_command_buf (_buf, sizeof _buf, label, command); \
+       ehci_dbg (ehci, "%s\n", _buf); \
+}
+
+#define ehci_dbg_port(ehci, label, port, status) { \
+       char _buf [80]; \
+       ehci_dbg_port_buf (_buf, sizeof _buf, label, port, status); \
+       ehci_dbg (ehci, "%s\n", _buf); \
+}
+
+
 #endif /* DEBUG */
 
 /*-------------------------------------------------------------------------*/
Index: linux-2.6-ixp2350/drivers/usb/host/ehci-hub.c
===================================================================
--- linux-2.6-ixp2350.orig/drivers/usb/host/ehci-hub.c
+++ linux-2.6-ixp2350/drivers/usb/host/ehci-hub.c
@@ -489,7 +489,7 @@ static int ehci_hub_control (
 #ifndef        EHCI_VERBOSE_DEBUG
        if (status & ~0xffff)   /* only if wPortChange is interesting */
 #endif
-               dbg_port (ehci, "GetStatus", wIndex + 1, temp);
+               ehci_dbg_port (ehci, "GetStatus", wIndex + 1, temp);
                // we "know" this alignment is good, caller used kmalloc()...
                *((__le32 *) buf) = cpu_to_le32 (status);
                break;
-- 
Deepak Saxena - [EMAIL PROTECTED] - http://www.plexity.net

"To question your government is not unpatriotic - to not question your
 government is unpatriotic." -  Senator Chuck Hagel (R-NE) - Nov 15, 2005


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to