reset.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2012 Thomas Langer <[email protected]>
  5. * Copyright (C) 2012 John Crispin <[email protected]>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/io.h>
  9. #include <linux/pm.h>
  10. #include <asm/reboot.h>
  11. #include <linux/export.h>
  12. #include <lantiq_soc.h>
  13. /*
  14. * Dummy implementation. Used to allow platform code to find out what
  15. * source was booted from
  16. */
  17. unsigned char ltq_boot_select(void)
  18. {
  19. return BS_SPI;
  20. }
  21. #define BOOT_REG_BASE (KSEG1 | 0x1F200000)
  22. #define BOOT_PW1_REG (BOOT_REG_BASE | 0x20)
  23. #define BOOT_PW2_REG (BOOT_REG_BASE | 0x24)
  24. #define BOOT_PW1 0x4C545100
  25. #define BOOT_PW2 0x0051544C
  26. #define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
  27. #define WDT_PW1 0x00BE0000
  28. #define WDT_PW2 0x00DC0000
  29. static void machine_restart(char *command)
  30. {
  31. local_irq_disable();
  32. /* reboot magic */
  33. ltq_w32(BOOT_PW1, (void *)BOOT_PW1_REG); /* 'LTQ\0' */
  34. ltq_w32(BOOT_PW2, (void *)BOOT_PW2_REG); /* '\0QTL' */
  35. ltq_w32(0, (void *)BOOT_REG_BASE); /* reset Bootreg RVEC */
  36. /* watchdog magic */
  37. ltq_w32(WDT_PW1, (void *)WDT_REG_BASE);
  38. ltq_w32(WDT_PW2 |
  39. (0x3 << 26) | /* PWL */
  40. (0x2 << 24) | /* CLKDIV */
  41. (0x1 << 31) | /* enable */
  42. (1), /* reload */
  43. (void *)WDT_REG_BASE);
  44. unreachable();
  45. }
  46. static void machine_halt(void)
  47. {
  48. local_irq_disable();
  49. unreachable();
  50. }
  51. static void machine_power_off(void)
  52. {
  53. local_irq_disable();
  54. unreachable();
  55. }
  56. static int __init mips_reboot_setup(void)
  57. {
  58. _machine_restart = machine_restart;
  59. _machine_halt = machine_halt;
  60. pm_power_off = machine_power_off;
  61. return 0;
  62. }
  63. arch_initcall(mips_reboot_setup);