Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
| 5 | * |
| 6 | * Low level I/O functions for Jazz family machines. |
| 7 | * |
| 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> |
| 15 | |
| 16 | /* |
| 17 | * Map an 16mb segment of the EISA address space to 0xe3000000; |
| 18 | */ |
| 19 | static inline void map_eisa_address(unsigned long address) |
| 20 | { |
| 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 ... */ |
| 25 | } |
| 26 | |
| 27 | static unsigned char jazz_readb(unsigned long addr) |
| 28 | { |
| 29 | unsigned char res; |
| 30 | |
| 31 | map_eisa_address(addr); |
| 32 | addr &= 0xffffff; |
| 33 | res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr); |
| 34 | |
| 35 | return res; |
| 36 | } |
| 37 | |
| 38 | static unsigned short jazz_readw(unsigned long addr) |
| 39 | { |
| 40 | unsigned short res; |
| 41 | |
| 42 | map_eisa_address(addr); |
| 43 | addr &= 0xffffff; |
| 44 | res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr); |
| 45 | |
| 46 | return res; |
| 47 | } |
| 48 | |
| 49 | static unsigned int jazz_readl(unsigned long addr) |
| 50 | { |
| 51 | unsigned int res; |
| 52 | |
| 53 | map_eisa_address(addr); |
| 54 | addr &= 0xffffff; |
| 55 | res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr); |
| 56 | |
| 57 | return res; |
| 58 | } |
| 59 | |
| 60 | static void jazz_writeb(unsigned char val, unsigned long addr) |
| 61 | { |
| 62 | map_eisa_address(addr); |
| 63 | addr &= 0xffffff; |
| 64 | *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val; |
| 65 | } |
| 66 | |
| 67 | static void jazz_writew(unsigned short val, unsigned long addr) |
| 68 | { |
| 69 | map_eisa_address(addr); |
| 70 | addr &= 0xffffff; |
| 71 | *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val; |
| 72 | } |
| 73 | |
| 74 | static void jazz_writel(unsigned int val, unsigned long addr) |
| 75 | { |
| 76 | map_eisa_address(addr); |
| 77 | addr &= 0xffffff; |
| 78 | *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val; |
| 79 | } |
| 80 | |
| 81 | static void jazz_memset_io(unsigned long addr, int val, unsigned long len) |
| 82 | { |
| 83 | unsigned long waddr; |
| 84 | |
| 85 | waddr = JAZZ_EISA_BASE | (addr & 0xffffff); |
| 86 | while(len) { |
| 87 | unsigned long fraglen; |
| 88 | |
| 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; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | static void jazz_memcpy_fromio(unsigned long to, unsigned long from, unsigned long len) |
| 100 | { |
| 101 | unsigned long waddr; |
| 102 | |
| 103 | waddr = JAZZ_EISA_BASE | (from & 0xffffff); |
| 104 | while(len) { |
| 105 | unsigned long fraglen; |
| 106 | |
| 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; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | static void jazz_memcpy_toio(unsigned long to, unsigned long from, unsigned long len) |
| 119 | { |
| 120 | unsigned long waddr; |
| 121 | |
| 122 | waddr = JAZZ_EISA_BASE | (to & 0xffffff); |
| 123 | while(len) { |
| 124 | unsigned long fraglen; |
| 125 | |
| 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; |
| 134 | } |
| 135 | } |