cpuidle-zynq.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2012-2013 Xilinx
  3. *
  4. * CPU idle support for Xilinx Zynq
  5. *
  6. * based on arch/arm/mach-at91/cpuidle.c
  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. * The cpu idle uses wait-for-interrupt and RAM self refresh in order
  21. * to implement two idle states -
  22. * #1 wait-for-interrupt
  23. * #2 wait-for-interrupt and RAM self refresh
  24. *
  25. * Maintainer: Michal Simek <michal.simek@xilinx.com>
  26. */
  27. #include <linux/init.h>
  28. #include <linux/cpuidle.h>
  29. #include <linux/platform_device.h>
  30. #include <asm/cpuidle.h>
  31. #define ZYNQ_MAX_STATES 2
  32. /* Actual code that puts the SoC in different idle states */
  33. static int zynq_enter_idle(struct cpuidle_device *dev,
  34. struct cpuidle_driver *drv, int index)
  35. {
  36. /* Add code for DDR self refresh start */
  37. cpu_do_idle();
  38. return index;
  39. }
  40. static struct cpuidle_driver zynq_idle_driver = {
  41. .name = "zynq_idle",
  42. .owner = THIS_MODULE,
  43. .states = {
  44. ARM_CPUIDLE_WFI_STATE,
  45. {
  46. .enter = zynq_enter_idle,
  47. .exit_latency = 10,
  48. .target_residency = 10000,
  49. .name = "RAM_SR",
  50. .desc = "WFI and RAM Self Refresh",
  51. },
  52. },
  53. .safe_state_index = 0,
  54. .state_count = ZYNQ_MAX_STATES,
  55. };
  56. /* Initialize CPU idle by registering the idle states */
  57. static int zynq_cpuidle_probe(struct platform_device *pdev)
  58. {
  59. pr_info("Xilinx Zynq CpuIdle Driver started\n");
  60. return cpuidle_register(&zynq_idle_driver, NULL);
  61. }
  62. static struct platform_driver zynq_cpuidle_driver = {
  63. .driver = {
  64. .name = "cpuidle-zynq",
  65. },
  66. .probe = zynq_cpuidle_probe,
  67. };
  68. builtin_platform_driver(zynq_cpuidle_driver);