reset.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #include <linux/io.h>
  10. #include <linux/pm.h>
  11. #include <asm/idle.h>
  12. #include <asm/reboot.h>
  13. #include <loongson1.h>
  14. static void __iomem *wdt_base;
  15. static void ls1x_halt(void)
  16. {
  17. while (1) {
  18. if (cpu_wait)
  19. cpu_wait();
  20. }
  21. }
  22. static void ls1x_restart(char *command)
  23. {
  24. __raw_writel(0x1, wdt_base + WDT_EN);
  25. __raw_writel(0x1, wdt_base + WDT_TIMER);
  26. __raw_writel(0x1, wdt_base + WDT_SET);
  27. ls1x_halt();
  28. }
  29. static void ls1x_power_off(void)
  30. {
  31. ls1x_halt();
  32. }
  33. static int __init ls1x_reboot_setup(void)
  34. {
  35. wdt_base = ioremap_nocache(LS1X_WDT_BASE, 0x0f);
  36. if (!wdt_base)
  37. panic("Failed to remap watchdog registers");
  38. _machine_restart = ls1x_restart;
  39. _machine_halt = ls1x_halt;
  40. pm_power_off = ls1x_power_off;
  41. return 0;
  42. }
  43. arch_initcall(ls1x_reboot_setup);