* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / mips / jazz / io.c
blobae0c8483b9e1af1fb12f8ab6290c8b9c568bab62
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/mipsconfig.h>
13 #include <asm/addrspace.h>
14 #include <asm/system.h>
15 #include <asm/jazz.h>
18 * Map an 16mb segment of the EISA address space to 0xe3000000;
20 static inline void map_eisa_address(unsigned long address)
22 /* XXX */
23 /* We've got an wired entry in the TLB. We just need to modify it.
24 fast and clean. But since we want to get rid of wired entries
25 things are a little bit more complicated ... */
28 static unsigned char jazz_readb(unsigned long addr)
30 unsigned char res;
32 map_eisa_address(addr);
33 addr &= 0xffffff;
34 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
36 return res;
39 static unsigned short jazz_readw(unsigned long addr)
41 unsigned short res;
43 map_eisa_address(addr);
44 addr &= 0xffffff;
45 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
47 return res;
50 static unsigned int jazz_readl(unsigned long addr)
52 unsigned int res;
54 map_eisa_address(addr);
55 addr &= 0xffffff;
56 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
58 return res;
61 static void jazz_writeb(unsigned char val, unsigned long addr)
63 map_eisa_address(addr);
64 addr &= 0xffffff;
65 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
68 static void jazz_writew(unsigned short val, unsigned long addr)
70 map_eisa_address(addr);
71 addr &= 0xffffff;
72 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
75 static void jazz_writel(unsigned int val, unsigned long addr)
77 map_eisa_address(addr);
78 addr &= 0xffffff;
79 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
82 static void jazz_memset_io(unsigned long addr, int val, unsigned long len)
84 unsigned long waddr;
86 waddr = JAZZ_EISA_BASE | (addr & 0xffffff);
87 while(len) {
88 unsigned long fraglen;
90 fraglen = (~addr + 1) & 0xffffff;
91 fraglen = (fraglen < len) ? fraglen : len;
92 map_eisa_address(addr);
93 memset((char *)waddr, val, fraglen);
94 addr += fraglen;
95 waddr = waddr + fraglen - 0x1000000;
96 len -= fraglen;
100 static void jazz_memcpy_fromio(unsigned long to, unsigned long from, unsigned long len)
102 unsigned long waddr;
104 waddr = JAZZ_EISA_BASE | (from & 0xffffff);
105 while(len) {
106 unsigned long fraglen;
108 fraglen = (~from + 1) & 0xffffff;
109 fraglen = (fraglen < len) ? fraglen : len;
110 map_eisa_address(from);
111 memcpy((void *)to, (void *)waddr, fraglen);
112 to += fraglen;
113 from += fraglen;
114 waddr = waddr + fraglen - 0x1000000;
115 len -= fraglen;
119 static void jazz_memcpy_toio(unsigned long to, unsigned long from, unsigned long len)
121 unsigned long waddr;
123 waddr = JAZZ_EISA_BASE | (to & 0xffffff);
124 while(len) {
125 unsigned long fraglen;
127 fraglen = (~to + 1) & 0xffffff;
128 fraglen = (fraglen < len) ? fraglen : len;
129 map_eisa_address(to);
130 memcpy((char *)to + JAZZ_EISA_BASE, (void *)from, fraglen);
131 to += fraglen;
132 from += fraglen;
133 waddr = waddr + fraglen - 0x1000000;
134 len -= fraglen;