ACPI: EC acpi-ecdt-uid-hack
[pandora-kernel.git] / include / asm-parisc / io.h
1 #ifndef _ASM_IO_H
2 #define _ASM_IO_H
3
4 #include <linux/config.h>
5 #include <linux/types.h>
6 #include <asm/pgtable.h>
7
8 extern unsigned long parisc_vmerge_boundary;
9 extern unsigned long parisc_vmerge_max_size;
10
11 #define BIO_VMERGE_BOUNDARY     parisc_vmerge_boundary
12 #define BIO_VMERGE_MAX_SIZE     parisc_vmerge_max_size
13
14 #define virt_to_phys(a) ((unsigned long)__pa(a))
15 #define phys_to_virt(a) __va(a)
16 #define virt_to_bus virt_to_phys
17 #define bus_to_virt phys_to_virt
18
19 /*
20  * Memory mapped I/O
21  *
22  * readX()/writeX() do byteswapping and take an ioremapped address
23  * __raw_readX()/__raw_writeX() don't byteswap and take an ioremapped address.
24  * gsc_*() don't byteswap and operate on physical addresses;
25  *   eg dev->hpa or 0xfee00000.
26  */
27
28 static inline unsigned char gsc_readb(unsigned long addr)
29 {
30         long flags;
31         unsigned char ret;
32
33         __asm__ __volatile__(
34         "       rsm     2,%0\n"
35         "       ldbx    0(%2),%1\n"
36         "       mtsm    %0\n"
37         : "=&r" (flags), "=r" (ret) : "r" (addr) );
38
39         return ret;
40 }
41
42 static inline unsigned short gsc_readw(unsigned long addr)
43 {
44         long flags;
45         unsigned short ret;
46
47         __asm__ __volatile__(
48         "       rsm     2,%0\n"
49         "       ldhx    0(%2),%1\n"
50         "       mtsm    %0\n"
51         : "=&r" (flags), "=r" (ret) : "r" (addr) );
52
53         return ret;
54 }
55
56 static inline unsigned int gsc_readl(unsigned long addr)
57 {
58         u32 ret;
59
60         __asm__ __volatile__(
61         "       ldwax   0(%1),%0\n"
62         : "=r" (ret) : "r" (addr) );
63
64         return ret;
65 }
66
67 static inline unsigned long long gsc_readq(unsigned long addr)
68 {
69         unsigned long long ret;
70
71 #ifdef __LP64__
72         __asm__ __volatile__(
73         "       ldda    0(%1),%0\n"
74         :  "=r" (ret) : "r" (addr) );
75 #else
76         /* two reads may have side effects.. */
77         ret = ((u64) gsc_readl(addr)) << 32;
78         ret |= gsc_readl(addr+4);
79 #endif
80         return ret;
81 }
82
83 static inline void gsc_writeb(unsigned char val, unsigned long addr)
84 {
85         long flags;
86         __asm__ __volatile__(
87         "       rsm     2,%0\n"
88         "       stbs    %1,0(%2)\n"
89         "       mtsm    %0\n"
90         : "=&r" (flags) :  "r" (val), "r" (addr) );
91 }
92
93 static inline void gsc_writew(unsigned short val, unsigned long addr)
94 {
95         long flags;
96         __asm__ __volatile__(
97         "       rsm     2,%0\n"
98         "       sths    %1,0(%2)\n"
99         "       mtsm    %0\n"
100         : "=&r" (flags) :  "r" (val), "r" (addr) );
101 }
102
103 static inline void gsc_writel(unsigned int val, unsigned long addr)
104 {
105         __asm__ __volatile__(
106         "       stwas   %0,0(%1)\n"
107         : :  "r" (val), "r" (addr) );
108 }
109
110 static inline void gsc_writeq(unsigned long long val, unsigned long addr)
111 {
112 #ifdef __LP64__
113         __asm__ __volatile__(
114         "       stda    %0,0(%1)\n"
115         : :  "r" (val), "r" (addr) );
116 #else
117         /* two writes may have side effects.. */
118         gsc_writel(val >> 32, addr);
119         gsc_writel(val, addr+4);
120 #endif
121 }
122
123 /*
124  * The standard PCI ioremap interfaces
125  */
126
127 extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
128
129 extern inline void __iomem * ioremap(unsigned long offset, unsigned long size)
130 {
131         return __ioremap(offset, size, 0);
132 }
133
134 /*
135  * This one maps high address device memory and turns off caching for that area.
136  * it's useful if some control registers are in such an area and write combining
137  * or read caching is not desirable:
138  */
139 extern inline void * ioremap_nocache(unsigned long offset, unsigned long size)
140 {
141         return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
142 }
143
144 extern void iounmap(void __iomem *addr);
145
146
147 static inline unsigned char __raw_readb(const volatile void __iomem *addr)
148 {
149         return (*(volatile unsigned char __force *) (addr));
150 }
151 static inline unsigned short __raw_readw(const volatile void __iomem *addr)
152 {
153         return *(volatile unsigned short __force *) addr;
154 }
155 static inline unsigned int __raw_readl(const volatile void __iomem *addr)
156 {
157         return *(volatile unsigned int __force *) addr;
158 }
159 static inline unsigned long long __raw_readq(const volatile void __iomem *addr)
160 {
161         return *(volatile unsigned long long __force *) addr;
162 }
163
164 static inline void __raw_writeb(unsigned char b, volatile void __iomem *addr)
165 {
166         *(volatile unsigned char __force *) addr = b;
167 }
168 static inline void __raw_writew(unsigned short b, volatile void __iomem *addr)
169 {
170         *(volatile unsigned short __force *) addr = b;
171 }
172 static inline void __raw_writel(unsigned int b, volatile void __iomem *addr)
173 {
174         *(volatile unsigned int __force *) addr = b;
175 }
176 static inline void __raw_writeq(unsigned long long b, volatile void __iomem *addr)
177 {
178         *(volatile unsigned long long __force *) addr = b;
179 }
180
181 /* readb can never be const, so use __fswab instead of le*_to_cpu */
182 #define readb(addr) __raw_readb(addr)
183 #define readw(addr) __fswab16(__raw_readw(addr))
184 #define readl(addr) __fswab32(__raw_readl(addr))
185 #define readq(addr) __fswab64(__raw_readq(addr))
186 #define writeb(b, addr) __raw_writeb(b, addr)
187 #define writew(b, addr) __raw_writew(cpu_to_le16(b), addr)
188 #define writel(b, addr) __raw_writel(cpu_to_le32(b), addr)
189 #define writeq(b, addr) __raw_writeq(cpu_to_le64(b), addr)
190
191 #define readb_relaxed(addr) readb(addr)
192 #define readw_relaxed(addr) readw(addr)
193 #define readl_relaxed(addr) readl(addr)
194 #define readq_relaxed(addr) readq(addr)
195
196 #define mmiowb() do { } while (0)
197
198 void memset_io(volatile void __iomem *addr, unsigned char val, int count);
199 void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
200 void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
201
202 /*
203  * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
204  * just copy it. The net code will then do the checksum later. Presently 
205  * only used by some shared memory 8390 Ethernet cards anyway.
206  */
207
208 #define eth_io_copy_and_sum(skb,src,len,unused) \
209   memcpy_fromio((skb)->data,(src),(len))
210
211 /* Port-space IO */
212
213 #define inb_p inb
214 #define inw_p inw
215 #define inl_p inl
216 #define outb_p outb
217 #define outw_p outw
218 #define outl_p outl
219
220 extern unsigned char eisa_in8(unsigned short port);
221 extern unsigned short eisa_in16(unsigned short port);
222 extern unsigned int eisa_in32(unsigned short port);
223 extern void eisa_out8(unsigned char data, unsigned short port);
224 extern void eisa_out16(unsigned short data, unsigned short port);
225 extern void eisa_out32(unsigned int data, unsigned short port);
226
227 #if defined(CONFIG_PCI)
228 extern unsigned char inb(int addr);
229 extern unsigned short inw(int addr);
230 extern unsigned int inl(int addr);
231
232 extern void outb(unsigned char b, int addr);
233 extern void outw(unsigned short b, int addr);
234 extern void outl(unsigned int b, int addr);
235 #elif defined(CONFIG_EISA)
236 #define inb eisa_in8
237 #define inw eisa_in16
238 #define inl eisa_in32
239 #define outb eisa_out8
240 #define outw eisa_out16
241 #define outl eisa_out32
242 #else
243 static inline char inb(unsigned long addr)
244 {
245         BUG();
246         return -1;
247 }
248
249 static inline short inw(unsigned long addr)
250 {
251         BUG();
252         return -1;
253 }
254
255 static inline int inl(unsigned long addr)
256 {
257         BUG();
258         return -1;
259 }
260
261 #define outb(x, y)      BUG()
262 #define outw(x, y)      BUG()
263 #define outl(x, y)      BUG()
264 #endif
265
266 /*
267  * String versions of in/out ops:
268  */
269 extern void insb (unsigned long port, void *dst, unsigned long count);
270 extern void insw (unsigned long port, void *dst, unsigned long count);
271 extern void insl (unsigned long port, void *dst, unsigned long count);
272 extern void outsb (unsigned long port, const void *src, unsigned long count);
273 extern void outsw (unsigned long port, const void *src, unsigned long count);
274 extern void outsl (unsigned long port, const void *src, unsigned long count);
275
276
277 /* IO Port space is :      BBiiii   where BB is HBA number. */
278 #define IO_SPACE_LIMIT 0x00ffffff
279
280
281 #define dma_cache_inv(_start,_size)             do { flush_kernel_dcache_range(_start,_size); } while (0)
282 #define dma_cache_wback(_start,_size)           do { flush_kernel_dcache_range(_start,_size); } while (0)
283 #define dma_cache_wback_inv(_start,_size)       do { flush_kernel_dcache_range(_start,_size); } while (0)
284
285 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
286  * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
287  * mode (essentially just sign extending.  This macro takes in a 32
288  * bit I/O address (still with the leading f) and outputs the correct
289  * value for either 32 or 64 bit mode */
290 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))
291
292 #include <asm-generic/iomap.h>
293
294 /*
295  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
296  * access
297  */
298 #define xlate_dev_mem_ptr(p)    __va(p)
299
300 /*
301  * Convert a virtual cached pointer to an uncached pointer
302  */
303 #define xlate_dev_kmem_ptr(p)   p
304
305 #endif