Skip to content

Commit 9b00793

Browse files
Sivaprakash MurugesanJassiBrar
authored andcommitted
mailbox: qcom: Add clock driver name in apcs mailbox driver data
Some apcs mailbox devices supports a clock driver, the compatible strings of devices supporting clock driver along with the clock driver name are maintained in a separate structure within the mailbox driver. And the clock driver is added based on device match. With increase in number of devices supporting the clock feature move the clock driver name inside the driver data. so that we can use a single API to get the register offset of mailbox driver and clock driver name together, and the clock driver will be added based on the driver data. Signed-off-by: Sivaprakash Murugesan <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent f3a1381 commit 9b00793

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

drivers/mailbox/qcom-apcs-ipc-mailbox.c

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@ struct qcom_apcs_ipc {
2424
struct platform_device *clk;
2525
};
2626

27+
struct qcom_apcs_ipc_data {
28+
int offset;
29+
char *clk_name;
30+
};
31+
32+
static const struct qcom_apcs_ipc_data ipq8074_apcs_data = {
33+
.offset = 8, .clk_name = NULL
34+
};
35+
36+
static const struct qcom_apcs_ipc_data msm8916_apcs_data = {
37+
.offset = 8, .clk_name = "qcom-apcs-msm8916-clk"
38+
};
39+
40+
static const struct qcom_apcs_ipc_data msm8996_apcs_data = {
41+
.offset = 16, .clk_name = NULL
42+
};
43+
44+
static const struct qcom_apcs_ipc_data msm8998_apcs_data = {
45+
.offset = 8, .clk_name = NULL
46+
};
47+
48+
static const struct qcom_apcs_ipc_data apps_shared_apcs_data = {
49+
.offset = 12, .clk_name = NULL
50+
};
51+
2752
static const struct regmap_config apcs_regmap_config = {
2853
.reg_bits = 32,
2954
.reg_stride = 4,
@@ -48,17 +73,12 @@ static const struct mbox_chan_ops qcom_apcs_ipc_ops = {
4873
static int qcom_apcs_ipc_probe(struct platform_device *pdev)
4974
{
5075
struct qcom_apcs_ipc *apcs;
76+
const struct qcom_apcs_ipc_data *apcs_data;
5177
struct regmap *regmap;
5278
struct resource *res;
53-
unsigned long offset;
5479
void __iomem *base;
5580
unsigned long i;
5681
int ret;
57-
const struct of_device_id apcs_clk_match_table[] = {
58-
{ .compatible = "qcom,msm8916-apcs-kpss-global", },
59-
{ .compatible = "qcom,qcs404-apcs-apps-global", },
60-
{}
61-
};
6282

6383
apcs = devm_kzalloc(&pdev->dev, sizeof(*apcs), GFP_KERNEL);
6484
if (!apcs)
@@ -73,10 +93,10 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)
7393
if (IS_ERR(regmap))
7494
return PTR_ERR(regmap);
7595

76-
offset = (unsigned long)of_device_get_match_data(&pdev->dev);
96+
apcs_data = of_device_get_match_data(&pdev->dev);
7797

7898
apcs->regmap = regmap;
79-
apcs->offset = offset;
99+
apcs->offset = apcs_data->offset;
80100

81101
/* Initialize channel identifiers */
82102
for (i = 0; i < ARRAY_SIZE(apcs->mbox_chans); i++)
@@ -93,9 +113,9 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)
93113
return ret;
94114
}
95115

96-
if (of_match_device(apcs_clk_match_table, &pdev->dev)) {
116+
if (apcs_data->clk_name) {
97117
apcs->clk = platform_device_register_data(&pdev->dev,
98-
"qcom-apcs-msm8916-clk",
118+
apcs_data->clk_name,
99119
PLATFORM_DEVID_NONE,
100120
NULL, 0);
101121
if (IS_ERR(apcs->clk))
@@ -119,14 +139,14 @@ static int qcom_apcs_ipc_remove(struct platform_device *pdev)
119139

120140
/* .data is the offset of the ipc register within the global block */
121141
static const struct of_device_id qcom_apcs_ipc_of_match[] = {
122-
{ .compatible = "qcom,msm8916-apcs-kpss-global", .data = (void *)8 },
123-
{ .compatible = "qcom,msm8996-apcs-hmss-global", .data = (void *)16 },
124-
{ .compatible = "qcom,msm8998-apcs-hmss-global", .data = (void *)8 },
125-
{ .compatible = "qcom,qcs404-apcs-apps-global", .data = (void *)8 },
126-
{ .compatible = "qcom,sc7180-apss-shared", .data = (void *)12 },
127-
{ .compatible = "qcom,sdm845-apss-shared", .data = (void *)12 },
128-
{ .compatible = "qcom,sm8150-apss-shared", .data = (void *)12 },
129-
{ .compatible = "qcom,ipq8074-apcs-apps-global", .data = (void *)8 },
142+
{ .compatible = "qcom,ipq8074-apcs-apps-global", .data = &ipq8074_apcs_data },
143+
{ .compatible = "qcom,msm8916-apcs-kpss-global", .data = &msm8916_apcs_data },
144+
{ .compatible = "qcom,msm8996-apcs-hmss-global", .data = &msm8996_apcs_data },
145+
{ .compatible = "qcom,msm8998-apcs-hmss-global", .data = &msm8998_apcs_data },
146+
{ .compatible = "qcom,qcs404-apcs-apps-global", .data = &msm8916_apcs_data },
147+
{ .compatible = "qcom,sc7180-apss-shared", .data = &apps_shared_apcs_data },
148+
{ .compatible = "qcom,sdm845-apss-shared", .data = &apps_shared_apcs_data },
149+
{ .compatible = "qcom,sm8150-apss-shared", .data = &apps_shared_apcs_data },
130150
{}
131151
};
132152
MODULE_DEVICE_TABLE(of, qcom_apcs_ipc_of_match);

0 commit comments

Comments
 (0)