forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/clk/mvebu/cp110-system-controller.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Marvell Armada CP110 System Controller
34 *
....@@ -5,9 +6,6 @@
56 *
67 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
78 *
8
- * This file is licensed under the terms of the GNU General Public
9
- * License version 2. This program is licensed "as is" without any
10
- * warranty of any kind, whether express or implied.
119 */
1210
1311 /*
....@@ -23,16 +21,16 @@
2321 * - Equal to SDIO clock
2422 * - 2/5 PLL0
2523 *
26
- * CP110 has 32 gatable clocks, for the various peripherals in the IP.
24
+ * CP110 has 32 gateable clocks, for the various peripherals in the IP.
2725 */
2826
2927 #define pr_fmt(fmt) "cp110-system-controller: " fmt
3028
29
+#include "armada_ap_cp_helper.h"
3130 #include <linux/clk-provider.h>
3231 #include <linux/mfd/syscon.h>
3332 #include <linux/init.h>
3433 #include <linux/of.h>
35
-#include <linux/of_address.h>
3634 #include <linux/platform_device.h>
3735 #include <linux/regmap.h>
3836 #include <linux/slab.h>
....@@ -59,7 +57,7 @@
5957 #define CP110_CORE_NAND 4
6058 #define CP110_CORE_SDIO 5
6159
62
-/* A number of gatable clocks need special handling */
60
+/* A number of gateable clocks need special handling */
6361 #define CP110_GATE_AUDIO 0
6462 #define CP110_GATE_COMM_UNIT 1
6563 #define CP110_GATE_NAND 2
....@@ -160,7 +158,7 @@
160158 {
161159 struct cp110_gate_clk *gate;
162160 struct clk_hw *hw;
163
- struct clk_init_data init = {};
161
+ struct clk_init_data init;
164162 int ret;
165163
166164 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
....@@ -214,22 +212,6 @@
214212 return ERR_PTR(-EINVAL);
215213 }
216214
217
-static char *cp110_unique_name(struct device *dev, struct device_node *np,
218
- const char *name)
219
-{
220
- const __be32 *reg;
221
- u64 addr;
222
-
223
- /* Do not create a name if there is no clock */
224
- if (!name)
225
- return NULL;
226
-
227
- reg = of_get_property(np, "reg", NULL);
228
- addr = of_translate_address(np, reg);
229
- return devm_kasprintf(dev, GFP_KERNEL, "%llx-%s",
230
- (unsigned long long)addr, name);
231
-}
232
-
233215 static int cp110_syscon_common_probe(struct platform_device *pdev,
234216 struct device_node *syscon_node)
235217 {
....@@ -253,8 +235,8 @@
253235 if (ret)
254236 return ret;
255237
256
- cp110_clk_data = devm_kzalloc(dev, sizeof(*cp110_clk_data) +
257
- sizeof(struct clk_hw *) * CP110_CLK_NUM,
238
+ cp110_clk_data = devm_kzalloc(dev, struct_size(cp110_clk_data, hws,
239
+ CP110_CLK_NUM),
258240 GFP_KERNEL);
259241 if (!cp110_clk_data)
260242 return -ENOMEM;
....@@ -263,7 +245,7 @@
263245 cp110_clk_data->num = CP110_CLK_NUM;
264246
265247 /* Register the PLL0 which is the root of the hw tree */
266
- pll0_name = cp110_unique_name(dev, syscon_node, "pll0");
248
+ pll0_name = ap_cp_unique_name(dev, syscon_node, "pll0");
267249 hw = clk_hw_register_fixed_rate(NULL, pll0_name, NULL, 0,
268250 1000 * 1000 * 1000);
269251 if (IS_ERR(hw)) {
....@@ -274,7 +256,7 @@
274256 cp110_clks[CP110_CORE_PLL0] = hw;
275257
276258 /* PPv2 is PLL0/3 */
277
- ppv2_name = cp110_unique_name(dev, syscon_node, "ppv2-core");
259
+ ppv2_name = ap_cp_unique_name(dev, syscon_node, "ppv2-core");
278260 hw = clk_hw_register_fixed_factor(NULL, ppv2_name, pll0_name, 0, 1, 3);
279261 if (IS_ERR(hw)) {
280262 ret = PTR_ERR(hw);
....@@ -284,7 +266,7 @@
284266 cp110_clks[CP110_CORE_PPV2] = hw;
285267
286268 /* X2CORE clock is PLL0/2 */
287
- x2core_name = cp110_unique_name(dev, syscon_node, "x2core");
269
+ x2core_name = ap_cp_unique_name(dev, syscon_node, "x2core");
288270 hw = clk_hw_register_fixed_factor(NULL, x2core_name, pll0_name,
289271 0, 1, 2);
290272 if (IS_ERR(hw)) {
....@@ -295,7 +277,7 @@
295277 cp110_clks[CP110_CORE_X2CORE] = hw;
296278
297279 /* Core clock is X2CORE/2 */
298
- core_name = cp110_unique_name(dev, syscon_node, "core");
280
+ core_name = ap_cp_unique_name(dev, syscon_node, "core");
299281 hw = clk_hw_register_fixed_factor(NULL, core_name, x2core_name,
300282 0, 1, 2);
301283 if (IS_ERR(hw)) {
....@@ -305,7 +287,7 @@
305287
306288 cp110_clks[CP110_CORE_CORE] = hw;
307289 /* NAND can be either PLL0/2.5 or core clock */
308
- nand_name = cp110_unique_name(dev, syscon_node, "nand-core");
290
+ nand_name = ap_cp_unique_name(dev, syscon_node, "nand-core");
309291 if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK)
310292 hw = clk_hw_register_fixed_factor(NULL, nand_name,
311293 pll0_name, 0, 2, 5);
....@@ -320,7 +302,7 @@
320302 cp110_clks[CP110_CORE_NAND] = hw;
321303
322304 /* SDIO clock is PLL0/2.5 */
323
- sdio_name = cp110_unique_name(dev, syscon_node, "sdio-core");
305
+ sdio_name = ap_cp_unique_name(dev, syscon_node, "sdio-core");
324306 hw = clk_hw_register_fixed_factor(NULL, sdio_name,
325307 pll0_name, 0, 2, 5);
326308 if (IS_ERR(hw)) {
....@@ -332,7 +314,7 @@
332314
333315 /* create the unique name for all the gate clocks */
334316 for (i = 0; i < ARRAY_SIZE(gate_base_names); i++)
335
- gate_name[i] = cp110_unique_name(dev, syscon_node,
317
+ gate_name[i] = ap_cp_unique_name(dev, syscon_node,
336318 gate_base_names[i]);
337319
338320 for (i = 0; i < ARRAY_SIZE(gate_base_names); i++) {