cpuidle-kirkwood.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * CPU idle Marvell Kirkwood SoCs
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. *
  8. * The cpu idle uses wait-for-interrupt and DDR self refresh in order
  9. * to implement two idle states -
  10. * #1 wait-for-interrupt
  11. * #2 wait-for-interrupt and DDR self refresh
  12. *
  13. * Maintainer: Jason Cooper <jason@lakedaemon.net>
  14. * Maintainer: Andrew Lunn <andrew@lunn.ch>
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/cpuidle.h>
  21. #include <linux/io.h>
  22. #include <linux/export.h>
  23. #include <asm/cpuidle.h>
  24. #define KIRKWOOD_MAX_STATES 2
  25. static void __iomem *ddr_operation_base;
  26. /* Actual code that puts the SoC in different idle states */
  27. static int kirkwood_enter_idle(struct cpuidle_device *dev,
  28. struct cpuidle_driver *drv,
  29. int index)
  30. {
  31. writel(0x7, ddr_operation_base);
  32. cpu_do_idle();
  33. return index;
  34. }
  35. static struct cpuidle_driver kirkwood_idle_driver = {
  36. .name = "kirkwood_idle",
  37. .owner = THIS_MODULE,
  38. .states[0] = ARM_CPUIDLE_WFI_STATE,
  39. .states[1] = {
  40. .enter = kirkwood_enter_idle,
  41. .exit_latency = 10,
  42. .target_residency = 100000,
  43. .name = "DDR SR",
  44. .desc = "WFI and DDR Self Refresh",
  45. },
  46. .state_count = KIRKWOOD_MAX_STATES,
  47. };
  48. /* Initialize CPU idle by registering the idle states */
  49. static int kirkwood_cpuidle_probe(struct platform_device *pdev)
  50. {
  51. ddr_operation_base = devm_platform_ioremap_resource(pdev, 0);
  52. if (IS_ERR(ddr_operation_base))
  53. return PTR_ERR(ddr_operation_base);
  54. return cpuidle_register(&kirkwood_idle_driver, NULL);
  55. }
  56. static int kirkwood_cpuidle_remove(struct platform_device *pdev)
  57. {
  58. cpuidle_unregister(&kirkwood_idle_driver);
  59. return 0;
  60. }
  61. static struct platform_driver kirkwood_cpuidle_driver = {
  62. .probe = kirkwood_cpuidle_probe,
  63. .remove = kirkwood_cpuidle_remove,
  64. .driver = {
  65. .name = "kirkwood_cpuidle",
  66. },
  67. };
  68. module_platform_driver(kirkwood_cpuidle_driver);
  69. MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
  70. MODULE_DESCRIPTION("Kirkwood cpu idle driver");
  71. MODULE_LICENSE("GPL v2");
  72. MODULE_ALIAS("platform:kirkwood-cpuidle");