cpuidle-imx6sl.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2014 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/cpuidle.h>
  9. #include <linux/module.h>
  10. #include <asm/cpuidle.h>
  11. #include <asm/proc-fns.h>
  12. #include "common.h"
  13. #include "cpuidle.h"
  14. static int imx6sl_enter_wait(struct cpuidle_device *dev,
  15. struct cpuidle_driver *drv, int index)
  16. {
  17. imx6q_set_lpm(WAIT_UNCLOCKED);
  18. /*
  19. * Software workaround for ERR005311, see function
  20. * description for details.
  21. */
  22. imx6sl_set_wait_clk(true);
  23. cpu_do_idle();
  24. imx6sl_set_wait_clk(false);
  25. imx6q_set_lpm(WAIT_CLOCKED);
  26. return index;
  27. }
  28. static struct cpuidle_driver imx6sl_cpuidle_driver = {
  29. .name = "imx6sl_cpuidle",
  30. .owner = THIS_MODULE,
  31. .states = {
  32. /* WFI */
  33. ARM_CPUIDLE_WFI_STATE,
  34. /* WAIT */
  35. {
  36. .exit_latency = 50,
  37. .target_residency = 75,
  38. .flags = CPUIDLE_FLAG_TIME_VALID |
  39. CPUIDLE_FLAG_TIMER_STOP,
  40. .enter = imx6sl_enter_wait,
  41. .name = "WAIT",
  42. .desc = "Clock off",
  43. },
  44. },
  45. .state_count = 2,
  46. .safe_state_index = 0,
  47. };
  48. int __init imx6sl_cpuidle_init(void)
  49. {
  50. return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
  51. }