tegra-aconnect.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Tegra ACONNECT Bus Driver
  3. *
  4. * Copyright (C) 2016, NVIDIA CORPORATION. All rights reserved.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/clk.h>
  11. #include <linux/module.h>
  12. #include <linux/of_platform.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/pm_clock.h>
  15. #include <linux/pm_runtime.h>
  16. static int tegra_aconnect_probe(struct platform_device *pdev)
  17. {
  18. int ret;
  19. if (!pdev->dev.of_node)
  20. return -EINVAL;
  21. ret = pm_clk_create(&pdev->dev);
  22. if (ret)
  23. return ret;
  24. ret = of_pm_clk_add_clk(&pdev->dev, "ape");
  25. if (ret)
  26. goto clk_destroy;
  27. ret = of_pm_clk_add_clk(&pdev->dev, "apb2ape");
  28. if (ret)
  29. goto clk_destroy;
  30. pm_runtime_enable(&pdev->dev);
  31. of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  32. dev_info(&pdev->dev, "Tegra ACONNECT bus registered\n");
  33. return 0;
  34. clk_destroy:
  35. pm_clk_destroy(&pdev->dev);
  36. return ret;
  37. }
  38. static int tegra_aconnect_remove(struct platform_device *pdev)
  39. {
  40. pm_runtime_disable(&pdev->dev);
  41. pm_clk_destroy(&pdev->dev);
  42. return 0;
  43. }
  44. static int tegra_aconnect_runtime_resume(struct device *dev)
  45. {
  46. return pm_clk_resume(dev);
  47. }
  48. static int tegra_aconnect_runtime_suspend(struct device *dev)
  49. {
  50. return pm_clk_suspend(dev);
  51. }
  52. static const struct dev_pm_ops tegra_aconnect_pm_ops = {
  53. SET_RUNTIME_PM_OPS(tegra_aconnect_runtime_suspend,
  54. tegra_aconnect_runtime_resume, NULL)
  55. };
  56. static const struct of_device_id tegra_aconnect_of_match[] = {
  57. { .compatible = "nvidia,tegra210-aconnect", },
  58. { }
  59. };
  60. MODULE_DEVICE_TABLE(of, tegra_aconnect_of_match);
  61. static struct platform_driver tegra_aconnect_driver = {
  62. .probe = tegra_aconnect_probe,
  63. .remove = tegra_aconnect_remove,
  64. .driver = {
  65. .name = "tegra-aconnect",
  66. .of_match_table = tegra_aconnect_of_match,
  67. .pm = &tegra_aconnect_pm_ops,
  68. },
  69. };
  70. module_platform_driver(tegra_aconnect_driver);
  71. MODULE_DESCRIPTION("NVIDIA Tegra ACONNECT Bus Driver");
  72. MODULE_AUTHOR("Jon Hunter <jonathanh@nvidia.com>");
  73. MODULE_LICENSE("GPL v2");