staging: vboxvideo: Atomic phase 2: Wire up state object handlers
[linux/fpc-iii.git] / drivers / bus / tegra-aconnect.c
blob084ae286fa239472cc55bbd398c38d35d63fc8ac
1 /*
2 * Tegra ACONNECT Bus Driver
4 * Copyright (C) 2016, NVIDIA CORPORATION. All rights reserved.
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 */
11 #include <linux/clk.h>
12 #include <linux/module.h>
13 #include <linux/of_platform.h>
14 #include <linux/platform_device.h>
15 #include <linux/pm_clock.h>
16 #include <linux/pm_runtime.h>
18 static int tegra_aconnect_probe(struct platform_device *pdev)
20 int ret;
22 if (!pdev->dev.of_node)
23 return -EINVAL;
25 ret = pm_clk_create(&pdev->dev);
26 if (ret)
27 return ret;
29 ret = of_pm_clk_add_clk(&pdev->dev, "ape");
30 if (ret)
31 goto clk_destroy;
33 ret = of_pm_clk_add_clk(&pdev->dev, "apb2ape");
34 if (ret)
35 goto clk_destroy;
37 pm_runtime_enable(&pdev->dev);
39 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
41 dev_info(&pdev->dev, "Tegra ACONNECT bus registered\n");
43 return 0;
45 clk_destroy:
46 pm_clk_destroy(&pdev->dev);
48 return ret;
51 static int tegra_aconnect_remove(struct platform_device *pdev)
53 pm_runtime_disable(&pdev->dev);
55 pm_clk_destroy(&pdev->dev);
57 return 0;
60 static int tegra_aconnect_runtime_resume(struct device *dev)
62 return pm_clk_resume(dev);
65 static int tegra_aconnect_runtime_suspend(struct device *dev)
67 return pm_clk_suspend(dev);
70 static const struct dev_pm_ops tegra_aconnect_pm_ops = {
71 SET_RUNTIME_PM_OPS(tegra_aconnect_runtime_suspend,
72 tegra_aconnect_runtime_resume, NULL)
75 static const struct of_device_id tegra_aconnect_of_match[] = {
76 { .compatible = "nvidia,tegra210-aconnect", },
77 { }
79 MODULE_DEVICE_TABLE(of, tegra_aconnect_of_match);
81 static struct platform_driver tegra_aconnect_driver = {
82 .probe = tegra_aconnect_probe,
83 .remove = tegra_aconnect_remove,
84 .driver = {
85 .name = "tegra-aconnect",
86 .of_match_table = tegra_aconnect_of_match,
87 .pm = &tegra_aconnect_pm_ops,
90 module_platform_driver(tegra_aconnect_driver);
92 MODULE_DESCRIPTION("NVIDIA Tegra ACONNECT Bus Driver");
93 MODULE_AUTHOR("Jon Hunter <jonathanh@nvidia.com>");
94 MODULE_LICENSE("GPL v2");