reset.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <linux/sizes.h>
  12. #include <asm/idle.h>
  13. #include <asm/reboot.h>
  14. #include <loongson1.h>
  15. static void __iomem *wdt_reg_base;
  16. static void ls1x_halt(void)
  17. {
  18. while (1) {
  19. if (cpu_wait)
  20. cpu_wait();
  21. }
  22. }
  23. static void ls1x_restart(char *command)
  24. {
  25. __raw_writel(0x1, wdt_reg_base + WDT_EN);
  26. __raw_writel(0x1, wdt_reg_base + WDT_TIMER);
  27. __raw_writel(0x1, wdt_reg_base + WDT_SET);
  28. ls1x_halt();
  29. }
  30. static void ls1x_power_off(void)
  31. {
  32. ls1x_halt();
  33. }
  34. static int __init ls1x_reboot_setup(void)
  35. {
  36. wdt_reg_base = ioremap_nocache(LS1X_WDT_BASE, (SZ_4 + SZ_8));
  37. if (!wdt_reg_base)
  38. panic("Failed to remap watchdog registers");
  39. _machine_restart = ls1x_restart;
  40. _machine_halt = ls1x_halt;
  41. pm_power_off = ls1x_power_off;
  42. return 0;
  43. }
  44. arch_initcall(ls1x_reboot_setup);