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(cpu_to_le16(val), (base + index));
32 static inline unsigned short nsp32_read2(unsigned int base,
35 return le16_to_cpu(inw(base + index));
38 static inline void nsp32_write4(unsigned int base,
42 outl(cpu_to_le32(val), (base + index));
45 static inline unsigned long nsp32_read4(unsigned int base,
48 return le32_to_cpu(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 *ptr = cpu_to_le16(val);
85 static inline unsigned short nsp32_mmio_read2(unsigned long base,
88 volatile unsigned short *ptr;
90 //printk(__FUNCTION__ "\n");
92 ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + index);
94 return le16_to_cpu(*ptr);
97 static inline void nsp32_mmio_write4(unsigned long base,
101 volatile unsigned long *ptr;
103 ptr = (unsigned long *)(base + NSP32_MMIO_OFFSET + index);
105 *ptr = cpu_to_le32(val);
108 static inline unsigned long nsp32_mmio_read4(unsigned long base,
111 volatile unsigned long *ptr;
113 //printk(__FUNCTION__ "\n");
115 ptr = (unsigned long *)(base + NSP32_MMIO_OFFSET + index);
117 return le32_to_cpu(*ptr);
121 /*=============================================*/
124 static inline unsigned char nsp32_index_read1(unsigned int base,
127 outb(reg, base + INDEX_REG);
128 return inb(base + DATA_REG_LOW);
131 static inline void nsp32_index_write1(unsigned int base,
135 outb(reg, base + INDEX_REG);
136 outb(val, base + DATA_REG_LOW);
139 static inline unsigned short nsp32_index_read2(unsigned int base,
142 outb(reg, base + INDEX_REG);
143 return le16_to_cpu(inw(base + DATA_REG_LOW));
146 static inline void nsp32_index_write2(unsigned int base,
150 outb(reg, base + INDEX_REG);
151 outw(cpu_to_le16(val), base + DATA_REG_LOW);
154 static inline unsigned long nsp32_index_read4(unsigned int base,
159 outb(reg, base + INDEX_REG);
160 l = le16_to_cpu(inw(base + DATA_REG_LOW));
161 h = le16_to_cpu(inw(base + DATA_REG_HI ));
163 return ((h << 16) | l);
166 static inline void nsp32_index_write4(unsigned int base,
172 h = (val & 0xffff0000) >> 16;
173 l = (val & 0x0000ffff) >> 0;
175 outb(reg, base + INDEX_REG);
176 outw(cpu_to_le16(l), base + DATA_REG_LOW);
177 outw(cpu_to_le16(h), base + DATA_REG_HI);
181 /* ===================================*/
183 static inline unsigned char nsp32_mmio_index_read1(unsigned int base,
186 volatile unsigned short *index_ptr, *data_ptr;
188 index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
189 data_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
193 return ((*data_ptr) & 0xff);
196 static inline void nsp32_mmio_index_write1(unsigned int base,
200 volatile unsigned short *index_ptr, *data_ptr;
202 index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
203 data_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
206 *data_ptr = (unsigned short)val;
209 static inline unsigned short nsp32_mmio_index_read2(unsigned int base,
212 volatile unsigned short *index_ptr, *data_ptr;
214 index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
215 data_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
219 return le16_to_cpu(*data_ptr);
222 static inline void nsp32_mmio_index_write2(unsigned int base,
226 volatile unsigned short *index_ptr, *data_ptr;
228 index_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + INDEX_REG);
229 data_ptr = (unsigned short *)(base + NSP32_MMIO_OFFSET + DATA_REG_LOW);
235 /*-------------------------------------------------------------------*/
237 static inline void nsp32_multi_read4(unsigned int BaseAddr,
238 unsigned int Register,
242 insl(BaseAddr + Register, buf, count);
245 static inline void nsp32_fifo_read(unsigned int base,
249 //DEBUG(0, __FUNCTION__ "() buf=0x%p, count=0x%lx*4\n", buf, count);
250 nsp32_multi_read4(base, FIFO_DATA_LOW, buf, count);
253 static inline void nsp32_multi_write4(unsigned int BaseAddr,
254 unsigned int Register,
258 outsl(BaseAddr + Register, buf, count);
261 static inline void nsp32_fifo_write(unsigned int base,
265 nsp32_multi_write4(base, FIFO_DATA_LOW, buf, count);