xref: /openbmc/linux/arch/powerpc/platforms/embedded6xx/gamecube.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2e90d71d0SAlbert Herranz /*
3e90d71d0SAlbert Herranz  * arch/powerpc/platforms/embedded6xx/gamecube.c
4e90d71d0SAlbert Herranz  *
5e90d71d0SAlbert Herranz  * Nintendo GameCube board-specific support
6e90d71d0SAlbert Herranz  * Copyright (C) 2004-2009 The GameCube Linux Team
7e90d71d0SAlbert Herranz  * Copyright (C) 2007,2008,2009 Albert Herranz
8e90d71d0SAlbert Herranz  */
9e90d71d0SAlbert Herranz 
10e90d71d0SAlbert Herranz #include <linux/kernel.h>
11e90d71d0SAlbert Herranz #include <linux/init.h>
12e90d71d0SAlbert Herranz #include <linux/irq.h>
13e90d71d0SAlbert Herranz #include <linux/kexec.h>
14e90d71d0SAlbert Herranz #include <linux/seq_file.h>
15e90d71d0SAlbert Herranz #include <linux/of_platform.h>
16e90d71d0SAlbert Herranz 
17e90d71d0SAlbert Herranz #include <asm/io.h>
18e90d71d0SAlbert Herranz #include <asm/machdep.h>
19e90d71d0SAlbert Herranz #include <asm/time.h>
20e90d71d0SAlbert Herranz #include <asm/udbg.h>
21e90d71d0SAlbert Herranz 
22e90d71d0SAlbert Herranz #include "flipper-pic.h"
23e90d71d0SAlbert Herranz #include "usbgecko_udbg.h"
24e90d71d0SAlbert Herranz 
25e90d71d0SAlbert Herranz 
gamecube_spin(void)2695ec77c0SDaniel Axtens static void __noreturn gamecube_spin(void)
27e90d71d0SAlbert Herranz {
28e90d71d0SAlbert Herranz 	/* spin until power button pressed */
29e90d71d0SAlbert Herranz 	for (;;)
30e90d71d0SAlbert Herranz 		cpu_relax();
31e90d71d0SAlbert Herranz }
32e90d71d0SAlbert Herranz 
gamecube_restart(char * cmd)3395ec77c0SDaniel Axtens static void __noreturn gamecube_restart(char *cmd)
34e90d71d0SAlbert Herranz {
35e90d71d0SAlbert Herranz 	local_irq_disable();
36e90d71d0SAlbert Herranz 	flipper_platform_reset();
37e90d71d0SAlbert Herranz 	gamecube_spin();
38e90d71d0SAlbert Herranz }
39e90d71d0SAlbert Herranz 
gamecube_power_off(void)40e90d71d0SAlbert Herranz static void gamecube_power_off(void)
41e90d71d0SAlbert Herranz {
42e90d71d0SAlbert Herranz 	local_irq_disable();
43e90d71d0SAlbert Herranz 	gamecube_spin();
44e90d71d0SAlbert Herranz }
45e90d71d0SAlbert Herranz 
gamecube_halt(void)4695ec77c0SDaniel Axtens static void __noreturn gamecube_halt(void)
47e90d71d0SAlbert Herranz {
48e90d71d0SAlbert Herranz 	gamecube_restart(NULL);
49e90d71d0SAlbert Herranz }
50e90d71d0SAlbert Herranz 
gamecube_probe(void)51e90d71d0SAlbert Herranz static int __init gamecube_probe(void)
52e90d71d0SAlbert Herranz {
539178ba29SAlexander Graf 	pm_power_off = gamecube_power_off;
549178ba29SAlexander Graf 
55f2d57694SBenjamin Herrenschmidt 	ug_udbg_init();
56f2d57694SBenjamin Herrenschmidt 
57e90d71d0SAlbert Herranz 	return 1;
58e90d71d0SAlbert Herranz }
59e90d71d0SAlbert Herranz 
gamecube_shutdown(void)60e90d71d0SAlbert Herranz static void gamecube_shutdown(void)
61e90d71d0SAlbert Herranz {
62e90d71d0SAlbert Herranz 	flipper_quiesce();
63e90d71d0SAlbert Herranz }
64e90d71d0SAlbert Herranz 
define_machine(gamecube)65e90d71d0SAlbert Herranz define_machine(gamecube) {
66e90d71d0SAlbert Herranz 	.name			= "gamecube",
671c96fcdeSChristophe Leroy 	.compatible		= "nintendo,gamecube",
68e90d71d0SAlbert Herranz 	.probe			= gamecube_probe,
69e90d71d0SAlbert Herranz 	.restart		= gamecube_restart,
70e90d71d0SAlbert Herranz 	.halt			= gamecube_halt,
71e90d71d0SAlbert Herranz 	.init_IRQ		= flipper_pic_probe,
72e90d71d0SAlbert Herranz 	.get_irq		= flipper_pic_get_irq,
73e90d71d0SAlbert Herranz 	.progress		= udbg_progress,
74e90d71d0SAlbert Herranz 	.machine_shutdown	= gamecube_shutdown,
75e90d71d0SAlbert Herranz };
76e90d71d0SAlbert Herranz 
77e90d71d0SAlbert Herranz 
78ce6d73c9SUwe Kleine-König static const struct of_device_id gamecube_of_bus[] = {
79e90d71d0SAlbert Herranz 	{ .compatible = "nintendo,flipper", },
80e90d71d0SAlbert Herranz 	{ },
81e90d71d0SAlbert Herranz };
82e90d71d0SAlbert Herranz 
gamecube_device_probe(void)83e90d71d0SAlbert Herranz static int __init gamecube_device_probe(void)
84e90d71d0SAlbert Herranz {
85e90d71d0SAlbert Herranz 	of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
86e90d71d0SAlbert Herranz 	return 0;
87e90d71d0SAlbert Herranz }
88*f47b17d5SChristophe Leroy machine_device_initcall(gamecube, gamecube_device_probe);
89e90d71d0SAlbert Herranz 
90