reboot.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <linux/pm.h>
  2. #include <linux/kexec.h>
  3. #include <linux/kernel.h>
  4. #include <linux/reboot.h>
  5. #include <linux/module.h>
  6. #ifdef CONFIG_SUPERH32
  7. #include <asm/watchdog.h>
  8. #endif
  9. #include <asm/addrspace.h>
  10. #include <asm/reboot.h>
  11. #include <asm/tlbflush.h>
  12. #include <asm/traps.h>
  13. void (*pm_power_off)(void);
  14. EXPORT_SYMBOL(pm_power_off);
  15. #ifdef CONFIG_SUPERH32
  16. static void watchdog_trigger_immediate(void)
  17. {
  18. sh_wdt_write_cnt(0xFF);
  19. sh_wdt_write_csr(0xC2);
  20. }
  21. #endif
  22. static void native_machine_restart(char * __unused)
  23. {
  24. local_irq_disable();
  25. /* Destroy all of the TLBs in preparation for reset by MMU */
  26. __flush_tlb_global();
  27. /* Address error with SR.BL=1 first. */
  28. trigger_address_error();
  29. #ifdef CONFIG_SUPERH32
  30. /* If that fails or is unsupported, go for the watchdog next. */
  31. watchdog_trigger_immediate();
  32. #endif
  33. /*
  34. * Give up and sleep.
  35. */
  36. while (1)
  37. cpu_sleep();
  38. }
  39. static void native_machine_shutdown(void)
  40. {
  41. smp_send_stop();
  42. }
  43. static void native_machine_power_off(void)
  44. {
  45. if (pm_power_off)
  46. pm_power_off();
  47. }
  48. static void native_machine_halt(void)
  49. {
  50. /* stop other cpus */
  51. machine_shutdown();
  52. /* stop this cpu */
  53. stop_this_cpu(NULL);
  54. }
  55. struct machine_ops machine_ops = {
  56. .power_off = native_machine_power_off,
  57. .shutdown = native_machine_shutdown,
  58. .restart = native_machine_restart,
  59. .halt = native_machine_halt,
  60. #ifdef CONFIG_KEXEC
  61. .crash_shutdown = native_machine_crash_shutdown,
  62. #endif
  63. };
  64. void machine_power_off(void)
  65. {
  66. machine_ops.power_off();
  67. }
  68. void machine_shutdown(void)
  69. {
  70. machine_ops.shutdown();
  71. }
  72. void machine_restart(char *cmd)
  73. {
  74. machine_ops.restart(cmd);
  75. }
  76. void machine_halt(void)
  77. {
  78. machine_ops.halt();
  79. }
  80. #ifdef CONFIG_KEXEC
  81. void machine_crash_shutdown(struct pt_regs *regs)
  82. {
  83. machine_ops.crash_shutdown(regs);
  84. }
  85. #endif