reboot.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/system.h>
  12. void (*pm_power_off)(void);
  13. EXPORT_SYMBOL(pm_power_off);
  14. #ifdef CONFIG_SUPERH32
  15. static void watchdog_trigger_immediate(void)
  16. {
  17. sh_wdt_write_cnt(0xFF);
  18. sh_wdt_write_csr(0xC2);
  19. }
  20. #endif
  21. static void native_machine_restart(char * __unused)
  22. {
  23. local_irq_disable();
  24. /* Address error with SR.BL=1 first. */
  25. trigger_address_error();
  26. #ifdef CONFIG_SUPERH32
  27. /* If that fails or is unsupported, go for the watchdog next. */
  28. watchdog_trigger_immediate();
  29. #endif
  30. /*
  31. * Give up and sleep.
  32. */
  33. while (1)
  34. cpu_sleep();
  35. }
  36. static void native_machine_shutdown(void)
  37. {
  38. smp_send_stop();
  39. }
  40. static void native_machine_power_off(void)
  41. {
  42. if (pm_power_off)
  43. pm_power_off();
  44. }
  45. static void native_machine_halt(void)
  46. {
  47. /* stop other cpus */
  48. machine_shutdown();
  49. /* stop this cpu */
  50. stop_this_cpu(NULL);
  51. }
  52. struct machine_ops machine_ops = {
  53. .power_off = native_machine_power_off,
  54. .shutdown = native_machine_shutdown,
  55. .restart = native_machine_restart,
  56. .halt = native_machine_halt,
  57. #ifdef CONFIG_KEXEC
  58. .crash_shutdown = native_machine_crash_shutdown,
  59. #endif
  60. };
  61. void machine_power_off(void)
  62. {
  63. machine_ops.power_off();
  64. }
  65. void machine_shutdown(void)
  66. {
  67. machine_ops.shutdown();
  68. }
  69. void machine_restart(char *cmd)
  70. {
  71. machine_ops.restart(cmd);
  72. }
  73. void machine_halt(void)
  74. {
  75. machine_ops.halt();
  76. }
  77. #ifdef CONFIG_KEXEC
  78. void machine_crash_shutdown(struct pt_regs *regs)
  79. {
  80. machine_ops.crash_shutdown(regs);
  81. }
  82. #endif