pm_domain.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * PM domain driver for Keystone2 devices
  3. *
  4. * Copyright 2013 Texas Instruments, Inc.
  5. * Santosh Shilimkar <santosh.shillimkar@ti.com>
  6. *
  7. * Based on Kevins work on DAVINCI SOCs
  8. * Kevin Hilman <khilman@linaro.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms and conditions of the GNU General Public License,
  12. * version 2, as published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/pm_runtime.h>
  16. #include <linux/pm_clock.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/clk-provider.h>
  19. #include <linux/of.h>
  20. #ifdef CONFIG_PM_RUNTIME
  21. static int keystone_pm_runtime_suspend(struct device *dev)
  22. {
  23. int ret;
  24. dev_dbg(dev, "%s\n", __func__);
  25. ret = pm_generic_runtime_suspend(dev);
  26. if (ret)
  27. return ret;
  28. ret = pm_clk_suspend(dev);
  29. if (ret) {
  30. pm_generic_runtime_resume(dev);
  31. return ret;
  32. }
  33. return 0;
  34. }
  35. static int keystone_pm_runtime_resume(struct device *dev)
  36. {
  37. dev_dbg(dev, "%s\n", __func__);
  38. pm_clk_resume(dev);
  39. return pm_generic_runtime_resume(dev);
  40. }
  41. #endif
  42. static struct dev_pm_domain keystone_pm_domain = {
  43. .ops = {
  44. SET_RUNTIME_PM_OPS(keystone_pm_runtime_suspend,
  45. keystone_pm_runtime_resume, NULL)
  46. USE_PLATFORM_PM_SLEEP_OPS
  47. },
  48. };
  49. static struct pm_clk_notifier_block platform_domain_notifier = {
  50. .pm_domain = &keystone_pm_domain,
  51. };
  52. static struct of_device_id of_keystone_table[] = {
  53. {.compatible = "ti,keystone"},
  54. { /* end of list */ },
  55. };
  56. int __init keystone_pm_runtime_init(void)
  57. {
  58. struct device_node *np;
  59. np = of_find_matching_node(NULL, of_keystone_table);
  60. if (!np)
  61. return 0;
  62. of_clk_init(NULL);
  63. pm_clk_add_notifier(&platform_bus_type, &platform_domain_notifier);
  64. return 0;
  65. }
  66. subsys_initcall(keystone_pm_runtime_init);