cpuidle-imx6sl.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "common.h"
  12. #include "cpuidle.h"
  13. #include "hardware.h"
  14. static int imx6sl_enter_wait(struct cpuidle_device *dev,
  15. struct cpuidle_driver *drv, int index)
  16. {
  17. imx6_set_lpm(WAIT_UNCLOCKED);
  18. /*
  19. * Software workaround for ERR005311, see function
  20. * description for details.
  21. */
  22. if (cpu_is_imx6sl())
  23. imx6sl_set_wait_clk(true);
  24. cpu_do_idle();
  25. if (cpu_is_imx6sl())
  26. imx6sl_set_wait_clk(false);
  27. imx6_set_lpm(WAIT_CLOCKED);
  28. return index;
  29. }
  30. static struct cpuidle_driver imx6sl_cpuidle_driver = {
  31. .name = "imx6sl_cpuidle",
  32. .owner = THIS_MODULE,
  33. .states = {
  34. /* WFI */
  35. ARM_CPUIDLE_WFI_STATE,
  36. /* WAIT */
  37. {
  38. .exit_latency = 50,
  39. .target_residency = 75,
  40. .flags = CPUIDLE_FLAG_TIMER_STOP,
  41. .enter = imx6sl_enter_wait,
  42. .name = "WAIT",
  43. .desc = "Clock off",
  44. },
  45. },
  46. .state_count = 2,
  47. .safe_state_index = 0,
  48. };
  49. int __init imx6sl_cpuidle_init(void)
  50. {
  51. return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
  52. }