cpuidle.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/acpi.h>
  12. #include <linux/cpuidle.h>
  13. #include <linux/cpu_pm.h>
  14. #include <linux/of.h>
  15. #include <linux/of_device.h>
  16. #include <asm/cpuidle.h>
  17. #include <asm/cpu_ops.h>
  18. int arm_cpuidle_init(unsigned int cpu)
  19. {
  20. int ret = -EOPNOTSUPP;
  21. if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend &&
  22. cpu_ops[cpu]->cpu_init_idle)
  23. ret = cpu_ops[cpu]->cpu_init_idle(cpu);
  24. return ret;
  25. }
  26. /**
  27. * cpu_suspend() - function to enter a low-power idle state
  28. * @arg: argument to pass to CPU suspend operations
  29. *
  30. * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU
  31. * operations back-end error code otherwise.
  32. */
  33. int arm_cpuidle_suspend(int index)
  34. {
  35. int cpu = smp_processor_id();
  36. return cpu_ops[cpu]->cpu_suspend(index);
  37. }
  38. #ifdef CONFIG_ACPI
  39. #include <acpi/processor.h>
  40. int acpi_processor_ffh_lpi_probe(unsigned int cpu)
  41. {
  42. return arm_cpuidle_init(cpu);
  43. }
  44. int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
  45. {
  46. return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
  47. }
  48. #endif