gamecube.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. return 1;
  59. }
  60. static void gamecube_shutdown(void)
  61. {
  62. flipper_quiesce();
  63. }
  64. #ifdef CONFIG_KEXEC
  65. static int gamecube_kexec_prepare(struct kimage *image)
  66. {
  67. return 0;
  68. }
  69. #endif /* CONFIG_KEXEC */
  70. define_machine(gamecube) {
  71. .name = "gamecube",
  72. .probe = gamecube_probe,
  73. .init_early = gamecube_init_early,
  74. .restart = gamecube_restart,
  75. .power_off = gamecube_power_off,
  76. .halt = gamecube_halt,
  77. .init_IRQ = flipper_pic_probe,
  78. .get_irq = flipper_pic_get_irq,
  79. .calibrate_decr = generic_calibrate_decr,
  80. .progress = udbg_progress,
  81. .machine_shutdown = gamecube_shutdown,
  82. #ifdef CONFIG_KEXEC
  83. .machine_kexec_prepare = gamecube_kexec_prepare,
  84. #endif
  85. };
  86. static struct of_device_id gamecube_of_bus[] = {
  87. { .compatible = "nintendo,flipper", },
  88. { },
  89. };
  90. static int __init gamecube_device_probe(void)
  91. {
  92. if (!machine_is(gamecube))
  93. return 0;
  94. of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
  95. return 0;
  96. }
  97. device_initcall(gamecube_device_probe);