blob: 084ae286fa239472cc55bbd398c38d35d63fc8ac [file] [log] [blame]
Jon Hunter46a88532016-06-17 13:40:32 +01001/*
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
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>
17
Jon Hunter46a88532016-06-17 13:40:32 +010018static int tegra_aconnect_probe(struct platform_device *pdev)
19{
20 int ret;
21
22 if (!pdev->dev.of_node)
23 return -EINVAL;
24
25 ret = pm_clk_create(&pdev->dev);
26 if (ret)
27 return ret;
28
Jon Hunter3a99cb02016-08-16 11:17:36 +010029 ret = of_pm_clk_add_clk(&pdev->dev, "ape");
Jon Hunter46a88532016-06-17 13:40:32 +010030 if (ret)
31 goto clk_destroy;
32
Jon Hunter3a99cb02016-08-16 11:17:36 +010033 ret = of_pm_clk_add_clk(&pdev->dev, "apb2ape");
Jon Hunter46a88532016-06-17 13:40:32 +010034 if (ret)
35 goto clk_destroy;
36
37 pm_runtime_enable(&pdev->dev);
38
39 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
40
41 dev_info(&pdev->dev, "Tegra ACONNECT bus registered\n");
42
43 return 0;
44
45clk_destroy:
46 pm_clk_destroy(&pdev->dev);
47
48 return ret;
49}
50
51static int tegra_aconnect_remove(struct platform_device *pdev)
52{
53 pm_runtime_disable(&pdev->dev);
54
55 pm_clk_destroy(&pdev->dev);
56
57 return 0;
58}
59
60static int tegra_aconnect_runtime_resume(struct device *dev)
61{
62 return pm_clk_resume(dev);
63}
64
65static int tegra_aconnect_runtime_suspend(struct device *dev)
66{
67 return pm_clk_suspend(dev);
68}
69
70static const struct dev_pm_ops tegra_aconnect_pm_ops = {
71 SET_RUNTIME_PM_OPS(tegra_aconnect_runtime_suspend,
72 tegra_aconnect_runtime_resume, NULL)
73};
74
75static const struct of_device_id tegra_aconnect_of_match[] = {
76 { .compatible = "nvidia,tegra210-aconnect", },
77 { }
78};
79MODULE_DEVICE_TABLE(of, tegra_aconnect_of_match);
80
81static 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,
88 },
89};
90module_platform_driver(tegra_aconnect_driver);
91
92MODULE_DESCRIPTION("NVIDIA Tegra ACONNECT Bus Driver");
93MODULE_AUTHOR("Jon Hunter <jonathanh@nvidia.com>");
94MODULE_LICENSE("GPL v2");