omap-ocp2scp.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 __devinit 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, "failed to add resources for ocp2scp child\n");
  38. goto err0;
  39. }
  40. }
  41. pm_runtime_enable(&pdev->dev);
  42. return 0;
  43. err0:
  44. device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
  45. return ret;
  46. }
  47. static int __devexit omap_ocp2scp_remove(struct platform_device *pdev)
  48. {
  49. pm_runtime_disable(&pdev->dev);
  50. device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
  51. return 0;
  52. }
  53. #ifdef CONFIG_OF
  54. static const struct of_device_id omap_ocp2scp_id_table[] = {
  55. { .compatible = "ti,omap-ocp2scp" },
  56. {}
  57. };
  58. MODULE_DEVICE_TABLE(of, omap_ocp2scp_id_table);
  59. #endif
  60. static struct platform_driver omap_ocp2scp_driver = {
  61. .probe = omap_ocp2scp_probe,
  62. .remove = __devexit_p(omap_ocp2scp_remove),
  63. .driver = {
  64. .name = "omap-ocp2scp",
  65. .owner = THIS_MODULE,
  66. .of_match_table = of_match_ptr(omap_ocp2scp_id_table),
  67. },
  68. };
  69. module_platform_driver(omap_ocp2scp_driver);
  70. MODULE_ALIAS("platform: omap-ocp2scp");
  71. MODULE_AUTHOR("Texas Instruments Inc.");
  72. MODULE_DESCRIPTION("OMAP OCP2SCP driver");
  73. MODULE_LICENSE("GPL v2");