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/mipsconfig.h>
13 #include <asm/addrspace.h>
14 #include <asm/system.h>
18 * Map an 16mb segment of the EISA address space to 0xe3000000;
20 static inline void map_eisa_address(unsigned long address
)
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
)
32 map_eisa_address(addr
);
34 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
39 static unsigned short jazz_readw(unsigned long addr
)
43 map_eisa_address(addr
);
45 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
50 static unsigned int jazz_readl(unsigned long addr
)
54 map_eisa_address(addr
);
56 res
= *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
);
61 static void jazz_writeb(unsigned char val
, unsigned long addr
)
63 map_eisa_address(addr
);
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
);
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
);
79 *(volatile unsigned char *) (JAZZ_EISA_BASE
+ addr
) = val
;
82 static void jazz_memset_io(unsigned long addr
, int val
, unsigned long len
)
86 waddr
= JAZZ_EISA_BASE
| (addr
& 0xffffff);
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
);
95 waddr
= waddr
+ fraglen
- 0x1000000;
100 static void jazz_memcpy_fromio(unsigned long to
, unsigned long from
, unsigned long len
)
104 waddr
= JAZZ_EISA_BASE
| (from
& 0xffffff);
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
);
114 waddr
= waddr
+ fraglen
- 0x1000000;
119 static void jazz_memcpy_toio(unsigned long to
, unsigned long from
, unsigned long len
)
123 waddr
= JAZZ_EISA_BASE
| (to
& 0xffffff);
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
);
133 waddr
= waddr
+ fraglen
- 0x1000000;