reset.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Joshua Henderson <joshua.henderson@microchip.com>
  3. * Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
  4. *
  5. * This program is free software; you can distribute it and/or modify it
  6. * under the terms of the GNU General Public License (Version 2) as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/pm.h>
  16. #include <asm/reboot.h>
  17. #include <asm/mach-pic32/pic32.h>
  18. #define PIC32_RSWRST 0x10
  19. static void pic32_halt(void)
  20. {
  21. while (1) {
  22. __asm__(".set push;\n"
  23. ".set arch=r4000;\n"
  24. "wait;\n"
  25. ".set pop;\n"
  26. );
  27. }
  28. }
  29. static void pic32_machine_restart(char *command)
  30. {
  31. void __iomem *reg =
  32. ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32));
  33. pic32_syskey_unlock();
  34. /* magic write/read */
  35. __raw_writel(1, reg);
  36. (void)__raw_readl(reg);
  37. pic32_halt();
  38. }
  39. static void pic32_machine_halt(void)
  40. {
  41. local_irq_disable();
  42. pic32_halt();
  43. }
  44. static int __init mips_reboot_setup(void)
  45. {
  46. _machine_restart = pic32_machine_restart;
  47. _machine_halt = pic32_machine_halt;
  48. pm_power_off = pic32_machine_halt;
  49. return 0;
  50. }
  51. arch_initcall(mips_reboot_setup);