gamecube.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 gamecube_spin(void)
  28. {
  29. /* spin until power button pressed */
  30. for (;;)
  31. cpu_relax();
  32. }
  33. static void 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 gamecube_halt(void)
  45. {
  46. gamecube_restart(NULL);
  47. }
  48. static void __init gamecube_init_early(void)
  49. {
  50. ug_udbg_init();
  51. }
  52. static int __init gamecube_probe(void)
  53. {
  54. unsigned long dt_root;
  55. dt_root = of_get_flat_dt_root();
  56. if (!of_flat_dt_is_compatible(dt_root, "nintendo,gamecube"))
  57. return 0;
  58. pm_power_off = gamecube_power_off;
  59. return 1;
  60. }
  61. static void gamecube_shutdown(void)
  62. {
  63. flipper_quiesce();
  64. }
  65. define_machine(gamecube) {
  66. .name = "gamecube",
  67. .probe = gamecube_probe,
  68. .init_early = gamecube_init_early,
  69. .restart = gamecube_restart,
  70. .halt = gamecube_halt,
  71. .init_IRQ = flipper_pic_probe,
  72. .get_irq = flipper_pic_get_irq,
  73. .calibrate_decr = generic_calibrate_decr,
  74. .progress = udbg_progress,
  75. .machine_shutdown = gamecube_shutdown,
  76. };
  77. static const struct of_device_id gamecube_of_bus[] = {
  78. { .compatible = "nintendo,flipper", },
  79. { },
  80. };
  81. static int __init gamecube_device_probe(void)
  82. {
  83. if (!machine_is(gamecube))
  84. return 0;
  85. of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
  86. return 0;
  87. }
  88. device_initcall(gamecube_device_probe);