hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/clk/clk-clps711x.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Cirrus Logic CLPS711X CLK driver
34 *
45 * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/clk-provider.h>
....@@ -32,11 +28,13 @@
3228 { .val = 1, .div = 8, },
3329 { .val = 2, .div = 2, },
3430 { .val = 3, .div = 1, },
31
+ { /* sentinel */ }
3532 };
3633
3734 static const struct clk_div_table timer_div_table[] = {
3835 { .val = 0, .div = 256, },
3936 { .val = 1, .div = 1, },
37
+ { /* sentinel */ }
4038 };
4139
4240 struct clps711x_clk {
....@@ -44,21 +42,21 @@
4442 struct clk_hw_onecell_data clk_data;
4543 };
4644
47
-static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base,
48
- u32 fref)
45
+static void __init clps711x_clk_init_dt(struct device_node *np)
4946 {
50
- u32 tmp, f_cpu, f_pll, f_bus, f_tim, f_pwm, f_spi;
47
+ u32 tmp, f_cpu, f_pll, f_bus, f_tim, f_pwm, f_spi, fref = 0;
5148 struct clps711x_clk *clps711x_clk;
52
- unsigned i;
49
+ void __iomem *base;
5350
54
- if (!base)
55
- return ERR_PTR(-ENOMEM);
51
+ WARN_ON(of_property_read_u32(np, "startup-frequency", &fref));
52
+
53
+ base = of_iomap(np, 0);
54
+ BUG_ON(!base);
5655
5756 clps711x_clk = kzalloc(struct_size(clps711x_clk, clk_data.hws,
5857 CLPS711X_CLK_MAX),
5958 GFP_KERNEL);
60
- if (!clps711x_clk)
61
- return ERR_PTR(-ENOMEM);
59
+ BUG_ON(!clps711x_clk);
6260
6361 spin_lock_init(&clps711x_clk->lock);
6462
....@@ -137,52 +135,13 @@
137135 clk_hw_register_fixed_factor(NULL, "uart", "bus", 0, 1, 10);
138136 clps711x_clk->clk_data.hws[CLPS711X_CLK_TICK] =
139137 clk_hw_register_fixed_rate(NULL, "tick", NULL, 0, 64);
140
- for (i = 0; i < CLPS711X_CLK_MAX; i++)
141
- if (IS_ERR(clps711x_clk->clk_data.hws[i]))
138
+ for (tmp = 0; tmp < CLPS711X_CLK_MAX; tmp++)
139
+ if (IS_ERR(clps711x_clk->clk_data.hws[tmp]))
142140 pr_err("clk %i: register failed with %ld\n",
143
- i, PTR_ERR(clps711x_clk->clk_data.hws[i]));
144
-
145
- return clps711x_clk;
146
-}
147
-
148
-void __init clps711x_clk_init(void __iomem *base)
149
-{
150
- struct clps711x_clk *clps711x_clk;
151
-
152
- clps711x_clk = _clps711x_clk_init(base, 73728000);
153
-
154
- BUG_ON(IS_ERR(clps711x_clk));
155
-
156
- /* Clocksource */
157
- clk_hw_register_clkdev(clps711x_clk->clk_data.hws[CLPS711X_CLK_TIMER1],
158
- NULL, "clps711x-timer.0");
159
- clk_hw_register_clkdev(clps711x_clk->clk_data.hws[CLPS711X_CLK_TIMER2],
160
- NULL, "clps711x-timer.1");
161
-
162
- /* Drivers */
163
- clk_hw_register_clkdev(clps711x_clk->clk_data.hws[CLPS711X_CLK_PWM],
164
- NULL, "clps711x-pwm");
165
- clk_hw_register_clkdev(clps711x_clk->clk_data.hws[CLPS711X_CLK_UART],
166
- NULL, "clps711x-uart.0");
167
- clk_hw_register_clkdev(clps711x_clk->clk_data.hws[CLPS711X_CLK_UART],
168
- NULL, "clps711x-uart.1");
169
-}
170
-
171
-#ifdef CONFIG_OF
172
-static void __init clps711x_clk_init_dt(struct device_node *np)
173
-{
174
- void __iomem *base = of_iomap(np, 0);
175
- struct clps711x_clk *clps711x_clk;
176
- u32 fref = 0;
177
-
178
- WARN_ON(of_property_read_u32(np, "startup-frequency", &fref));
179
-
180
- clps711x_clk = _clps711x_clk_init(base, fref);
181
- BUG_ON(IS_ERR(clps711x_clk));
141
+ tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp]));
182142
183143 clps711x_clk->clk_data.num = CLPS711X_CLK_MAX;
184144 of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
185145 &clps711x_clk->clk_data);
186146 }
187147 CLK_OF_DECLARE(clps711x, "cirrus,ep7209-clk", clps711x_clk_init_dt);
188
-#endif