cpuidle-tegra114.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/cpuidle.h>
  19. #include <linux/cpu_pm.h>
  20. #include <linux/clockchips.h>
  21. #include <asm/cpuidle.h>
  22. #include <asm/suspend.h>
  23. #include <asm/smp_plat.h>
  24. #include "pm.h"
  25. #include "sleep.h"
  26. #ifdef CONFIG_PM_SLEEP
  27. #define TEGRA114_MAX_STATES 2
  28. #else
  29. #define TEGRA114_MAX_STATES 1
  30. #endif
  31. #ifdef CONFIG_PM_SLEEP
  32. static int tegra114_idle_power_down(struct cpuidle_device *dev,
  33. struct cpuidle_driver *drv,
  34. int index)
  35. {
  36. local_fiq_disable();
  37. tegra_set_cpu_in_lp2();
  38. cpu_pm_enter();
  39. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu);
  40. cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
  41. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu);
  42. cpu_pm_exit();
  43. tegra_clear_cpu_in_lp2();
  44. local_fiq_enable();
  45. return index;
  46. }
  47. #endif
  48. static struct cpuidle_driver tegra_idle_driver = {
  49. .name = "tegra_idle",
  50. .owner = THIS_MODULE,
  51. .state_count = TEGRA114_MAX_STATES,
  52. .states = {
  53. [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
  54. #ifdef CONFIG_PM_SLEEP
  55. [1] = {
  56. .enter = tegra114_idle_power_down,
  57. .exit_latency = 500,
  58. .target_residency = 1000,
  59. .power_usage = 0,
  60. .flags = CPUIDLE_FLAG_TIME_VALID,
  61. .name = "powered-down",
  62. .desc = "CPU power gated",
  63. },
  64. #endif
  65. },
  66. };
  67. int __init tegra114_cpuidle_init(void)
  68. {
  69. return cpuidle_register(&tegra_idle_driver, NULL);
  70. }