gamecube.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  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. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/irq.h>
  17. #include <linux/kexec.h>
  18. #include <linux/seq_file.h>
  19. #include <linux/of_platform.h>
  20. #include <asm/io.h>
  21. #include <asm/machdep.h>
  22. #include <asm/prom.h>
  23. #include <asm/time.h>
  24. #include <asm/udbg.h>
  25. #include "flipper-pic.h"
  26. #include "usbgecko_udbg.h"
  27. static void __noreturn gamecube_spin(void)
  28. {
  29. /* spin until power button pressed */
  30. for (;;)
  31. cpu_relax();
  32. }
  33. static void __noreturn gamecube_restart(char *cmd)
  34. {
  35. local_irq_disable();
  36. flipper_platform_reset();
  37. gamecube_spin();
  38. }
  39. static void gamecube_power_off(void)
  40. {
  41. local_irq_disable();
  42. gamecube_spin();
  43. }
  44. static void __noreturn gamecube_halt(void)
  45. {
  46. gamecube_restart(NULL);
  47. }
  48. static int __init gamecube_probe(void)
  49. {
  50. if (!of_machine_is_compatible("nintendo,gamecube"))
  51. return 0;
  52. pm_power_off = gamecube_power_off;
  53. ug_udbg_init();
  54. return 1;
  55. }
  56. static void gamecube_shutdown(void)
  57. {
  58. flipper_quiesce();
  59. }
  60. define_machine(gamecube) {
  61. .name = "gamecube",
  62. .probe = gamecube_probe,
  63. .restart = gamecube_restart,
  64. .halt = gamecube_halt,
  65. .init_IRQ = flipper_pic_probe,
  66. .get_irq = flipper_pic_get_irq,
  67. .calibrate_decr = generic_calibrate_decr,
  68. .progress = udbg_progress,
  69. .machine_shutdown = gamecube_shutdown,
  70. };
  71. static const struct of_device_id gamecube_of_bus[] = {
  72. { .compatible = "nintendo,flipper", },
  73. { },
  74. };
  75. static int __init gamecube_device_probe(void)
  76. {
  77. if (!machine_is(gamecube))
  78. return 0;
  79. of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
  80. return 0;
  81. }
  82. device_initcall(gamecube_device_probe);