omap-ocp2scp.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * omap-ocp2scp.c - transform ocp interface protocol to scp protocol
  3. *
  4. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Author: Kishon Vijay Abraham I <kishon@ti.com>
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #include <linux/module.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/err.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/of.h>
  23. #include <linux/of_platform.h>
  24. static int ocp2scp_remove_devices(struct device *dev, void *c)
  25. {
  26. struct platform_device *pdev = to_platform_device(dev);
  27. platform_device_unregister(pdev);
  28. return 0;
  29. }
  30. static int omap_ocp2scp_probe(struct platform_device *pdev)
  31. {
  32. int ret;
  33. struct device_node *np = pdev->dev.of_node;
  34. if (np) {
  35. ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
  36. if (ret) {
  37. dev_err(&pdev->dev,
  38. "failed to add resources for ocp2scp child\n");
  39. goto err0;
  40. }
  41. }
  42. pm_runtime_enable(&pdev->dev);
  43. return 0;
  44. err0:
  45. device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
  46. return ret;
  47. }
  48. static int omap_ocp2scp_remove(struct platform_device *pdev)
  49. {
  50. pm_runtime_disable(&pdev->dev);
  51. device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
  52. return 0;
  53. }
  54. #ifdef CONFIG_OF
  55. static const struct of_device_id omap_ocp2scp_id_table[] = {
  56. { .compatible = "ti,omap-ocp2scp" },
  57. {}
  58. };
  59. MODULE_DEVICE_TABLE(of, omap_ocp2scp_id_table);
  60. #endif
  61. static struct platform_driver omap_ocp2scp_driver = {
  62. .probe = omap_ocp2scp_probe,
  63. .remove = omap_ocp2scp_remove,
  64. .driver = {
  65. .name = "omap-ocp2scp",
  66. .owner = THIS_MODULE,
  67. .of_match_table = of_match_ptr(omap_ocp2scp_id_table),
  68. },
  69. };
  70. module_platform_driver(omap_ocp2scp_driver);
  71. MODULE_ALIAS("platform: omap-ocp2scp");
  72. MODULE_AUTHOR("Texas Instruments Inc.");
  73. MODULE_DESCRIPTION("OMAP OCP2SCP driver");
  74. MODULE_LICENSE("GPL v2");