hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/bus/tegra-aconnect.c
....@@ -12,28 +12,38 @@
1212 #include <linux/module.h>
1313 #include <linux/of_platform.h>
1414 #include <linux/platform_device.h>
15
-#include <linux/pm_clock.h>
1615 #include <linux/pm_runtime.h>
16
+
17
+struct tegra_aconnect {
18
+ struct clk *ape_clk;
19
+ struct clk *apb2ape_clk;
20
+};
1721
1822 static int tegra_aconnect_probe(struct platform_device *pdev)
1923 {
20
- int ret;
24
+ struct tegra_aconnect *aconnect;
2125
2226 if (!pdev->dev.of_node)
2327 return -EINVAL;
2428
25
- ret = pm_clk_create(&pdev->dev);
26
- if (ret)
27
- return ret;
29
+ aconnect = devm_kzalloc(&pdev->dev, sizeof(struct tegra_aconnect),
30
+ GFP_KERNEL);
31
+ if (!aconnect)
32
+ return -ENOMEM;
2833
29
- ret = of_pm_clk_add_clk(&pdev->dev, "ape");
30
- if (ret)
31
- goto clk_destroy;
34
+ aconnect->ape_clk = devm_clk_get(&pdev->dev, "ape");
35
+ if (IS_ERR(aconnect->ape_clk)) {
36
+ dev_err(&pdev->dev, "Can't retrieve ape clock\n");
37
+ return PTR_ERR(aconnect->ape_clk);
38
+ }
3239
33
- ret = of_pm_clk_add_clk(&pdev->dev, "apb2ape");
34
- if (ret)
35
- goto clk_destroy;
40
+ aconnect->apb2ape_clk = devm_clk_get(&pdev->dev, "apb2ape");
41
+ if (IS_ERR(aconnect->apb2ape_clk)) {
42
+ dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n");
43
+ return PTR_ERR(aconnect->apb2ape_clk);
44
+ }
3645
46
+ dev_set_drvdata(&pdev->dev, aconnect);
3747 pm_runtime_enable(&pdev->dev);
3848
3949 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
....@@ -41,35 +51,51 @@
4151 dev_info(&pdev->dev, "Tegra ACONNECT bus registered\n");
4252
4353 return 0;
44
-
45
-clk_destroy:
46
- pm_clk_destroy(&pdev->dev);
47
-
48
- return ret;
4954 }
5055
5156 static int tegra_aconnect_remove(struct platform_device *pdev)
5257 {
5358 pm_runtime_disable(&pdev->dev);
5459
55
- pm_clk_destroy(&pdev->dev);
56
-
5760 return 0;
5861 }
5962
6063 static int tegra_aconnect_runtime_resume(struct device *dev)
6164 {
62
- return pm_clk_resume(dev);
65
+ struct tegra_aconnect *aconnect = dev_get_drvdata(dev);
66
+ int ret;
67
+
68
+ ret = clk_prepare_enable(aconnect->ape_clk);
69
+ if (ret) {
70
+ dev_err(dev, "ape clk_enable failed: %d\n", ret);
71
+ return ret;
72
+ }
73
+
74
+ ret = clk_prepare_enable(aconnect->apb2ape_clk);
75
+ if (ret) {
76
+ clk_disable_unprepare(aconnect->ape_clk);
77
+ dev_err(dev, "apb2ape clk_enable failed: %d\n", ret);
78
+ return ret;
79
+ }
80
+
81
+ return 0;
6382 }
6483
6584 static int tegra_aconnect_runtime_suspend(struct device *dev)
6685 {
67
- return pm_clk_suspend(dev);
86
+ struct tegra_aconnect *aconnect = dev_get_drvdata(dev);
87
+
88
+ clk_disable_unprepare(aconnect->ape_clk);
89
+ clk_disable_unprepare(aconnect->apb2ape_clk);
90
+
91
+ return 0;
6892 }
6993
7094 static const struct dev_pm_ops tegra_aconnect_pm_ops = {
7195 SET_RUNTIME_PM_OPS(tegra_aconnect_runtime_suspend,
7296 tegra_aconnect_runtime_resume, NULL)
97
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
98
+ pm_runtime_force_resume)
7399 };
74100
75101 static const struct of_device_id tegra_aconnect_of_match[] = {