USB: r8a66597-hcd: suspend/resume support
[pandora-kernel.git] / drivers / usb / host / r8a66597.h
index 5738825..f49208f 100644 (file)
 #ifndef __R8A66597_H__
 #define __R8A66597_H__
 
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
+#include <linux/clk.h>
+#endif
+
 #define SYSCFG0                0x00
 #define SYSCFG1                0x02
 #define SYSSTS0                0x04
 #define        REW             0x4000  /* b14: Buffer rewind */
 #define        DCLRM           0x2000  /* b13: DMA buffer clear mode */
 #define        DREQE           0x1000  /* b12: DREQ output enable */
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
+#define        MBW             0x0800
+#else
 #define        MBW             0x0400  /* b10: Maximum bit width for FIFO access */
+#endif
 #define          MBW_8          0x0000   /*  8bit */
 #define          MBW_16         0x0400   /* 16bit */
 #define        BIGEND          0x0100  /* b8: Big endian mode */
 #define R8A66597_MAX_NUM_PIPE          10
 #define R8A66597_BUF_BSIZE             8
 #define R8A66597_MAX_DEVICE            10
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
+#define R8A66597_MAX_ROOT_HUB          1
+#else
 #define R8A66597_MAX_ROOT_HUB          2
-#define R8A66597_MAX_SAMPLING          10
+#endif
+#define R8A66597_MAX_SAMPLING          5
+#define R8A66597_RH_POLL_TIME          10
 #define R8A66597_MAX_DMA_CHANNEL       2
 #define R8A66597_PIPE_NO_DMA           R8A66597_MAX_DMA_CHANNEL
 #define check_bulk_or_isoc(pipenum)    ((pipenum >= 1 && pipenum <= 5))
 #define make_devsel(addr)              (addr << 12)
 
 struct r8a66597_pipe_info {
+       unsigned long timer_interval;
        u16 pipenum;
        u16 address;    /* R8A66597 HCD usb address */
        u16 epnum;
@@ -471,21 +485,27 @@ struct r8a66597_root_hub {
 struct r8a66597 {
        spinlock_t lock;
        unsigned long reg;
-
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
+       struct clk *clk;
+#endif
        struct r8a66597_device          device0;
        struct r8a66597_root_hub        root_hub[R8A66597_MAX_ROOT_HUB];
        struct list_head                pipe_queue[R8A66597_MAX_NUM_PIPE];
 
        struct timer_list rh_timer;
        struct timer_list td_timer[R8A66597_MAX_NUM_PIPE];
+       struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE];
 
        unsigned short address_map;
        unsigned short timeout_map;
+       unsigned short interval_map;
        unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
        unsigned char dma_map;
 
        struct list_head child_device;
        unsigned long child_connect_map[4];
+
+       unsigned bus_suspended:1;
 };
 
 static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd)
@@ -526,8 +546,21 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
                                      unsigned long offset, u16 *buf,
                                      int len)
 {
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
+       unsigned long fifoaddr = r8a66597->reg + offset;
+       unsigned long count;
+
+       count = len / 4;
+       insl(fifoaddr, buf, count);
+
+       if (len & 0x00000003) {
+               unsigned long tmp = inl(fifoaddr);
+               memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03);
+       }
+#else
        len = (len + 1) / 2;
        insw(r8a66597->reg + offset, buf, len);
+#endif
 }
 
 static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
@@ -541,6 +574,24 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
                                       int len)
 {
        unsigned long fifoaddr = r8a66597->reg + offset;
+#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
+       unsigned long count;
+       unsigned char *pb;
+       int i;
+
+       count = len / 4;
+       outsl(fifoaddr, buf, count);
+
+       if (len & 0x00000003) {
+               pb = (unsigned char *)buf + count * 4;
+               for (i = 0; i < (len & 0x00000003); i++) {
+                       if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND)
+                               outb(pb[i], fifoaddr + i);
+                       else
+                               outb(pb[i], fifoaddr + 3 - i);
+               }
+       }
+#else
        int odd = len & 0x0001;
 
        len = len / 2;
@@ -549,6 +600,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
                buf = &buf[len];
                outb((unsigned char)*buf, fifoaddr);
        }
+#endif
 }
 
 static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
@@ -581,6 +633,11 @@ static inline unsigned long get_dvstctr_reg(int port)
        return port == 0 ? DVSTCTR0 : DVSTCTR1;
 }
 
+static inline unsigned long get_dmacfg_reg(int port)
+{
+       return port == 0 ? DMA0CFG : DMA1CFG;
+}
+
 static inline unsigned long get_intenb_reg(int port)
 {
        return port == 0 ? INTENB1 : INTENB2;