3 By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
5 This software may be used and distributed according to the terms of
6 the GNU General Public License.
10 /* $Id: nsp_io.h,v 1.3 2003/08/04 21:15:26 elca Exp $ */
15 static inline void nsp_write(unsigned int base
,
18 static inline unsigned char nsp_read(unsigned int base
,
20 static inline void nsp_index_write(unsigned int BaseAddr
,
21 unsigned int Register
,
23 static inline unsigned char nsp_index_read(unsigned int BaseAddr
,
24 unsigned int Register
);
26 /*******************************************************************
30 static inline void nsp_write(unsigned int base
,
34 outb(val
, (base
+ index
));
37 static inline unsigned char nsp_read(unsigned int base
,
40 return inb(base
+ index
);
44 /**********************************************************************
47 static inline unsigned char nsp_index_read(unsigned int BaseAddr
,
48 unsigned int Register
)
50 outb(Register
, BaseAddr
+ INDEXREG
);
51 return inb(BaseAddr
+ DATAREG
);
54 static inline void nsp_index_write(unsigned int BaseAddr
,
55 unsigned int Register
,
58 outb(Register
, BaseAddr
+ INDEXREG
);
59 outb(Value
, BaseAddr
+ DATAREG
);
62 /*********************************************************************
67 static inline void nsp_multi_read_1(unsigned int BaseAddr
,
68 unsigned int Register
,
72 insb(BaseAddr
+ Register
, buf
, count
);
75 static inline void nsp_fifo8_read(unsigned int base
,
79 /*nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx", buf, count);*/
80 nsp_multi_read_1(base
, FIFODATA
, buf
, count
);
83 /*--------------------------------------------------------------*/
85 /* read 16 bit FIFO */
86 static inline void nsp_multi_read_2(unsigned int BaseAddr
,
87 unsigned int Register
,
91 insw(BaseAddr
+ Register
, buf
, count
);
94 static inline void nsp_fifo16_read(unsigned int base
,
98 //nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*2", buf, count);
99 nsp_multi_read_2(base
, FIFODATA
, buf
, count
);
102 /*--------------------------------------------------------------*/
104 /* read 32bit FIFO */
105 static inline void nsp_multi_read_4(unsigned int BaseAddr
,
106 unsigned int Register
,
110 insl(BaseAddr
+ Register
, buf
, count
);
113 static inline void nsp_fifo32_read(unsigned int base
,
117 //nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
118 nsp_multi_read_4(base
, FIFODATA
, buf
, count
);
121 /*----------------------------------------------------------*/
123 /* write 8bit FIFO */
124 static inline void nsp_multi_write_1(unsigned int BaseAddr
,
125 unsigned int Register
,
129 outsb(BaseAddr
+ Register
, buf
, count
);
132 static inline void nsp_fifo8_write(unsigned int base
,
136 nsp_multi_write_1(base
, FIFODATA
, buf
, count
);
139 /*---------------------------------------------------------*/
141 /* write 16bit FIFO */
142 static inline void nsp_multi_write_2(unsigned int BaseAddr
,
143 unsigned int Register
,
147 outsw(BaseAddr
+ Register
, buf
, count
);
150 static inline void nsp_fifo16_write(unsigned int base
,
154 nsp_multi_write_2(base
, FIFODATA
, buf
, count
);
157 /*---------------------------------------------------------*/
159 /* write 32bit FIFO */
160 static inline void nsp_multi_write_4(unsigned int BaseAddr
,
161 unsigned int Register
,
165 outsl(BaseAddr
+ Register
, buf
, count
);
168 static inline void nsp_fifo32_write(unsigned int base
,
172 nsp_multi_write_4(base
, FIFODATA
, buf
, count
);
176 /*====================================================================*/
178 static inline void nsp_mmio_write(unsigned long base
,
182 unsigned char *ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ index
);
187 static inline unsigned char nsp_mmio_read(unsigned long base
,
190 unsigned char *ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ index
);
197 static inline unsigned char nsp_mmio_index_read(unsigned long base
,
200 unsigned char *index_ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ INDEXREG
);
201 unsigned char *data_ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ DATAREG
);
203 writeb((unsigned char)reg
, index_ptr
);
204 return readb(data_ptr
);
207 static inline void nsp_mmio_index_write(unsigned long base
,
211 unsigned char *index_ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ INDEXREG
);
212 unsigned char *data_ptr
= (unsigned char *)(base
+ NSP_MMIO_OFFSET
+ DATAREG
);
214 writeb((unsigned char)reg
, index_ptr
);
215 writeb(val
, data_ptr
);
218 /* read 32bit FIFO */
219 static inline void nsp_mmio_multi_read_4(unsigned long base
,
220 unsigned int Register
,
224 unsigned long *ptr
= (unsigned long *)(base
+ Register
);
225 unsigned long *tmp
= (unsigned long *)buf
;
228 //nsp_dbg(NSP_DEBUG_DATA_IO, "base 0x%0lx ptr 0x%p",base,ptr);
230 for (i
= 0; i
< count
; i
++) {
232 //nsp_dbg(NSP_DEBUG_DATA_IO, "<%d,%p,%p,%lx>", i, ptr, tmp, *tmp);
237 static inline void nsp_mmio_fifo32_read(unsigned int base
,
241 //nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
242 nsp_mmio_multi_read_4(base
, FIFODATA
, buf
, count
);
245 static inline void nsp_mmio_multi_write_4(unsigned long base
,
246 unsigned int Register
,
250 unsigned long *ptr
= (unsigned long *)(base
+ Register
);
251 unsigned long *tmp
= (unsigned long *)buf
;
254 //nsp_dbg(NSP_DEBUG_DATA_IO, "base 0x%0lx ptr 0x%p",base,ptr);
256 for (i
= 0; i
< count
; i
++) {
258 //nsp_dbg(NSP_DEBUG_DATA_IO, "<%d,%p,%p,%lx>", i, ptr, tmp, *tmp);
263 static inline void nsp_mmio_fifo32_write(unsigned int base
,
267 //nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
268 nsp_mmio_multi_write_4(base
, FIFODATA
, buf
, count
);