cpuidle-clps711x.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * CLPS711X CPU idle driver
  3. *
  4. * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/cpuidle.h>
  12. #include <linux/err.h>
  13. #include <linux/io.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle"
  17. static void __iomem *clps711x_halt;
  18. static int clps711x_cpuidle_halt(struct cpuidle_device *dev,
  19. struct cpuidle_driver *drv, int index)
  20. {
  21. writel(0xaa, clps711x_halt);
  22. return index;
  23. }
  24. static struct cpuidle_driver clps711x_idle_driver = {
  25. .name = CLPS711X_CPUIDLE_NAME,
  26. .owner = THIS_MODULE,
  27. .states[0] = {
  28. .name = "HALT",
  29. .desc = "CLPS711X HALT",
  30. .enter = clps711x_cpuidle_halt,
  31. .exit_latency = 1,
  32. },
  33. .state_count = 1,
  34. };
  35. static int __init clps711x_cpuidle_probe(struct platform_device *pdev)
  36. {
  37. struct resource *res;
  38. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  39. clps711x_halt = devm_ioremap_resource(&pdev->dev, res);
  40. if (IS_ERR(clps711x_halt))
  41. return PTR_ERR(clps711x_halt);
  42. return cpuidle_register(&clps711x_idle_driver, NULL);
  43. }
  44. static struct platform_driver clps711x_cpuidle_driver = {
  45. .driver = {
  46. .name = CLPS711X_CPUIDLE_NAME,
  47. },
  48. };
  49. builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);