diff options
Diffstat (limited to 'arch/arm/include/asm/io.h')
-rw-r--r-- | arch/arm/include/asm/io.h | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 815c669fec0a..35c1ed89b936 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h | |||
@@ -47,13 +47,68 @@ extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen); | |||
47 | extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); | 47 | extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); |
48 | extern void __raw_readsl(const void __iomem *addr, void *data, int longlen); | 48 | extern void __raw_readsl(const void __iomem *addr, void *data, int longlen); |
49 | 49 | ||
50 | #define __raw_writeb(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned char __force *)(a) = (v))) | 50 | #if __LINUX_ARM_ARCH__ < 6 |
51 | #define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v))) | 51 | /* |
52 | #define __raw_writel(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned int __force *)(a) = (v))) | 52 | * Half-word accesses are problematic with RiscPC due to limitations of |
53 | * the bus. Rather than special-case the machine, just let the compiler | ||
54 | * generate the access for CPUs prior to ARMv6. | ||
55 | */ | ||
56 | #define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a)) | ||
57 | #define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v))) | ||
58 | #else | ||
59 | /* | ||
60 | * When running under a hypervisor, we want to avoid I/O accesses with | ||
61 | * writeback addressing modes as these incur a significant performance | ||
62 | * overhead (the address generation must be emulated in software). | ||
63 | */ | ||
64 | static inline void __raw_writew(u16 val, volatile void __iomem *addr) | ||
65 | { | ||
66 | asm volatile("strh %1, %0" | ||
67 | : "+Qo" (*(volatile u16 __force *)addr) | ||
68 | : "r" (val)); | ||
69 | } | ||
70 | |||
71 | static inline u16 __raw_readw(const volatile void __iomem *addr) | ||
72 | { | ||
73 | u16 val; | ||
74 | asm volatile("ldrh %1, %0" | ||
75 | : "+Qo" (*(volatile u16 __force *)addr), | ||
76 | "=r" (val)); | ||
77 | return val; | ||
78 | } | ||
79 | #endif | ||
80 | |||
81 | static inline void __raw_writeb(u8 val, volatile void __iomem *addr) | ||
82 | { | ||
83 | asm volatile("strb %1, %0" | ||
84 | : "+Qo" (*(volatile u8 __force *)addr) | ||
85 | : "r" (val)); | ||
86 | } | ||
87 | |||
88 | static inline void __raw_writel(u32 val, volatile void __iomem *addr) | ||
89 | { | ||
90 | asm volatile("str %1, %0" | ||
91 | : "+Qo" (*(volatile u32 __force *)addr) | ||
92 | : "r" (val)); | ||
93 | } | ||
94 | |||
95 | static inline u8 __raw_readb(const volatile void __iomem *addr) | ||
96 | { | ||
97 | u8 val; | ||
98 | asm volatile("ldrb %1, %0" | ||
99 | : "+Qo" (*(volatile u8 __force *)addr), | ||
100 | "=r" (val)); | ||
101 | return val; | ||
102 | } | ||
53 | 103 | ||
54 | #define __raw_readb(a) (__chk_io_ptr(a), *(volatile unsigned char __force *)(a)) | 104 | static inline u32 __raw_readl(const volatile void __iomem *addr) |
55 | #define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a)) | 105 | { |
56 | #define __raw_readl(a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a)) | 106 | u32 val; |
107 | asm volatile("ldr %1, %0" | ||
108 | : "+Qo" (*(volatile u32 __force *)addr), | ||
109 | "=r" (val)); | ||
110 | return val; | ||
111 | } | ||
57 | 112 | ||
58 | /* | 113 | /* |
59 | * Architecture ioremap implementation. | 114 | * Architecture ioremap implementation. |
@@ -113,11 +168,19 @@ static inline void __iomem *__typesafe_io(unsigned long addr) | |||
113 | #define __iowmb() do { } while (0) | 168 | #define __iowmb() do { } while (0) |
114 | #endif | 169 | #endif |
115 | 170 | ||
171 | /* PCI fixed i/o mapping */ | ||
172 | #define PCI_IO_VIRT_BASE 0xfee00000 | ||
173 | |||
174 | extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr); | ||
175 | |||
116 | /* | 176 | /* |
117 | * Now, pick up the machine-defined IO definitions | 177 | * Now, pick up the machine-defined IO definitions |
118 | */ | 178 | */ |
119 | #ifdef CONFIG_NEED_MACH_IO_H | 179 | #ifdef CONFIG_NEED_MACH_IO_H |
120 | #include <mach/io.h> | 180 | #include <mach/io.h> |
181 | #elif defined(CONFIG_PCI) | ||
182 | #define IO_SPACE_LIMIT ((resource_size_t)0xfffff) | ||
183 | #define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT)) | ||
121 | #else | 184 | #else |
122 | #define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT) | 185 | #define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT) |
123 | #endif | 186 | #endif |