aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 16:26:53 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 16:26:53 -0500
commita73611b6aafa3b902524dad2d68e378c4ec9f4db (patch)
tree5dc4877055a2297d9f7f5db4cf6a5a7aad392dd0 /arch/powerpc/boot
parent5fa3577b1a1202972e6e419040438c29f39f59cc (diff)
parentae4cec4736969ec2196a6bbce4ab263ff7cb7eef (diff)
Merge branch 'next' of git://git.secretlab.ca/git/linux-2.6
* 'next' of git://git.secretlab.ca/git/linux-2.6: (23 commits) powerpc: fix up for mmu_mapin_ram api change powerpc: wii: allow ioremap within the memory hole powerpc: allow ioremap within reserved memory regions wii: use both mem1 and mem2 as ram wii: bootwrapper: add fixup to calc useable mem2 powerpc: gamecube/wii: early debugging using usbgecko powerpc: reserve fixmap entries for early debug powerpc: wii: default config powerpc: wii: platform support powerpc: wii: hollywood interrupt controller support powerpc: broadway processor support powerpc: wii: bootwrapper bits powerpc: wii: device tree powerpc: gamecube: default config powerpc: gamecube: platform support powerpc: gamecube/wii: flipper interrupt controller support powerpc: gamecube/wii: udbg support for usbgecko powerpc: gamecube/wii: do not include PCI support powerpc: gamecube/wii: declare as non-coherent platforms powerpc: gamecube/wii: introduce GAMECUBE_COMMON ... Fix up conflicts in arch/powerpc/mm/fsl_booke_mmu.c. Hopefully even close to correctly.
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r--arch/powerpc/boot/Makefile7
-rw-r--r--arch/powerpc/boot/dts/gamecube.dts114
-rw-r--r--arch/powerpc/boot/dts/wii.dts218
-rw-r--r--arch/powerpc/boot/gamecube-head.S111
-rw-r--r--arch/powerpc/boot/gamecube.c35
-rw-r--r--arch/powerpc/boot/ugecon.c147
-rw-r--r--arch/powerpc/boot/ugecon.h24
-rw-r--r--arch/powerpc/boot/wii-head.S142
-rw-r--r--arch/powerpc/boot/wii.c158
-rwxr-xr-xarch/powerpc/boot/wrapper4
10 files changed, 958 insertions, 2 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 7bfc8ad87798..bb2465bcb327 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -66,7 +66,7 @@ src-wlib := string.S crt0.S crtsavres.S stdio.c main.c \
66 gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ 66 gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
67 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ 67 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
68 cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \ 68 cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
69 fsl-soc.c mpc8xx.c pq2.c 69 fsl-soc.c mpc8xx.c pq2.c ugecon.c
70src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \ 70src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \
71 cuboot-ebony.c cuboot-hotfoot.c treeboot-ebony.c prpmc2800.c \ 71 cuboot-ebony.c cuboot-hotfoot.c treeboot-ebony.c prpmc2800.c \
72 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ 72 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
@@ -76,7 +76,8 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
76 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \ 76 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
77 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \ 77 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
78 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \ 78 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
79 cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c 79 cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \
80 gamecube-head.S gamecube.c wii-head.S wii.c
80src-boot := $(src-wlib) $(src-plat) empty.c 81src-boot := $(src-wlib) $(src-plat) empty.c
81 82
82src-boot := $(addprefix $(obj)/, $(src-boot)) 83src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -254,6 +255,8 @@ image-$(CONFIG_KSI8560) += cuImage.ksi8560
254image-$(CONFIG_STORCENTER) += cuImage.storcenter 255image-$(CONFIG_STORCENTER) += cuImage.storcenter
255image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2 256image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2
256image-$(CONFIG_PPC_C2K) += cuImage.c2k 257image-$(CONFIG_PPC_C2K) += cuImage.c2k
258image-$(CONFIG_GAMECUBE) += dtbImage.gamecube
259image-$(CONFIG_WII) += dtbImage.wii
257 260
258# Board port in arch/powerpc/platform/amigaone/Kconfig 261# Board port in arch/powerpc/platform/amigaone/Kconfig
259image-$(CONFIG_AMIGAONE) += cuImage.amigaone 262image-$(CONFIG_AMIGAONE) += cuImage.amigaone
diff --git a/arch/powerpc/boot/dts/gamecube.dts b/arch/powerpc/boot/dts/gamecube.dts
new file mode 100644
index 000000000000..ef3be0e58b02
--- /dev/null
+++ b/arch/powerpc/boot/dts/gamecube.dts
@@ -0,0 +1,114 @@
1/*
2 * arch/powerpc/boot/dts/gamecube.dts
3 *
4 * Nintendo GameCube platform device tree source
5 * Copyright (C) 2007-2009 The GameCube Linux Team
6 * Copyright (C) 2007,2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15/dts-v1/;
16
17/ {
18 model = "nintendo,gamecube";
19 compatible = "nintendo,gamecube";
20 #address-cells = <1>;
21 #size-cells = <1>;
22
23 chosen {
24 bootargs = "root=/dev/gcnsda2 rootwait udbg-immortal";
25 };
26
27 memory {
28 device_type = "memory";
29 reg = <0x00000000 0x01800000>;
30 };
31
32 cpus {
33 #address-cells = <1>;
34 #size-cells = <0>;
35
36 PowerPC,gekko@0 {
37 device_type = "cpu";
38 reg = <0>;
39 clock-frequency = <486000000>; /* 486MHz */
40 bus-frequency = <162000000>; /* 162MHz core-to-bus 3x */
41 timebase-frequency = <40500000>; /* 162MHz / 4 */
42 i-cache-line-size = <32>;
43 d-cache-line-size = <32>;
44 i-cache-size = <32768>;
45 d-cache-size = <32768>;
46 };
47 };
48
49 /* devices contained int the flipper chipset */
50 flipper {
51 #address-cells = <1>;
52 #size-cells = <1>;
53 compatible = "nintendo,flipper";
54 ranges = <0x0c000000 0x0c000000 0x00010000>;
55 interrupt-parent = <&PIC>;
56
57 video@0c002000 {
58 compatible = "nintendo,flipper-vi";
59 reg = <0x0c002000 0x100>;
60 interrupts = <8>;
61 };
62
63 processor-interface@0c003000 {
64 compatible = "nintendo,flipper-pi";
65 reg = <0x0c003000 0x100>;
66
67 PIC: pic {
68 #interrupt-cells = <1>;
69 compatible = "nintendo,flipper-pic";
70 interrupt-controller;
71 };
72 };
73
74 dsp@0c005000 {
75 #address-cells = <1>;
76 #size-cells = <1>;
77 compatible = "nintendo,flipper-dsp";
78 reg = <0x0c005000 0x200>;
79 interrupts = <6>;
80
81 memory@0 {
82 compatible = "nintendo,flipper-aram";
83 reg = <0 0x1000000>; /* 16MB */
84 };
85 };
86
87 disk@0c006000 {
88 compatible = "nintendo,flipper-di";
89 reg = <0x0c006000 0x40>;
90 interrupts = <2>;
91 };
92
93 audio@0c006c00 {
94 compatible = "nintendo,flipper-ai";
95 reg = <0x0c006c00 0x20>;
96 interrupts = <6>;
97 };
98
99 gamepad-controller@0c006400 {
100 compatible = "nintendo,flipper-si";
101 reg = <0x0c006400 0x100>;
102 interrupts = <3>;
103 };
104
105 /* External Interface bus */
106 exi@0c006800 {
107 compatible = "nintendo,flipper-exi";
108 reg = <0x0c006800 0x40>;
109 virtual-reg = <0x0c006800>;
110 interrupts = <4>;
111 };
112 };
113};
114
diff --git a/arch/powerpc/boot/dts/wii.dts b/arch/powerpc/boot/dts/wii.dts
new file mode 100644
index 000000000000..77528c9a8dbd
--- /dev/null
+++ b/arch/powerpc/boot/dts/wii.dts
@@ -0,0 +1,218 @@
1/*
2 * arch/powerpc/boot/dts/wii.dts
3 *
4 * Nintendo Wii platform device tree source
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15/dts-v1/;
16
17/*
18 * This is commented-out for now.
19 * Until a later patch is merged, the kernel can use only the first
20 * contiguous RAM range and will BUG() if the memreserve is outside
21 * that range.
22 */
23/*/memreserve/ 0x10000000 0x0004000;*/ /* DSP RAM */
24
25/ {
26 model = "nintendo,wii";
27 compatible = "nintendo,wii";
28 #address-cells = <1>;
29 #size-cells = <1>;
30
31 chosen {
32 bootargs = "root=/dev/mmcblk0p2 rootwait udbg-immortal";
33 };
34
35 memory {
36 device_type = "memory";
37 reg = <0x00000000 0x01800000 /* MEM1 24MB 1T-SRAM */
38 0x10000000 0x04000000>; /* MEM2 64MB GDDR3 */
39 };
40
41 cpus {
42 #address-cells = <1>;
43 #size-cells = <0>;
44
45 PowerPC,broadway@0 {
46 device_type = "cpu";
47 reg = <0>;
48 clock-frequency = <729000000>; /* 729MHz */
49 bus-frequency = <243000000>; /* 243MHz core-to-bus 3x */
50 timebase-frequency = <60750000>; /* 243MHz / 4 */
51 i-cache-line-size = <32>;
52 d-cache-line-size = <32>;
53 i-cache-size = <32768>;
54 d-cache-size = <32768>;
55 };
56 };
57
58 /* devices contained in the hollywood chipset */
59 hollywood {
60 #address-cells = <1>;
61 #size-cells = <1>;
62 compatible = "nintendo,hollywood";
63 ranges = <0x0c000000 0x0c000000 0x01000000
64 0x0d000000 0x0d000000 0x00800000
65 0x0d800000 0x0d800000 0x00800000>;
66 interrupt-parent = <&PIC0>;
67
68 video@0c002000 {
69 compatible = "nintendo,hollywood-vi",
70 "nintendo,flipper-vi";
71 reg = <0x0c002000 0x100>;
72 interrupts = <8>;
73 };
74
75 processor-interface@0c003000 {
76 compatible = "nintendo,hollywood-pi",
77 "nintendo,flipper-pi";
78 reg = <0x0c003000 0x100>;
79
80 PIC0: pic0 {
81 #interrupt-cells = <1>;
82 compatible = "nintendo,flipper-pic";
83 interrupt-controller;
84 };
85 };
86
87 dsp@0c005000 {
88 #address-cells = <1>;
89 #size-cells = <1>;
90 compatible = "nintendo,hollywood-dsp",
91 "nintendo,flipper-dsp";
92 reg = <0x0c005000 0x200>;
93 interrupts = <6>;
94 };
95
96 gamepad-controller@0d006400 {
97 compatible = "nintendo,hollywood-si",
98 "nintendo,flipper-si";
99 reg = <0x0d006400 0x100>;
100 interrupts = <3>;
101 };
102
103 audio@0c006c00 {
104 compatible = "nintendo,hollywood-ai",
105 "nintendo,flipper-ai";
106 reg = <0x0d006c00 0x20>;
107 interrupts = <6>;
108 };
109
110 /* External Interface bus */
111 exi@0d006800 {
112 compatible = "nintendo,hollywood-exi",
113 "nintendo,flipper-exi";
114 reg = <0x0d006800 0x40>;
115 virtual-reg = <0x0d006800>;
116 interrupts = <4>;
117 };
118
119 usb@0d040000 {
120 compatible = "nintendo,hollywood-usb-ehci",
121 "usb-ehci";
122 reg = <0x0d040000 0x100>;
123 interrupts = <4>;
124 interrupt-parent = <&PIC1>;
125 };
126
127 usb@0d050000 {
128 compatible = "nintendo,hollywood-usb-ohci",
129 "usb-ohci";
130 reg = <0x0d050000 0x100>;
131 interrupts = <5>;
132 interrupt-parent = <&PIC1>;
133 };
134
135 usb@0d060000 {
136 compatible = "nintendo,hollywood-usb-ohci",
137 "usb-ohci";
138 reg = <0x0d060000 0x100>;
139 interrupts = <6>;
140 interrupt-parent = <&PIC1>;
141 };
142
143 sd@0d070000 {
144 compatible = "nintendo,hollywood-sdhci",
145 "sdhci";
146 reg = <0x0d070000 0x200>;
147 interrupts = <7>;
148 interrupt-parent = <&PIC1>;
149 };
150
151 sdio@0d080000 {
152 compatible = "nintendo,hollywood-sdhci",
153 "sdhci";
154 reg = <0x0d080000 0x200>;
155 interrupts = <8>;
156 interrupt-parent = <&PIC1>;
157 };
158
159 ipc@0d000000 {
160 compatible = "nintendo,hollywood-ipc";
161 reg = <0x0d000000 0x10>;
162 interrupts = <30>;
163 interrupt-parent = <&PIC1>;
164 };
165
166 PIC1: pic1@0d800030 {
167 #interrupt-cells = <1>;
168 compatible = "nintendo,hollywood-pic";
169 reg = <0x0d800030 0x10>;
170 interrupt-controller;
171 interrupts = <14>;
172 };
173
174 GPIO: gpio@0d8000c0 {
175 #gpio-cells = <2>;
176 compatible = "nintendo,hollywood-gpio";
177 reg = <0x0d8000c0 0x40>;
178 gpio-controller;
179
180 /*
181 * This is commented out while a standard binding
182 * for i2c over gpio is defined.
183 */
184 /*
185 i2c-video {
186 #address-cells = <1>;
187 #size-cells = <0>;
188 compatible = "i2c-gpio";
189
190 gpios = <&GPIO 15 0
191 &GPIO 14 0>;
192 clock-frequency = <250000>;
193 no-clock-stretching;
194 scl-is-open-drain;
195 sda-is-open-drain;
196 sda-enforce-dir;
197
198 AVE: audio-video-encoder@70 {
199 compatible = "nintendo,wii-audio-video-encoder";
200 reg = <0x70>;
201 };
202 };
203 */
204 };
205
206 control@0d800100 {
207 compatible = "nintendo,hollywood-control";
208 reg = <0x0d800100 0x300>;
209 };
210
211 disk@0d806000 {
212 compatible = "nintendo,hollywood-di";
213 reg = <0x0d806000 0x40>;
214 interrupts = <2>;
215 };
216 };
217};
218
diff --git a/arch/powerpc/boot/gamecube-head.S b/arch/powerpc/boot/gamecube-head.S
new file mode 100644
index 000000000000..65a9b2a3bf33
--- /dev/null
+++ b/arch/powerpc/boot/gamecube-head.S
@@ -0,0 +1,111 @@
1/*
2 * arch/powerpc/boot/gamecube-head.S
3 *
4 * Nintendo GameCube bootwrapper entry.
5 * Copyright (C) 2004-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#include "ppc_asm.h"
16
17/*
18 * The entry code does no assumptions regarding:
19 * - if the data and instruction caches are enabled or not
20 * - if the MMU is enabled or not
21 *
22 * We enable the caches if not already enabled, enable the MMU with an
23 * identity mapping scheme and jump to the start code.
24 */
25
26 .text
27
28 .globl _zimage_start
29_zimage_start:
30
31 /* turn the MMU off */
32 mfmsr 9
33 rlwinm 9, 9, 0, ~((1<<4)|(1<<5)) /* MSR_DR|MSR_IR */
34 bcl 20, 31, 1f
351:
36 mflr 8
37 clrlwi 8, 8, 3 /* convert to a real address */
38 addi 8, 8, _mmu_off - 1b
39 mtsrr0 8
40 mtsrr1 9
41 rfi
42_mmu_off:
43 /* MMU disabled */
44
45 /* setup BATs */
46 isync
47 li 8, 0
48 mtspr 0x210, 8 /* IBAT0U */
49 mtspr 0x212, 8 /* IBAT1U */
50 mtspr 0x214, 8 /* IBAT2U */
51 mtspr 0x216, 8 /* IBAT3U */
52 mtspr 0x218, 8 /* DBAT0U */
53 mtspr 0x21a, 8 /* DBAT1U */
54 mtspr 0x21c, 8 /* DBAT2U */
55 mtspr 0x21e, 8 /* DBAT3U */
56
57 li 8, 0x01ff /* first 16MiB */
58 li 9, 0x0002 /* rw */
59 mtspr 0x211, 9 /* IBAT0L */
60 mtspr 0x210, 8 /* IBAT0U */
61 mtspr 0x219, 9 /* DBAT0L */
62 mtspr 0x218, 8 /* DBAT0U */
63
64 lis 8, 0x0c00 /* I/O mem */
65 ori 8, 8, 0x3ff /* 32MiB */
66 lis 9, 0x0c00
67 ori 9, 9, 0x002a /* uncached, guarded, rw */
68 mtspr 0x21b, 9 /* DBAT1L */
69 mtspr 0x21a, 8 /* DBAT1U */
70
71 lis 8, 0x0100 /* next 8MiB */
72 ori 8, 8, 0x00ff /* 8MiB */
73 lis 9, 0x0100
74 ori 9, 9, 0x0002 /* rw */
75 mtspr 0x215, 9 /* IBAT2L */
76 mtspr 0x214, 8 /* IBAT2U */
77 mtspr 0x21d, 9 /* DBAT2L */
78 mtspr 0x21c, 8 /* DBAT2U */
79
80 /* enable and invalidate the caches if not already enabled */
81 mfspr 8, 0x3f0 /* HID0 */
82 andi. 0, 8, (1<<15) /* HID0_ICE */
83 bne 1f
84 ori 8, 8, (1<<15)|(1<<11) /* HID0_ICE|HID0_ICFI*/
851:
86 andi. 0, 8, (1<<14) /* HID0_DCE */
87 bne 1f
88 ori 8, 8, (1<<14)|(1<<10) /* HID0_DCE|HID0_DCFI*/
891:
90 mtspr 0x3f0, 8 /* HID0 */
91 isync
92
93 /* initialize arguments */
94 li 3, 0
95 li 4, 0
96 li 5, 0
97
98 /* turn the MMU on */
99 bcl 20, 31, 1f
1001:
101 mflr 8
102 addi 8, 8, _mmu_on - 1b
103 mfmsr 9
104 ori 9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */
105 mtsrr0 8
106 mtsrr1 9
107 sync
108 rfi
109_mmu_on:
110 b _zimage_start_lib
111
diff --git a/arch/powerpc/boot/gamecube.c b/arch/powerpc/boot/gamecube.c
new file mode 100644
index 000000000000..28ae7057be5e
--- /dev/null
+++ b/arch/powerpc/boot/gamecube.c
@@ -0,0 +1,35 @@
1/*
2 * arch/powerpc/boot/gamecube.c
3 *
4 * Nintendo GameCube bootwrapper support
5 * Copyright (C) 2004-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#include <stddef.h>
16#include "stdio.h"
17#include "types.h"
18#include "io.h"
19#include "ops.h"
20
21#include "ugecon.h"
22
23BSS_STACK(8192);
24
25void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
26{
27 u32 heapsize = 16*1024*1024 - (u32)_end;
28
29 simple_alloc_init(_end, heapsize, 32, 64);
30 fdt_init(_dtb_start);
31
32 if (ug_probe())
33 console_ops.write = ug_console_write;
34}
35
diff --git a/arch/powerpc/boot/ugecon.c b/arch/powerpc/boot/ugecon.c
new file mode 100644
index 000000000000..50609ea6ddf8
--- /dev/null
+++ b/arch/powerpc/boot/ugecon.c
@@ -0,0 +1,147 @@
1/*
2 * arch/powerpc/boot/ugecon.c
3 *
4 * USB Gecko bootwrapper console.
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#include <stddef.h>
16#include "stdio.h"
17#include "types.h"
18#include "io.h"
19#include "ops.h"
20
21
22#define EXI_CLK_32MHZ 5
23
24#define EXI_CSR 0x00
25#define EXI_CSR_CLKMASK (0x7<<4)
26#define EXI_CSR_CLK_32MHZ (EXI_CLK_32MHZ<<4)
27#define EXI_CSR_CSMASK (0x7<<7)
28#define EXI_CSR_CS_0 (0x1<<7) /* Chip Select 001 */
29
30#define EXI_CR 0x0c
31#define EXI_CR_TSTART (1<<0)
32#define EXI_CR_WRITE (1<<2)
33#define EXI_CR_READ_WRITE (2<<2)
34#define EXI_CR_TLEN(len) (((len)-1)<<4)
35
36#define EXI_DATA 0x10
37
38
39/* virtual address base for input/output, retrieved from device tree */
40static void *ug_io_base;
41
42
43static u32 ug_io_transaction(u32 in)
44{
45 u32 *csr_reg = ug_io_base + EXI_CSR;
46 u32 *data_reg = ug_io_base + EXI_DATA;
47 u32 *cr_reg = ug_io_base + EXI_CR;
48 u32 csr, data, cr;
49
50 /* select */
51 csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
52 out_be32(csr_reg, csr);
53
54 /* read/write */
55 data = in;
56 out_be32(data_reg, data);
57 cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
58 out_be32(cr_reg, cr);
59
60 while (in_be32(cr_reg) & EXI_CR_TSTART)
61 barrier();
62
63 /* deselect */
64 out_be32(csr_reg, 0);
65
66 data = in_be32(data_reg);
67 return data;
68}
69
70static int ug_is_txfifo_ready(void)
71{
72 return ug_io_transaction(0xc0000000) & 0x04000000;
73}
74
75static void ug_raw_putc(char ch)
76{
77 ug_io_transaction(0xb0000000 | (ch << 20));
78}
79
80static void ug_putc(char ch)
81{
82 int count = 16;
83
84 if (!ug_io_base)
85 return;
86
87 while (!ug_is_txfifo_ready() && count--)
88 barrier();
89 if (count)
90 ug_raw_putc(ch);
91}
92
93void ug_console_write(const char *buf, int len)
94{
95 char *b = (char *)buf;
96
97 while (len--) {
98 if (*b == '\n')
99 ug_putc('\r');
100 ug_putc(*b++);
101 }
102}
103
104static int ug_is_adapter_present(void)
105{
106 if (!ug_io_base)
107 return 0;
108 return ug_io_transaction(0x90000000) == 0x04700000;
109}
110
111static void *ug_grab_exi_io_base(void)
112{
113 u32 v;
114 void *devp;
115
116 devp = find_node_by_compatible(NULL, "nintendo,flipper-exi");
117 if (devp == NULL)
118 goto err_out;
119 if (getprop(devp, "virtual-reg", &v, sizeof(v)) != sizeof(v))
120 goto err_out;
121
122 return (void *)v;
123
124err_out:
125 return NULL;
126}
127
128void *ug_probe(void)
129{
130 void *exi_io_base;
131 int i;
132
133 exi_io_base = ug_grab_exi_io_base();
134 if (!exi_io_base)
135 return NULL;
136
137 /* look for a usbgecko on memcard slots A and B */
138 for (i = 0; i < 2; i++) {
139 ug_io_base = exi_io_base + 0x14 * i;
140 if (ug_is_adapter_present())
141 break;
142 }
143 if (i == 2)
144 ug_io_base = NULL;
145 return ug_io_base;
146}
147
diff --git a/arch/powerpc/boot/ugecon.h b/arch/powerpc/boot/ugecon.h
new file mode 100644
index 000000000000..43737539169b
--- /dev/null
+++ b/arch/powerpc/boot/ugecon.h
@@ -0,0 +1,24 @@
1/*
2 * arch/powerpc/boot/ugecon.h
3 *
4 * USB Gecko early bootwrapper console.
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#ifndef __UGECON_H
16#define __UGECON_H
17
18extern void *ug_probe(void);
19
20extern void ug_putc(char ch);
21extern void ug_console_write(const char *buf, int len);
22
23#endif /* __UGECON_H */
24
diff --git a/arch/powerpc/boot/wii-head.S b/arch/powerpc/boot/wii-head.S
new file mode 100644
index 000000000000..edd79b836fcf
--- /dev/null
+++ b/arch/powerpc/boot/wii-head.S
@@ -0,0 +1,142 @@
1/*
2 * arch/powerpc/boot/wii-head.S
3 *
4 * Nintendo Wii bootwrapper entry.
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#include "ppc_asm.h"
16
17/*
18 * The entry code does no assumptions regarding:
19 * - if the data and instruction caches are enabled or not
20 * - if the MMU is enabled or not
21 * - if the high BATs are enabled or not
22 *
23 * We enable the high BATs, enable the caches if not already enabled,
24 * enable the MMU with an identity mapping scheme and jump to the start code.
25 */
26
27 .text
28
29 .globl _zimage_start
30_zimage_start:
31
32 /* turn the MMU off */
33 mfmsr 9
34 rlwinm 9, 9, 0, ~((1<<4)|(1<<5)) /* MSR_DR|MSR_IR */
35 bcl 20, 31, 1f
361:
37 mflr 8
38 clrlwi 8, 8, 3 /* convert to a real address */
39 addi 8, 8, _mmu_off - 1b
40 mtsrr0 8
41 mtsrr1 9
42 rfi
43_mmu_off:
44 /* MMU disabled */
45
46 /* setup BATs */
47 isync
48 li 8, 0
49 mtspr 0x210, 8 /* IBAT0U */
50 mtspr 0x212, 8 /* IBAT1U */
51 mtspr 0x214, 8 /* IBAT2U */
52 mtspr 0x216, 8 /* IBAT3U */
53 mtspr 0x218, 8 /* DBAT0U */
54 mtspr 0x21a, 8 /* DBAT1U */
55 mtspr 0x21c, 8 /* DBAT2U */
56 mtspr 0x21e, 8 /* DBAT3U */
57
58 mtspr 0x230, 8 /* IBAT4U */
59 mtspr 0x232, 8 /* IBAT5U */
60 mtspr 0x234, 8 /* IBAT6U */
61 mtspr 0x236, 8 /* IBAT7U */
62 mtspr 0x238, 8 /* DBAT4U */
63 mtspr 0x23a, 8 /* DBAT5U */
64 mtspr 0x23c, 8 /* DBAT6U */
65 mtspr 0x23e, 8 /* DBAT7U */
66
67 li 8, 0x01ff /* first 16MiB */
68 li 9, 0x0002 /* rw */
69 mtspr 0x211, 9 /* IBAT0L */
70 mtspr 0x210, 8 /* IBAT0U */
71 mtspr 0x219, 9 /* DBAT0L */
72 mtspr 0x218, 8 /* DBAT0U */
73
74 lis 8, 0x0c00 /* I/O mem */
75 ori 8, 8, 0x3ff /* 32MiB */
76 lis 9, 0x0c00
77 ori 9, 9, 0x002a /* uncached, guarded, rw */
78 mtspr 0x21b, 9 /* DBAT1L */
79 mtspr 0x21a, 8 /* DBAT1U */
80
81 lis 8, 0x0100 /* next 8MiB */
82 ori 8, 8, 0x00ff /* 8MiB */
83 lis 9, 0x0100
84 ori 9, 9, 0x0002 /* rw */
85 mtspr 0x215, 9 /* IBAT2L */
86 mtspr 0x214, 8 /* IBAT2U */
87 mtspr 0x21d, 9 /* DBAT2L */
88 mtspr 0x21c, 8 /* DBAT2U */
89
90 lis 8, 0x1000 /* MEM2 */
91 ori 8, 8, 0x07ff /* 64MiB */
92 lis 9, 0x1000
93 ori 9, 9, 0x0002 /* rw */
94 mtspr 0x216, 8 /* IBAT3U */
95 mtspr 0x217, 9 /* IBAT3L */
96 mtspr 0x21e, 8 /* DBAT3U */
97 mtspr 0x21f, 9 /* DBAT3L */
98
99 /* enable the high BATs */
100 mfspr 8, 0x3f3 /* HID4 */
101 oris 8, 8, 0x0200
102 mtspr 0x3f3, 8 /* HID4 */
103
104 /* enable and invalidate the caches if not already enabled */
105 mfspr 8, 0x3f0 /* HID0 */
106 andi. 0, 8, (1<<15) /* HID0_ICE */
107 bne 1f
108 ori 8, 8, (1<<15)|(1<<11) /* HID0_ICE|HID0_ICFI*/
1091:
110 andi. 0, 8, (1<<14) /* HID0_DCE */
111 bne 1f
112 ori 8, 8, (1<<14)|(1<<10) /* HID0_DCE|HID0_DCFI*/
1131:
114 mtspr 0x3f0, 8 /* HID0 */
115 isync
116
117 /* initialize arguments */
118 li 3, 0
119 li 4, 0
120 li 5, 0
121
122 /* turn the MMU on */
123 bcl 20, 31, 1f
1241:
125 mflr 8
126 addi 8, 8, _mmu_on - 1b
127 mfmsr 9
128 ori 9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */
129 mtsrr0 8
130 mtsrr1 9
131 sync
132 rfi
133_mmu_on:
134 /* turn on the front blue led (aka: yay! we got here!) */
135 lis 8, 0x0d00
136 ori 8, 8, 0x00c0
137 lwz 9, 0(8)
138 ori 9, 9, 0x20
139 stw 9, 0(8)
140
141 b _zimage_start_lib
142
diff --git a/arch/powerpc/boot/wii.c b/arch/powerpc/boot/wii.c
new file mode 100644
index 000000000000..2ebaec0344dd
--- /dev/null
+++ b/arch/powerpc/boot/wii.c
@@ -0,0 +1,158 @@
1/*
2 * arch/powerpc/boot/wii.c
3 *
4 * Nintendo Wii bootwrapper support
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 */
14
15#include <stddef.h>
16#include "stdio.h"
17#include "types.h"
18#include "io.h"
19#include "ops.h"
20
21#include "ugecon.h"
22
23BSS_STACK(8192);
24
25#define HW_REG(x) ((void *)(x))
26
27#define EXI_CTRL HW_REG(0x0d800070)
28#define EXI_CTRL_ENABLE (1<<0)
29
30#define MEM2_TOP (0x10000000 + 64*1024*1024)
31#define FIRMWARE_DEFAULT_SIZE (12*1024*1024)
32
33
34struct mipc_infohdr {
35 char magic[3];
36 u8 version;
37 u32 mem2_boundary;
38 u32 ipc_in;
39 size_t ipc_in_size;
40 u32 ipc_out;
41 size_t ipc_out_size;
42};
43
44static int mipc_check_address(u32 pa)
45{
46 /* only MEM2 addresses */
47 if (pa < 0x10000000 || pa > 0x14000000)
48 return -EINVAL;
49 return 0;
50}
51
52static struct mipc_infohdr *mipc_get_infohdr(void)
53{
54 struct mipc_infohdr **hdrp, *hdr;
55
56 /* 'mini' header pointer is the last word of MEM2 memory */
57 hdrp = (struct mipc_infohdr **)0x13fffffc;
58 if (mipc_check_address((u32)hdrp)) {
59 printf("mini: invalid hdrp %08X\n", (u32)hdrp);
60 hdr = NULL;
61 goto out;
62 }
63
64 hdr = *hdrp;
65 if (mipc_check_address((u32)hdr)) {
66 printf("mini: invalid hdr %08X\n", (u32)hdr);
67 hdr = NULL;
68 goto out;
69 }
70 if (memcmp(hdr->magic, "IPC", 3)) {
71 printf("mini: invalid magic\n");
72 hdr = NULL;
73 goto out;
74 }
75
76out:
77 return hdr;
78}
79
80static int mipc_get_mem2_boundary(u32 *mem2_boundary)
81{
82 struct mipc_infohdr *hdr;
83 int error;
84
85 hdr = mipc_get_infohdr();
86 if (!hdr) {
87 error = -1;
88 goto out;
89 }
90
91 if (mipc_check_address(hdr->mem2_boundary)) {
92 printf("mini: invalid mem2_boundary %08X\n",
93 hdr->mem2_boundary);
94 error = -EINVAL;
95 goto out;
96 }
97 *mem2_boundary = hdr->mem2_boundary;
98 error = 0;
99out:
100 return error;
101
102}
103
104static void platform_fixups(void)
105{
106 void *mem;
107 u32 reg[4];
108 u32 mem2_boundary;
109 int len;
110 int error;
111
112 mem = finddevice("/memory");
113 if (!mem)
114 fatal("Can't find memory node\n");
115
116 /* two ranges of (address, size) words */
117 len = getprop(mem, "reg", reg, sizeof(reg));
118 if (len != sizeof(reg)) {
119 /* nothing to do */
120 goto out;
121 }
122
123 /* retrieve MEM2 boundary from 'mini' */
124 error = mipc_get_mem2_boundary(&mem2_boundary);
125 if (error) {
126 /* if that fails use a sane value */
127 mem2_boundary = MEM2_TOP - FIRMWARE_DEFAULT_SIZE;
128 }
129
130 if (mem2_boundary > reg[2] && mem2_boundary < reg[2] + reg[3]) {
131 reg[3] = mem2_boundary - reg[2];
132 printf("top of MEM2 @ %08X\n", reg[2] + reg[3]);
133 setprop(mem, "reg", reg, sizeof(reg));
134 }
135
136out:
137 return;
138}
139
140void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
141{
142 u32 heapsize = 24*1024*1024 - (u32)_end;
143
144 simple_alloc_init(_end, heapsize, 32, 64);
145 fdt_init(_dtb_start);
146
147 /*
148 * 'mini' boots the Broadway processor with EXI disabled.
149 * We need it enabled before probing for the USB Gecko.
150 */
151 out_be32(EXI_CTRL, in_be32(EXI_CTRL) | EXI_CTRL_ENABLE);
152
153 if (ug_probe())
154 console_ops.write = ug_console_write;
155
156 platform_ops.fixups = platform_fixups;
157}
158
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ac9e9a58b2b0..390512ae7f86 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -230,6 +230,10 @@ xpedite52*)
230 link_address='0x1400000' 230 link_address='0x1400000'
231 platformo=$object/cuboot-85xx.o 231 platformo=$object/cuboot-85xx.o
232 ;; 232 ;;
233gamecube|wii)
234 link_address='0x600000'
235 platformo="$object/$platform-head.o $object/$platform.o"
236 ;;
233esac 237esac
234 238
235vmz="$tmpdir/`basename \"$kernel\"`.$ext" 239vmz="$tmpdir/`basename \"$kernel\"`.$ext"