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 + local-mac-address = [00 00 00 00 00 00];
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 + local-mac-address = [00 00 00 00 00 00];
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 + local-mac-address = [00 00 00 00 00 00];
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 *reg, *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);
887 + /* Set the MAC addresses. */
888 + node = fdt_path_offset(fw_dtb, "/qe@e0100000/ucc@2200");
889 + reg = fdt_getprop(fw_dtb, node, "mac-address", &size);
890 + dt_fixup_mac_address_by_alias("ethernet0", (const u8 *)reg);
892 + node = fdt_path_offset(fw_dtb, "/qe@e0100000/ucc@3200");
893 + reg = fdt_getprop(fw_dtb, node, "mac-address", &size);
894 + dt_fixup_mac_address_by_alias("ethernet1", (const u8 *)reg);
896 + node = fdt_path_offset(fw_dtb, "/qe@e0100000/ucc@3000");
897 + reg = fdt_getprop(fw_dtb, node, "mac-address", &size);
898 + dt_fixup_mac_address_by_alias("ethernet2", (const u8 *)reg);
901 + * The bootloader reads the kernelparm segment and adds the content to
902 + * bootargs. This is needed to specify root and other boot flags.
904 + chosen = finddevice("/chosen");
905 + node = fdt_path_offset(fw_dtb, "/chosen");
906 + bootargs = fdt_getprop(fw_dtb, node, "bootargs", &size);
907 + setprop_str(chosen, "bootargs", bootargs);
910 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
911 + unsigned long r6, unsigned long r7)
916 + fw_dtb = (const void *)r3;
918 + /* Find the memory range. */
919 + node = fdt_node_offset_by_prop_value(fw_dtb, -1, "device_type", "memory", sizeof("memory"));
920 + reg = fdt_getprop(fw_dtb, node, "reg", &size);
921 + memsize64 = reg[1];
923 + /* Now we have the memory size; initialize the heap. */
924 + simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
926 + /* Prepare the device tree and find the console. */
927 + fdt_init(_dtb_start);
928 + serial_console_init();
930 + /* Remaining fixups... */
931 + platform_ops.fixups = rb333_fixups;
934 +++ b/arch/powerpc/platforms/83xx/rbppc.c
937 + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
938 + * Copyright (C) 2008-2009 Noah Fontes <nfontes@transtruct.org>
939 + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
940 + * Copyright (C) Mikrotik 2007
942 + * This program is free software; you can redistribute it and/or modify it
943 + * under the terms of the GNU General Public License as published by the
944 + * Free Software Foundation; either version 2 of the License, or (at your
945 + * option) any later version.
948 +#include <linux/delay.h>
949 +#include <linux/root_dev.h>
950 +#include <linux/initrd.h>
951 +#include <linux/interrupt.h>
952 +#include <linux/of_platform.h>
953 +#include <linux/of_device.h>
954 +#include <linux/of_platform.h>
955 +#include <linux/pci.h>
956 +#include <asm/time.h>
957 +#include <asm/ipic.h>
958 +#include <asm/udbg.h>
960 +#include <asm/qe_ic.h>
961 +#include <sysdev/fsl_soc.h>
962 +#include <sysdev/fsl_pci.h>
963 +#include "mpc83xx.h"
965 +#define SYSCTL 0x100
975 +#define GTCFR_BCM 0x40
976 +#define GTCFR_STP4 0x20
977 +#define GTCFR_RST4 0x10
978 +#define GTCFR_STP3 0x02
979 +#define GTCFR_RST3 0x01
981 +#define GTMDR_ORI 0x10
982 +#define GTMDR_FRR 0x08
983 +#define GTMDR_ICLK16 0x04
985 +extern int par_io_data_set(u8 port, u8 pin, u8 val);
986 +extern int par_io_config_pin(u8 port, u8 pin, int dir, int open_drain,
987 + int assignment, int has_irq);
989 +static unsigned timer_freq;
992 +static int beeper_irq;
993 +static unsigned beeper_gpio_pin[2];
997 +irqreturn_t rbppc_timer_irq(int irq, void *ptr)
999 + static int toggle = 0;
1001 + par_io_data_set(beeper_gpio_pin[0], beeper_gpio_pin[1], toggle);
1004 + /* ack interrupt */
1005 + out_be16(gtm + GTVER4, 3);
1007 + return IRQ_HANDLED;
1010 +void rbppc_beep(unsigned freq)
1014 + if (freq > 5000) freq = 5000;
1019 + out_8(gtm + GTCFR2, GTCFR_STP4 | GTCFR_STP3);
1023 + out_8(gtm + GTCFR2, GTCFR_RST4 | GTCFR_STP3);
1024 + out_be16(gtm + GTPSR4, 255);
1025 + gtmdr = GTMDR_FRR | GTMDR_ICLK16;
1026 + if (beeper_irq != NO_IRQ) gtmdr |= GTMDR_ORI;
1027 + out_be16(gtm + GTMDR4, gtmdr);
1028 + out_be16(gtm + GTVER4, 3);
1030 + out_be16(gtm + GTRFR4, timer_freq / 16 / 256 / freq / 2);
1031 + out_be16(gtm + GTCNR4, 0);
1033 +EXPORT_SYMBOL(rbppc_beep);
1035 +static void __init rbppc_setup_arch(void)
1037 + struct device_node *np;
1039 + np = of_find_node_by_type(NULL, "cpu");
1041 + const unsigned *fp = of_get_property(np, "clock-frequency", NULL);
1042 + loops_per_jiffy = fp ? *fp / HZ : 0;
1047 + np = of_find_node_by_name(NULL, "serial");
1050 + *(unsigned *) of_get_property(np, "clock-frequency", NULL);
1055 + np = of_find_node_by_type(NULL, "pci");
1057 + mpc83xx_add_bridge(np);
1063 +#ifdef CONFIG_QUICC_ENGINE
1066 + if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
1070 + for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
1071 + par_io_of_config(np);
1079 +void __init rbppc_init_IRQ(void)
1081 + struct device_node *np;
1083 + np = of_find_node_by_type(NULL, "ipic");
1086 + ipic_set_default_priority();
1092 +#ifdef CONFIG_QUICC_ENGINE
1093 + np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
1095 + np = of_find_node_by_type(NULL, "qeic");
1099 + qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
1101 +#endif /* CONFIG_QUICC_ENGINE */
1107 +static int __init rbppc_probe(void)
1111 + model = of_get_flat_dt_prop(of_get_flat_dt_root(), "model", NULL);
1116 + if (strcmp(model, "RB333") == 0) {
1121 + if (strcmp(model, "RB600") == 0)
1127 +static void __init rbppc_beeper_init(struct device_node *beeper)
1129 + struct resource res;
1130 + struct device_node *gpio;
1131 + const unsigned *pin;
1132 + const unsigned *gpio_id;
1134 + if (of_address_to_resource(beeper, 0, &res)) {
1135 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: No region specified\n", beeper->full_name);
1139 + pin = of_get_property(beeper, "gpio", NULL);
1141 + gpio = of_find_node_by_phandle(pin[0]);
1144 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: GPIO handle %x not found\n", beeper->full_name, pin[0]);
1148 + gpio_id = of_get_property(gpio, "device-id", NULL);
1150 + printk(KERN_ERR "rbppc_beeper_init(%s): Beeper error: No device-id specified in GPIO\n", beeper->full_name);
1154 + beeper_gpio_pin[0] = *gpio_id;
1155 + beeper_gpio_pin[1] = pin[1];
1157 + par_io_config_pin(*gpio_id, pin[1], 1, 0, 0, 0);
1161 + sysctl = ioremap_nocache(get_immrbase() + SYSCTL, 0x100);
1162 + out_be32(sysctl + SICRL,
1163 + in_be32(sysctl + SICRL) | (1 << (31 - 19)));
1167 + gtm = ioremap_nocache(res.start, res.end - res.start + 1);
1169 + beeper_irq = irq_of_parse_and_map(beeper, 0);
1170 + if (beeper_irq != NO_IRQ) {
1171 + int e = request_irq(beeper_irq, rbppc_timer_irq, 0, "beeper", NULL);
1173 + printk(KERN_ERR "rbppc_beeper_init(%s): Request of beeper irq failed!\n", beeper->full_name);
1178 +#define SBIT(x) (0x80000000 >> (x))
1179 +#define DBIT(x, y) ((y) << (32 - (((x % 16) + 1) * 2)))
1181 +#define GPIO_DIR_RB333(x) ((x) + (0x1408 >> 2))
1182 +#define GPIO_DATA_RB333(x) ((x) + (0x1404 >> 2))
1184 +#define SICRL_RB600(x) ((x) + (0x114 >> 2))
1185 +#define GPIO_DIR_RB600(x) ((x) + (0xc00 >> 2))
1186 +#define GPIO_DATA_RB600(x) ((x) + (0xc08 >> 2))
1188 +static void rbppc_restart(char *cmd)
1190 + __be32 __iomem *reg;
1191 + unsigned rb_model;
1192 + struct device_node *root;
1193 + unsigned int size;
1195 + root = of_find_node_by_path("/");
1197 + const char *prop = (char *) of_get_property(root, "model", &size);
1198 + rb_model = prop[sizeof("RB") - 1] - '0';
1199 + of_node_put(root);
1200 + switch (rb_model) {
1202 + reg = ioremap(get_immrbase(), 0x2000);
1203 + local_irq_disable();
1204 + out_be32(GPIO_DIR_RB333(reg),
1205 + (in_be32(GPIO_DIR_RB333(reg)) & ~DBIT(4, 3)) | DBIT(4, 1));
1206 + out_be32(GPIO_DATA_RB333(reg), in_be32(GPIO_DATA_RB333(reg)) & ~SBIT(4));
1209 + reg = ioremap(get_immrbase(), 0x1000);
1210 + local_irq_disable();
1211 + out_be32(SICRL_RB600(reg), in_be32(SICRL_RB600(reg)) & ~0x00800000);
1212 + out_be32(GPIO_DIR_RB600(reg), in_be32(GPIO_DIR_RB600(reg)) | SBIT(2));
1213 + out_be32(GPIO_DATA_RB600(reg), in_be32(GPIO_DATA_RB600(reg)) & ~SBIT(2));
1216 + mpc83xx_restart(cmd);
1220 + else mpc83xx_restart(cmd);
1225 +static void rbppc_halt(void)
1230 +static struct of_device_id rbppc_ids[] = {
1231 + { .type = "soc", },
1232 + { .compatible = "soc", },
1233 + { .compatible = "simple-bus", },
1234 + { .type = "qe", },
1235 + { .compatible = "fsl,qe", },
1236 + { .compatible = "gianfar", },
1240 +static int __init rbppc_declare_of_platform_devices(void)
1242 + struct device_node *np;
1245 + of_platform_bus_probe(NULL, rbppc_ids, NULL);
1247 + np = of_find_node_by_type(NULL, "mdio");
1251 + const unsigned *eres;
1252 + struct device_node *ep;
1254 + ep = of_find_compatible_node(NULL, "network", "ucc_geth");
1256 + eres = of_get_property(ep, "reg", &len);
1257 + res = (unsigned *) of_get_property(np, "reg", &len);
1258 + if (res && eres) {
1259 + res[0] = eres[0] + 0x120;
1264 + np = of_find_node_by_name(NULL, "nand");
1266 + of_platform_device_create(np, "nand", NULL);
1270 + for_each_node_by_type(np, "rb,cf") {
1271 + char dev_name[12];
1272 + snprintf(dev_name, sizeof(dev_name), "cf.%u", idx);
1273 + of_platform_device_create(np, dev_name, NULL);
1277 + np = of_find_node_by_name(NULL, "beeper");
1279 + rbppc_beeper_init(np);
1284 +machine_device_initcall(rb600, rbppc_declare_of_platform_devices);
1286 +define_machine(rb600) {
1287 + .name = "MikroTik RouterBOARD 333/600 series",
1288 + .probe = rbppc_probe,
1289 + .setup_arch = rbppc_setup_arch,
1290 + .init_IRQ = rbppc_init_IRQ,
1291 + .get_irq = ipic_get_irq,
1292 + .restart = rbppc_restart,
1293 + .halt = rbppc_halt,
1294 + .time_init = mpc83xx_time_init,
1295 + .calibrate_decr = generic_calibrate_decr,
1298 +static void fixup_pcibridge(struct pci_dev *dev)
1300 + if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
1301 + /* let the kernel itself set right memory windows */
1302 + pci_write_config_word(dev, PCI_MEMORY_BASE, 0);
1303 + pci_write_config_word(dev, PCI_MEMORY_LIMIT, 0);
1304 + pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0);
1305 + pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
1306 + pci_write_config_byte(dev, PCI_IO_BASE, 0);
1307 + pci_write_config_byte(dev, PCI_IO_LIMIT, 4 << 4);
1309 + pci_write_config_byte(
1311 + PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
1312 + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
1317 +static void fixup_rb604(struct pci_dev *dev)
1319 + pci_write_config_byte(dev, 0xC0, 0x01);
1322 +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_pcibridge)
1323 +DECLARE_PCI_FIXUP_HEADER(0x3388, 0x0021, fixup_rb604)