add ATA version of the Magicbox CF driver
[openwrt/openwrt.git] / target / linux / ppc40x / patches-2.6.30 / 006-magicboxv2.patch
1 --- /dev/null
2 +++ b/arch/powerpc/boot/cuboot-magicboxv2.c
3 @@ -0,0 +1,70 @@
4 +/*
5 + * Old U-boot compatibility for Magicbox v2
6 + *
7 + * Author: Imre Kaloz <kaloz@openwrt.org>
8 + * Gabor Juhos <juhosg@openwrt.org>
9 + *
10 + * This program is free software; you can redistribute it and/or modify it
11 + * under the terms of the GNU General Public License version 2 as published
12 + * by the Free Software Foundation.
13 + */
14 +
15 +#include "ops.h"
16 +#include "io.h"
17 +#include "dcr.h"
18 +#include "stdio.h"
19 +#include "4xx.h"
20 +#include "44x.h"
21 +#include "cuboot.h"
22 +
23 +#define TARGET_4xx
24 +#define TARGET_405EP
25 +#include "ppcboot.h"
26 +
27 +static bd_t bd;
28 +
29 +static void fixup_cf_card(void)
30 +{
31 +#define DCRN_CPC0_PCI_BASE 0xf9
32 +#define CF_CS0_BASE 0xff100000
33 +#define CF_CS1_BASE 0xff200000
34 +
35 + /* Turn on PerWE instead of PCIsomething */
36 + mtdcr(DCRN_CPC0_PCI_BASE,
37 + mfdcr(DCRN_CPC0_PCI_BASE) | (0x80000000L >> 27));
38 +
39 + /* PerCS1 (CF's CS0): base 0xff100000, 16-bit, rw */
40 + mtdcr(DCRN_EBC0_CFGADDR, EBC_B1CR);
41 + mtdcr(DCRN_EBC0_CFGDATA, CF_CS0_BASE | EBC_BXCR_BU_RW | EBC_BXCR_BW_16);
42 + mtdcr(DCRN_EBC0_CFGADDR, EBC_B1AP);
43 + mtdcr(DCRN_EBC0_CFGDATA, 0x080bd800);
44 +
45 + /* PerCS2 (CF's CS1): base 0xff200000, 16-bit, rw */
46 + mtdcr(DCRN_EBC0_CFGADDR, EBC_B2CR);
47 + mtdcr(DCRN_EBC0_CFGDATA, CF_CS1_BASE | EBC_BXCR_BU_RW | EBC_BXCR_BW_16);
48 + mtdcr(DCRN_EBC0_CFGADDR, EBC_B2AP);
49 + mtdcr(DCRN_EBC0_CFGDATA, 0x080bd800);
50 +
51 +#undef DCRN_CPC0_PCI_BASE
52 +#undef CF_CS0_BASE
53 +#undef CF_CS1_BASE
54 +}
55 +
56 +static void magicboxv2_fixups(void)
57 +{
58 + fixup_cf_card();
59 + ibm405ep_fixup_clocks(25000000);
60 + ibm4xx_sdram_fixup_memsize();
61 + dt_fixup_mac_addresses(&bd.bi_enetaddr, &bd.bi_enet1addr);
62 +}
63 +
64 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
65 + unsigned long r6, unsigned long r7)
66 +{
67 + CUBOOT_INIT();
68 + platform_ops.fixups = magicboxv2_fixups;
69 + platform_ops.exit = ibm40x_dbcr_reset;
70 + fdt_init(_dtb_start);
71 + serial_console_init();
72 +}
73 +
74 --- /dev/null
75 +++ b/arch/powerpc/boot/dts/magicboxv2.dts
76 @@ -0,0 +1,279 @@
77 +/*
78 + * Device Tree Source for Magicbox v2
79 + *
80 + * Copyright 2008 Imre Kaloz <kaloz@openwrt.org>
81 + * Copyright 2009 Gabor Juhos <juhosg@openwrt.org>
82 + *
83 + * Based on walnut.dts
84 + *
85 + * This file is licensed under the terms of the GNU General Public
86 + * License version 2. This program is licensed "as is" without
87 + * any warranty of any kind, whether express or implied.
88 + */
89 +
90 +/dts-v1/;
91 +
92 +/ {
93 + #address-cells = <1>;
94 + #size-cells = <1>;
95 + model = "magicboxv2";
96 + compatible = "magicboxv2";
97 + dcr-parent = <&{/cpus/cpu@0}>;
98 +
99 + aliases {
100 + ethernet0 = &EMAC0;
101 + ethernet1 = &EMAC1;
102 + serial0 = &UART0;
103 + serial1 = &UART1;
104 + };
105 +
106 + cpus {
107 + #address-cells = <1>;
108 + #size-cells = <0>;
109 +
110 + cpu@0 {
111 + device_type = "cpu";
112 + model = "PowerPC,405EP";
113 + reg = <0x00000000>;
114 + clock-frequency = <0xbebc200>; /* Filled in by zImage */
115 + timebase-frequency = <0>; /* Filled in by zImage */
116 + i-cache-line-size = <20>;
117 + d-cache-line-size = <20>;
118 + i-cache-size = <4000>;
119 + d-cache-size = <4000>;
120 + dcr-controller;
121 + dcr-access-method = "native";
122 + };
123 + };
124 +
125 + memory {
126 + device_type = "memory";
127 + reg = <0x00000000 0x00000000>; /* Filled in by zImage */
128 + };
129 +
130 + UIC0: interrupt-controller {
131 + compatible = "ibm,uic";
132 + interrupt-controller;
133 + cell-index = <0>;
134 + dcr-reg = <0x0c0 0x009>;
135 + #address-cells = <0>;
136 + #size-cells = <0>;
137 + #interrupt-cells = <2>;
138 + };
139 +
140 + plb {
141 + compatible = "ibm,plb3";
142 + #address-cells = <1>;
143 + #size-cells = <1>;
144 + ranges;
145 + clock-frequency = <0>; /* Filled in by zImage */
146 +
147 + SDRAM0: memory-controller {
148 + compatible = "ibm,sdram-405ep";
149 + dcr-reg = <0x010 0x002>;
150 + };
151 +
152 + MAL: mcmal {
153 + compatible = "ibm,mcmal-405ep", "ibm,mcmal";
154 + dcr-reg = <0x180 0x062>;
155 + num-tx-chans = <4>;
156 + num-rx-chans = <2>;
157 + interrupt-parent = <&UIC0>;
158 + interrupts = <
159 + 0xb 0x4 /* TXEOB */
160 + 0xc 0x4 /* RXEOB */
161 + 0xa 0x4 /* SERR */
162 + 0xd 0x4 /* TXDE */
163 + 0xe 0x4 /* RXDE */>;
164 + };
165 +
166 + POB0: opb {
167 + compatible = "ibm,opb-405ep", "ibm,opb";
168 + #address-cells = <1>;
169 + #size-cells = <1>;
170 + ranges = <0xef600000 0xef600000 0x00a00000>;
171 + dcr-reg = <0x0a0 0x005>;
172 + clock-frequency = <0>; /* Filled in by zImage */
173 +
174 + UART0: serial@ef600300 {
175 + device_type = "serial";
176 + compatible = "ns16550";
177 + reg = <0xef600300 0x00000008>;
178 + virtual-reg = <0xef600300>;
179 + clock-frequency = <0>; /* Filled in by zImage */
180 + current-speed = <115200>;
181 + interrupt-parent = <&UIC0>;
182 + interrupts = <0x0 0x4>;
183 + };
184 +
185 + UART1: serial@ef600400 {
186 + device_type = "serial";
187 + compatible = "ns16550";
188 + reg = <0xef600400 0x00000008>;
189 + virtual-reg = <0xef600400>;
190 + clock-frequency = <0>; /* Filled in by zImage */
191 + current-speed = <115200>;
192 + interrupt-parent = <&UIC0>;
193 + interrupts = <0x1 0x4>;
194 + };
195 +
196 + IIC: i2c@ef600500 {
197 + compatible = "ibm,iic-405ep", "ibm,iic";
198 + reg = <0xef600500 0x00000011>;
199 + interrupt-parent = <&UIC0>;
200 + interrupts = <0x2 0x4>;
201 +
202 + dtt@48 {
203 + compatible = "national,lm75";
204 + reg = <0x48>;
205 + };
206 +
207 + eeprom@50 {
208 + compatible = "at24,24c16";
209 + reg = <0x50>;
210 + };
211 + };
212 +
213 + GPIO0: gpio-controller@ef600700 {
214 + compatible = "ibm,ppc4xx-gpio";
215 + reg = <0xef600700 0x00000020>;
216 + #gpio-cells = <2>;
217 + gpio-controller;
218 + };
219 +
220 + EMAC0: ethernet@ef600800 {
221 + linux,network-index = <0x0>;
222 + device_type = "network";
223 + compatible = "ibm,emac-405ep", "ibm,emac";
224 + interrupt-parent = <&UIC0>;
225 + interrupts = <
226 + 0xf 0x4 /* Ethernet */
227 + 0x9 0x4 /* Ethernet Wake Up */>;
228 + local-mac-address = [000000000000]; /* Filled in by zImage */
229 + reg = <0xef600800 0x00000070>;
230 + mal-device = <&MAL>;
231 + mal-tx-channel = <0>;
232 + mal-rx-channel = <0>;
233 + cell-index = <0>;
234 + max-frame-size = <0x5dc>;
235 + rx-fifo-size = <0x1000>;
236 + tx-fifo-size = <0x800>;
237 + phy-mode = "mii";
238 + phy-map = <0x00000000>;
239 + };
240 +
241 + EMAC1: ethernet@ef600900 {
242 + linux,network-index = <0x1>;
243 + device_type = "network";
244 + compatible = "ibm,emac-405ep", "ibm,emac";
245 + interrupt-parent = <&UIC0>;
246 + interrupts = <
247 + 0x11 0x4 /* Ethernet */
248 + 0x09 0x4 /* Ethernet Wake Up */>;
249 + local-mac-address = [000000000000]; /* Filled in by zImage */
250 + reg = <0xef600900 0x00000070>;
251 + mal-device = <&MAL>;
252 + mal-tx-channel = <2>;
253 + mal-rx-channel = <1>;
254 + cell-index = <1>;
255 + max-frame-size = <0x5dc>;
256 + rx-fifo-size = <0x1000>;
257 + tx-fifo-size = <0x800>;
258 + mdio-device = <&EMAC0>;
259 + phy-mode = "mii";
260 + phy-map = <0x00000001>;
261 + };
262 +
263 + leds {
264 + compatible = "gpio-leds";
265 + user {
266 + label = "magicbox:red:user";
267 + gpios = <&GPIO0 2 1>;
268 + };
269 + };
270 + };
271 +
272 + EBC0: ebc {
273 + compatible = "ibm,ebc-405ep", "ibm,ebc";
274 + dcr-reg = <0x012 0x002>;
275 + #address-cells = <2>;
276 + #size-cells = <1>;
277 + /* The ranges property is supplied by the bootwrapper
278 + * and is based on the firmware's configuration of the
279 + * EBC bridge
280 + */
281 + clock-frequency = <0>; /* Filled in by zImage */
282 +
283 + cf_card@ff100000 {
284 + compatible = "magicbox-cf", "pata-magicbox-cf";
285 + reg = <0x00000000 0xff100000 0x00001000
286 + 0x00000000 0xff200000 0x00001000>;
287 + interrupt-parent = <&UIC0>;
288 + interrupts = <0x19 0x1 /* IRQ_TYPE_EDGE_RISING */ >;
289 + };
290 +
291 + nor_flash@ffc00000 {
292 + compatible = "cfi-flash";
293 + bank-width = <2>;
294 + reg = <0x00000000 0xffc00000 0x00400000>;
295 + #address-cells = <1>;
296 + #size-cells = <1>;
297 + partition@0 {
298 + label = "linux";
299 + reg = <0x0 0x120000>;
300 + };
301 + partition@120000 {
302 + label = "rootfs";
303 + reg = <0x120000 0x2a0000>;
304 + };
305 + partition@3c0000 {
306 + label = "u-boot";
307 + reg = <0x3c0000 0x30000>;
308 + read-only;
309 + };
310 + };
311 + };
312 +
313 + PCI0: pci@ec000000 {
314 + device_type = "pci";
315 + #interrupt-cells = <1>;
316 + #size-cells = <2>;
317 + #address-cells = <3>;
318 + compatible = "ibm,plb405ep-pci", "ibm,plb-pci";
319 + primary;
320 + reg = <0xeec00000 0x00000008 /* Config space access */
321 + 0xeed80000 0x00000004 /* IACK */
322 + 0xeed80000 0x00000004 /* Special cycle */
323 + 0xef480000 0x00000040>; /* Internal registers */
324 +
325 + /* Outbound ranges, one memory and one IO,
326 + * later cannot be changed. Chip supports a second
327 + * IO range but we don't use it for now
328 + */
329 + ranges = <0x02000000 0x00000000 0x80000000 0x80000000 0x00000000 0x20000000
330 + 0x01000000 0x00000000 0x00000000 0xe8000000 0x00000000 0x00010000>;
331 +
332 + /* Inbound 2GB range starting at 0 */
333 + dma-ranges = <0x42000000 0x0 0x0 0x0 0x0 0x80000000>;
334 +
335 + interrupt-map-mask = <0xf800 0x0 0x0 0x0>;
336 + interrupt-map = <
337 + /* IDSEL 1 */
338 + 0x800 0x0 0x0 0x0 &UIC0 0x1c 0x8
339 +
340 + /* IDSEL 2 */
341 + 0x1000 0x0 0x0 0x0 &UIC0 0x1d 0x8
342 +
343 + /* IDSEL 3 */
344 + 0x1800 0x0 0x0 0x0 &UIC0 0x1e 0x8
345 +
346 + /* IDSEL 4 */
347 + 0x2000 0x0 0x0 0x0 &UIC0 0x1f 0x8
348 + >;
349 + };
350 + };
351 +
352 + chosen {
353 + linux,stdout-path = "/plb/opb/serial@ef600300";
354 + };
355 +};
356 --- a/arch/powerpc/boot/Makefile
357 +++ b/arch/powerpc/boot/Makefile
358 @@ -75,7 +75,8 @@ src-plat := of.c cuboot-52xx.c cuboot-82
359 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
360 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
361 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
362 - cuboot-acadia.c cuboot-amigaone.c cuboot-magicboxv1.c
363 + cuboot-acadia.c cuboot-amigaone.c cuboot-magicboxv1.c \
364 + cuboot-magicboxv2.c
365 src-boot := $(src-wlib) $(src-plat) empty.c
366
367 src-boot := $(addprefix $(obj)/, $(src-boot))
368 @@ -193,6 +194,7 @@ image-$(CONFIG_EP405) += dtbImage.ep40
369 image-$(CONFIG_WALNUT) += treeImage.walnut
370 image-$(CONFIG_ACADIA) += cuImage.acadia
371 image-$(CONFIG_MAGICBOXV1) += cuImage.magicboxv1
372 +image-$(CONFIG_MAGICBOXV2) += cuImage.magicboxv2
373
374 # Board ports in arch/powerpc/platform/44x/Kconfig
375 image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
376 --- a/arch/powerpc/platforms/40x/Kconfig
377 +++ b/arch/powerpc/platforms/40x/Kconfig
378 @@ -59,6 +59,16 @@ config MAGICBOXV1
379 help
380 This option enables support for the Magicbox v1 board.
381
382 +config MAGICBOXV2
383 + bool "Magicbox v2"
384 + depends on 40x
385 + default n
386 + select PPC40x_SIMPLE
387 + select 405EP
388 + select PCI
389 + help
390 + This option enables support for the Magicbox v2 board.
391 +
392 config MAKALU
393 bool "Makalu"
394 depends on 40x
395 --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
396 +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
397 @@ -53,6 +53,7 @@ machine_device_initcall(ppc40x_simple, p
398 static char *board[] __initdata = {
399 "amcc,acadia",
400 "magicboxv1",
401 + "magicboxv2",
402 };
403
404 static int __init ppc40x_probe(void)