reset.c 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/reboot.h>
  12. #include <loongson1.h>
  13. static void ls1x_restart(char *command)
  14. {
  15. __raw_writel(0x1, LS1X_WDT_EN);
  16. __raw_writel(0x5000000, LS1X_WDT_TIMER);
  17. __raw_writel(0x1, LS1X_WDT_SET);
  18. }
  19. static void ls1x_halt(void)
  20. {
  21. while (1) {
  22. if (cpu_wait)
  23. cpu_wait();
  24. }
  25. }
  26. static void ls1x_power_off(void)
  27. {
  28. ls1x_halt();
  29. }
  30. static int __init ls1x_reboot_setup(void)
  31. {
  32. _machine_restart = ls1x_restart;
  33. _machine_halt = ls1x_halt;
  34. pm_power_off = ls1x_power_off;
  35. return 0;
  36. }
  37. arch_initcall(ls1x_reboot_setup);