cpuidle-calxeda.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2012 Calxeda, Inc.
  3. *
  4. * Based on arch/arm/plat-mxc/cpuidle.c: #v3.7
  5. * Copyright 2012 Freescale Semiconductor, Inc.
  6. * Copyright 2012 Linaro Ltd.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Maintainer: Rob Herring <rob.herring@calxeda.com>
  21. */
  22. #include <linux/cpuidle.h>
  23. #include <linux/cpu_pm.h>
  24. #include <linux/init.h>
  25. #include <linux/mm.h>
  26. #include <linux/platform_device.h>
  27. #include <asm/cpuidle.h>
  28. #include <asm/suspend.h>
  29. #include <asm/psci.h>
  30. static int calxeda_idle_finish(unsigned long val)
  31. {
  32. const struct psci_power_state ps = {
  33. .type = PSCI_POWER_STATE_TYPE_POWER_DOWN,
  34. };
  35. return psci_ops.cpu_suspend(ps, __pa(cpu_resume));
  36. }
  37. static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
  38. struct cpuidle_driver *drv,
  39. int index)
  40. {
  41. cpu_pm_enter();
  42. cpu_suspend(0, calxeda_idle_finish);
  43. cpu_pm_exit();
  44. return index;
  45. }
  46. static struct cpuidle_driver calxeda_idle_driver = {
  47. .name = "calxeda_idle",
  48. .states = {
  49. ARM_CPUIDLE_WFI_STATE,
  50. {
  51. .name = "PG",
  52. .desc = "Power Gate",
  53. .exit_latency = 30,
  54. .power_usage = 50,
  55. .target_residency = 200,
  56. .enter = calxeda_pwrdown_idle,
  57. },
  58. },
  59. .state_count = 2,
  60. };
  61. static int calxeda_cpuidle_probe(struct platform_device *pdev)
  62. {
  63. return cpuidle_register(&calxeda_idle_driver, NULL);
  64. }
  65. static struct platform_driver calxeda_cpuidle_plat_driver = {
  66. .driver = {
  67. .name = "cpuidle-calxeda",
  68. },
  69. .probe = calxeda_cpuidle_probe,
  70. };
  71. builtin_platform_driver(calxeda_cpuidle_plat_driver);