blob: 36789cec957cac11a7a23e92fcf5cc5184c59aba [file] [log] [blame]
Albert Herranze90d71d2009-12-12 06:31:42 +00001/*
2 * arch/powerpc/platforms/embedded6xx/gamecube.c
3 *
4 * Nintendo GameCube board-specific support
5 * Copyright (C) 2004-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#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/irq.h>
18#include <linux/kexec.h>
19#include <linux/seq_file.h>
20#include <linux/of_platform.h>
21
22#include <asm/io.h>
23#include <asm/machdep.h>
24#include <asm/prom.h>
25#include <asm/time.h>
26#include <asm/udbg.h>
27
28#include "flipper-pic.h"
29#include "usbgecko_udbg.h"
30
31
Daniel Axtens95ec77c2016-07-12 10:54:52 +100032static void __noreturn gamecube_spin(void)
Albert Herranze90d71d2009-12-12 06:31:42 +000033{
34 /* spin until power button pressed */
35 for (;;)
36 cpu_relax();
37}
38
Daniel Axtens95ec77c2016-07-12 10:54:52 +100039static void __noreturn gamecube_restart(char *cmd)
Albert Herranze90d71d2009-12-12 06:31:42 +000040{
41 local_irq_disable();
42 flipper_platform_reset();
43 gamecube_spin();
44}
45
46static void gamecube_power_off(void)
47{
48 local_irq_disable();
49 gamecube_spin();
50}
51
Daniel Axtens95ec77c2016-07-12 10:54:52 +100052static void __noreturn gamecube_halt(void)
Albert Herranze90d71d2009-12-12 06:31:42 +000053{
54 gamecube_restart(NULL);
55}
56
Albert Herranze90d71d2009-12-12 06:31:42 +000057static int __init gamecube_probe(void)
58{
Benjamin Herrenschmidt56571382016-07-05 15:04:05 +100059 if (!of_machine_is_compatible("nintendo,gamecube"))
Albert Herranze90d71d2009-12-12 06:31:42 +000060 return 0;
61
Alexander Graf9178ba22014-10-13 16:01:09 +020062 pm_power_off = gamecube_power_off;
63
Benjamin Herrenschmidtf2d57692016-07-05 15:04:06 +100064 ug_udbg_init();
65
Albert Herranze90d71d2009-12-12 06:31:42 +000066 return 1;
67}
68
69static void gamecube_shutdown(void)
70{
71 flipper_quiesce();
72}
73
Albert Herranze90d71d2009-12-12 06:31:42 +000074define_machine(gamecube) {
75 .name = "gamecube",
76 .probe = gamecube_probe,
Albert Herranze90d71d2009-12-12 06:31:42 +000077 .restart = gamecube_restart,
Albert Herranze90d71d2009-12-12 06:31:42 +000078 .halt = gamecube_halt,
79 .init_IRQ = flipper_pic_probe,
80 .get_irq = flipper_pic_get_irq,
81 .calibrate_decr = generic_calibrate_decr,
82 .progress = udbg_progress,
83 .machine_shutdown = gamecube_shutdown,
Albert Herranze90d71d2009-12-12 06:31:42 +000084};
85
86
Uwe Kleine-Königce6d73c2014-09-10 21:56:38 +020087static const struct of_device_id gamecube_of_bus[] = {
Albert Herranze90d71d2009-12-12 06:31:42 +000088 { .compatible = "nintendo,flipper", },
89 { },
90};
91
92static int __init gamecube_device_probe(void)
93{
94 if (!machine_is(gamecube))
95 return 0;
96
97 of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
98 return 0;
99}
100device_initcall(gamecube_device_probe);
101