[ppc40x] enable GPIO sysfs interface
[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,259 @@
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 +
203 +                       GPIO: gpio@ef600700 {
204 +                               compatible = "ibm,gpio-405ep";
205 +                               reg = <0xef600700 0x00000020>;
206 +                       };
207 +
208 +                       EMAC0: ethernet@ef600800 {
209 +                               linux,network-index = <0x0>;
210 +                               device_type = "network";
211 +                               compatible = "ibm,emac-405ep", "ibm,emac";
212 +                               interrupt-parent = <&UIC0>;
213 +                               interrupts = <
214 +                                       0xf 0x4 /* Ethernet */
215 +                                       0x9 0x4 /* Ethernet Wake Up */>;
216 +                               local-mac-address = [000000000000]; /* Filled in by zImage */
217 +                               reg = <0xef600800 0x00000070>;
218 +                               mal-device = <&MAL>;
219 +                               mal-tx-channel = <0>;
220 +                               mal-rx-channel = <0>;
221 +                               cell-index = <0>;
222 +                               max-frame-size = <0x5dc>;
223 +                               rx-fifo-size = <0x1000>;
224 +                               tx-fifo-size = <0x800>;
225 +                               phy-mode = "mii";
226 +                               phy-map = <0x00000000>;
227 +                       };
228 +                       EMAC1: ethernet@ef600900 {
229 +                               linux,network-index = <0x1>;
230 +                               device_type = "network";
231 +                               compatible = "ibm,emac-405ep", "ibm,emac";
232 +                               interrupt-parent = <&UIC0>;
233 +                               interrupts = <
234 +                                       0x11 0x4 /* Ethernet */
235 +                                       0x09 0x4 /* Ethernet Wake Up */>;
236 +                               local-mac-address = [000000000000]; /* Filled in by zImage */
237 +                               reg = <0xef600900 0x00000070>;
238 +                               mal-device = <&MAL>;
239 +                               mal-tx-channel = <2>;
240 +                               mal-rx-channel = <1>;
241 +                               cell-index = <1>;
242 +                               max-frame-size = <0x5dc>;
243 +                               rx-fifo-size = <0x1000>;
244 +                               tx-fifo-size = <0x800>;
245 +                               mdio-device = <&EMAC0>;
246 +                               phy-mode = "mii";
247 +                               phy-map = <0x00000001>;
248 +                       };
249 +
250 +               };
251 +
252 +               EBC0: ebc {
253 +                       compatible = "ibm,ebc-405ep", "ibm,ebc";
254 +                       dcr-reg = <0x012 0x002>;
255 +                       #address-cells = <2>;
256 +                       #size-cells = <1>;
257 +                       /* The ranges property is supplied by the bootwrapper
258 +                        * and is based on the firmware's configuration of the
259 +                        * EBC bridge
260 +                        */
261 +                       clock-frequency = <0>; /* Filled in by zImage */
262 +
263 +                       cf_card@ff100000 {
264 +                               compatible = "magicbox-cf";
265 +                               reg = <0x00000000 0xff100000 0x00001000
266 +                                      0x00000000 0xff200000 0x00001000>;
267 +                               interrupt-parent = <&UIC0>;
268 +                               interrupts = <0x19 0x1 /* IRQ_TYPE_EDGE_RISING */ >;
269 +                       };
270 +
271 +                       nor_flash@ffc00000 {
272 +                               compatible = "cfi-flash";
273 +                               bank-width = <2>;
274 +                               reg = <0x00000000 0xffc00000 0x00400000>;
275 +                               #address-cells = <1>;
276 +                               #size-cells = <1>;
277 +                               partition@0 {
278 +                                       label = "linux";
279 +                                       reg = <0x0 0x120000>;
280 +                               };
281 +                               partition@120000 {
282 +                                       label = "rootfs";
283 +                                       reg = <0x120000 0x2a0000>;
284 +                               };
285 +                               partition@3c0000 {
286 +                                       label = "u-boot";
287 +                                       reg = <0x3c0000 0x30000>;
288 +                                       read-only;
289 +                               };
290 +                       };
291 +               };
292 +
293 +               PCI0: pci@ec000000 {
294 +                       device_type = "pci";
295 +                       #interrupt-cells = <1>;
296 +                       #size-cells = <2>;
297 +                       #address-cells = <3>;
298 +                       compatible = "ibm,plb405ep-pci", "ibm,plb-pci";
299 +                       primary;
300 +                       reg = <0xeec00000 0x00000008    /* Config space access */
301 +                              0xeed80000 0x00000004    /* IACK */
302 +                              0xeed80000 0x00000004    /* Special cycle */
303 +                              0xef480000 0x00000040>;  /* Internal registers */
304 +
305 +                       /* Outbound ranges, one memory and one IO,
306 +                        * later cannot be changed. Chip supports a second
307 +                        * IO range but we don't use it for now
308 +                        */
309 +                       ranges = <0x02000000 0x00000000 0x80000000 0x80000000 0x00000000 0x20000000
310 +                                 0x01000000 0x00000000 0x00000000 0xe8000000 0x00000000 0x00010000>;
311 +
312 +                       /* Inbound 2GB range starting at 0 */
313 +                       dma-ranges = <0x42000000 0x0 0x0 0x0 0x0 0x80000000>;
314 +
315 +                       interrupt-map-mask = <0xf800 0x0 0x0 0x0>;
316 +                       interrupt-map = <
317 +                               /* IDSEL 1 */
318 +                               0x800 0x0 0x0 0x0 &UIC0 0x1c 0x8
319 +
320 +                               /* IDSEL 2 */
321 +                               0x1000 0x0 0x0 0x0 &UIC0 0x1d 0x8
322 +
323 +                               /* IDSEL 3 */
324 +                               0x1800 0x0 0x0 0x0 &UIC0 0x1e 0x8
325 +
326 +                               /* IDSEL 4 */
327 +                               0x2000 0x0 0x0 0x0 &UIC0 0x1f 0x8
328 +                       >;
329 +               };
330 +       };
331 +
332 +       chosen {
333 +               linux,stdout-path = "/plb/opb/serial@ef600300";
334 +       };
335 +};
336 --- a/arch/powerpc/boot/Makefile
337 +++ b/arch/powerpc/boot/Makefile
338 @@ -75,7 +75,8 @@ src-plat := of.c cuboot-52xx.c cuboot-82
339                 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
340                 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
341                 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
342 -               cuboot-acadia.c cuboot-amigaone.c cuboot-magicboxv1.c
343 +               cuboot-acadia.c cuboot-amigaone.c cuboot-magicboxv1.c \
344 +               cuboot-magicboxv2.c
345  src-boot := $(src-wlib) $(src-plat) empty.c
346  
347  src-boot := $(addprefix $(obj)/, $(src-boot))
348 @@ -193,6 +194,7 @@ image-$(CONFIG_EP405)                       += dtbImage.ep40
349  image-$(CONFIG_WALNUT)                 += treeImage.walnut
350  image-$(CONFIG_ACADIA)                 += cuImage.acadia
351  image-$(CONFIG_MAGICBOXV1)             += cuImage.magicboxv1
352 +image-$(CONFIG_MAGICBOXV2)             += cuImage.magicboxv2
353  
354  # Board ports in arch/powerpc/platform/44x/Kconfig
355  image-$(CONFIG_EBONY)                  += treeImage.ebony cuImage.ebony
356 --- a/arch/powerpc/platforms/40x/Kconfig
357 +++ b/arch/powerpc/platforms/40x/Kconfig
358 @@ -59,6 +59,16 @@ config MAGICBOXV1
359         help
360           This option enables support for the Magicbox v1 board.
361  
362 +config MAGICBOXV2
363 +       bool "Magicbox v2"
364 +       depends on 40x
365 +       default n
366 +       select PPC40x_SIMPLE
367 +       select 405EP
368 +       select PCI
369 +       help
370 +         This option enables support for the Magicbox v2 board.
371 +
372  config MAKALU
373         bool "Makalu"
374         depends on 40x
375 --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
376 +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
377 @@ -53,6 +53,7 @@ machine_device_initcall(ppc40x_simple, p
378  static char *board[] __initdata = {
379         "amcc,acadia",
380         "magicboxv1",
381 +       "magicboxv2",
382  };
383  
384  static int __init ppc40x_probe(void)