reset.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the
  4. * Free Software Foundation; either version 2 of the License, or (at your
  5. * option) any later version.
  6. *
  7. * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
  8. * Author: Fuxin Zhang, zhangfx@lemote.com
  9. */
  10. #include <linux/init.h>
  11. #include <linux/pm.h>
  12. #include <asm/reboot.h>
  13. static void loongson2e_restart(char *command)
  14. {
  15. #ifdef CONFIG_32BIT
  16. *(unsigned long *)0xbfe00104 &= ~(1 << 2);
  17. *(unsigned long *)0xbfe00104 |= (1 << 2);
  18. #else
  19. *(unsigned long *)0xffffffffbfe00104 &= ~(1 << 2);
  20. *(unsigned long *)0xffffffffbfe00104 |= (1 << 2);
  21. #endif
  22. __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
  23. }
  24. static void loongson2e_halt(void)
  25. {
  26. while (1) ;
  27. }
  28. static void loongson2e_power_off(void)
  29. {
  30. loongson2e_halt();
  31. }
  32. static int __init mips_reboot_setup(void)
  33. {
  34. _machine_restart = loongson2e_restart;
  35. _machine_halt = loongson2e_halt;
  36. pm_power_off = loongson2e_power_off;
  37. return 0;
  38. }
  39. arch_initcall(mips_reboot_setup);