1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
---
include/asm-avr32/io.h | 73 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 24 deletions(-)
Index: linux-2.6.18-avr32/include/asm-avr32/io.h
===================================================================
--- linux-2.6.18-avr32.orig/include/asm-avr32/io.h 2006-11-02 16:40:37.000000000 +0100
+++ linux-2.6.18-avr32/include/asm-avr32/io.h 2006-11-03 17:58:06.000000000 +0100
@@ -5,6 +5,8 @@
#ifdef __KERNEL__
+#include <linux/types.h>
+
#include <asm/addrspace.h>
#include <asm/byteorder.h>
@@ -36,37 +38,64 @@ extern void __raw_readsb(unsigned int ad
extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
extern void __raw_readsl(unsigned int addr, void *data, int longlen);
-static inline void writeb(unsigned char b, volatile void __iomem *addr)
+static inline void __raw_writeb(u8 v, volatile void __iomem *addr)
+{
+ *(volatile u8 __force *)addr = v;
+}
+static inline void __raw_writew(u16 v, volatile void __iomem *addr)
+{
+ *(volatile u16 __force *)addr = v;
+}
+static inline void __raw_writel(u32 v, volatile void __iomem *addr)
+{
+ *(volatile u32 __force *)addr = v;
+}
+
+static inline u8 __raw_readb(const volatile void __iomem *addr)
{
- *(volatile unsigned char __force *)addr = b;
+ return *(const volatile u8 __force *)addr;
}
-static inline void writew(unsigned short b, volatile void __iomem *addr)
+static inline u16 __raw_readw(const volatile void __iomem *addr)
{
- *(volatile unsigned short __force *)addr = b;
+ return *(const volatile u16 __force *)addr;
}
-static inline void writel(unsigned int b, volatile void __iomem *addr)
+static inline u32 __raw_readl(const volatile void __iomem *addr)
{
- *(volatile unsigned int __force *)addr = b;
+ return *(const volatile u32 __force *)addr;
}
-#define __raw_writeb writeb
-#define __raw_writew writew
-#define __raw_writel writel
-static inline unsigned char readb(const volatile void __iomem *addr)
+#define __swizzle_addr_b(addr) \
+ ((typeof(addr))((unsigned long)(addr) ^ 3UL))
+#define __swizzle_addr_w(addr) \
+ ((typeof(addr))((unsigned long)(addr) ^ 2UL))
+#define __swizzle_addr_l(addr) \
+ (addr)
+
+static inline void writeb(u8 v, volatile void __iomem *addr)
{
- return *(const volatile unsigned char __force *)addr;
+ __raw_writeb(v, __swizzle_addr_b(addr));
}
-static inline unsigned short readw(const volatile void __iomem *addr)
+static inline void writew(u16 v, volatile void __iomem *addr)
{
- return *(const volatile unsigned short __force *)addr;
+ __raw_writew(v, __swizzle_addr_w(addr));
}
-static inline unsigned int readl(const volatile void __iomem *addr)
+static inline void writel(u32 v, volatile void __iomem *addr)
{
- return *(const volatile unsigned int __force *)addr;
+ __raw_writel(v, __swizzle_addr_l(addr));
+}
+
+static inline u8 readb(const volatile void __iomem *addr)
+{
+ return __raw_readb(__swizzle_addr_b(addr));
+}
+static inline u16 readw(const volatile void __iomem *addr)
+{
+ return __raw_readw(__swizzle_addr_w(addr));
+}
+static inline u32 readl(const volatile void __iomem *addr)
+{
+ return __raw_readl(__swizzle_addr_l(addr));
}
-#define __raw_readb readb
-#define __raw_readw readw
-#define __raw_readl readl
#define writesb(p, d, l) __raw_writesb((unsigned int)p, d, l)
#define writesw(p, d, l) __raw_writesw((unsigned int)p, d, l)
@@ -108,17 +137,13 @@ static inline unsigned int readl(const v
#endif
-
-/*
- * These two are only here because ALSA _thinks_ it needs them...
- */
static inline void memcpy_fromio(void * to, const volatile void __iomem *from,
unsigned long count)
{
char *p = to;
while (count) {
count--;
- *p = readb(from);
+ *p = __raw_readb(from);
p++;
from++;
}
@@ -130,7 +155,7 @@ static inline void memcpy_toio(volatile
const char *p = from;
while (count) {
count--;
- writeb(*p, to);
+ __raw_writeb(*p, to);
p++;
to++;
}
|