Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * arch/powerpc/platforms/embedded6xx/gamecube.c
0004  *
0005  * Nintendo GameCube board-specific support
0006  * Copyright (C) 2004-2009 The GameCube Linux Team
0007  * Copyright (C) 2007,2008,2009 Albert Herranz
0008  */
0009 
0010 #include <linux/kernel.h>
0011 #include <linux/init.h>
0012 #include <linux/irq.h>
0013 #include <linux/kexec.h>
0014 #include <linux/seq_file.h>
0015 #include <linux/of_platform.h>
0016 
0017 #include <asm/io.h>
0018 #include <asm/machdep.h>
0019 #include <asm/time.h>
0020 #include <asm/udbg.h>
0021 
0022 #include "flipper-pic.h"
0023 #include "usbgecko_udbg.h"
0024 
0025 
0026 static void __noreturn gamecube_spin(void)
0027 {
0028     /* spin until power button pressed */
0029     for (;;)
0030         cpu_relax();
0031 }
0032 
0033 static void __noreturn gamecube_restart(char *cmd)
0034 {
0035     local_irq_disable();
0036     flipper_platform_reset();
0037     gamecube_spin();
0038 }
0039 
0040 static void gamecube_power_off(void)
0041 {
0042     local_irq_disable();
0043     gamecube_spin();
0044 }
0045 
0046 static void __noreturn gamecube_halt(void)
0047 {
0048     gamecube_restart(NULL);
0049 }
0050 
0051 static int __init gamecube_probe(void)
0052 {
0053     if (!of_machine_is_compatible("nintendo,gamecube"))
0054         return 0;
0055 
0056     pm_power_off = gamecube_power_off;
0057 
0058     ug_udbg_init();
0059 
0060     return 1;
0061 }
0062 
0063 static void gamecube_shutdown(void)
0064 {
0065     flipper_quiesce();
0066 }
0067 
0068 define_machine(gamecube) {
0069     .name           = "gamecube",
0070     .probe          = gamecube_probe,
0071     .restart        = gamecube_restart,
0072     .halt           = gamecube_halt,
0073     .init_IRQ       = flipper_pic_probe,
0074     .get_irq        = flipper_pic_get_irq,
0075     .calibrate_decr     = generic_calibrate_decr,
0076     .progress       = udbg_progress,
0077     .machine_shutdown   = gamecube_shutdown,
0078 };
0079 
0080 
0081 static const struct of_device_id gamecube_of_bus[] = {
0082     { .compatible = "nintendo,flipper", },
0083     { },
0084 };
0085 
0086 static int __init gamecube_device_probe(void)
0087 {
0088     if (!machine_is(gamecube))
0089         return 0;
0090 
0091     of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
0092     return 0;
0093 }
0094 device_initcall(gamecube_device_probe);
0095