cpuidle-exynos.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* linux/arch/arm/mach-exynos/cpuidle.c
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/cpuidle.h>
  11. #include <linux/cpu_pm.h>
  12. #include <linux/export.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <asm/proc-fns.h>
  16. #include <asm/suspend.h>
  17. #include <asm/cpuidle.h>
  18. static void (*exynos_enter_aftr)(void);
  19. static int exynos_enter_lowpower(struct cpuidle_device *dev,
  20. struct cpuidle_driver *drv,
  21. int index)
  22. {
  23. int new_index = index;
  24. /* AFTR can only be entered when cores other than CPU0 are offline */
  25. if (num_online_cpus() > 1 || dev->cpu != 0)
  26. new_index = drv->safe_state_index;
  27. if (new_index == 0)
  28. return arm_cpuidle_simple_enter(dev, drv, new_index);
  29. exynos_enter_aftr();
  30. return new_index;
  31. }
  32. static struct cpuidle_driver exynos_idle_driver = {
  33. .name = "exynos_idle",
  34. .owner = THIS_MODULE,
  35. .states = {
  36. [0] = ARM_CPUIDLE_WFI_STATE,
  37. [1] = {
  38. .enter = exynos_enter_lowpower,
  39. .exit_latency = 300,
  40. .target_residency = 100000,
  41. .name = "C1",
  42. .desc = "ARM power down",
  43. },
  44. },
  45. .state_count = 2,
  46. .safe_state_index = 0,
  47. };
  48. static int exynos_cpuidle_probe(struct platform_device *pdev)
  49. {
  50. int ret;
  51. exynos_enter_aftr = (void *)(pdev->dev.platform_data);
  52. ret = cpuidle_register(&exynos_idle_driver, NULL);
  53. if (ret) {
  54. dev_err(&pdev->dev, "failed to register cpuidle driver\n");
  55. return ret;
  56. }
  57. return 0;
  58. }
  59. static struct platform_driver exynos_cpuidle_driver = {
  60. .probe = exynos_cpuidle_probe,
  61. .driver = {
  62. .name = "exynos_cpuidle",
  63. },
  64. };
  65. module_platform_driver(exynos_cpuidle_driver);