fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / usb / host / ehci.h
index 0e85411..74dbc6c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2001-2002 by David Brownell
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
@@ -36,7 +36,7 @@ struct ehci_stats {
 
 /* ehci_hcd->lock guards shared data against other CPUs:
  *   ehci_hcd: async, reclaim, periodic (and shadow), ...
- *   hcd_dev:  ep[]
+ *   usb_host_endpoint: hcpriv
  *   ehci_qh:  qh_next, qtd_list
  *   ehci_qtd: qtd_list
  *
@@ -47,6 +47,12 @@ struct ehci_stats {
 #define        EHCI_MAX_ROOT_PORTS     15              /* see HCS_N_PORTS */
 
 struct ehci_hcd {                      /* one per controller */
+       /* glue to PCI and HCD framework */
+       struct ehci_caps __iomem *caps;
+       struct ehci_regs __iomem *regs;
+       struct ehci_dbg_port __iomem *debug;
+
+       __u32                   hcs_params;     /* cached register copy */
        spinlock_t              lock;
 
        /* async schedule support */
@@ -68,12 +74,7 @@ struct ehci_hcd {                    /* one per controller */
 
        /* per root hub port */
        unsigned long           reset_done [EHCI_MAX_ROOT_PORTS];
-
-       /* glue to PCI and HCD framework */
-       struct usb_hcd          hcd;
-       struct ehci_caps __iomem *caps;
-       struct ehci_regs __iomem *regs;
-       __u32                   hcs_params;     /* cached register copy */
+       unsigned long           bus_suspended;
 
        /* per-HC memory pools (could be per-bus, but ...) */
        struct dma_pool         *qh_pool;       /* qh per active urb */
@@ -82,13 +83,17 @@ struct ehci_hcd {                   /* one per controller */
        struct dma_pool         *sitd_pool;     /* sitd per split iso urb */
 
        struct timer_list       watchdog;
-       struct notifier_block   reboot_notifier;
        unsigned long           actions;
        unsigned                stamp;
        unsigned long           next_statechange;
        u32                     command;
 
-       unsigned                is_arc_rh_tt:1; /* ARC roothub with TT */
+       /* SILICON QUIRKS */
+       unsigned                is_tdi_rh_tt:1; /* TDI roothub with TT */
+       unsigned                no_selective_suspend:1;
+       unsigned                has_fsl_port_bug:1; /* FreeScale */
+
+       u8                      sbrn;           /* packed release number */
 
        /* irq statistics */
 #ifdef EHCI_STATS
@@ -99,8 +104,15 @@ struct ehci_hcd {                   /* one per controller */
 #endif
 };
 
-/* unwrap an HCD pointer to get an EHCI_HCD pointer */ 
-#define hcd_to_ehci(hcd_ptr) container_of(hcd_ptr, struct ehci_hcd, hcd)
+/* convert between an HCD pointer and the corresponding EHCI_HCD */
+static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd)
+{
+       return (struct ehci_hcd *) (hcd->hcd_priv);
+}
+static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
+{
+       return container_of ((void *) ehci, struct usb_hcd, hcd_priv);
+}
 
 
 enum ehci_timer_action {
@@ -159,7 +171,7 @@ struct ehci_caps {
        /* these fields are specified as 8 and 16 bit registers,
         * but some hosts can't perform 8 or 16 bit PCI accesses.
         */
-       u32     hc_capbase;
+       u32             hc_capbase;
 #define HC_LENGTH(p)           (((p)>>00)&0x00ff)      /* bits 7:0 */
 #define HC_VERSION(p)          (((p)>>16)&0xffff)      /* bits 31:16 */
        u32             hcs_params;     /* HCSPARAMS - offset 0x4 */
@@ -167,8 +179,8 @@ struct ehci_caps {
 #define HCS_INDICATOR(p)       ((p)&(1 << 16)) /* true: has port indicators */
 #define HCS_N_CC(p)            (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
 #define HCS_N_PCC(p)           (((p)>>8)&0xf)  /* bits 11:8, ports per CC */
-#define HCS_PORTROUTED(p)      ((p)&(1 << 7))  /* true: port routing */ 
-#define HCS_PPC(p)             ((p)&(1 << 4))  /* true: port power control */ 
+#define HCS_PORTROUTED(p)      ((p)&(1 << 7))  /* true: port routing */
+#define HCS_PPC(p)             ((p)&(1 << 4))  /* true: port power control */
 #define HCS_N_PORTS(p)         (((p)>>0)&0xf)  /* bits 3:0, ports on HC */
 
        u32             hcc_params;      /* HCCPARAMS - offset 0x8 */
@@ -193,7 +205,7 @@ struct ehci_regs {
 #define CMD_LRESET     (1<<7)          /* partial reset (no ports, etc) */
 #define CMD_IAAD       (1<<6)          /* "doorbell" interrupt async advance */
 #define CMD_ASE                (1<<5)          /* async schedule enable */
-#define CMD_PSE        (1<<4)          /* periodic schedule enable */
+#define CMD_PSE                (1<<4)          /* periodic schedule enable */
 /* 3:2 is periodic frame list size */
 #define CMD_RESET      (1<<1)          /* reset HC not bus */
 #define CMD_RUN                (1<<0)          /* start/stop HC */
@@ -219,9 +231,9 @@ struct ehci_regs {
        /* FRINDEX: offset 0x0C */
        u32             frame_index;    /* current microframe number */
        /* CTRLDSSEGMENT: offset 0x10 */
-       u32             segment;        /* address bits 63:32 if needed */
+       u32             segment;        /* address bits 63:32 if needed */
        /* PERIODICLISTBASE: offset 0x14 */
-       u32             frame_list;     /* points to periodic list */
+       u32             frame_list;     /* points to periodic list */
        /* ASYNCLISTADDR: offset 0x18 */
        u32             async_next;     /* address of next async queue head */
 
@@ -256,8 +268,33 @@ struct ehci_regs {
 #define PORT_PE                (1<<2)          /* port enable */
 #define PORT_CSC       (1<<1)          /* connect status change */
 #define PORT_CONNECT   (1<<0)          /* device connected */
+#define PORT_RWC_BITS   (PORT_CSC | PORT_PEC | PORT_OCC)
 } __attribute__ ((packed));
 
+/* Appendix C, Debug port ... intended for use with special "debug devices"
+ * that can help if there's no serial console.  (nonstandard enumeration.)
+ */
+struct ehci_dbg_port {
+       u32     control;
+#define DBGP_OWNER     (1<<30)
+#define DBGP_ENABLED   (1<<28)
+#define DBGP_DONE      (1<<16)
+#define DBGP_INUSE     (1<<10)
+#define DBGP_ERRCODE(x)        (((x)>>7)&0x07)
+#      define DBGP_ERR_BAD     1
+#      define DBGP_ERR_SIGNAL  2
+#define DBGP_ERROR     (1<<6)
+#define DBGP_GO                (1<<5)
+#define DBGP_OUT       (1<<4)
+#define DBGP_LEN(x)    (((x)>>0)&0x0f)
+       u32     pids;
+#define DBGP_PID_GET(x)                (((x)>>16)&0xff)
+#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
+       u32     data03;
+       u32     data47;
+       u32     address;
+#define DBGP_EPADDR(dev,ep)    (((dev)<<8)|(ep))
+} __attribute__ ((packed));
 
 /*-------------------------------------------------------------------------*/
 
@@ -265,7 +302,7 @@ struct ehci_regs {
 
 /*
  * EHCI Specification 0.95 Section 3.5
- * QTD: describe data transfer components (buffer, direction, ...) 
+ * QTD: describe data transfer components (buffer, direction, ...)
  * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram".
  *
  * These are associated only with "QH" (Queue Head) structures,
@@ -275,7 +312,7 @@ struct ehci_qtd {
        /* first part defined by EHCI spec */
        __le32                  hw_next;          /* see EHCI 3.5.1 */
        __le32                  hw_alt_next;      /* see EHCI 3.5.2 */
-       __le32                  hw_token;         /* see EHCI 3.5.3 */       
+       __le32                  hw_token;         /* see EHCI 3.5.3 */
 #define        QTD_TOGGLE      (1 << 31)       /* data toggle */
 #define        QTD_LENGTH(tok) (((tok)>>16) & 0x7fff)
 #define        QTD_IOC         (1 << 15)       /* interrupt on complete */
@@ -312,8 +349,8 @@ struct ehci_qtd {
 /* values for that type tag */
 #define Q_TYPE_ITD     __constant_cpu_to_le32 (0 << 1)
 #define Q_TYPE_QH      __constant_cpu_to_le32 (1 << 1)
-#define Q_TYPE_SITD    __constant_cpu_to_le32 (2 << 1)
-#define Q_TYPE_FSTN    __constant_cpu_to_le32 (3 << 1)
+#define Q_TYPE_SITD    __constant_cpu_to_le32 (2 << 1)
+#define Q_TYPE_FSTN    __constant_cpu_to_le32 (3 << 1)
 
 /* next async queue entry, or pointer to interrupt/periodic QH */
 #define        QH_NEXT(dma)    (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH)
@@ -330,11 +367,11 @@ struct ehci_qtd {
  * For entries in the async schedule, the type tag always says "qh".
  */
 union ehci_shadow {
-       struct ehci_qh          *qh;            /* Q_TYPE_QH */
+       struct ehci_qh          *qh;            /* Q_TYPE_QH */
        struct ehci_itd         *itd;           /* Q_TYPE_ITD */
        struct ehci_sitd        *sitd;          /* Q_TYPE_SITD */
        struct ehci_fstn        *fstn;          /* Q_TYPE_FSTN */
-       u32                     *hw_next;       /* (all types) */
+       __le32                  *hw_next;       /* (all types) */
        void                    *ptr;
 };
 
@@ -354,8 +391,13 @@ struct ehci_qh {
        __le32                  hw_info1;        /* see EHCI 3.6.2 */
 #define        QH_HEAD         0x00008000
        __le32                  hw_info2;        /* see EHCI 3.6.2 */
+#define        QH_SMASK        0x000000ff
+#define        QH_CMASK        0x0000ff00
+#define        QH_HUBADDR      0x007f0000
+#define        QH_HUBPORT      0x3f800000
+#define        QH_MULT         0xc0000000
        __le32                  hw_current;      /* qtd list - see EHCI 3.6.4 */
-       
+
        /* qtd overlay (hardware parts of a struct ehci_qtd) */
        __le32                  hw_qtd_next;
        __le32                  hw_alt_next;
@@ -385,6 +427,7 @@ struct ehci_qh {
        u8                      usecs;          /* intr bandwidth */
        u8                      gap_uf;         /* uframes split/csplit gap */
        u8                      c_usecs;        /* ... split completion bw */
+       u16                     tt_usecs;       /* tt downstream bandwidth */
        unsigned short          period;         /* polling interval */
        unsigned short          start;          /* where polling starts */
 #define NO_FRAME ((unsigned short)~0)                  /* pick new start */
@@ -400,7 +443,7 @@ struct ehci_iso_packet {
        __le32                  transaction;    /* itd->hw_transaction[i] |= */
        u8                      cross;          /* buf crosses pages */
        /* for full speed OUT splits */
-       u16                     buf1;
+       u32                     buf1;
 };
 
 /* temporary schedule data for packets from iso urbs (both speeds)
@@ -429,6 +472,7 @@ struct ehci_iso_stream {
        struct list_head        td_list;        /* queued itds/sitds */
        struct list_head        free_list;      /* list of unused itds/sitds */
        struct usb_device       *udev;
+       struct usb_host_endpoint *ep;
 
        /* output of (re)scheduling */
        unsigned long           start;          /* jiffies */
@@ -442,13 +486,14 @@ struct ehci_iso_stream {
         */
        u8                      interval;
        u8                      usecs, c_usecs;
+       u16                     tt_usecs;
        u16                     maxp;
        u16                     raw_mask;
        unsigned                bandwidth;
 
        /* This is used to initialize iTD's hw_bufp fields */
-       __le32                  buf0;           
-       __le32                  buf1;           
+       __le32                  buf0;
+       __le32                  buf1;
        __le32                  buf2;
 
        /* this is used to initialize sITD's tt info */
@@ -476,7 +521,7 @@ struct ehci_itd {
 
 #define ITD_ACTIVE     __constant_cpu_to_le32(EHCI_ISOC_ACTIVE)
 
-       __le32                  hw_bufp [7];    /* see EHCI 3.3.3 */ 
+       __le32                  hw_bufp [7];    /* see EHCI 3.3.3 */
        __le32                  hw_bufp_hi [7]; /* Appendix B */
 
        /* the rest is HCD-private */
@@ -497,7 +542,7 @@ struct ehci_itd {
 /*-------------------------------------------------------------------------*/
 
 /*
- * EHCI Specification 0.95 Section 3.4 
+ * EHCI Specification 0.95 Section 3.4
  * siTD, aka split-transaction isochronous Transfer Descriptor
  *       ... describe full speed iso xfers through TT in hubs
  * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD)
@@ -568,13 +613,13 @@ struct ehci_fstn {
  * needed (mostly in root hub code).
  */
 
-#define        ehci_is_ARC(e)                  ((e)->is_arc_rh_tt)
+#define        ehci_is_TDI(e)                  ((e)->is_tdi_rh_tt)
 
 /* Returns the speed of a device attached to a port on the root hub. */
 static inline unsigned int
 ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
 {
-       if (ehci_is_ARC(ehci)) {
+       if (ehci_is_TDI(ehci)) {
                switch ((portsc>>26)&3) {
                case 0:
                        return 0;
@@ -590,11 +635,23 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
 
 #else
 
-#define        ehci_is_ARC(e)                  (0)
+#define        ehci_is_TDI(e)                  (0)
 
 #define        ehci_port_speed(ehci, portsc)   (1<<USB_PORT_FEAT_HIGHSPEED)
 #endif
 
+/*-------------------------------------------------------------------------*/
+
+#ifdef CONFIG_PPC_83xx
+/* Some Freescale processors have an erratum in which the TT
+ * port number in the queue head was 0..N-1 instead of 1..N.
+ */
+#define        ehci_has_fsl_portno_bug(e)              ((e)->has_fsl_port_bug)
+#else
+#define        ehci_has_fsl_portno_bug(e)              (0)
+#endif
+
+
 /*-------------------------------------------------------------------------*/
 
 #ifndef DEBUG