/arch/mips/loongson/common/reset.c

http://github.com/mirrors/linux · C · 71 lines · 46 code · 12 blank · 13 comment · 2 complexity · 8fb8a26f58043d9c36d49c294cd18863 MD5 · raw file

  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. * Copyright (C) 2009 Lemote, Inc.
  10. * Author: Zhangjin Wu, wuzhangjin@gmail.com
  11. */
  12. #include <linux/init.h>
  13. #include <linux/pm.h>
  14. #include <asm/idle.h>
  15. #include <asm/reboot.h>
  16. #include <loongson.h>
  17. static inline void loongson_reboot(void)
  18. {
  19. #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
  20. ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
  21. #else
  22. void (*func)(void);
  23. func = (void *)ioremap_nocache(LOONGSON_BOOT_BASE, 4);
  24. __asm__ __volatile__(
  25. " .set noat \n"
  26. " jr %[func] \n"
  27. " .set at \n"
  28. : /* No outputs */
  29. : [func] "r" (func));
  30. #endif
  31. }
  32. static void loongson_restart(char *command)
  33. {
  34. /* do preparation for reboot */
  35. mach_prepare_reboot();
  36. /* reboot via jumping to boot base address */
  37. loongson_reboot();
  38. }
  39. static void loongson_poweroff(void)
  40. {
  41. mach_prepare_shutdown();
  42. unreachable();
  43. }
  44. static void loongson_halt(void)
  45. {
  46. pr_notice("\n\n** You can safely turn off the power now **\n\n");
  47. while (1) {
  48. if (cpu_wait)
  49. cpu_wait();
  50. }
  51. }
  52. static int __init mips_reboot_setup(void)
  53. {
  54. _machine_restart = loongson_restart;
  55. _machine_halt = loongson_halt;
  56. pm_power_off = loongson_poweroff;
  57. return 0;
  58. }
  59. arch_initcall(mips_reboot_setup);