pwm-tipwmss.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * TI PWM Subsystem driver
  3. *
  4. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  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. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include <linux/module.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/io.h>
  20. #include <linux/err.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/of_device.h>
  23. static const struct of_device_id pwmss_of_match[] = {
  24. { .compatible = "ti,am33xx-pwmss" },
  25. {},
  26. };
  27. MODULE_DEVICE_TABLE(of, pwmss_of_match);
  28. static int pwmss_probe(struct platform_device *pdev)
  29. {
  30. int ret;
  31. struct device_node *node = pdev->dev.of_node;
  32. pm_runtime_enable(&pdev->dev);
  33. pm_runtime_get_sync(&pdev->dev);
  34. /* Populate all the child nodes here... */
  35. ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
  36. if (ret)
  37. dev_err(&pdev->dev, "no child node found\n");
  38. return ret;
  39. }
  40. static int pwmss_remove(struct platform_device *pdev)
  41. {
  42. pm_runtime_put_sync(&pdev->dev);
  43. pm_runtime_disable(&pdev->dev);
  44. return 0;
  45. }
  46. #ifdef CONFIG_PM_SLEEP
  47. static int pwmss_suspend(struct device *dev)
  48. {
  49. pm_runtime_put_sync(dev);
  50. return 0;
  51. }
  52. static int pwmss_resume(struct device *dev)
  53. {
  54. pm_runtime_get_sync(dev);
  55. return 0;
  56. }
  57. #endif
  58. static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume);
  59. static struct platform_driver pwmss_driver = {
  60. .driver = {
  61. .name = "pwmss",
  62. .pm = &pwmss_pm_ops,
  63. .of_match_table = pwmss_of_match,
  64. },
  65. .probe = pwmss_probe,
  66. .remove = pwmss_remove,
  67. };
  68. module_platform_driver(pwmss_driver);
  69. MODULE_DESCRIPTION("PWM Subsystem driver");
  70. MODULE_AUTHOR("Texas Instruments");
  71. MODULE_LICENSE("GPL");