1 --- a/arch/powerpc/boot/Makefile
2 +++ b/arch/powerpc/boot/Makefile
3 @@ -76,7 +76,7 @@ src-plat := of.c cuboot-52xx.c cuboot-82
4 cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \
5 cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \
6 fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \
7 - cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
8 + cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c rb600.c rb333.c \
9 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
10 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
11 cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \
12 @@ -242,6 +242,8 @@ image-$(CONFIG_MPC834x_ITX) += cuImage.
13 image-$(CONFIG_MPC834x_MDS) += cuImage.mpc834x_mds
14 image-$(CONFIG_MPC836x_MDS) += cuImage.mpc836x_mds
15 image-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot
16 +image-$(CONFIG_RB_PPC) += dtbImage.rb600 \
19 # Board ports in arch/powerpc/platform/85xx/Kconfig
20 image-$(CONFIG_MPC8540_ADS) += cuImage.mpc8540ads
22 +++ b/arch/powerpc/boot/dts/rb600.dts
25 + * RouterBOARD 600 series Device Tree Source
27 + * Copyright 2009 Michael Guntsche <mike@it-loops.com>
29 + * This program is free software; you can redistribute it and/or modify it
30 + * under the terms of the GNU General Public License as published by the
31 + * Free Software Foundation; either version 2 of the License, or (at your
32 + * option) any later version.
39 + compatible = "MPC83xx";
40 + #address-cells = <1>;
50 + bootargs = "console=ttyS0,115200 board=mpc8323 rootfstype=squashfs,yaffs2,jffs2 root=/dev/mtdblock1 boot=1";
51 + linux,stdout-path = "/soc8343@e0000000/serial@4500";
55 + #address-cells = <1>;
59 + device_type = "cpu";
61 + d-cache-line-size = <0x20>;
62 + i-cache-line-size = <0x20>;
63 + d-cache-size = <0x8000>;
64 + i-cache-size = <0x8000>;
65 + timebase-frequency = <0x0000000>; // filled by the bootwrapper from the firmware blob
66 + clock-frequency = <0x00000000>; // filled by the bootwrapper from the firmware blob
71 + device_type = "memory";
72 + reg = <0x0 0x0000000>; // filled by the bootwrapper from the firmware blob
76 + lb-timings = <0x5dc 0x3e8 0x1194 0x5dc 0x2af8>;
77 + interrupt-at-level = <0x0>;
78 + interrupt-parent = <&ipic>;
79 + interrupts = <0x16 0x8>;
80 + lbc_extra_divider = <0x1>;
81 + reg = <0xf9200000 0x200000>;
82 + device_type = "rb,cf";
86 + lb-timings = <0x5dc 0x3e8 0x1194 0x5dc 0x2af8>;
87 + interrupt-at-level = <0x0>;
88 + interrupt-parent = <&ipic>;
89 + interrupts = <0x14 0x8>;
90 + lbc_extra_divider = <0x1>;
91 + reg = <0xf9000000 0x200000>;
92 + device_type = "rb,cf";
96 + reg = <0xff800000 0x20000>;
100 + reg = <0xf0000000 0x1000>;
108 + reg = <0xf8000000 0x1000>;
109 + device_type = "rb,nand";
113 + interrupt-parent = <&ipic>;
114 + interrupts = <0x17 0x8>;
115 + sense = <&gpio 0x7>;
116 + fan_on = <&gpio 0x9>;
119 + pci0: pci@e0008500 {
120 + device_type = "pci";
121 + compatible = "fsl,mpc8349-pci";
122 + reg = <0xe0008500 0x100 0xe0008300 0x8>;
123 + #address-cells = <3>;
125 + #interrupt-cells = <1>;
126 + ranges = <0x2000000 0x0 0x80000000 0x80000000 0x0 0x20000000 0x1000000 0x0 0x0 0xd0000000 0x0 0x4000000>;
127 + bus-range = <0x0 0x0>;
129 + 0x5800 0x0 0x0 0x1 &ipic 0x15 0x8
130 + 0x6000 0x0 0x0 0x1 &ipic 0x30 0x8
131 + 0x6000 0x0 0x0 0x2 &ipic 0x11 0x8
132 + 0x6800 0x0 0x0 0x1 &ipic 0x11 0x8
133 + 0x6800 0x0 0x0 0x2 &ipic 0x12 0x8
134 + 0x7000 0x0 0x0 0x1 &ipic 0x12 0x8
135 + 0x7000 0x0 0x0 0x2 &ipic 0x13 0x8
136 + 0x7800 0x0 0x0 0x1 &ipic 0x13 0x8
137 + 0x7800 0x0 0x0 0x2 &ipic 0x30 0x8
138 + 0x8000 0x0 0x0 0x1 &ipic 0x30 0x8
139 + 0x8000 0x0 0x0 0x2 &ipic 0x12 0x8
140 + 0x8000 0x0 0x0 0x3 &ipic 0x11 0x8
141 + 0x8000 0x0 0x0 0x4 &ipic 0x13 0x8
142 + 0xa000 0x0 0x0 0x1 &ipic 0x30 0x8
143 + 0xa000 0x0 0x0 0x2 &ipic 0x11 0x8
144 + 0xa000 0x0 0x0 0x3 &ipic 0x12 0x8
145 + 0xa000 0x0 0x0 0x4 &ipic 0x13 0x8
146 + 0xa800 0x0 0x0 0x1 &ipic 0x11 0x8
147 + 0xa800 0x0 0x0 0x2 &ipic 0x12 0x8
148 + 0xa800 0x0 0x0 0x3 &ipic 0x13 0x8
149 + 0xa800 0x0 0x0 0x4 &ipic 0x30 0x8>;
150 + interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
151 + interrupt-parent = <&ipic>;
155 + #address-cells = <1>;
157 + device_type = "soc";
158 + compatible = "simple-bus";
159 + ranges = <0x0 0xe0000000 0x100000>;
160 + reg = <0xe0000000 0x200>;
161 + bus-frequency = <0x1>;
164 + user_led = <0x400 0x8>;
168 + reg = <0x500 0x100>;
174 + compatible = "gpio";
175 + device_type = "gpio";
179 + #address-cells = <1>;
181 + compatible = "fsl,mpc8349-dma", "fsl,elo-dma";
183 + ranges = <0 0x8100 0x1a8>;
184 + interrupt-parent = <&ipic>;
185 + interrupts = <71 8>;
188 + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
191 + interrupt-parent = <&ipic>;
192 + interrupts = <71 8>;
195 + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
198 + interrupt-parent = <&ipic>;
199 + interrupts = <71 8>;
202 + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
203 + reg = <0x100 0x80>;
205 + interrupt-parent = <&ipic>;
206 + interrupts = <71 8>;
209 + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
210 + reg = <0x180 0x28>;
212 + interrupt-parent = <&ipic>;
213 + interrupts = <71 8>;
217 + enet0: ethernet@25000 {
218 + #address-cells = <1>;
221 + phy-handle = <&phy0>;
222 + tbi-handle = <&tbi0>;
223 + interrupt-parent = <&ipic>;
224 + interrupts = <0x23 0x8 0x24 0x8 0x25 0x8>;
225 + local-mac-address = [00 00 00 00 00 00];
226 + reg = <0x25000 0x1000>;
227 + ranges = <0x0 0x25000 0x1000>;
228 + compatible = "gianfar";
230 + device_type = "network";
233 + #address-cells = <1>;
235 + compatible = "fsl,gianfar-tbi";
236 + reg = <0x520 0x20>;
240 + device_type = "tbi-phy";
245 + enet1: ethernet@24000 {
246 + #address-cells = <1>;
249 + phy-handle = <&phy1>;
250 + tbi-handle = <&tbi1>;
251 + interrupt-parent = <&ipic>;
252 + interrupts = <0x20 0x8 0x21 0x8 0x22 0x8>;
253 + local-mac-address = [00 00 00 00 00 00];
254 + reg = <0x24000 0x1000>;
255 + ranges = <0x0 0x24000 0x1000>;
256 + compatible = "gianfar";
258 + device_type = "network";
261 + #size-cells = <0x0>;
262 + #address-cells = <0x1>;
263 + reg = <0x520 0x20>;
264 + compatible = "fsl,gianfar-mdio";
266 + phy0: ethernet-phy@0 {
267 + device_type = "ethernet-phy";
271 + phy1: ethernet-phy@1 {
272 + device_type = "ethernet-phy";
278 + device_type = "tbi-phy";
284 + interrupt-controller;
285 + #address-cells = <0>;
286 + #interrupt-cells = <2>;
287 + reg = <0x700 0x100>;
288 + device_type = "ipic";
292 + interrupt-parent = <&ipic>;
293 + interrupts = <0x9 0x8>;
294 + clock-frequency = <0xfe4f840>;
295 + reg = <0x4500 0x100>;
296 + compatible = "ns16550";
297 + device_type = "serial";
301 + reg = <0x200 0x100>;
302 + compatible = "mpc83xx_wdt";
303 + device_type = "watchdog";
308 +++ b/arch/powerpc/boot/rb600.c
311 + * The RouterBOARD platform -- for booting RB600(A) RouterBOARDs.
313 + * Author: Michael Guntsche <mike@it-loops.com>
315 + * Copyright (c) 2009 Michael Guntsche
317 + * This program is free software; you can redistribute it and/or modify it
318 + * under the terms of the GNU General Public License version 2 as published
319 + * by the Free Software Foundation.
333 +static void rb600_fixups(void)
335 + const u32 *reg, *timebase, *clock;
338 + dt_fixup_memory(0, memsize64);
340 + /* Set the MAC addresses. */
341 + node = fdt_path_offset(fw_dtb, "/soc8343@e0000000/ethernet@24000");
342 + reg = fdt_getprop(fw_dtb, node, "mac-address", &size);
343 + dt_fixup_mac_address_by_alias("ethernet1", (const u8 *)reg);
345 + node = fdt_path_offset(fw_dtb, "/soc8343@e0000000/ethernet@25000");
346 + reg = fdt_getprop(fw_dtb, node, "mac-address", &size);
347 + dt_fixup_mac_address_by_alias("ethernet0", (const u8 *)reg);
349 + /* Find the CPU timebase and clock frequencies. */
350 + node = fdt_node_offset_by_prop_value(fw_dtb, -1, "device_type", "cpu", sizeof("cpu"));
351 + timebase = fdt_getprop(fw_dtb, node, "timebase-frequency", &size);
352 + clock = fdt_getprop(fw_dtb, node, "clock-frequency", &size);
353 + dt_fixup_cpu_clocks(*clock, *timebase, 0);
357 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
358 + unsigned long r6, unsigned long r7)
363 + fw_dtb = (const void *)r3;
365 + /* Find the memory range. */
366 + node = fdt_node_offset_by_prop_value(fw_dtb, -1, "device_type", "memory", sizeof("memory"));
367 + reg = fdt_getprop(fw_dtb, node, "reg", &size);
368 + memsize64 = reg[1];
370 + /* Now we have the memory size; initialize the heap. */
371 + simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
373 + /* Prepare the device tree and find the console. */
374 + fdt_init(_dtb_start);
375 + serial_console_init();
377 + /* Remaining fixups... */
378 + platform_ops.fixups = rb600_fixups;
380 --- a/arch/powerpc/boot/wrapper
381 +++ b/arch/powerpc/boot/wrapper
382 @@ -215,7 +215,7 @@ ps3)
386 -ep88xc|ep405|ep8248e)
387 +ep88xc|ep405|ep8248e|rb600|rb333)
388 platformo="$object/fixed-head.o $object/$platform.o"
391 --- a/arch/powerpc/platforms/83xx/Kconfig
392 +++ b/arch/powerpc/platforms/83xx/Kconfig
393 @@ -38,6 +38,15 @@ config MPC832x_RDB
395 This option enables support for the MPC8323 RDB board.
398 + bool "MikroTik RouterBOARD 333/600 series"
399 + select DEFAULT_UIMAGE
400 + select QUICC_ENGINE
404 + This option enables support for MikroTik RouterBOARD 333/600 series boards.
407 bool "Freescale MPC834x MDS"
408 select DEFAULT_UIMAGE
410 +++ b/arch/powerpc/boot/dts/rb333.dts
414 + * RouterBOARD 333 series Device Tree Source
416 + * Copyright 2010 Alexandros C. Couloumbis <alex@ozo.com>
417 + * Copyright 2009 Michael Guntsche <mike@it-loops.com>
419 + * This program is free software; you can redistribute it and/or modify it
420 + * under the terms of the GNU General Public License as published by the
421 + * Free Software Foundation; either version 2 of the License, or (at your
422 + * option) any later version.
424 + * Warning (reg_format): "reg" property in /qe@e0100000/muram@10000/data-only@0 has invalid length (8 bytes) (#address-cells == 2, #size-cells == 1)
425 + * Warning (ranges_format): "ranges" property in /qe@e0100000/muram@10000 has invalid length (12 bytes) (parent #address-cells == 1, child #address-cells == 2, #size-cells == 1)
426 + * Warning (avoid_default_addr_size): Relying on default #address-cells value for /qe@e0100000/muram@10000/data-only@0
427 + * Warning (avoid_default_addr_size): Relying on default #size-cells value for /qe@e0100000/muram@10000/data-only@0
428 + * Warning (obsolete_chosen_interrupt_controller): /chosen has obsolete "interrupt-controller" property
437 + compatible = "MPC83xx";
439 + #address-cells = <1>;
443 + ethernet0 = &enet0;
444 + ethernet1 = &enet1;
445 + ethernet2 = &enet2;
451 + bootargs = "console=ttyS0,115200 board=mpc8323 rootfstype=squashfs,yaffs2,jffs2 root=/dev/mtdblock1 boot=1";
452 + // linux,platform = <0x8062>;
453 + // linux,initrd = <0x488000 0x0>;
454 + linux,stdout-path = "/soc8323@e0000000/serial@4500";
455 + // interrupt-controller = <&ipic>;
461 + #address-cells = <1>;
464 + device_type = "cpu";
466 + i-cache-size = <0x4000>;
467 + d-cache-size = <0x4000>;
468 + i-cache-line-size = <0x20>;
469 + d-cache-line-size = <0x20>;
470 + // clock-frequency = <0x13de3650>;
471 + // timebase-frequency = <0x1fc9f08>;
472 + timebase-frequency = <0x0000000>; // filled by the bootwrapper from the firmware blob
473 + clock-frequency = <0x00000000>; // filled by the bootwrapper from the firmware blob
479 + device_type = "memory";
480 + reg = <0x0 0x4000000>;
481 + // reg = <0x0 0x0000000>; // filled by the bootwrapper from the firmware blob
485 + reg = <0xfe000000 0x20000>;
489 + ale = <&gpio2 0x3>;
490 + cle = <&gpio2 0x2>;
491 + nce = <&gpio2 0x1>;
492 + rdy = <&gpio2 0x0>;
493 + reg = <0xf8000000 0x1000>;
494 + device_type = "rb,nand";
498 + reg = <0xf0000000 0x1000>;
502 + voltage_gpio = <&gpio3 0x11>;
506 + interrupt-parent = <&ipic>;
507 + interrupts = <0x14 0x8>;
508 + fan_on = <&gpio0 0x10>;
511 + pci0: pci@e0008500 {
512 + device_type = "pci";
513 + // compatible = "83xx";
514 + compatible = "fsl,mpc8349-pci";
515 + reg = <0xe0008500 0x100 0xe0008300 0x8>;
516 + #address-cells = <3>;
518 + #interrupt-cells = <1>;
519 + // clock-frequency = <0>;
520 + ranges = <0x2000000 0x0 0x80000000 0x80000000 0x0 0x20000000 0x1000000 0x0 0x0 0xd0000000 0x0 0x4000000>;
521 + bus-range = <0x0 0x0>;
523 + /* IDSEL 0x10 AD16 miniPCI slot 0 */
524 + 0x8000 0x0 0x0 0x1 &ipic 0x11 0x8
525 + 0x8000 0x0 0x0 0x2 &ipic 0x12 0x8
527 + /* IDSEL 0x11 AD17 miniPCI slot 1 */
528 + 0x8800 0x0 0x0 0x1 &ipic 0x12 0x8
529 + 0x8800 0x0 0x0 0x2 &ipic 0x13 0x8
531 + /* IDSEL 0x12 AD18 miniPCI slot 2 */
532 + 0x9000 0x0 0x0 0x1 &ipic 0x13 0x8
533 + 0x9000 0x0 0x0 0x2 &ipic 0x11 0x8>;
535 + interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
536 + interrupt-parent = <&ipic>;
537 + // interrupts = <66 0x8>;
542 + reg = <0xe0100000 0x480>;
543 + ranges = <0x0 0xe0100000 0x100000>;
545 + device_type = "qe";
546 + compatible = "fsl,qe";
548 + #address-cells = <1>;
549 + brg-frequency = <0>;
550 + bus-frequency = <0>;
551 + // bus-frequency = <198000000>;
552 + fsl,qe-num-riscs = <1>;
553 + fsl,qe-num-snums = <28>;
556 + interrupt-controller;
557 + compatible = "fsl,qe-ic";
561 + #interrupt-cells = <1>;
562 + #address-cells = <0>;
563 + device_type = "qeic";
564 + interrupts = <0x20 0x8 0x21 0x8>;
565 + interrupt-parent = <&ipic>;
569 + compatible = "ucc_geth_phy";
570 + device_type = "mdio";
571 + reg = <0x3120 0x18>;
573 + #address-cells = <1>;
575 + phy3: ethernet-phy@03 {
576 + // interface = <0x3>;
577 + device_type = "ethernet-phy";
581 + phy2: ethernet-phy@02 {
582 + // interface = <0x3>;
583 + device_type = "ethernet-phy";
587 + phy1: ethernet-phy@01 {
588 + // interface = <0x3>;
589 + device_type = "ethernet-phy";
597 + mac-address = [00 0c 42 1c 29 d2];
598 + interrupt-parent = <&qeic>;
599 + interrupts = <0x22>;
600 + reg = <0x2200 0x200>;
603 + compatible = "ucc_geth";
604 + device_type = "network";
605 + phy-handle = <&phy2>;
606 + pio-handle = <&pio3>;
612 + mac-address = [00 0c 42 1c 29 d1];
613 + interrupt-parent = <&qeic>;
614 + interrupts = <0x23>;
615 + reg = <0x3200 0x200>;
618 + compatible = "ucc_geth";
619 + device_type = "network";
620 + phy-handle = <&phy3>;
621 + pio-handle = <&pio4>;
627 + mac-address = [00 0c 42 1c 29 d0];
628 + interrupt-parent = <&qeic>;
629 + interrupts = <0x21>;
630 + reg = <0x3000 0x200>;
633 + compatible = "ucc_geth";
634 + device_type = "network";
635 + phy-handle = <&phy1>;
636 + pio-handle = <&pio2>;
641 + interrupt-parent = <&qeic>;
642 + interrupts = <0x1>;
643 + reg = <0x500 0x40>;
644 + compatible = "fsl,spi";
645 + device_type = "spi";
650 + interrupt-parent = <&qeic>;
651 + interrupts = <0x2>;
652 + reg = <0x4c0 0x40>;
653 + compatible = "fsl,spi";
654 + device_type = "spi";
658 + #address-cells = <1>;
660 + compatible = "fsl,qe-muram", "fsl,cpm-muram";
661 + ranges = <0x0 0x10000 0x4000>;
662 + device_type = "muram";
665 + compatible = "fsl,qe-muram-data",
666 + "fsl,cpm-muram-data";
667 + reg = <0x0 0x4000>;
674 + bus-frequency = <0x1>;
675 + reg = <0xe0000000 0x200>;
676 + ranges = <0x0 0xe0000000 0x100000>;
677 + device_type = "soc";
678 + compatible = "simple-bus";
679 + #interrupt-cells = <0x2>;
681 + #address-cells = <1>;
684 + gpio = <&gpio3 0x12>;
685 + reg = <0x500 0x100>;
686 + interrupt-parent = <&ipic>;
687 + interrupts = <0x48 0x8>;
691 + reg = <0x144c 0x4>;
693 + compatible = "qe_gpio";
694 + device_type = "gpio";
698 + reg = <0x1434 0x4>;
700 + compatible = "qe_gpio";
701 + device_type = "gpio";
705 + reg = <0x1404 0x4>;
707 + compatible = "qe_gpio";
708 + device_type = "gpio";
713 + device_type = "par_io";
714 + reg = <0x1400 0x100>;
718 + /* port pin dir open_drain assignment has_irq */
738 + /* port pin dir open_drain assignment has_irq */
758 + /* port pin dir open_drain assignment has_irq */
780 + device_type = "ipic";
782 + reg = <0x700 0x100>;
783 + #interrupt-cells = <0x2>;
784 + #address-cells = <0x0>;
785 + interrupt-controller;
790 + interrupt-parent = <&ipic>;
791 + interrupts = <0x9 0x8>;
792 + clock-frequency = <0x7f27c20>;
793 + reg = <0x4500 0x100>;
794 + compatible = "ns16550";
795 + device_type = "serial";
799 + #address-cells = <1>;
801 + compatible = "fsl,mpc8323-dma", "fsl,elo-dma";
803 + ranges = <0 0x8100 0x1a8>;
804 + interrupt-parent = <&ipic>;
805 + interrupts = <71 8>;
808 + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
811 + interrupt-parent = <&ipic>;
812 + interrupts = <71 8>;
815 + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
818 + interrupt-parent = <&ipic>;
819 + interrupts = <71 8>;
822 + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
823 + reg = <0x100 0x80>;
825 + interrupt-parent = <&ipic>;
826 + interrupts = <71 8>;
829 + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
830 + reg = <0x180 0x28>;
832 + interrupt-parent = <&ipic>;
833 + interrupts = <71 8>;
838 + reg = <0x200 0x100>;
839 + compatible = "mpc83xx_wdt";
840 + device_type = "watchdog";
845 +++ b/arch/powerpc/boot/rb333.c
848 + * The RouterBOARD platform -- for booting RB333 RouterBOARDs.
850 + * Author: Alexandros C. Couloumbis <alex@ozo.com>
851 + * Author: Michael Guntsche <mike@it-loops.com>
853 + * Copyright (c) 2010 Alexandros C. Couloumbis
854 + * Copyright (c) 2009 Michael Guntsche
856 + * This program is free software; you can redistribute it and/or modify it
857 + * under the terms of the GNU General Public License version 2 as published
858 + * by the Free Software Foundation.
872 +static void rb333_fixups(void)
874 + const u32 *timebase, *clock;
877 + const char* bootargs;
879 + dt_fixup_memory(0, memsize64);
881 + /* Find the CPU timebase and clock frequencies. */
882 + node = fdt_node_offset_by_prop_value(fw_dtb, -1, "device_type", "cpu", sizeof("cpu"));
883 + timebase = fdt_getprop(fw_dtb, node, "timebase-frequency", &size);
884 + clock = fdt_getprop(fw_dtb, node, "clock-frequency", &size);
885 + dt_fixup_cpu_clocks(*clock, *timebase, 0);
888 + * The bootloader reads the kernelparm segment and adds the content to
889 + * bootargs. This is needed to specify root and other boot flags.
891 + chosen = finddevice("/chosen");
892 + node = fdt_path_offset(fw_dtb, "/chosen");
893 + bootargs = fdt_getprop(fw_dtb, node, "bootargs", &size);
894 + setprop_str(chosen, "bootargs", bootargs);
897 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
898 + unsigned long r6, unsigned long r7)
903 + fw_dtb = (const void *)r3;
905 + /* Find the memory range. */
906 + node = fdt_node_offset_by_prop_value(fw_dtb, -1, "device_type", "memory", sizeof("memory"));
907 + reg = fdt_getprop(fw_dtb, node, "reg", &size);
908 + memsize64 = reg[1];
910 + /* Now we have the memory size; initialize the heap. */
911 + simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
913 + /* Prepare the device tree and find the console. */
914 + fdt_init(_dtb_start);
915 + serial_console_init();
917 + /* Remaining fixups... */
918 + platform_ops.fixups = rb333_fixups;
921 +++ b/arch/powerpc/platforms/83xx/rbppc.c
924 + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
925 + * Copyright (C) 2008-2009 Noah Fontes <nfontes@transtruct.org>
926 + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
927 + * Copyright (C) Mikrotik 2007
929 + * This program is free software; you can redistribute it and/or modify it
930 + * under the terms of the GNU General Public License as published by the
931 + * Free Software Foundation; either version 2 of the License, or (at your
932 + * option) any later version.
935 +#include <linux/delay.h>
936 +#include <linux/root_dev.h>
937 +#include <linux/initrd.h>
938 +#include <linux/interrupt.h>
939 +#include <linux/of_platform.h>
940 +#include <linux/of_device.h>
941 +#include <linux/of_platform.h>
942 +#include <linux/pci.h>
943 +#include <asm/time.h>
944 +#include <asm/ipic.h>
945 +#include <asm/udbg.h>
947 +#include <asm/qe_ic.h>
948 +#include <sysdev/fsl_soc.h>
949 +#include <sysdev/fsl_pci.h>
950 +#include "mpc83xx.h"
952 +#define SYSCTL 0x100
962 +#define GTCFR_BCM 0x40
963 +#define GTCFR_STP4 0x20
964 +#define GTCFR_RST4 0x10
965 +#define GTCFR_STP3 0x02
966 +#define GTCFR_RST3 0x01
968 +#define GTMDR_ORI 0x10
969 +#define GTMDR_FRR 0x08
970 +#define GTMDR_ICLK16 0x04
972 +extern int par_io_data_set(u8 port, u8 pin, u8 val);
973 +extern int par_io_config_pin(u8 port, u8 pin, int dir, int open_drain,
974 + int assignment, int has_irq);
976 +static unsigned timer_freq;
979 +static int beeper_irq;
980 +static unsigned beeper_gpio_pin[2];
984 +irqreturn_t rbppc_timer_irq(int irq, void *ptr)
986 + static int toggle = 0;
988 + par_io_data_set(beeper_gpio_pin[0], beeper_gpio_pin[1], toggle);
991 + /* ack interrupt */
992 + out_be16(gtm + GTVER4, 3);
994 + return IRQ_HANDLED;
997 +void rbppc_beep(unsigned freq)
1001 + if (freq > 5000) freq = 5000;
1006 + out_8(gtm + GTCFR2, GTCFR_STP4 | GTCFR_STP3);
1010 + out_8(gtm + GTCFR2, GTCFR_RST4 | GTCFR_STP3);
1011 + out_be16(gtm + GTPSR4, 255);
1012 + gtmdr = GTMDR_FRR | GTMDR_ICLK16;
1013 + if (beeper_irq != NO_IRQ) gtmdr |= GTMDR_ORI;
1014 + out_be16(gtm + GTMDR4, gtmdr);
1015 + out_be16(gtm + GTVER4, 3);
1017 + out_be16(gtm + GTRFR4, timer_freq / 16 / 256 / freq / 2);
1018 + out_be16(gtm + GTCNR4, 0);
1020 +EXPORT_SYMBOL(rbppc_beep);
1022 +static void __init rbppc_setup_arch(void)
1024 + struct device_node *np;
1026 + np = of_find_node_by_type(NULL, "cpu");
1028 + const unsigned *fp = of_get_property(np, "clock-frequency", NULL);
1029 + loops_per_jiffy = fp ? *fp / HZ : 0;
1034 + np = of_find_node_by_name(NULL, "serial");
1037 + *(unsigned *) of_get_property(np, "clock-frequency", NULL);
1042 + np = of_find_node_by_type(NULL, "pci");
1044 + mpc83xx_add_bridge(np);
1050 +#ifdef CONFIG_QUICC_ENGINE
1053 + if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
1057 + for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
1058 + par_io_of_config(np);
1066 +void __init rbppc_init_IRQ(void)
1068 + struct device_node *np;
1070 + np = of_find_node_by_type(NULL, "ipic");
1073 + ipic_set_default_priority();
1079 +#ifdef CONFIG_QUICC_ENGINE
1080 + np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
1082 + np = of_find_node_by_type(NULL, "qeic");
1086 + qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
1088 +#endif /* CONFIG_QUICC_ENGINE */
1094 +static int __init rbppc_probe(void)
1098 + model = of_get_flat_dt_prop(of_get_flat_dt_root(), "model", NULL);
1103 + if (strcmp(model, "RB333") == 0) {
1108 + if (strcmp(model, "RB600") == 0)
1114 +static void __init rbppc_beeper_init(struct device_node *beeper)
1116 + struct resource res;
1117 + struct device_node *gpio;
1118 + const unsigned *pin;
1119 + const unsigned *gpio_id;
1121 + if (of_address_to_resource(beeper, 0, &res)) {
1122 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: No region specified\n", beeper->full_name);
1126 + pin = of_get_property(beeper, "gpio", NULL);
1128 + gpio = of_find_node_by_phandle(pin[0]);
1131 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: GPIO handle %x not found\n", beeper->full_name, pin[0]);
1135 + gpio_id = of_get_property(gpio, "device-id", NULL);
1137 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: No device-id specified in GPIO\n", beeper->full_name);
1141 + beeper_gpio_pin[0] = *gpio_id;
1142 + beeper_gpio_pin[1] = pin[1];
1144 + par_io_config_pin(*gpio_id, pin[1], 1, 0, 0, 0);
1148 + sysctl = ioremap_nocache(get_immrbase() + SYSCTL, 0x100);
1149 + out_be32(sysctl + SICRL,
1150 + in_be32(sysctl + SICRL) | (1 << (31 - 19)));
1154 + gtm = ioremap_nocache(res.start, res.end - res.start + 1);
1156 + beeper_irq = irq_of_parse_and_map(beeper, 0);
1157 + if (beeper_irq != NO_IRQ) {
1158 + int e = request_irq(beeper_irq, rbppc_timer_irq, 0, "beeper", NULL);
1160 + printk(KERN_ERR "rbppc_beeper_init(%s): Request of beeper irq failed!\n", beeper->full_name);
1165 +#define SBIT(x) (0x80000000 >> (x))
1166 +#define DBIT(x, y) ((y) << (32 - (((x % 16) + 1) * 2)))
1168 +#define GPIO_DIR_RB333(x) ((x) + (0x1408 >> 2))
1169 +#define GPIO_DATA_RB333(x) ((x) + (0x1404 >> 2))
1171 +#define SICRL_RB600(x) ((x) + (0x114 >> 2))
1172 +#define GPIO_DIR_RB600(x) ((x) + (0xc00 >> 2))
1173 +#define GPIO_DATA_RB600(x) ((x) + (0xc08 >> 2))
1175 +static void rbppc_restart(char *cmd)
1177 + __be32 __iomem *reg;
1178 + unsigned rb_model;
1179 + struct device_node *root;
1180 + unsigned int size;
1182 + root = of_find_node_by_path("/");
1184 + const char *prop = (char *) of_get_property(root, "model", &size);
1185 + rb_model = prop[sizeof("RB") - 1] - '0';
1186 + of_node_put(root);
1187 + switch (rb_model) {
1189 + reg = ioremap(get_immrbase(), 0x2000);
1190 + local_irq_disable();
1191 + out_be32(GPIO_DIR_RB333(reg),
1192 + (in_be32(GPIO_DIR_RB333(reg)) & ~DBIT(4, 3)) | DBIT(4, 1));
1193 + out_be32(GPIO_DATA_RB333(reg), in_be32(GPIO_DATA_RB333(reg)) & ~SBIT(4));
1196 + reg = ioremap(get_immrbase(), 0x1000);
1197 + local_irq_disable();
1198 + out_be32(SICRL_RB600(reg), in_be32(SICRL_RB600(reg)) & ~0x00800000);
1199 + out_be32(GPIO_DIR_RB600(reg), in_be32(GPIO_DIR_RB600(reg)) | SBIT(2));
1200 + out_be32(GPIO_DATA_RB600(reg), in_be32(GPIO_DATA_RB600(reg)) & ~SBIT(2));
1203 + mpc83xx_restart(cmd);
1207 + else mpc83xx_restart(cmd);
1212 +static void rbppc_halt(void)
1217 +static struct of_device_id rbppc_ids[] = {
1218 + { .type = "soc", },
1219 + { .compatible = "soc", },
1220 + { .compatible = "simple-bus", },
1221 + { .type = "qe", },
1222 + { .compatible = "fsl,qe", },
1223 + { .compatible = "gianfar", },
1227 +static int __init rbppc_declare_of_platform_devices(void)
1229 + struct device_node *np;
1232 + of_platform_bus_probe(NULL, rbppc_ids, NULL);
1234 + np = of_find_node_by_type(NULL, "mdio");
1238 + const unsigned *eres;
1239 + struct device_node *ep;
1241 + ep = of_find_compatible_node(NULL, "network", "ucc_geth");
1243 + eres = of_get_property(ep, "reg", &len);
1244 + res = (unsigned *) of_get_property(np, "reg", &len);
1245 + if (res && eres) {
1246 + res[0] = eres[0] + 0x120;
1251 + np = of_find_node_by_name(NULL, "nand");
1253 + of_platform_device_create(np, "nand", NULL);
1257 + for_each_node_by_type(np, "rb,cf") {
1258 + char dev_name[12];
1259 + snprintf(dev_name, sizeof(dev_name), "cf.%u", idx);
1260 + of_platform_device_create(np, dev_name, NULL);
1264 + np = of_find_node_by_name(NULL, "beeper");
1266 + rbppc_beeper_init(np);
1271 +machine_device_initcall(rb600, rbppc_declare_of_platform_devices);
1273 +define_machine(rb600) {
1274 + .name = "MikroTik RouterBOARD 333/600 series",
1275 + .probe = rbppc_probe,
1276 + .setup_arch = rbppc_setup_arch,
1277 + .init_IRQ = rbppc_init_IRQ,
1278 + .get_irq = ipic_get_irq,
1279 + .restart = rbppc_restart,
1280 + .halt = rbppc_halt,
1281 + .time_init = mpc83xx_time_init,
1282 + .calibrate_decr = generic_calibrate_decr,
1285 +static void fixup_pcibridge(struct pci_dev *dev)
1287 + if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
1288 + /* let the kernel itself set right memory windows */
1289 + pci_write_config_word(dev, PCI_MEMORY_BASE, 0);
1290 + pci_write_config_word(dev, PCI_MEMORY_LIMIT, 0);
1291 + pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0);
1292 + pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
1293 + pci_write_config_byte(dev, PCI_IO_BASE, 0);
1294 + pci_write_config_byte(dev, PCI_IO_LIMIT, 4 << 4);
1296 + pci_write_config_byte(
1298 + PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
1299 + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
1304 +static void fixup_rb604(struct pci_dev *dev)
1306 + pci_write_config_byte(dev, 0xC0, 0x01);
1309 +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_pcibridge)
1310 +DECLARE_PCI_FIXUP_HEADER(0x3388, 0x0021, fixup_rb604)