hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/clk/clk-scmi.c
....@@ -2,7 +2,7 @@
22 /*
33 * System Control and Power Interface (SCMI) Protocol based clock driver
44 *
5
- * Copyright (C) 2018 ARM Ltd.
5
+ * Copyright (C) 2018-2020 ARM Ltd.
66 */
77
88 #include <linux/clk-provider.h>
....@@ -13,11 +13,13 @@
1313 #include <linux/scmi_protocol.h>
1414 #include <asm/div64.h>
1515
16
+static const struct scmi_clk_proto_ops *clk_ops;
17
+
1618 struct scmi_clk {
1719 u32 id;
1820 struct clk_hw hw;
1921 const struct scmi_clock_info *info;
20
- const struct scmi_handle *handle;
22
+ const struct scmi_protocol_handle *ph;
2123 };
2224
2325 #define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw)
....@@ -29,7 +31,7 @@
2931 u64 rate;
3032 struct scmi_clk *clk = to_scmi_clk(hw);
3133
32
- ret = clk->handle->clk_ops->rate_get(clk->handle, clk->id, &rate);
34
+ ret = clk_ops->rate_get(clk->ph, clk->id, &rate);
3335 if (ret)
3436 return 0;
3537 return rate;
....@@ -69,21 +71,21 @@
6971 {
7072 struct scmi_clk *clk = to_scmi_clk(hw);
7173
72
- return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate);
74
+ return clk_ops->rate_set(clk->ph, clk->id, rate);
7375 }
7476
7577 static int scmi_clk_enable(struct clk_hw *hw)
7678 {
7779 struct scmi_clk *clk = to_scmi_clk(hw);
7880
79
- return clk->handle->clk_ops->enable(clk->handle, clk->id);
81
+ return clk_ops->enable(clk->ph, clk->id);
8082 }
8183
8284 static void scmi_clk_disable(struct clk_hw *hw)
8385 {
8486 struct scmi_clk *clk = to_scmi_clk(hw);
8587
86
- clk->handle->clk_ops->disable(clk->handle, clk->id);
88
+ clk_ops->disable(clk->ph, clk->id);
8789 }
8890
8991 static const struct clk_ops scmi_clk_ops = {
....@@ -142,13 +144,18 @@
142144 struct device *dev = &sdev->dev;
143145 struct device_node *np = dev->of_node;
144146 const struct scmi_handle *handle = sdev->handle;
147
+ struct scmi_protocol_handle *ph;
145148
146
- if (!handle || !handle->clk_ops)
149
+ if (!handle)
147150 return -ENODEV;
148151
149
- count = handle->clk_ops->count_get(handle);
152
+ clk_ops = handle->devm_get_protocol(sdev, SCMI_PROTOCOL_CLOCK, &ph);
153
+ if (IS_ERR(clk_ops))
154
+ return PTR_ERR(clk_ops);
155
+
156
+ count = clk_ops->count_get(ph);
150157 if (count < 0) {
151
- dev_err(dev, "%s: invalid clock output count\n", np->name);
158
+ dev_err(dev, "%pOFn: invalid clock output count\n", np);
152159 return -EINVAL;
153160 }
154161
....@@ -167,14 +174,14 @@
167174 if (!sclk)
168175 return -ENOMEM;
169176
170
- sclk->info = handle->clk_ops->info_get(handle, idx);
177
+ sclk->info = clk_ops->info_get(ph, idx);
171178 if (!sclk->info) {
172179 dev_dbg(dev, "invalid clock info for idx %d\n", idx);
173180 continue;
174181 }
175182
176183 sclk->id = idx;
177
- sclk->handle = handle;
184
+ sclk->ph = ph;
178185
179186 err = scmi_clk_ops_init(dev, sclk);
180187 if (err) {
....@@ -192,7 +199,7 @@
192199 }
193200
194201 static const struct scmi_device_id scmi_id_table[] = {
195
- { SCMI_PROTOCOL_CLOCK },
202
+ { SCMI_PROTOCOL_CLOCK, "clocks" },
196203 { },
197204 };
198205 MODULE_DEVICE_TABLE(scmi, scmi_id_table);
....@@ -202,21 +209,7 @@
202209 .probe = scmi_clocks_probe,
203210 .id_table = scmi_id_table,
204211 };
205
-#ifdef CONFIG_ARCH_ROCKCHIP
206
-static int __init scmi_clocks_driver_init(void)
207
-{
208
- return scmi_register(&scmi_clocks_driver);
209
-}
210
-subsys_initcall_sync(scmi_clocks_driver_init);
211
-
212
-static void __exit scmi_clocks_driver_exit(void)
213
-{
214
- scmi_unregister(&scmi_clocks_driver);
215
-}
216
-module_exit(scmi_clocks_driver_exit);
217
-#else
218212 module_scmi_driver(scmi_clocks_driver);
219
-#endif
220213
221214 MODULE_AUTHOR("Sudeep Holla <sudeep.holla@arm.com>");
222215 MODULE_DESCRIPTION("ARM SCMI clock driver");