idle.c 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright 2008 IBM Corp.
  4. *
  5. * Based on arch/powerpc/platforms/pasemi/idle.c:
  6. * Copyright (C) 2006-2007 PA Semi, Inc
  7. *
  8. * Added by: Jerone Young <[email protected]>
  9. */
  10. #include <linux/of.h>
  11. #include <linux/kernel.h>
  12. #include <asm/machdep.h>
  13. static int mode_spin;
  14. static void ppc44x_idle(void)
  15. {
  16. unsigned long msr_save;
  17. msr_save = mfmsr();
  18. /* set wait state MSR */
  19. mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE);
  20. isync();
  21. /* return to initial state */
  22. mtmsr(msr_save);
  23. isync();
  24. }
  25. int __init ppc44x_idle_init(void)
  26. {
  27. if (!mode_spin) {
  28. /* If we are not setting spin mode
  29. then we set to wait mode */
  30. ppc_md.power_save = &ppc44x_idle;
  31. }
  32. return 0;
  33. }
  34. arch_initcall(ppc44x_idle_init);
  35. static int __init idle_param(char *p)
  36. {
  37. if (!strcmp("spin", p)) {
  38. mode_spin = 1;
  39. ppc_md.power_save = NULL;
  40. }
  41. return 0;
  42. }
  43. early_param("idle", idle_param);