[PATCH 10/12] powerpc: wiiu: platform support

From: Ash Logan
Date: Tue Mar 01 2022 - 23:45:44 EST


Add platform support for the Nintendo Wii U console.

Signed-off-by: Ash Logan <ash@xxxxxxxxxxxx>
Co-developed-by: Roberto Van Eeden <rw-r-r-0644@xxxxxxxxxxxxxx>
Signed-off-by: Roberto Van Eeden <rw-r-r-0644@xxxxxxxxxxxxxx>
Co-developed-by: Emmanuel Gil Peyrot <linkmauve@xxxxxxxxxxxx>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@xxxxxxxxxxxx>
---
arch/powerpc/platforms/wiiu/Makefile | 2 +-
arch/powerpc/platforms/wiiu/setup.c | 67 ++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/platforms/wiiu/setup.c

diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/wiiu/Makefile
index fa16c60261e6..abcb7a1beebf 100644
--- a/arch/powerpc/platforms/wiiu/Makefile
+++ b/arch/powerpc/platforms/wiiu/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0

-obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
+obj-$(CONFIG_WIIU) += setup.o espresso-pic.o latte-pic.o
obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
diff --git a/arch/powerpc/platforms/wiiu/setup.c b/arch/powerpc/platforms/wiiu/setup.c
new file mode 100644
index 000000000000..279fa899a296
--- /dev/null
+++ b/arch/powerpc/platforms/wiiu/setup.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Nintendo Wii U board-specific support
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+#define DRV_MODULE_NAME "wiiu"
+#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/of_platform.h>
+
+#include <asm/machdep.h>
+#include <asm/udbg.h>
+
+#include "espresso-pic.h"
+#include "latte-pic.h"
+#include "udbg_latteipc.h"
+
+static int __init wiiu_probe(void)
+{
+ if (!of_machine_is_compatible("nintendo,wiiu"))
+ return 0;
+
+ latteipc_udbg_init();
+
+ return 1;
+}
+
+static void __noreturn wiiu_halt(void)
+{
+ for (;;)
+ cpu_relax();
+}
+
+static void __init wiiu_init_irq(void)
+{
+ espresso_pic_init();
+ latte_pic_init();
+}
+
+static const struct of_device_id wiiu_of_bus[] = {
+ {
+ .compatible = "nintendo,latte",
+ },
+ {},
+};
+
+static int __init wiiu_device_probe(void)
+{
+ if (!machine_is(wiiu))
+ return 0;
+
+ of_platform_populate(NULL, wiiu_of_bus, NULL, NULL);
+ return 0;
+}
+device_initcall(wiiu_device_probe);
+
+define_machine(wiiu) {
+ .name = "wiiu",
+ .probe = wiiu_probe,
+ .halt = wiiu_halt,
+ .progress = udbg_progress,
+ .calibrate_decr = generic_calibrate_decr,
+ .init_IRQ = wiiu_init_irq,
+ .get_irq = espresso_pic_get_irq,
+};
--
2.35.1