reset.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2012 Thomas Langer <thomas.langer@lantiq.com>
  7. * Copyright (C) 2012 John Crispin <john@phrozen.org>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/io.h>
  11. #include <linux/pm.h>
  12. #include <asm/reboot.h>
  13. #include <linux/export.h>
  14. #include <lantiq_soc.h>
  15. /*
  16. * Dummy implementation. Used to allow platform code to find out what
  17. * source was booted from
  18. */
  19. unsigned char ltq_boot_select(void)
  20. {
  21. return BS_SPI;
  22. }
  23. #define BOOT_REG_BASE (KSEG1 | 0x1F200000)
  24. #define BOOT_PW1_REG (BOOT_REG_BASE | 0x20)
  25. #define BOOT_PW2_REG (BOOT_REG_BASE | 0x24)
  26. #define BOOT_PW1 0x4C545100
  27. #define BOOT_PW2 0x0051544C
  28. #define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
  29. #define WDT_PW1 0x00BE0000
  30. #define WDT_PW2 0x00DC0000
  31. static void machine_restart(char *command)
  32. {
  33. local_irq_disable();
  34. /* reboot magic */
  35. ltq_w32(BOOT_PW1, (void *)BOOT_PW1_REG); /* 'LTQ\0' */
  36. ltq_w32(BOOT_PW2, (void *)BOOT_PW2_REG); /* '\0QTL' */
  37. ltq_w32(0, (void *)BOOT_REG_BASE); /* reset Bootreg RVEC */
  38. /* watchdog magic */
  39. ltq_w32(WDT_PW1, (void *)WDT_REG_BASE);
  40. ltq_w32(WDT_PW2 |
  41. (0x3 << 26) | /* PWL */
  42. (0x2 << 24) | /* CLKDIV */
  43. (0x1 << 31) | /* enable */
  44. (1), /* reload */
  45. (void *)WDT_REG_BASE);
  46. unreachable();
  47. }
  48. static void machine_halt(void)
  49. {
  50. local_irq_disable();
  51. unreachable();
  52. }
  53. static void machine_power_off(void)
  54. {
  55. local_irq_disable();
  56. unreachable();
  57. }
  58. static int __init mips_reboot_setup(void)
  59. {
  60. _machine_restart = machine_restart;
  61. _machine_halt = machine_halt;
  62. pm_power_off = machine_power_off;
  63. return 0;
  64. }
  65. arch_initcall(mips_reboot_setup);