cpuidle-imx6sl.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2014 Freescale Semiconductor, Inc.
  4. */
  5. #include <linux/clk/imx.h>
  6. #include <linux/cpuidle.h>
  7. #include <linux/module.h>
  8. #include <asm/cpuidle.h>
  9. #include "common.h"
  10. #include "cpuidle.h"
  11. static int imx6sl_enter_wait(struct cpuidle_device *dev,
  12. struct cpuidle_driver *drv, int index)
  13. {
  14. imx6_set_lpm(WAIT_UNCLOCKED);
  15. /*
  16. * Software workaround for ERR005311, see function
  17. * description for details.
  18. */
  19. imx6sl_set_wait_clk(true);
  20. cpu_do_idle();
  21. imx6sl_set_wait_clk(false);
  22. imx6_set_lpm(WAIT_CLOCKED);
  23. return index;
  24. }
  25. static struct cpuidle_driver imx6sl_cpuidle_driver = {
  26. .name = "imx6sl_cpuidle",
  27. .owner = THIS_MODULE,
  28. .states = {
  29. /* WFI */
  30. ARM_CPUIDLE_WFI_STATE,
  31. /* WAIT */
  32. {
  33. .exit_latency = 50,
  34. .target_residency = 75,
  35. .flags = CPUIDLE_FLAG_TIMER_STOP,
  36. .enter = imx6sl_enter_wait,
  37. .name = "WAIT",
  38. .desc = "Clock off",
  39. },
  40. },
  41. .state_count = 2,
  42. .safe_state_index = 0,
  43. };
  44. int __init imx6sl_cpuidle_init(void)
  45. {
  46. return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
  47. }