diff options
author | Albert Herranz <albert_herranz@yahoo.es> | 2009-12-12 01:31:48 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2009-12-13 00:24:30 -0500 |
commit | 5a7ee3198dfade8eaea260399fd168e4e9c1a3a9 (patch) | |
tree | df0d3758939c3ab759eca29eedfe8f7486996d1b /arch/powerpc/platforms/embedded6xx/wii.c | |
parent | 9c21025c7845bd32fb76eb38cb512c911930d85d (diff) |
powerpc: wii: platform support
Add platform support for the Nintendo Wii video game console.
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc/platforms/embedded6xx/wii.c')
-rw-r--r-- | arch/powerpc/platforms/embedded6xx/wii.c | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c new file mode 100644 index 000000000000..1bd41cc8039d --- /dev/null +++ b/arch/powerpc/platforms/embedded6xx/wii.c | |||
@@ -0,0 +1,202 @@ | |||
1 | /* | ||
2 | * arch/powerpc/platforms/embedded6xx/wii.c | ||
3 | * | ||
4 | * Nintendo Wii board-specific 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 | #define DRV_MODULE_NAME "wii" | ||
15 | #define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/irq.h> | ||
20 | #include <linux/seq_file.h> | ||
21 | #include <linux/kexec.h> | ||
22 | #include <linux/of_platform.h> | ||
23 | |||
24 | #include <asm/io.h> | ||
25 | #include <asm/machdep.h> | ||
26 | #include <asm/prom.h> | ||
27 | #include <asm/time.h> | ||
28 | #include <asm/udbg.h> | ||
29 | |||
30 | #include "flipper-pic.h" | ||
31 | #include "hlwd-pic.h" | ||
32 | #include "usbgecko_udbg.h" | ||
33 | |||
34 | /* control block */ | ||
35 | #define HW_CTRL_COMPATIBLE "nintendo,hollywood-control" | ||
36 | |||
37 | #define HW_CTRL_RESETS 0x94 | ||
38 | #define HW_CTRL_RESETS_SYS (1<<0) | ||
39 | |||
40 | /* gpio */ | ||
41 | #define HW_GPIO_COMPATIBLE "nintendo,hollywood-gpio" | ||
42 | |||
43 | #define HW_GPIO_BASE(idx) (idx * 0x20) | ||
44 | #define HW_GPIO_OUT(idx) (HW_GPIO_BASE(idx) + 0) | ||
45 | #define HW_GPIO_DIR(idx) (HW_GPIO_BASE(idx) + 4) | ||
46 | |||
47 | #define HW_GPIO_SHUTDOWN (1<<1) | ||
48 | #define HW_GPIO_SLOT_LED (1<<5) | ||
49 | #define HW_GPIO_SENSOR_BAR (1<<8) | ||
50 | |||
51 | |||
52 | static void __iomem *hw_ctrl; | ||
53 | static void __iomem *hw_gpio; | ||
54 | |||
55 | static void wii_spin(void) | ||
56 | { | ||
57 | local_irq_disable(); | ||
58 | for (;;) | ||
59 | cpu_relax(); | ||
60 | } | ||
61 | |||
62 | static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible) | ||
63 | { | ||
64 | void __iomem *hw_regs = NULL; | ||
65 | struct device_node *np; | ||
66 | struct resource res; | ||
67 | int error = -ENODEV; | ||
68 | |||
69 | np = of_find_compatible_node(NULL, NULL, compatible); | ||
70 | if (!np) { | ||
71 | pr_err("no compatible node found for %s\n", compatible); | ||
72 | goto out; | ||
73 | } | ||
74 | error = of_address_to_resource(np, 0, &res); | ||
75 | if (error) { | ||
76 | pr_err("no valid reg found for %s\n", np->name); | ||
77 | goto out_put; | ||
78 | } | ||
79 | |||
80 | hw_regs = ioremap(res.start, resource_size(&res)); | ||
81 | if (hw_regs) { | ||
82 | pr_info("%s at 0x%08x mapped to 0x%p\n", name, | ||
83 | res.start, hw_regs); | ||
84 | } | ||
85 | |||
86 | out_put: | ||
87 | of_node_put(np); | ||
88 | out: | ||
89 | return hw_regs; | ||
90 | } | ||
91 | |||
92 | static void __init wii_setup_arch(void) | ||
93 | { | ||
94 | hw_ctrl = wii_ioremap_hw_regs("hw_ctrl", HW_CTRL_COMPATIBLE); | ||
95 | hw_gpio = wii_ioremap_hw_regs("hw_gpio", HW_GPIO_COMPATIBLE); | ||
96 | if (hw_gpio) { | ||
97 | /* turn off the front blue led and IR light */ | ||
98 | clrbits32(hw_gpio + HW_GPIO_OUT(0), | ||
99 | HW_GPIO_SLOT_LED | HW_GPIO_SENSOR_BAR); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | static void wii_restart(char *cmd) | ||
104 | { | ||
105 | local_irq_disable(); | ||
106 | |||
107 | if (hw_ctrl) { | ||
108 | /* clear the system reset pin to cause a reset */ | ||
109 | clrbits32(hw_ctrl + HW_CTRL_RESETS, HW_CTRL_RESETS_SYS); | ||
110 | } | ||
111 | wii_spin(); | ||
112 | } | ||
113 | |||
114 | static void wii_power_off(void) | ||
115 | { | ||
116 | local_irq_disable(); | ||
117 | |||
118 | if (hw_gpio) { | ||
119 | /* make sure that the poweroff GPIO is configured as output */ | ||
120 | setbits32(hw_gpio + HW_GPIO_DIR(1), HW_GPIO_SHUTDOWN); | ||
121 | |||
122 | /* drive the poweroff GPIO high */ | ||
123 | setbits32(hw_gpio + HW_GPIO_OUT(1), HW_GPIO_SHUTDOWN); | ||
124 | } | ||
125 | wii_spin(); | ||
126 | } | ||
127 | |||
128 | static void wii_halt(void) | ||
129 | { | ||
130 | if (ppc_md.restart) | ||
131 | ppc_md.restart(NULL); | ||
132 | wii_spin(); | ||
133 | } | ||
134 | |||
135 | static void __init wii_init_early(void) | ||
136 | { | ||
137 | ug_udbg_init(); | ||
138 | } | ||
139 | |||
140 | static void __init wii_pic_probe(void) | ||
141 | { | ||
142 | flipper_pic_probe(); | ||
143 | hlwd_pic_probe(); | ||
144 | } | ||
145 | |||
146 | static int __init wii_probe(void) | ||
147 | { | ||
148 | unsigned long dt_root; | ||
149 | |||
150 | dt_root = of_get_flat_dt_root(); | ||
151 | if (!of_flat_dt_is_compatible(dt_root, "nintendo,wii")) | ||
152 | return 0; | ||
153 | |||
154 | return 1; | ||
155 | } | ||
156 | |||
157 | static void wii_shutdown(void) | ||
158 | { | ||
159 | hlwd_quiesce(); | ||
160 | flipper_quiesce(); | ||
161 | } | ||
162 | |||
163 | #ifdef CONFIG_KEXEC | ||
164 | static int wii_machine_kexec_prepare(struct kimage *image) | ||
165 | { | ||
166 | return 0; | ||
167 | } | ||
168 | #endif /* CONFIG_KEXEC */ | ||
169 | |||
170 | define_machine(wii) { | ||
171 | .name = "wii", | ||
172 | .probe = wii_probe, | ||
173 | .init_early = wii_init_early, | ||
174 | .setup_arch = wii_setup_arch, | ||
175 | .restart = wii_restart, | ||
176 | .power_off = wii_power_off, | ||
177 | .halt = wii_halt, | ||
178 | .init_IRQ = wii_pic_probe, | ||
179 | .get_irq = flipper_pic_get_irq, | ||
180 | .calibrate_decr = generic_calibrate_decr, | ||
181 | .progress = udbg_progress, | ||
182 | .machine_shutdown = wii_shutdown, | ||
183 | #ifdef CONFIG_KEXEC | ||
184 | .machine_kexec_prepare = wii_machine_kexec_prepare, | ||
185 | #endif | ||
186 | }; | ||
187 | |||
188 | static struct of_device_id wii_of_bus[] = { | ||
189 | { .compatible = "nintendo,hollywood", }, | ||
190 | { }, | ||
191 | }; | ||
192 | |||
193 | static int __init wii_device_probe(void) | ||
194 | { | ||
195 | if (!machine_is(wii)) | ||
196 | return 0; | ||
197 | |||
198 | of_platform_bus_probe(NULL, wii_of_bus, NULL); | ||
199 | return 0; | ||
200 | } | ||
201 | device_initcall(wii_device_probe); | ||
202 | |||