reset.c 973 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Joshua Henderson <[email protected]>
  4. * Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
  5. */
  6. #include <linux/init.h>
  7. #include <linux/pm.h>
  8. #include <asm/reboot.h>
  9. #include <asm/mach-pic32/pic32.h>
  10. #define PIC32_RSWRST 0x10
  11. static void pic32_halt(void)
  12. {
  13. while (1) {
  14. __asm__(".set push;\n"
  15. ".set arch=r4000;\n"
  16. "wait;\n"
  17. ".set pop;\n"
  18. );
  19. }
  20. }
  21. static void pic32_machine_restart(char *command)
  22. {
  23. void __iomem *reg =
  24. ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32));
  25. pic32_syskey_unlock();
  26. /* magic write/read */
  27. __raw_writel(1, reg);
  28. (void)__raw_readl(reg);
  29. pic32_halt();
  30. }
  31. static void pic32_machine_halt(void)
  32. {
  33. local_irq_disable();
  34. pic32_halt();
  35. }
  36. static int __init mips_reboot_setup(void)
  37. {
  38. _machine_restart = pic32_machine_restart;
  39. _machine_halt = pic32_machine_halt;
  40. pm_power_off = pic32_machine_halt;
  41. return 0;
  42. }
  43. arch_initcall(mips_reboot_setup);