mpc83xx: add support for 3.7
[openwrt/svn-archive/archive.git] / target / linux / mpc83xx / patches-3.7 / 201-powerpc-add-rb_iomap.patch
1 --- a/arch/powerpc/kernel/Makefile
2 +++ b/arch/powerpc/kernel/Makefile
3 @@ -118,9 +118,11 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.
4
5 obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o
6
7 +ifneq ($(CONFIG_RB_IOMAP),y)
8 ifneq ($(CONFIG_PPC_INDIRECT_IO),y)
9 obj-y += iomap.o
10 endif
11 +endif
12
13 obj-$(CONFIG_PPC64) += $(obj64-y)
14 obj-$(CONFIG_PPC32) += $(obj32-y)
15 --- a/arch/powerpc/platforms/83xx/Makefile
16 +++ b/arch/powerpc/platforms/83xx/Makefile
17 @@ -7,6 +7,7 @@ obj-$(CONFIG_MCU_MPC8349EMITX) += mcu_mp
18 obj-$(CONFIG_MPC830x_RDB) += mpc830x_rdb.o
19 obj-$(CONFIG_MPC831x_RDB) += mpc831x_rdb.o
20 obj-$(CONFIG_MPC832x_RDB) += mpc832x_rdb.o
21 +obj-$(CONFIG_RB_PPC) += rbppc.o
22 obj-$(CONFIG_MPC834x_MDS) += mpc834x_mds.o
23 obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o
24 obj-$(CONFIG_MPC836x_MDS) += mpc836x_mds.o
25 --- a/arch/powerpc/platforms/Kconfig
26 +++ b/arch/powerpc/platforms/Kconfig
27 @@ -191,6 +191,10 @@ config PPC_INDIRECT_MMIO
28 config PPC_IO_WORKAROUNDS
29 bool
30
31 +config RB_IOMAP
32 + bool
33 + default y if RB_PPC
34 +
35 source "drivers/cpufreq/Kconfig"
36
37 menu "CPU Frequency drivers"
38 --- a/arch/powerpc/sysdev/Makefile
39 +++ b/arch/powerpc/sysdev/Makefile
40 @@ -69,3 +69,6 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -
41 obj-$(CONFIG_PPC_XICS) += xics/
42
43 obj-$(CONFIG_GE_FPGA) += ge/
44 +
45 +obj-$(CONFIG_RB_IOMAP) += rb_iomap.o
46 +
47 --- /dev/null
48 +++ b/arch/powerpc/sysdev/rb_iomap.c
49 @@ -0,0 +1,204 @@
50 +#include <linux/init.h>
51 +#include <linux/pci.h>
52 +#include <linux/mm.h>
53 +#include <asm/io.h>
54 +
55 +#define LOCALBUS_START 0x40000000
56 +#define LOCALBUS_MASK 0x007fffff
57 +#define LOCALBUS_REGMASK 0x001fffff
58 +
59 +static void __iomem *localbus_base;
60 +
61 +static inline int is_localbus(void __iomem *addr)
62 +{
63 + return ((unsigned) addr & ~LOCALBUS_MASK) == LOCALBUS_START;
64 +}
65 +
66 +static inline unsigned localbus_regoff(unsigned reg) {
67 + return (reg << 16) | (((reg ^ 8) & 8) << 17);
68 +}
69 +
70 +static inline void __iomem *localbus_addr(void __iomem *addr)
71 +{
72 + return localbus_base
73 + + ((unsigned) addr & LOCALBUS_MASK & ~LOCALBUS_REGMASK)
74 + + localbus_regoff((unsigned) addr & LOCALBUS_REGMASK);
75 +}
76 +
77 +unsigned int ioread8(void __iomem *addr)
78 +{
79 + if (is_localbus(addr))
80 + return in_be16(localbus_addr(addr)) >> 8;
81 + return readb(addr);
82 +}
83 +EXPORT_SYMBOL(ioread8);
84 +
85 +unsigned int ioread16(void __iomem *addr)
86 +{
87 + if (is_localbus(addr))
88 + return le16_to_cpu(in_be16(localbus_addr(addr)));
89 + return readw(addr);
90 +}
91 +EXPORT_SYMBOL(ioread16);
92 +
93 +unsigned int ioread16be(void __iomem *addr)
94 +{
95 + return in_be16(addr);
96 +}
97 +EXPORT_SYMBOL(ioread16be);
98 +
99 +unsigned int ioread32(void __iomem *addr)
100 +{
101 + return readl(addr);
102 +}
103 +EXPORT_SYMBOL(ioread32);
104 +
105 +unsigned int ioread32be(void __iomem *addr)
106 +{
107 + return in_be32(addr);
108 +}
109 +EXPORT_SYMBOL(ioread32be);
110 +
111 +void iowrite8(u8 val, void __iomem *addr)
112 +{
113 + if (is_localbus(addr))
114 + out_be16(localbus_addr(addr), ((u16) val) << 8);
115 + else
116 + writeb(val, addr);
117 +}
118 +EXPORT_SYMBOL(iowrite8);
119 +
120 +void iowrite16(u16 val, void __iomem *addr)
121 +{
122 + if (is_localbus(addr))
123 + out_be16(localbus_addr(addr), cpu_to_le16(val));
124 + else
125 + writew(val, addr);
126 +}
127 +EXPORT_SYMBOL(iowrite16);
128 +
129 +void iowrite16be(u16 val, void __iomem *addr)
130 +{
131 + out_be16(addr, val);
132 +}
133 +EXPORT_SYMBOL(iowrite16be);
134 +
135 +void iowrite32(u32 val, void __iomem *addr)
136 +{
137 + writel(val, addr);
138 +}
139 +EXPORT_SYMBOL(iowrite32);
140 +
141 +void iowrite32be(u32 val, void __iomem *addr)
142 +{
143 + out_be32(addr, val);
144 +}
145 +EXPORT_SYMBOL(iowrite32be);
146 +
147 +void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
148 +{
149 + if (is_localbus(addr)) {
150 + unsigned i;
151 + void *laddr = localbus_addr(addr);
152 + u8 *buf = dst;
153 +
154 + for (i = 0; i < count; ++i) {
155 + *buf++ = in_be16(laddr) >> 8;
156 + }
157 + } else {
158 + _insb((u8 __iomem *) addr, dst, count);
159 + }
160 +}
161 +EXPORT_SYMBOL(ioread8_rep);
162 +
163 +void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
164 +{
165 + if (is_localbus(addr)) {
166 + unsigned i;
167 + void *laddr = localbus_addr(addr);
168 + u16 *buf = dst;
169 +
170 + for (i = 0; i < count; ++i) {
171 + *buf++ = in_be16(laddr);
172 + }
173 + } else {
174 + _insw_ns((u16 __iomem *) addr, dst, count);
175 + }
176 +}
177 +EXPORT_SYMBOL(ioread16_rep);
178 +
179 +void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
180 +{
181 + _insl_ns((u32 __iomem *) addr, dst, count);
182 +}
183 +EXPORT_SYMBOL(ioread32_rep);
184 +
185 +void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
186 +{
187 + if (is_localbus(addr)) {
188 + unsigned i;
189 + void *laddr = localbus_addr(addr);
190 + const u8 *buf = src;
191 +
192 + for (i = 0; i < count; ++i) {
193 + out_be16(laddr, ((u16) *buf++) << 8);
194 + }
195 + } else {
196 + _outsb((u8 __iomem *) addr, src, count);
197 + }
198 +}
199 +EXPORT_SYMBOL(iowrite8_rep);
200 +
201 +void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
202 +{
203 + if (is_localbus(addr)) {
204 + unsigned i;
205 + void *laddr = localbus_addr(addr);
206 + const u16 *buf = src;
207 +
208 + for (i = 0; i < count; ++i) {
209 + out_be16(laddr, *buf++);
210 + }
211 + } else {
212 + _outsw_ns((u16 __iomem *) addr, src, count);
213 + }
214 +}
215 +EXPORT_SYMBOL(iowrite16_rep);
216 +
217 +void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
218 +{
219 + _outsl_ns((u32 __iomem *) addr, src, count);
220 +}
221 +EXPORT_SYMBOL(iowrite32_rep);
222 +
223 +void __iomem *ioport_map(unsigned long port, unsigned int len)
224 +{
225 + return (void __iomem *) (port + _IO_BASE);
226 +}
227 +EXPORT_SYMBOL(ioport_unmap);
228 +
229 +void ioport_unmap(void __iomem *addr)
230 +{
231 + /* Nothing to do */
232 +}
233 +EXPORT_SYMBOL(ioport_map);
234 +
235 +void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
236 +{
237 + /* Nothing to do */
238 +}
239 +EXPORT_SYMBOL(pci_iounmap);
240 +
241 +void __iomem *localbus_map(unsigned long addr, unsigned int len)
242 +{
243 + if (!localbus_base)
244 + localbus_base = ioremap(addr & ~LOCALBUS_MASK,
245 + LOCALBUS_MASK + 1);
246 + return (void *) (LOCALBUS_START + (addr & LOCALBUS_MASK));
247 +}
248 +EXPORT_SYMBOL(localbus_map);
249 +
250 +void localbus_unmap(void __iomem *addr)
251 +{
252 +}
253 +EXPORT_SYMBOL(localbus_unmap);
254 --- a/arch/powerpc/platforms/83xx/Kconfig
255 +++ b/arch/powerpc/platforms/83xx/Kconfig
256 @@ -44,6 +44,7 @@ config RB_PPC
257 select QUICC_ENGINE
258 select PPC_MPC832x
259 select PPC_MPC834x
260 + select RB_IOMAP
261 help
262 This option enables support for MikroTik RouterBOARD 333/600 series boards.
263