cpuidle-clps711x.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * CLPS711X CPU idle driver
  4. *
  5. * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
  6. */
  7. #include <linux/cpuidle.h>
  8. #include <linux/err.h>
  9. #include <linux/io.h>
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle"
  13. static void __iomem *clps711x_halt;
  14. static int clps711x_cpuidle_halt(struct cpuidle_device *dev,
  15. struct cpuidle_driver *drv, int index)
  16. {
  17. writel(0xaa, clps711x_halt);
  18. return index;
  19. }
  20. static struct cpuidle_driver clps711x_idle_driver = {
  21. .name = CLPS711X_CPUIDLE_NAME,
  22. .owner = THIS_MODULE,
  23. .states[0] = {
  24. .name = "HALT",
  25. .desc = "CLPS711X HALT",
  26. .enter = clps711x_cpuidle_halt,
  27. .exit_latency = 1,
  28. },
  29. .state_count = 1,
  30. };
  31. static int __init clps711x_cpuidle_probe(struct platform_device *pdev)
  32. {
  33. clps711x_halt = devm_platform_ioremap_resource(pdev, 0);
  34. if (IS_ERR(clps711x_halt))
  35. return PTR_ERR(clps711x_halt);
  36. return cpuidle_register(&clps711x_idle_driver, NULL);
  37. }
  38. static struct platform_driver clps711x_cpuidle_driver = {
  39. .driver = {
  40. .name = CLPS711X_CPUIDLE_NAME,
  41. },
  42. };
  43. builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);