reboot.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * arch/blackfin/kernel/reboot.c - handle shutdown/reboot
  3. *
  4. * Copyright 2004-2007 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/interrupt.h>
  9. #include <asm/bfin-global.h>
  10. #include <asm/reboot.h>
  11. #include <asm/system.h>
  12. #if defined(BF537_FAMILY) || defined(BF533_FAMILY) || defined(BF527_FAMILY)
  13. #define SYSCR_VAL 0x0
  14. #elif defined(BF561_FAMILY)
  15. #define SYSCR_VAL 0x20
  16. #elif defined(BF548_FAMILY)
  17. #define SYSCR_VAL 0x10
  18. #endif
  19. /* A system soft reset makes external memory unusable
  20. * so force this function into L1.
  21. */
  22. __attribute__((l1_text))
  23. void bfin_reset(void)
  24. {
  25. /* force BMODE and disable Core B (as needed) */
  26. bfin_write_SYSCR(SYSCR_VAL);
  27. /* we use asm ssync here because it's save and we save some L1 */
  28. asm("ssync;");
  29. while (1) {
  30. /* initiate system soft reset with magic 0x7 */
  31. bfin_write_SWRST(0x7);
  32. bfin_read_SWRST();
  33. asm("ssync;");
  34. /* clear system soft reset */
  35. bfin_write_SWRST(0);
  36. bfin_read_SWRST();
  37. asm("ssync;");
  38. /* issue core reset */
  39. asm("raise 1");
  40. }
  41. }
  42. __attribute__((weak))
  43. void native_machine_restart(char *cmd)
  44. {
  45. }
  46. void machine_restart(char *cmd)
  47. {
  48. native_machine_restart(cmd);
  49. local_irq_disable();
  50. bfin_reset();
  51. }
  52. __attribute__((weak))
  53. void native_machine_halt(void)
  54. {
  55. idle_with_irq_disabled();
  56. }
  57. void machine_halt(void)
  58. {
  59. native_machine_halt();
  60. }
  61. __attribute__((weak))
  62. void native_machine_power_off(void)
  63. {
  64. idle_with_irq_disabled();
  65. }
  66. void machine_power_off(void)
  67. {
  68. native_machine_power_off();
  69. }