cpuidle.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * ARM64 CPU idle arch support
  3. *
  4. * Copyright (C) 2014 ARM Ltd.
  5. * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/of.h>
  12. #include <linux/of_device.h>
  13. #include <asm/cpuidle.h>
  14. #include <asm/cpu_ops.h>
  15. int __init arm_cpuidle_init(unsigned int cpu)
  16. {
  17. int ret = -EOPNOTSUPP;
  18. if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_init_idle)
  19. ret = cpu_ops[cpu]->cpu_init_idle(cpu);
  20. return ret;
  21. }
  22. /**
  23. * cpu_suspend() - function to enter a low-power idle state
  24. * @arg: argument to pass to CPU suspend operations
  25. *
  26. * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU
  27. * operations back-end error code otherwise.
  28. */
  29. int arm_cpuidle_suspend(int index)
  30. {
  31. int cpu = smp_processor_id();
  32. /*
  33. * If cpu_ops have not been registered or suspend
  34. * has not been initialized, cpu_suspend call fails early.
  35. */
  36. if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_suspend)
  37. return -EOPNOTSUPP;
  38. return cpu_ops[cpu]->cpu_suspend(index);
  39. }