cpuidle-calxeda.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <linux/psci.h>
  28. #include <asm/cpuidle.h>
  29. #include <asm/suspend.h>
  30. #include <uapi/linux/psci.h>
  31. #define CALXEDA_IDLE_PARAM \
  32. ((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \
  33. (0 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \
  34. (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT))
  35. static int calxeda_idle_finish(unsigned long val)
  36. {
  37. return psci_ops.cpu_suspend(CALXEDA_IDLE_PARAM, __pa(cpu_resume));
  38. }
  39. static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
  40. struct cpuidle_driver *drv,
  41. int index)
  42. {
  43. cpu_pm_enter();
  44. cpu_suspend(0, calxeda_idle_finish);
  45. cpu_pm_exit();
  46. return index;
  47. }
  48. static struct cpuidle_driver calxeda_idle_driver = {
  49. .name = "calxeda_idle",
  50. .states = {
  51. ARM_CPUIDLE_WFI_STATE,
  52. {
  53. .name = "PG",
  54. .desc = "Power Gate",
  55. .exit_latency = 30,
  56. .power_usage = 50,
  57. .target_residency = 200,
  58. .enter = calxeda_pwrdown_idle,
  59. },
  60. },
  61. .state_count = 2,
  62. };
  63. static int calxeda_cpuidle_probe(struct platform_device *pdev)
  64. {
  65. return cpuidle_register(&calxeda_idle_driver, NULL);
  66. }
  67. static struct platform_driver calxeda_cpuidle_plat_driver = {
  68. .driver = {
  69. .name = "cpuidle-calxeda",
  70. },
  71. .probe = calxeda_cpuidle_probe,
  72. };
  73. builtin_platform_driver(calxeda_cpuidle_plat_driver);