Linux 2.6.17.7
[linux/fpc-iii.git] / arch / mips / jazz / io.c
blobe86904454c89970c7c52543a85283fb58b954227
1 /*
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
4 * for more details.
6 * Low level I/O functions for Jazz family machines.
8 * Copyright (C) 1997 by Ralf Baechle.
9 */
10 #include <linux/string.h>
11 #include <linux/spinlock.h>
12 #include <asm/addrspace.h>
13 #include <asm/system.h>
14 #include <asm/jazz.h>
17 * Map an 16mb segment of the EISA address space to 0xe3000000;
19 static inline void map_eisa_address(unsigned long address)
21 /* XXX */
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)
29 unsigned char res;
31 map_eisa_address(addr);
32 addr &= 0xffffff;
33 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
35 return res;
38 static unsigned short jazz_readw(unsigned long addr)
40 unsigned short res;
42 map_eisa_address(addr);
43 addr &= 0xffffff;
44 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
46 return res;
49 static unsigned int jazz_readl(unsigned long addr)
51 unsigned int res;
53 map_eisa_address(addr);
54 addr &= 0xffffff;
55 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
57 return res;
60 static void jazz_writeb(unsigned char val, unsigned long addr)
62 map_eisa_address(addr);
63 addr &= 0xffffff;
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);
70 addr &= 0xffffff;
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);
77 addr &= 0xffffff;
78 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
81 static void jazz_memset_io(unsigned long addr, int val, unsigned long len)
83 unsigned long waddr;
85 waddr = JAZZ_EISA_BASE | (addr & 0xffffff);
86 while(len) {
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);
93 addr += fraglen;
94 waddr = waddr + fraglen - 0x1000000;
95 len -= fraglen;
99 static void jazz_memcpy_fromio(unsigned long to, unsigned long from, unsigned long len)
101 unsigned long waddr;
103 waddr = JAZZ_EISA_BASE | (from & 0xffffff);
104 while(len) {
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);
111 to += fraglen;
112 from += fraglen;
113 waddr = waddr + fraglen - 0x1000000;
114 len -= fraglen;
118 static void jazz_memcpy_toio(unsigned long to, unsigned long from, unsigned long len)
120 unsigned long waddr;
122 waddr = JAZZ_EISA_BASE | (to & 0xffffff);
123 while(len) {
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);
130 to += fraglen;
131 from += fraglen;
132 waddr = waddr + fraglen - 0x1000000;
133 len -= fraglen;