xref: /openbmc/linux/arch/arm/include/asm/io.h (revision 195bbcac2e5c12f7fb99cdcc492c3000c5537f4a)
14baa9922SRussell King /*
24baa9922SRussell King  *  arch/arm/include/asm/io.h
34baa9922SRussell King  *
44baa9922SRussell King  *  Copyright (C) 1996-2000 Russell King
54baa9922SRussell King  *
64baa9922SRussell King  * This program is free software; you can redistribute it and/or modify
74baa9922SRussell King  * it under the terms of the GNU General Public License version 2 as
84baa9922SRussell King  * published by the Free Software Foundation.
94baa9922SRussell King  *
104baa9922SRussell King  * Modifications:
114baa9922SRussell King  *  16-Sep-1996	RMK	Inlined the inx/outx functions & optimised for both
124baa9922SRussell King  *			constant addresses and variable addresses.
134baa9922SRussell King  *  04-Dec-1997	RMK	Moved a lot of this stuff to the new architecture
144baa9922SRussell King  *			specific IO header files.
154baa9922SRussell King  *  27-Mar-1999	PJB	Second parameter of memcpy_toio is const..
164baa9922SRussell King  *  04-Apr-1999	PJB	Added check_signature.
174baa9922SRussell King  *  12-Dec-1999	RMK	More cleanups
184baa9922SRussell King  *  18-Jun-2000 RMK	Removed virt_to_* and friends definitions
194baa9922SRussell King  *  05-Oct-2004 BJD     Moved memory string functions to use void __iomem
204baa9922SRussell King  */
214baa9922SRussell King #ifndef __ASM_ARM_IO_H
224baa9922SRussell King #define __ASM_ARM_IO_H
234baa9922SRussell King 
244baa9922SRussell King #ifdef __KERNEL__
254baa9922SRussell King 
264baa9922SRussell King #include <linux/types.h>
274baa9922SRussell King #include <asm/byteorder.h>
284baa9922SRussell King #include <asm/memory.h>
29e5bfb72cSMichael S. Tsirkin #include <asm-generic/pci_iomap.h>
304baa9922SRussell King 
314baa9922SRussell King /*
324baa9922SRussell King  * ISA I/O bus memory addresses are 1:1 with the physical address.
334baa9922SRussell King  */
344baa9922SRussell King #define isa_virt_to_bus virt_to_phys
354baa9922SRussell King #define isa_page_to_bus page_to_phys
364baa9922SRussell King #define isa_bus_to_virt phys_to_virt
374baa9922SRussell King 
384baa9922SRussell King /*
394baa9922SRussell King  * Generic IO read/write.  These perform native-endian accesses.  Note
404baa9922SRussell King  * that some architectures will want to re-define __raw_{read,write}w.
414baa9922SRussell King  */
424baa9922SRussell King extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
434baa9922SRussell King extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
444baa9922SRussell King extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
454baa9922SRussell King 
464baa9922SRussell King extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen);
474baa9922SRussell King extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
484baa9922SRussell King extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
494baa9922SRussell King 
50*195bbcacSWill Deacon #if __LINUX_ARM_ARCH__ < 6
51*195bbcacSWill Deacon /*
52*195bbcacSWill Deacon  * Half-word accesses are problematic with RiscPC due to limitations of
53*195bbcacSWill Deacon  * the bus. Rather than special-case the machine, just let the compiler
54*195bbcacSWill Deacon  * generate the access for CPUs prior to ARMv6.
55*195bbcacSWill Deacon  */
564baa9922SRussell King #define __raw_readw(a)         (__chk_io_ptr(a), *(volatile unsigned short __force *)(a))
57*195bbcacSWill Deacon #define __raw_writew(v,a)      ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v)))
58*195bbcacSWill Deacon #else
59*195bbcacSWill Deacon /*
60*195bbcacSWill Deacon  * When running under a hypervisor, we want to avoid I/O accesses with
61*195bbcacSWill Deacon  * writeback addressing modes as these incur a significant performance
62*195bbcacSWill Deacon  * overhead (the address generation must be emulated in software).
63*195bbcacSWill Deacon  */
64*195bbcacSWill Deacon static inline void __raw_writew(u16 val, volatile void __iomem *addr)
65*195bbcacSWill Deacon {
66*195bbcacSWill Deacon 	asm volatile("strh %1, %0"
67*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u16 __force *)addr)
68*195bbcacSWill Deacon 		     : "r" (val));
69*195bbcacSWill Deacon }
70*195bbcacSWill Deacon 
71*195bbcacSWill Deacon static inline u16 __raw_readw(const volatile void __iomem *addr)
72*195bbcacSWill Deacon {
73*195bbcacSWill Deacon 	u16 val;
74*195bbcacSWill Deacon 	asm volatile("ldrh %1, %0"
75*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u16 __force *)addr),
76*195bbcacSWill Deacon 		       "=r" (val));
77*195bbcacSWill Deacon 	return val;
78*195bbcacSWill Deacon }
79*195bbcacSWill Deacon #endif
80*195bbcacSWill Deacon 
81*195bbcacSWill Deacon static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
82*195bbcacSWill Deacon {
83*195bbcacSWill Deacon 	asm volatile("strb %1, %0"
84*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u8 __force *)addr)
85*195bbcacSWill Deacon 		     : "r" (val));
86*195bbcacSWill Deacon }
87*195bbcacSWill Deacon 
88*195bbcacSWill Deacon static inline void __raw_writel(u32 val, volatile void __iomem *addr)
89*195bbcacSWill Deacon {
90*195bbcacSWill Deacon 	asm volatile("str %1, %0"
91*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u32 __force *)addr)
92*195bbcacSWill Deacon 		     : "r" (val));
93*195bbcacSWill Deacon }
94*195bbcacSWill Deacon 
95*195bbcacSWill Deacon static inline u8 __raw_readb(const volatile void __iomem *addr)
96*195bbcacSWill Deacon {
97*195bbcacSWill Deacon 	u8 val;
98*195bbcacSWill Deacon 	asm volatile("ldrb %1, %0"
99*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u8 __force *)addr),
100*195bbcacSWill Deacon 		       "=r" (val));
101*195bbcacSWill Deacon 	return val;
102*195bbcacSWill Deacon }
103*195bbcacSWill Deacon 
104*195bbcacSWill Deacon static inline u32 __raw_readl(const volatile void __iomem *addr)
105*195bbcacSWill Deacon {
106*195bbcacSWill Deacon 	u32 val;
107*195bbcacSWill Deacon 	asm volatile("ldr %1, %0"
108*195bbcacSWill Deacon 		     : "+Qo" (*(volatile u32 __force *)addr),
109*195bbcacSWill Deacon 		       "=r" (val));
110*195bbcacSWill Deacon 	return val;
111*195bbcacSWill Deacon }
1124baa9922SRussell King 
1134baa9922SRussell King /*
1144baa9922SRussell King  * Architecture ioremap implementation.
1154baa9922SRussell King  */
1164baa9922SRussell King #define MT_DEVICE		0
1174baa9922SRussell King #define MT_DEVICE_NONSHARED	1
1184baa9922SRussell King #define MT_DEVICE_CACHED	2
119db5b7169SRussell King #define MT_DEVICE_WC		3
1204baa9922SRussell King /*
121db5b7169SRussell King  * types 4 onwards can be found in asm/mach/map.h and are undefined
1224baa9922SRussell King  * for ioremap
1234baa9922SRussell King  */
1244baa9922SRussell King 
1254baa9922SRussell King /*
1264baa9922SRussell King  * __arm_ioremap takes CPU physical address.
1274baa9922SRussell King  * __arm_ioremap_pfn takes a Page Frame Number and an offset into that page
12831aa8fd6SRussell King  * The _caller variety takes a __builtin_return_address(0) value for
12931aa8fd6SRussell King  * /proc/vmalloc to use - and should only be used in non-inline functions.
1304baa9922SRussell King  */
13131aa8fd6SRussell King extern void __iomem *__arm_ioremap_pfn_caller(unsigned long, unsigned long,
13231aa8fd6SRussell King 	size_t, unsigned int, void *);
13331aa8fd6SRussell King extern void __iomem *__arm_ioremap_caller(unsigned long, size_t, unsigned int,
13431aa8fd6SRussell King 	void *);
13531aa8fd6SRussell King 
1364baa9922SRussell King extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
1374baa9922SRussell King extern void __iomem *__arm_ioremap(unsigned long, size_t, unsigned int);
1386c5482d5STony Lindgren extern void __iomem *__arm_ioremap_exec(unsigned long, size_t, bool cached);
1394baa9922SRussell King extern void __iounmap(volatile void __iomem *addr);
1404fe7ef3aSRob Herring extern void __arm_iounmap(volatile void __iomem *addr);
1414fe7ef3aSRob Herring 
1424fe7ef3aSRob Herring extern void __iomem * (*arch_ioremap_caller)(unsigned long, size_t,
1434fe7ef3aSRob Herring 	unsigned int, void *);
1444fe7ef3aSRob Herring extern void (*arch_iounmap)(volatile void __iomem *);
1454baa9922SRussell King 
1464baa9922SRussell King /*
1474baa9922SRussell King  * Bad read/write accesses...
1484baa9922SRussell King  */
1494baa9922SRussell King extern void __readwrite_bug(const char *fn);
1504baa9922SRussell King 
1514baa9922SRussell King /*
1520560cf5aSRussell King  * A typesafe __io() helper
1530560cf5aSRussell King  */
1540560cf5aSRussell King static inline void __iomem *__typesafe_io(unsigned long addr)
1550560cf5aSRussell King {
1560560cf5aSRussell King 	return (void __iomem *)addr;
1570560cf5aSRussell King }
1580560cf5aSRussell King 
1596f6f6a70SRob Herring #define IOMEM(x)	((void __force __iomem *)(x))
1606f6f6a70SRob Herring 
161c1928022SRussell King /* IO barriers */
162c1928022SRussell King #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
1639f97da78SDavid Howells #include <asm/barrier.h>
164c1928022SRussell King #define __iormb()		rmb()
165c1928022SRussell King #define __iowmb()		wmb()
166c1928022SRussell King #else
167c1928022SRussell King #define __iormb()		do { } while (0)
168c1928022SRussell King #define __iowmb()		do { } while (0)
169c1928022SRussell King #endif
170c1928022SRussell King 
1710560cf5aSRussell King /*
1724baa9922SRussell King  * Now, pick up the machine-defined IO definitions
1734baa9922SRussell King  */
174c334bc15SRob Herring #ifdef CONFIG_NEED_MACH_IO_H
175a09e64fbSRussell King #include <mach/io.h>
176c334bc15SRob Herring #else
1771ac02d79SRob Herring #define __io(a)		__typesafe_io((a) & IO_SPACE_LIMIT)
178c334bc15SRob Herring #endif
1794baa9922SRussell King 
1804baa9922SRussell King /*
18104e1c838SRussell King  * This is the limit of PC card/PCI/ISA IO space, which is by default
18204e1c838SRussell King  * 64K if we have PC card, PCI or ISA support.  Otherwise, default to
18304e1c838SRussell King  * zero to prevent ISA/PCI drivers claiming IO space (and potentially
18404e1c838SRussell King  * oopsing.)
18504e1c838SRussell King  *
18604e1c838SRussell King  * Only set this larger if you really need inb() et.al. to operate over
18704e1c838SRussell King  * a larger address space.  Note that SOC_COMMON ioremaps each sockets
18804e1c838SRussell King  * IO space area, and so inb() et.al. must be defined to operate as per
18904e1c838SRussell King  * readb() et.al. on such platforms.
19004e1c838SRussell King  */
19104e1c838SRussell King #ifndef IO_SPACE_LIMIT
19204e1c838SRussell King #if defined(CONFIG_PCMCIA_SOC_COMMON) || defined(CONFIG_PCMCIA_SOC_COMMON_MODULE)
19304e1c838SRussell King #define IO_SPACE_LIMIT ((resource_size_t)0xffffffff)
19404e1c838SRussell King #elif defined(CONFIG_PCI) || defined(CONFIG_ISA) || defined(CONFIG_PCCARD)
19504e1c838SRussell King #define IO_SPACE_LIMIT ((resource_size_t)0xffff)
19604e1c838SRussell King #else
19704e1c838SRussell King #define IO_SPACE_LIMIT ((resource_size_t)0)
19804e1c838SRussell King #endif
19904e1c838SRussell King #endif
20004e1c838SRussell King 
20104e1c838SRussell King /*
2024baa9922SRussell King  *  IO port access primitives
2034baa9922SRussell King  *  -------------------------
2044baa9922SRussell King  *
2054baa9922SRussell King  * The ARM doesn't have special IO access instructions; all IO is memory
2064baa9922SRussell King  * mapped.  Note that these are defined to perform little endian accesses
2074baa9922SRussell King  * only.  Their primary purpose is to access PCI and ISA peripherals.
2084baa9922SRussell King  *
2094baa9922SRussell King  * Note that for a big endian machine, this implies that the following
2104baa9922SRussell King  * big endian mode connectivity is in place, as described by numerous
2114baa9922SRussell King  * ARM documents:
2124baa9922SRussell King  *
2134baa9922SRussell King  *    PCI:  D0-D7   D8-D15 D16-D23 D24-D31
2144baa9922SRussell King  *    ARM: D24-D31 D16-D23  D8-D15  D0-D7
2154baa9922SRussell King  *
2164baa9922SRussell King  * The machine specific io.h include defines __io to translate an "IO"
2174baa9922SRussell King  * address to a memory address.
2184baa9922SRussell King  *
2194baa9922SRussell King  * Note that we prevent GCC re-ordering or caching values in expressions
2204baa9922SRussell King  * by introducing sequence points into the in*() definitions.  Note that
2214baa9922SRussell King  * __raw_* do not guarantee this behaviour.
2224baa9922SRussell King  *
2234baa9922SRussell King  * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space.
2244baa9922SRussell King  */
2254baa9922SRussell King #ifdef __io
226c1928022SRussell King #define outb(v,p)	({ __iowmb(); __raw_writeb(v,__io(p)); })
227c1928022SRussell King #define outw(v,p)	({ __iowmb(); __raw_writew((__force __u16) \
228c1928022SRussell King 					cpu_to_le16(v),__io(p)); })
229c1928022SRussell King #define outl(v,p)	({ __iowmb(); __raw_writel((__force __u32) \
230c1928022SRussell King 					cpu_to_le32(v),__io(p)); })
2314baa9922SRussell King 
232c1928022SRussell King #define inb(p)	({ __u8 __v = __raw_readb(__io(p)); __iormb(); __v; })
2334baa9922SRussell King #define inw(p)	({ __u16 __v = le16_to_cpu((__force __le16) \
234c1928022SRussell King 			__raw_readw(__io(p))); __iormb(); __v; })
2354baa9922SRussell King #define inl(p)	({ __u32 __v = le32_to_cpu((__force __le32) \
236c1928022SRussell King 			__raw_readl(__io(p))); __iormb(); __v; })
2374baa9922SRussell King 
2384baa9922SRussell King #define outsb(p,d,l)		__raw_writesb(__io(p),d,l)
2394baa9922SRussell King #define outsw(p,d,l)		__raw_writesw(__io(p),d,l)
2404baa9922SRussell King #define outsl(p,d,l)		__raw_writesl(__io(p),d,l)
2414baa9922SRussell King 
2424baa9922SRussell King #define insb(p,d,l)		__raw_readsb(__io(p),d,l)
2434baa9922SRussell King #define insw(p,d,l)		__raw_readsw(__io(p),d,l)
2444baa9922SRussell King #define insl(p,d,l)		__raw_readsl(__io(p),d,l)
2454baa9922SRussell King #endif
2464baa9922SRussell King 
2474baa9922SRussell King #define outb_p(val,port)	outb((val),(port))
2484baa9922SRussell King #define outw_p(val,port)	outw((val),(port))
2494baa9922SRussell King #define outl_p(val,port)	outl((val),(port))
2504baa9922SRussell King #define inb_p(port)		inb((port))
2514baa9922SRussell King #define inw_p(port)		inw((port))
2524baa9922SRussell King #define inl_p(port)		inl((port))
2534baa9922SRussell King 
2544baa9922SRussell King #define outsb_p(port,from,len)	outsb(port,from,len)
2554baa9922SRussell King #define outsw_p(port,from,len)	outsw(port,from,len)
2564baa9922SRussell King #define outsl_p(port,from,len)	outsl(port,from,len)
2574baa9922SRussell King #define insb_p(port,to,len)	insb(port,to,len)
2584baa9922SRussell King #define insw_p(port,to,len)	insw(port,to,len)
2594baa9922SRussell King #define insl_p(port,to,len)	insl(port,to,len)
2604baa9922SRussell King 
2614baa9922SRussell King /*
2624baa9922SRussell King  * String version of IO memory access ops:
2634baa9922SRussell King  */
2644baa9922SRussell King extern void _memcpy_fromio(void *, const volatile void __iomem *, size_t);
2654baa9922SRussell King extern void _memcpy_toio(volatile void __iomem *, const void *, size_t);
2664baa9922SRussell King extern void _memset_io(volatile void __iomem *, int, size_t);
2674baa9922SRussell King 
2684baa9922SRussell King #define mmiowb()
2694baa9922SRussell King 
2704baa9922SRussell King /*
2714baa9922SRussell King  *  Memory access primitives
2724baa9922SRussell King  *  ------------------------
2734baa9922SRussell King  *
2744baa9922SRussell King  * These perform PCI memory accesses via an ioremap region.  They don't
2754baa9922SRussell King  * take an address as such, but a cookie.
2764baa9922SRussell King  *
2774baa9922SRussell King  * Again, this are defined to perform little endian accesses.  See the
2784baa9922SRussell King  * IO port primitives for more information.
2794baa9922SRussell King  */
2805621caacSRob Herring #ifndef readl
2815621caacSRob Herring #define readb_relaxed(c) ({ u8  __r = __raw_readb(c); __r; })
282b0c1264fSOlof Johansson #define readw_relaxed(c) ({ u16 __r = le16_to_cpu((__force __le16) \
2835621caacSRob Herring 					__raw_readw(c)); __r; })
284b0c1264fSOlof Johansson #define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32) \
2855621caacSRob Herring 					__raw_readl(c)); __r; })
286e936771aSCatalin Marinas 
287af06bb9fSRussell King #define writeb_relaxed(v,c)	__raw_writeb(v,c)
288af06bb9fSRussell King #define writew_relaxed(v,c)	__raw_writew((__force u16) cpu_to_le16(v),c)
289af06bb9fSRussell King #define writel_relaxed(v,c)	__raw_writel((__force u32) cpu_to_le32(v),c)
290e936771aSCatalin Marinas 
291b92b3612SRussell King #define readb(c)		({ u8  __v = readb_relaxed(c); __iormb(); __v; })
292b92b3612SRussell King #define readw(c)		({ u16 __v = readw_relaxed(c); __iormb(); __v; })
293b92b3612SRussell King #define readl(c)		({ u32 __v = readl_relaxed(c); __iormb(); __v; })
294b92b3612SRussell King 
295b92b3612SRussell King #define writeb(v,c)		({ __iowmb(); writeb_relaxed(v,c); })
296b92b3612SRussell King #define writew(v,c)		({ __iowmb(); writew_relaxed(v,c); })
297b92b3612SRussell King #define writel(v,c)		({ __iowmb(); writel_relaxed(v,c); })
298b92b3612SRussell King 
2995621caacSRob Herring #define readsb(p,d,l)		__raw_readsb(p,d,l)
3005621caacSRob Herring #define readsw(p,d,l)		__raw_readsw(p,d,l)
3015621caacSRob Herring #define readsl(p,d,l)		__raw_readsl(p,d,l)
3024baa9922SRussell King 
3035621caacSRob Herring #define writesb(p,d,l)		__raw_writesb(p,d,l)
3045621caacSRob Herring #define writesw(p,d,l)		__raw_writesw(p,d,l)
3055621caacSRob Herring #define writesl(p,d,l)		__raw_writesl(p,d,l)
3064baa9922SRussell King 
3075621caacSRob Herring #define memset_io(c,v,l)	_memset_io(c,(v),(l))
3085621caacSRob Herring #define memcpy_fromio(a,c,l)	_memcpy_fromio((a),c,(l))
3095621caacSRob Herring #define memcpy_toio(c,a,l)	_memcpy_toio(c,(a),(l))
3104baa9922SRussell King 
3115621caacSRob Herring #endif	/* readl */
3124baa9922SRussell King 
3134baa9922SRussell King /*
3144baa9922SRussell King  * ioremap and friends.
3154baa9922SRussell King  *
3164baa9922SRussell King  * ioremap takes a PCI memory address, as specified in
317395cf969SPaul Bolle  * Documentation/io-mapping.txt.
3184baa9922SRussell King  *
3194baa9922SRussell King  */
32021a5365bSRob Herring #define ioremap(cookie,size)		__arm_ioremap((cookie), (size), MT_DEVICE)
32121a5365bSRob Herring #define ioremap_nocache(cookie,size)	__arm_ioremap((cookie), (size), MT_DEVICE)
32221a5365bSRob Herring #define ioremap_cached(cookie,size)	__arm_ioremap((cookie), (size), MT_DEVICE_CACHED)
32321a5365bSRob Herring #define ioremap_wc(cookie,size)		__arm_ioremap((cookie), (size), MT_DEVICE_WC)
32421a5365bSRob Herring #define iounmap				__arm_iounmap
3254baa9922SRussell King 
3264baa9922SRussell King /*
3274baa9922SRussell King  * io{read,write}{8,16,32} macros
3284baa9922SRussell King  */
3294baa9922SRussell King #ifndef ioread8
330b92b3612SRussell King #define ioread8(p)	({ unsigned int __v = __raw_readb(p); __iormb(); __v; })
331b92b3612SRussell King #define ioread16(p)	({ unsigned int __v = le16_to_cpu((__force __le16)__raw_readw(p)); __iormb(); __v; })
332b92b3612SRussell King #define ioread32(p)	({ unsigned int __v = le32_to_cpu((__force __le32)__raw_readl(p)); __iormb(); __v; })
3334baa9922SRussell King 
33406901bd8SArnd Bergmann #define ioread16be(p)	({ unsigned int __v = be16_to_cpu((__force __be16)__raw_readw(p)); __iormb(); __v; })
33506901bd8SArnd Bergmann #define ioread32be(p)	({ unsigned int __v = be32_to_cpu((__force __be32)__raw_readl(p)); __iormb(); __v; })
33606901bd8SArnd Bergmann 
337af06bb9fSRussell King #define iowrite8(v,p)	({ __iowmb(); __raw_writeb(v, p); })
338af06bb9fSRussell King #define iowrite16(v,p)	({ __iowmb(); __raw_writew((__force __u16)cpu_to_le16(v), p); })
339af06bb9fSRussell King #define iowrite32(v,p)	({ __iowmb(); __raw_writel((__force __u32)cpu_to_le32(v), p); })
3404baa9922SRussell King 
341af06bb9fSRussell King #define iowrite16be(v,p) ({ __iowmb(); __raw_writew((__force __u16)cpu_to_be16(v), p); })
342af06bb9fSRussell King #define iowrite32be(v,p) ({ __iowmb(); __raw_writel((__force __u32)cpu_to_be32(v), p); })
34306901bd8SArnd Bergmann 
3444baa9922SRussell King #define ioread8_rep(p,d,c)	__raw_readsb(p,d,c)
3454baa9922SRussell King #define ioread16_rep(p,d,c)	__raw_readsw(p,d,c)
3464baa9922SRussell King #define ioread32_rep(p,d,c)	__raw_readsl(p,d,c)
3474baa9922SRussell King 
3484baa9922SRussell King #define iowrite8_rep(p,s,c)	__raw_writesb(p,s,c)
3494baa9922SRussell King #define iowrite16_rep(p,s,c)	__raw_writesw(p,s,c)
3504baa9922SRussell King #define iowrite32_rep(p,s,c)	__raw_writesl(p,s,c)
3514baa9922SRussell King 
3524baa9922SRussell King extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
3534baa9922SRussell King extern void ioport_unmap(void __iomem *addr);
3544baa9922SRussell King #endif
3554baa9922SRussell King 
3564baa9922SRussell King struct pci_dev;
3574baa9922SRussell King 
3584baa9922SRussell King extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
3594baa9922SRussell King 
3604baa9922SRussell King /*
3614baa9922SRussell King  * can the hardware map this into one segment or not, given no other
3624baa9922SRussell King  * constraints.
3634baa9922SRussell King  */
3644baa9922SRussell King #define BIOVEC_MERGEABLE(vec1, vec2)	\
3654baa9922SRussell King 	((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
3664baa9922SRussell King 
3674baa9922SRussell King #ifdef CONFIG_MMU
3684baa9922SRussell King #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
3694baa9922SRussell King extern int valid_phys_addr_range(unsigned long addr, size_t size);
3704baa9922SRussell King extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
371087aaffcSNicolas Pitre extern int devmem_is_allowed(unsigned long pfn);
3724baa9922SRussell King #endif
3734baa9922SRussell King 
3744baa9922SRussell King /*
3754baa9922SRussell King  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
3764baa9922SRussell King  * access
3774baa9922SRussell King  */
3784baa9922SRussell King #define xlate_dev_mem_ptr(p)	__va(p)
3794baa9922SRussell King 
3804baa9922SRussell King /*
3814baa9922SRussell King  * Convert a virtual cached pointer to an uncached pointer
3824baa9922SRussell King  */
3834baa9922SRussell King #define xlate_dev_kmem_ptr(p)	p
3844baa9922SRussell King 
3854baa9922SRussell King /*
3864baa9922SRussell King  * Register ISA memory and port locations for glibc iopl/inb/outb
3874baa9922SRussell King  * emulation.
3884baa9922SRussell King  */
3894baa9922SRussell King extern void register_isa_ports(unsigned int mmio, unsigned int io,
3904baa9922SRussell King 			       unsigned int io_shift);
3914baa9922SRussell King 
3924baa9922SRussell King #endif	/* __KERNEL__ */
3934baa9922SRussell King #endif	/* __ASM_ARM_IO_H */
394