reboot.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /*
  20. * Delay min 5 SCLK cycles using worst case CCLK/SCLK ratio (15)
  21. */
  22. #define SWRST_DELAY (5 * 15)
  23. /* A system soft reset makes external memory unusable
  24. * so force this function into L1.
  25. */
  26. __attribute__((l1_text))
  27. void bfin_reset(void)
  28. {
  29. /* force BMODE and disable Core B (as needed) */
  30. bfin_write_SYSCR(SYSCR_VAL);
  31. /* we use asm ssync here because it's save and we save some L1 */
  32. asm("ssync;");
  33. while (1) {
  34. /* initiate system soft reset with magic 0x7 */
  35. bfin_write_SWRST(0x7);
  36. /* Wait for System reset to actually reset, needs to be 5 SCLKs, */
  37. /* Assume CCLK / SCLK ratio is worst case (15), and use 5*15 */
  38. asm("LSETUP(.Lfoo,.Lfoo) LC0 = %0\n .Lfoo: NOP;\n"
  39. : : "a" (SWRST_DELAY) : "LC0", "LT0", "LB0");
  40. /* clear system soft reset */
  41. bfin_write_SWRST(0);
  42. asm("ssync;");
  43. /* issue core reset */
  44. asm("raise 1");
  45. }
  46. }
  47. __attribute__((weak))
  48. void native_machine_restart(char *cmd)
  49. {
  50. }
  51. void machine_restart(char *cmd)
  52. {
  53. native_machine_restart(cmd);
  54. local_irq_disable();
  55. bfin_reset();
  56. }
  57. __attribute__((weak))
  58. void native_machine_halt(void)
  59. {
  60. idle_with_irq_disabled();
  61. }
  62. void machine_halt(void)
  63. {
  64. native_machine_halt();
  65. }
  66. __attribute__((weak))
  67. void native_machine_power_off(void)
  68. {
  69. idle_with_irq_disabled();
  70. }
  71. void machine_power_off(void)
  72. {
  73. native_machine_power_off();
  74. }