2  * Workbit NinjaSCSI-32Bi/UDE PCI/CardBus SCSI Host Bus Adapter driver
 
   5  * This software may be used and distributed according to the terms of
 
   6  * the GNU General Public License.
 
  12 static inline void nsp32_write1(unsigned int  base,
 
  16         outb(val, (base + index));
 
  19 static inline unsigned char nsp32_read1(unsigned int base,
 
  22         return inb(base + index);
 
  25 static inline void nsp32_write2(unsigned int   base,
 
  29         outw(val, (base + index));
 
  32 static inline unsigned short nsp32_read2(unsigned int base,
 
  35         return inw(base + index);
 
  38 static inline void nsp32_write4(unsigned int  base,
 
  42         outl(val, (base + index));
 
  45 static inline unsigned long nsp32_read4(unsigned int base,
 
  48         return inl(base + index);
 
  51 /*==============================================*/
 
  53 static inline void nsp32_mmio_write1(unsigned long base,
 
  57         volatile unsigned char *ptr;
 
  59         ptr = (unsigned char *)(base + NSP32_MMIO_OFFSET + index);
 
  64 static inline unsigned char nsp32_mmio_read1(unsigned long base,
 
  67         volatile unsigned char *ptr;
 
  69         ptr = (unsigned char *)(base + NSP32_MMIO_OFFSET + index);
 
  74 static inline void nsp32_mmio_write2(unsigned long  base,
 
  78         volatile unsigned short *ptr;
 
  80         ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + index);
 
  82         writew(cpu_to_le16(val), ptr);
 
  85 static inline unsigned short nsp32_mmio_read2(unsigned long base,
 
  88         volatile unsigned short *ptr;
 
  90         ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + index);
 
  92         return le16_to_cpu(readw(ptr));
 
  95 static inline void nsp32_mmio_write4(unsigned long base,
 
  99         volatile unsigned long *ptr;
 
 101         ptr = (unsigned long *)(base + NSP32_MMIO_OFFSET + index);
 
 103         writel(cpu_to_le32(val), ptr);
 
 106 static inline unsigned long nsp32_mmio_read4(unsigned long base,
 
 109         volatile unsigned long *ptr;
 
 111         ptr = (unsigned long *)(base + NSP32_MMIO_OFFSET + index);
 
 113         return le32_to_cpu(readl(ptr));
 
 116 /*==============================================*/
 
 118 static inline unsigned char nsp32_index_read1(unsigned int base,
 
 121         outb(reg, base + INDEX_REG);
 
 122         return inb(base + DATA_REG_LOW);
 
 125 static inline void nsp32_index_write1(unsigned int  base,
 
 129         outb(reg, base + INDEX_REG   );
 
 130         outb(val, base + DATA_REG_LOW);
 
 133 static inline unsigned short nsp32_index_read2(unsigned int base,
 
 136         outb(reg, base + INDEX_REG);
 
 137         return inw(base + DATA_REG_LOW);
 
 140 static inline void nsp32_index_write2(unsigned int   base,
 
 144         outb(reg, base + INDEX_REG   );
 
 145         outw(val, base + DATA_REG_LOW);
 
 148 static inline unsigned long nsp32_index_read4(unsigned int base,
 
 153         outb(reg, base + INDEX_REG);
 
 154         l = inw(base + DATA_REG_LOW);
 
 155         h = inw(base + DATA_REG_HI );
 
 157         return ((h << 16) | l);
 
 160 static inline void nsp32_index_write4(unsigned int  base,
 
 166         h = (val & 0xffff0000) >> 16;
 
 167         l = (val & 0x0000ffff) >>  0;
 
 169         outb(reg, base + INDEX_REG   );
 
 170         outw(l,   base + DATA_REG_LOW);
 
 171         outw(h,   base + DATA_REG_HI );
 
 174 /*==============================================*/
 
 176 static inline unsigned char nsp32_mmio_index_read1(unsigned long base,
 
 179         volatile unsigned short *index_ptr, *data_ptr;
 
 181         index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
 
 182         data_ptr  = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
 
 184         writeb(reg, index_ptr);
 
 185         return readb(data_ptr);
 
 188 static inline void nsp32_mmio_index_write1(unsigned long base,
 
 192         volatile unsigned short *index_ptr, *data_ptr;
 
 194         index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
 
 195         data_ptr  = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
 
 197         writeb(reg, index_ptr);
 
 198         writeb(val, data_ptr );
 
 201 static inline unsigned short nsp32_mmio_index_read2(unsigned long base,
 
 204         volatile unsigned short *index_ptr, *data_ptr;
 
 206         index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
 
 207         data_ptr  = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
 
 209         writeb(reg, index_ptr);
 
 210         return le16_to_cpu(readw(data_ptr));
 
 213 static inline void nsp32_mmio_index_write2(unsigned long  base,
 
 217         volatile unsigned short *index_ptr, *data_ptr;
 
 219         index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
 
 220         data_ptr  = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
 
 222         writeb(reg,              index_ptr);
 
 223         writew(cpu_to_le16(val), data_ptr );
 
 226 /*==============================================*/
 
 228 static inline void nsp32_multi_read4(unsigned int   base,
 
 233         insl(base + reg, buf, count);
 
 236 static inline void nsp32_fifo_read(unsigned int   base,
 
 240         nsp32_multi_read4(base, FIFO_DATA_LOW, buf, count);
 
 243 static inline void nsp32_multi_write4(unsigned int   base,
 
 248         outsl(base + reg, buf, count);
 
 251 static inline void nsp32_fifo_write(unsigned int   base,
 
 255         nsp32_multi_write4(base, FIFO_DATA_LOW, buf, count);
 
 258 #endif /* _NSP32_IO_H */