2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
7 * This file contains the I/O routines for use on the overdrive board
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/delay.h>
14 #include <asm/system.h>
15 #include <asm/processor.h>
19 * readX/writeX() are used to access memory mapped devices. On some
20 * architectures the memory mapped IO stuff needs to be accessed
21 * differently. On the SuperH architecture, we just read/write the
22 * memory location directly.
25 /* This is horrible at the moment - needs more work to do something sensible */
28 #define OUT_DELAY(x,type) \
29 void out##x##_p(unsigned type value,unsigned long port){out##x(value,port);IO_DELAY();}
31 #define IN_DELAY(x,type) \
32 unsigned type in##x##_p(unsigned long port) {unsigned type tmp=in##x(port);IO_DELAY();return tmp;}
35 OUT_DELAY(b
, long) OUT_DELAY(w
, long) OUT_DELAY(l
, long)
36 IN_DELAY(b
, long) IN_DELAY(w
, long) IN_DELAY(l
, long)
38 /* Now for the string version of these functions */
39 void outsb(unsigned long port
, const void *addr
, unsigned long count
)
42 unsigned char *p
= (unsigned char *) addr
;
44 for (i
= 0; i
< count
; i
++, p
++) {
49 void insb(unsigned long port
, void *addr
, unsigned long count
)
52 unsigned char *p
= (unsigned char *) addr
;
54 for (i
= 0; i
< count
; i
++, p
++) {
59 /* For the 16 and 32 bit string functions, we have to worry about alignment.
60 * The SH does not do unaligned accesses, so we have to read as bytes and
61 * then write as a word or dword.
62 * This can be optimised a lot more, especially in the case where the data
66 void outsw(unsigned long port
, const void *addr
, unsigned long count
)
70 unsigned char *p
= (unsigned char *) addr
;
72 for (i
= 0; i
< count
; i
++, p
+= 2) {
73 tmp
= (*p
) | ((*(p
+ 1)) << 8);
78 void insw(unsigned long port
, void *addr
, unsigned long count
)
82 unsigned char *p
= (unsigned char *) addr
;
84 for (i
= 0; i
< count
; i
++, p
+= 2) {
87 p
[1] = (tmp
>> 8) & 0xff;
91 void outsl(unsigned long port
, const void *addr
, unsigned long count
)
95 unsigned char *p
= (unsigned char *) addr
;
97 for (i
= 0; i
< count
; i
++, p
+= 4) {
98 tmp
= (*p
) | ((*(p
+ 1)) << 8) | ((*(p
+ 2)) << 16) |
104 void insl(unsigned long port
, void *addr
, unsigned long count
)
108 unsigned char *p
= (unsigned char *) addr
;
110 for (i
= 0; i
< count
; i
++, p
+= 4) {
113 p
[1] = (tmp
>> 8) & 0xff;
114 p
[2] = (tmp
>> 16) & 0xff;
115 p
[3] = (tmp
>> 24) & 0xff;
120 void memcpy_toio(void __iomem
*to
, const void *from
, long count
)
122 unsigned char *p
= (unsigned char *) from
;
130 void memcpy_fromio(void *to
, void __iomem
*from
, long count
)
133 unsigned char *p
= (unsigned char *) to
;
135 for (i
= 0; i
< count
; i
++) {