hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/mailbox/qcom-apcs-ipc-mailbox.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2017, Linaro Ltd
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 and
6
- * only version 2 as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #include <linux/kernel.h>
....@@ -30,6 +22,43 @@
3022 struct regmap *regmap;
3123 unsigned long offset;
3224 struct platform_device *clk;
25
+};
26
+
27
+struct qcom_apcs_ipc_data {
28
+ int offset;
29
+ char *clk_name;
30
+};
31
+
32
+static const struct qcom_apcs_ipc_data ipq6018_apcs_data = {
33
+ .offset = 8, .clk_name = "qcom,apss-ipq6018-clk"
34
+};
35
+
36
+static const struct qcom_apcs_ipc_data ipq8074_apcs_data = {
37
+ .offset = 8, .clk_name = NULL
38
+};
39
+
40
+static const struct qcom_apcs_ipc_data msm8916_apcs_data = {
41
+ .offset = 8, .clk_name = "qcom-apcs-msm8916-clk"
42
+};
43
+
44
+static const struct qcom_apcs_ipc_data msm8994_apcs_data = {
45
+ .offset = 8, .clk_name = NULL
46
+};
47
+
48
+static const struct qcom_apcs_ipc_data msm8996_apcs_data = {
49
+ .offset = 16, .clk_name = NULL
50
+};
51
+
52
+static const struct qcom_apcs_ipc_data msm8998_apcs_data = {
53
+ .offset = 8, .clk_name = NULL
54
+};
55
+
56
+static const struct qcom_apcs_ipc_data sdm660_apcs_data = {
57
+ .offset = 8, .clk_name = NULL
58
+};
59
+
60
+static const struct qcom_apcs_ipc_data apps_shared_apcs_data = {
61
+ .offset = 12, .clk_name = NULL
3362 };
3463
3564 static const struct regmap_config apcs_regmap_config = {
....@@ -56,17 +85,12 @@
5685 static int qcom_apcs_ipc_probe(struct platform_device *pdev)
5786 {
5887 struct qcom_apcs_ipc *apcs;
88
+ const struct qcom_apcs_ipc_data *apcs_data;
5989 struct regmap *regmap;
6090 struct resource *res;
61
- unsigned long offset;
6291 void __iomem *base;
6392 unsigned long i;
6493 int ret;
65
- const struct of_device_id apcs_clk_match_table[] = {
66
- { .compatible = "qcom,msm8916-apcs-kpss-global", },
67
- { .compatible = "qcom,qcs404-apcs-apps-global", },
68
- {}
69
- };
7094
7195 apcs = devm_kzalloc(&pdev->dev, sizeof(*apcs), GFP_KERNEL);
7296 if (!apcs)
....@@ -81,10 +105,10 @@
81105 if (IS_ERR(regmap))
82106 return PTR_ERR(regmap);
83107
84
- offset = (unsigned long)of_device_get_match_data(&pdev->dev);
108
+ apcs_data = of_device_get_match_data(&pdev->dev);
85109
86110 apcs->regmap = regmap;
87
- apcs->offset = offset;
111
+ apcs->offset = apcs_data->offset;
88112
89113 /* Initialize channel identifiers */
90114 for (i = 0; i < ARRAY_SIZE(apcs->mbox_chans); i++)
....@@ -95,16 +119,17 @@
95119 apcs->mbox.chans = apcs->mbox_chans;
96120 apcs->mbox.num_chans = ARRAY_SIZE(apcs->mbox_chans);
97121
98
- ret = mbox_controller_register(&apcs->mbox);
122
+ ret = devm_mbox_controller_register(&pdev->dev, &apcs->mbox);
99123 if (ret) {
100124 dev_err(&pdev->dev, "failed to register APCS IPC controller\n");
101125 return ret;
102126 }
103127
104
- if (of_match_device(apcs_clk_match_table, &pdev->dev)) {
128
+ if (apcs_data->clk_name) {
105129 apcs->clk = platform_device_register_data(&pdev->dev,
106
- "qcom-apcs-msm8916-clk",
107
- -1, NULL, 0);
130
+ apcs_data->clk_name,
131
+ PLATFORM_DEVID_AUTO,
132
+ NULL, 0);
108133 if (IS_ERR(apcs->clk))
109134 dev_err(&pdev->dev, "failed to register APCS clk\n");
110135 }
....@@ -119,7 +144,6 @@
119144 struct qcom_apcs_ipc *apcs = platform_get_drvdata(pdev);
120145 struct platform_device *clk = apcs->clk;
121146
122
- mbox_controller_unregister(&apcs->mbox);
123147 platform_device_unregister(clk);
124148
125149 return 0;
....@@ -127,10 +151,17 @@
127151
128152 /* .data is the offset of the ipc register within the global block */
129153 static const struct of_device_id qcom_apcs_ipc_of_match[] = {
130
- { .compatible = "qcom,msm8916-apcs-kpss-global", .data = (void *)8 },
131
- { .compatible = "qcom,msm8996-apcs-hmss-global", .data = (void *)16 },
132
- { .compatible = "qcom,msm8998-apcs-hmss-global", .data = (void *)8 },
133
- { .compatible = "qcom,sdm845-apss-shared", .data = (void *)12 },
154
+ { .compatible = "qcom,ipq6018-apcs-apps-global", .data = &ipq6018_apcs_data },
155
+ { .compatible = "qcom,ipq8074-apcs-apps-global", .data = &ipq8074_apcs_data },
156
+ { .compatible = "qcom,msm8916-apcs-kpss-global", .data = &msm8916_apcs_data },
157
+ { .compatible = "qcom,msm8994-apcs-kpss-global", .data = &msm8994_apcs_data },
158
+ { .compatible = "qcom,msm8996-apcs-hmss-global", .data = &msm8996_apcs_data },
159
+ { .compatible = "qcom,msm8998-apcs-hmss-global", .data = &msm8998_apcs_data },
160
+ { .compatible = "qcom,qcs404-apcs-apps-global", .data = &msm8916_apcs_data },
161
+ { .compatible = "qcom,sc7180-apss-shared", .data = &apps_shared_apcs_data },
162
+ { .compatible = "qcom,sdm660-apcs-hmss-global", .data = &sdm660_apcs_data },
163
+ { .compatible = "qcom,sdm845-apss-shared", .data = &apps_shared_apcs_data },
164
+ { .compatible = "qcom,sm8150-apss-shared", .data = &apps_shared_apcs_data },
134165 {}
135166 };
136167 MODULE_DEVICE_TABLE(of, qcom_apcs_ipc_of_match);