.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
12 | 4 | */ |
---|
13 | 5 | |
---|
14 | 6 | #include <linux/kernel.h> |
---|
.. | .. |
---|
30 | 22 | struct regmap *regmap; |
---|
31 | 23 | unsigned long offset; |
---|
32 | 24 | 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 |
---|
33 | 62 | }; |
---|
34 | 63 | |
---|
35 | 64 | static const struct regmap_config apcs_regmap_config = { |
---|
.. | .. |
---|
56 | 85 | static int qcom_apcs_ipc_probe(struct platform_device *pdev) |
---|
57 | 86 | { |
---|
58 | 87 | struct qcom_apcs_ipc *apcs; |
---|
| 88 | + const struct qcom_apcs_ipc_data *apcs_data; |
---|
59 | 89 | struct regmap *regmap; |
---|
60 | 90 | struct resource *res; |
---|
61 | | - unsigned long offset; |
---|
62 | 91 | void __iomem *base; |
---|
63 | 92 | unsigned long i; |
---|
64 | 93 | 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 | | - }; |
---|
70 | 94 | |
---|
71 | 95 | apcs = devm_kzalloc(&pdev->dev, sizeof(*apcs), GFP_KERNEL); |
---|
72 | 96 | if (!apcs) |
---|
.. | .. |
---|
81 | 105 | if (IS_ERR(regmap)) |
---|
82 | 106 | return PTR_ERR(regmap); |
---|
83 | 107 | |
---|
84 | | - offset = (unsigned long)of_device_get_match_data(&pdev->dev); |
---|
| 108 | + apcs_data = of_device_get_match_data(&pdev->dev); |
---|
85 | 109 | |
---|
86 | 110 | apcs->regmap = regmap; |
---|
87 | | - apcs->offset = offset; |
---|
| 111 | + apcs->offset = apcs_data->offset; |
---|
88 | 112 | |
---|
89 | 113 | /* Initialize channel identifiers */ |
---|
90 | 114 | for (i = 0; i < ARRAY_SIZE(apcs->mbox_chans); i++) |
---|
.. | .. |
---|
95 | 119 | apcs->mbox.chans = apcs->mbox_chans; |
---|
96 | 120 | apcs->mbox.num_chans = ARRAY_SIZE(apcs->mbox_chans); |
---|
97 | 121 | |
---|
98 | | - ret = mbox_controller_register(&apcs->mbox); |
---|
| 122 | + ret = devm_mbox_controller_register(&pdev->dev, &apcs->mbox); |
---|
99 | 123 | if (ret) { |
---|
100 | 124 | dev_err(&pdev->dev, "failed to register APCS IPC controller\n"); |
---|
101 | 125 | return ret; |
---|
102 | 126 | } |
---|
103 | 127 | |
---|
104 | | - if (of_match_device(apcs_clk_match_table, &pdev->dev)) { |
---|
| 128 | + if (apcs_data->clk_name) { |
---|
105 | 129 | 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); |
---|
108 | 133 | if (IS_ERR(apcs->clk)) |
---|
109 | 134 | dev_err(&pdev->dev, "failed to register APCS clk\n"); |
---|
110 | 135 | } |
---|
.. | .. |
---|
119 | 144 | struct qcom_apcs_ipc *apcs = platform_get_drvdata(pdev); |
---|
120 | 145 | struct platform_device *clk = apcs->clk; |
---|
121 | 146 | |
---|
122 | | - mbox_controller_unregister(&apcs->mbox); |
---|
123 | 147 | platform_device_unregister(clk); |
---|
124 | 148 | |
---|
125 | 149 | return 0; |
---|
.. | .. |
---|
127 | 151 | |
---|
128 | 152 | /* .data is the offset of the ipc register within the global block */ |
---|
129 | 153 | 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 }, |
---|
134 | 165 | {} |
---|
135 | 166 | }; |
---|
136 | 167 | MODULE_DEVICE_TABLE(of, qcom_apcs_ipc_of_match); |
---|