Add platform support for the Nintendo Wii video game console.
Signed-off-by: Albert Herranz albert_herr...@yahoo.es
---
v1 - v2
- Get rid of show_cpuinfo hooks. Suggestion by Grant Likely.
- Drop unneeded (at this stage) empty functions. Suggestion by Grant Likely.
- Merge wii.c and wii_dev.c into a single file. Suggestion by Grant Likely.
- Use wii instead of rvl as a pr prefix. Suggestion by Segher Boessenkool.
- Assume 'mini'-like firmware environment.
arch/powerpc/platforms/embedded6xx/Kconfig |8 +
arch/powerpc/platforms/embedded6xx/Makefile |2 +-
arch/powerpc/platforms/embedded6xx/wii.c| 195 +++
3 files changed, 204 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/platforms/embedded6xx/wii.c
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig
b/arch/powerpc/platforms/embedded6xx/Kconfig
index e318ced..524d971 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -115,3 +115,11 @@ config GAMECUBE
Select GAMECUBE if configuring for the Nintendo GameCube.
More information at: http://gc-linux.sourceforge.net/
+config WII
+ bool Nintendo-Wii
+ depends on EMBEDDED6xx
+ select GAMECUBE_COMMON
+ help
+ Select WII if configuring for the Nintendo Wii.
+ More information at: http://gc-linux.sourceforge.net/
+
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile
b/arch/powerpc/platforms/embedded6xx/Makefile
index f75b9e4..66c23e4 100644
--- a/arch/powerpc/platforms/embedded6xx/Makefile
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -10,4 +10,4 @@ obj-$(CONFIG_PPC_C2K) += c2k.o
obj-$(CONFIG_USBGECKO_UDBG)+= usbgecko_udbg.o
obj-$(CONFIG_GAMECUBE_COMMON) += flipper-pic.o
obj-$(CONFIG_GAMECUBE) += gamecube.o
-obj-$(CONFIG_WII) += hlwd-pic.o
+obj-$(CONFIG_WII) += wii.o hlwd-pic.o
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c
b/arch/powerpc/platforms/embedded6xx/wii.c
new file mode 100644
index 000..f445472
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -0,0 +1,195 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/wii.c
+ *
+ * Nintendo Wii board-specific support
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+#define DRV_MODULE_NAME wii
+#define pr_fmt(fmt) DRV_MODULE_NAME : fmt
+
+#include linux/kernel.h
+#include linux/init.h
+#include linux/irq.h
+#include linux/seq_file.h
+#include linux/kexec.h
+#include linux/of_platform.h
+
+#include asm/io.h
+#include asm/machdep.h
+#include asm/prom.h
+#include asm/time.h
+#include asm/udbg.h
+
+#include flipper-pic.h
+#include hlwd-pic.h
+#include usbgecko_udbg.h
+
+/* control block */
+#define HW_CTRL_COMPATIBLE nintendo,hollywood-control
+
+#define HW_CTRL_RESETS 0x94
+#define HW_CTRL_RESETS_SYS (10)
+
+/* gpio */
+#define HW_GPIO_COMPATIBLE nintendo,hollywood-gpio
+
+#define HW_GPIO_BASE(idx) (idx * 0x20)
+#define HW_GPIO_OUT(idx) (HW_GPIO_BASE(idx) + 0)
+#define HW_GPIO_DIR(idx) (HW_GPIO_BASE(idx) + 4)
+
+#define HW_GPIO_SHUTDOWN (11)
+
+
+static void __iomem *hw_ctrl;
+static void __iomem *hw_gpio;
+
+static void wii_spin(void)
+{
+ local_irq_disable();
+ for (;;)
+ cpu_relax();
+}
+
+static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible)
+{
+ void __iomem *hw_regs = NULL;
+ struct device_node *np;
+ struct resource res;
+ int error = -ENODEV;
+
+ np = of_find_compatible_node(NULL, NULL, compatible);
+ if (!np) {
+ pr_err(no compatible node found for %s\n, compatible);
+ goto out;
+ }
+ error = of_address_to_resource(np, 0, res);
+ if (error) {
+ pr_err(no valid reg found for %s\n, np-name);
+ goto out_put;
+ }
+
+ hw_regs = ioremap(res.start, resource_size(res));
+ if (hw_regs) {
+ pr_info(%s at 0x%08x mapped to 0x%p\n, name,
+ res.start, hw_regs);
+ }
+
+out_put:
+ of_node_put(np);
+out:
+ return hw_regs;
+}
+
+static void __init wii_setup_arch(void)
+{
+ hw_ctrl = wii_ioremap_hw_regs(hw_ctrl, HW_CTRL_COMPATIBLE);
+ hw_gpio = wii_ioremap_hw_regs(hw_gpio, HW_GPIO_COMPATIBLE);
+}
+
+static void wii_restart(char *cmd)
+{
+ local_irq_disable();
+
+ if (hw_ctrl) {
+ /* clear the system reset pin to cause a reset */
+ clrbits32(hw_ctrl + HW_CTRL_RESETS, HW_CTRL_RESETS_SYS);
+ }
+ wii_spin();
+}
+
+static void wii_power_off(void)
+{
+ local_irq_disable();
+
+ if