2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Low level I/O functions for Jazz family machines.
8 * Copyright (C) 1997 by Ralf Baechle.
10 #include <linux/string.h>
11 #include <linux/spinlock.h>
12 #include <asm/addrspace.h>
13 #include <asm/system.h>
17 * Map an 16mb segment of the EISA address space to 0xe3000000;
19 static inline void map_eisa_address(unsigned long address
)
22 /* We've got an wired entry in the TLB. We just need to modify it.
23 fast and clean. But since we want to get rid of wired entries
24 things are a little bit more complicated ... */
27 static unsigned char jazz_readb(unsigned long addr
)
31 map_eisa_address(addr
);
33 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
38 static unsigned short jazz_readw(unsigned long addr
)
42 map_eisa_address(addr
);
44 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
49 static unsigned int jazz_readl(unsigned long addr
)
53 map_eisa_address(addr
);
55 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
60 static void jazz_writeb(unsigned char val
, unsigned long addr
)
62 map_eisa_address(addr
);
64 *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
) = val
;
67 static void jazz_writew(unsigned short val
, unsigned long addr
)
69 map_eisa_address(addr
);
71 *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
) = val
;
74 static void jazz_writel(unsigned int val
, unsigned long addr
)
76 map_eisa_address(addr
);
78 *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
) = val
;
81 static void jazz_memset_io(unsigned long addr
, int val
, unsigned long len
)
85 waddr
= JAZZ_EISA_BASE
| (addr
& 0xffffff);
87 unsigned long fraglen
;
89 fraglen
= (~addr
+ 1) & 0xffffff;
90 fraglen
= (fraglen
< len
) ? fraglen
: len
;
91 map_eisa_address(addr
);
92 memset((char *)waddr
, val
, fraglen
);
94 waddr
= waddr
+ fraglen
- 0x1000000;
99 static void jazz_memcpy_fromio(unsigned long to
, unsigned long from
, unsigned long len
)
103 waddr
= JAZZ_EISA_BASE
| (from
& 0xffffff);
105 unsigned long fraglen
;
107 fraglen
= (~from
+ 1) & 0xffffff;
108 fraglen
= (fraglen
< len
) ? fraglen
: len
;
109 map_eisa_address(from
);
110 memcpy((void *)to
, (void *)waddr
, fraglen
);
113 waddr
= waddr
+ fraglen
- 0x1000000;
118 static void jazz_memcpy_toio(unsigned long to
, unsigned long from
, unsigned long len
)
122 waddr
= JAZZ_EISA_BASE
| (to
& 0xffffff);
124 unsigned long fraglen
;
126 fraglen
= (~to
+ 1) & 0xffffff;
127 fraglen
= (fraglen
< len
) ? fraglen
: len
;
128 map_eisa_address(to
);
129 memcpy((char *)to
+ JAZZ_EISA_BASE
, (void *)from
, fraglen
);
132 waddr
= waddr
+ fraglen
- 0x1000000;