hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/clk/at91/clk-main.c
....@@ -1,18 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
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 as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
94 */
105
116 #include <linux/clk-provider.h>
127 #include <linux/clkdev.h>
138 #include <linux/clk/at91_pmc.h>
149 #include <linux/delay.h>
15
-#include <linux/of.h>
1610 #include <linux/mfd/syscon.h>
1711 #include <linux/regmap.h>
1812
....@@ -132,14 +126,14 @@
132126 .is_prepared = clk_main_osc_is_prepared,
133127 };
134128
135
-static struct clk_hw * __init
129
+struct clk_hw * __init
136130 at91_clk_register_main_osc(struct regmap *regmap,
137131 const char *name,
138132 const char *parent_name,
139133 bool bypass)
140134 {
141135 struct clk_main_osc *osc;
142
- struct clk_init_data init = {};
136
+ struct clk_init_data init;
143137 struct clk_hw *hw;
144138 int ret;
145139
....@@ -175,38 +169,13 @@
175169 return hw;
176170 }
177171
178
-static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
179
-{
180
- struct clk_hw *hw;
181
- const char *name = np->name;
182
- const char *parent_name;
183
- struct regmap *regmap;
184
- bool bypass;
185
-
186
- of_property_read_string(np, "clock-output-names", &name);
187
- bypass = of_property_read_bool(np, "atmel,osc-bypass");
188
- parent_name = of_clk_get_parent_name(np, 0);
189
-
190
- regmap = syscon_node_to_regmap(of_get_parent(np));
191
- if (IS_ERR(regmap))
192
- return;
193
-
194
- hw = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
195
- if (IS_ERR(hw))
196
- return;
197
-
198
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
199
-}
200
-CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc",
201
- of_at91rm9200_clk_main_osc_setup);
202
-
203172 static bool clk_main_rc_osc_ready(struct regmap *regmap)
204173 {
205174 unsigned int status;
206175
207176 regmap_read(regmap, AT91_PMC_SR, &status);
208177
209
- return status & AT91_PMC_MOSCRCS;
178
+ return !!(status & AT91_PMC_MOSCRCS);
210179 }
211180
212181 static int clk_main_rc_osc_prepare(struct clk_hw *hw)
....@@ -279,13 +248,13 @@
279248 .recalc_accuracy = clk_main_rc_osc_recalc_accuracy,
280249 };
281250
282
-static struct clk_hw * __init
251
+struct clk_hw * __init
283252 at91_clk_register_main_rc_osc(struct regmap *regmap,
284253 const char *name,
285254 u32 frequency, u32 accuracy)
286255 {
287256 struct clk_main_rc_osc *osc;
288
- struct clk_init_data init = {};
257
+ struct clk_init_data init;
289258 struct clk_hw *hw;
290259 int ret;
291260
....@@ -316,32 +285,6 @@
316285
317286 return hw;
318287 }
319
-
320
-static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
321
-{
322
- struct clk_hw *hw;
323
- u32 frequency = 0;
324
- u32 accuracy = 0;
325
- const char *name = np->name;
326
- struct regmap *regmap;
327
-
328
- of_property_read_string(np, "clock-output-names", &name);
329
- of_property_read_u32(np, "clock-frequency", &frequency);
330
- of_property_read_u32(np, "clock-accuracy", &accuracy);
331
-
332
- regmap = syscon_node_to_regmap(of_get_parent(np));
333
- if (IS_ERR(regmap))
334
- return;
335
-
336
- hw = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy);
337
- if (IS_ERR(hw))
338
- return;
339
-
340
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
341
-}
342
-CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc",
343
- of_at91sam9x5_clk_main_rc_osc_setup);
344
-
345288
346289 static int clk_main_probe_frequency(struct regmap *regmap)
347290 {
....@@ -393,7 +336,7 @@
393336
394337 regmap_read(clkmain->regmap, AT91_CKGR_MCFR, &status);
395338
396
- return status & AT91_PMC_MAINRDY ? 1 : 0;
339
+ return !!(status & AT91_PMC_MAINRDY);
397340 }
398341
399342 static unsigned long clk_rm9200_main_recalc_rate(struct clk_hw *hw,
....@@ -410,13 +353,13 @@
410353 .recalc_rate = clk_rm9200_main_recalc_rate,
411354 };
412355
413
-static struct clk_hw * __init
356
+struct clk_hw * __init
414357 at91_clk_register_rm9200_main(struct regmap *regmap,
415358 const char *name,
416359 const char *parent_name)
417360 {
418361 struct clk_rm9200_main *clkmain;
419
- struct clk_init_data init = {};
362
+ struct clk_init_data init;
420363 struct clk_hw *hw;
421364 int ret;
422365
....@@ -449,36 +392,13 @@
449392 return hw;
450393 }
451394
452
-static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
453
-{
454
- struct clk_hw *hw;
455
- const char *parent_name;
456
- const char *name = np->name;
457
- struct regmap *regmap;
458
-
459
- parent_name = of_clk_get_parent_name(np, 0);
460
- of_property_read_string(np, "clock-output-names", &name);
461
-
462
- regmap = syscon_node_to_regmap(of_get_parent(np));
463
- if (IS_ERR(regmap))
464
- return;
465
-
466
- hw = at91_clk_register_rm9200_main(regmap, name, parent_name);
467
- if (IS_ERR(hw))
468
- return;
469
-
470
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
471
-}
472
-CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main",
473
- of_at91rm9200_clk_main_setup);
474
-
475395 static inline bool clk_sam9x5_main_ready(struct regmap *regmap)
476396 {
477397 unsigned int status;
478398
479399 regmap_read(regmap, AT91_PMC_SR, &status);
480400
481
- return status & AT91_PMC_MOSCSELS ? 1 : 0;
401
+ return !!(status & AT91_PMC_MOSCSELS);
482402 }
483403
484404 static int clk_sam9x5_main_prepare(struct clk_hw *hw)
....@@ -553,14 +473,14 @@
553473 .get_parent = clk_sam9x5_main_get_parent,
554474 };
555475
556
-static struct clk_hw * __init
476
+struct clk_hw * __init
557477 at91_clk_register_sam9x5_main(struct regmap *regmap,
558478 const char *name,
559479 const char **parent_names,
560480 int num_parents)
561481 {
562482 struct clk_sam9x5_main *clkmain;
563
- struct clk_init_data init = {};
483
+ struct clk_init_data init;
564484 unsigned int status;
565485 struct clk_hw *hw;
566486 int ret;
....@@ -595,32 +515,3 @@
595515
596516 return hw;
597517 }
598
-
599
-static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
600
-{
601
- struct clk_hw *hw;
602
- const char *parent_names[2];
603
- unsigned int num_parents;
604
- const char *name = np->name;
605
- struct regmap *regmap;
606
-
607
- num_parents = of_clk_get_parent_count(np);
608
- if (num_parents == 0 || num_parents > 2)
609
- return;
610
-
611
- of_clk_parent_fill(np, parent_names, num_parents);
612
- regmap = syscon_node_to_regmap(of_get_parent(np));
613
- if (IS_ERR(regmap))
614
- return;
615
-
616
- of_property_read_string(np, "clock-output-names", &name);
617
-
618
- hw = at91_clk_register_sam9x5_main(regmap, name, parent_names,
619
- num_parents);
620
- if (IS_ERR(hw))
621
- return;
622
-
623
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
624
-}
625
-CLK_OF_DECLARE(at91sam9x5_clk_main, "atmel,at91sam9x5-clk-main",
626
- of_at91sam9x5_clk_main_setup);