cpuidle-tegra20.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * CPU idle driver for Tegra CPUs
  3. *
  4. * Copyright (c) 2010-2012, NVIDIA Corporation.
  5. * Copyright (c) 2011 Google, Inc.
  6. * Author: Colin Cross <ccross@android.com>
  7. * Gary King <gking@nvidia.com>
  8. *
  9. * Rework for 3.3 by Peter De Schrijver <pdeschrijver@nvidia.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful, but WITHOUT
  17. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  18. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  19. * more details.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/cpuidle.h>
  24. #include <asm/cpuidle.h>
  25. static struct cpuidle_driver tegra_idle_driver = {
  26. .name = "tegra_idle",
  27. .owner = THIS_MODULE,
  28. .en_core_tk_irqen = 1,
  29. .state_count = 1,
  30. .states = {
  31. [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
  32. },
  33. };
  34. static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
  35. int __init tegra20_cpuidle_init(void)
  36. {
  37. int ret;
  38. unsigned int cpu;
  39. struct cpuidle_device *dev;
  40. struct cpuidle_driver *drv = &tegra_idle_driver;
  41. ret = cpuidle_register_driver(&tegra_idle_driver);
  42. if (ret) {
  43. pr_err("CPUidle driver registration failed\n");
  44. return ret;
  45. }
  46. for_each_possible_cpu(cpu) {
  47. dev = &per_cpu(tegra_idle_device, cpu);
  48. dev->cpu = cpu;
  49. dev->state_count = drv->state_count;
  50. ret = cpuidle_register_device(dev);
  51. if (ret) {
  52. pr_err("CPU%u: CPUidle device registration failed\n",
  53. cpu);
  54. return ret;
  55. }
  56. }
  57. return 0;
  58. }