.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Marvell Armada CP110 System Controller |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
---|
7 | 8 | * |
---|
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. |
---|
11 | 9 | */ |
---|
12 | 10 | |
---|
13 | 11 | /* |
---|
.. | .. |
---|
23 | 21 | * - Equal to SDIO clock |
---|
24 | 22 | * - 2/5 PLL0 |
---|
25 | 23 | * |
---|
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. |
---|
27 | 25 | */ |
---|
28 | 26 | |
---|
29 | 27 | #define pr_fmt(fmt) "cp110-system-controller: " fmt |
---|
30 | 28 | |
---|
| 29 | +#include "armada_ap_cp_helper.h" |
---|
31 | 30 | #include <linux/clk-provider.h> |
---|
32 | 31 | #include <linux/mfd/syscon.h> |
---|
33 | 32 | #include <linux/init.h> |
---|
34 | 33 | #include <linux/of.h> |
---|
35 | | -#include <linux/of_address.h> |
---|
36 | 34 | #include <linux/platform_device.h> |
---|
37 | 35 | #include <linux/regmap.h> |
---|
38 | 36 | #include <linux/slab.h> |
---|
.. | .. |
---|
59 | 57 | #define CP110_CORE_NAND 4 |
---|
60 | 58 | #define CP110_CORE_SDIO 5 |
---|
61 | 59 | |
---|
62 | | -/* A number of gatable clocks need special handling */ |
---|
| 60 | +/* A number of gateable clocks need special handling */ |
---|
63 | 61 | #define CP110_GATE_AUDIO 0 |
---|
64 | 62 | #define CP110_GATE_COMM_UNIT 1 |
---|
65 | 63 | #define CP110_GATE_NAND 2 |
---|
.. | .. |
---|
160 | 158 | { |
---|
161 | 159 | struct cp110_gate_clk *gate; |
---|
162 | 160 | struct clk_hw *hw; |
---|
163 | | - struct clk_init_data init = {}; |
---|
| 161 | + struct clk_init_data init; |
---|
164 | 162 | int ret; |
---|
165 | 163 | |
---|
166 | 164 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); |
---|
.. | .. |
---|
214 | 212 | return ERR_PTR(-EINVAL); |
---|
215 | 213 | } |
---|
216 | 214 | |
---|
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 | | - |
---|
233 | 215 | static int cp110_syscon_common_probe(struct platform_device *pdev, |
---|
234 | 216 | struct device_node *syscon_node) |
---|
235 | 217 | { |
---|
.. | .. |
---|
253 | 235 | if (ret) |
---|
254 | 236 | return ret; |
---|
255 | 237 | |
---|
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), |
---|
258 | 240 | GFP_KERNEL); |
---|
259 | 241 | if (!cp110_clk_data) |
---|
260 | 242 | return -ENOMEM; |
---|
.. | .. |
---|
263 | 245 | cp110_clk_data->num = CP110_CLK_NUM; |
---|
264 | 246 | |
---|
265 | 247 | /* 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"); |
---|
267 | 249 | hw = clk_hw_register_fixed_rate(NULL, pll0_name, NULL, 0, |
---|
268 | 250 | 1000 * 1000 * 1000); |
---|
269 | 251 | if (IS_ERR(hw)) { |
---|
.. | .. |
---|
274 | 256 | cp110_clks[CP110_CORE_PLL0] = hw; |
---|
275 | 257 | |
---|
276 | 258 | /* 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"); |
---|
278 | 260 | hw = clk_hw_register_fixed_factor(NULL, ppv2_name, pll0_name, 0, 1, 3); |
---|
279 | 261 | if (IS_ERR(hw)) { |
---|
280 | 262 | ret = PTR_ERR(hw); |
---|
.. | .. |
---|
284 | 266 | cp110_clks[CP110_CORE_PPV2] = hw; |
---|
285 | 267 | |
---|
286 | 268 | /* 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"); |
---|
288 | 270 | hw = clk_hw_register_fixed_factor(NULL, x2core_name, pll0_name, |
---|
289 | 271 | 0, 1, 2); |
---|
290 | 272 | if (IS_ERR(hw)) { |
---|
.. | .. |
---|
295 | 277 | cp110_clks[CP110_CORE_X2CORE] = hw; |
---|
296 | 278 | |
---|
297 | 279 | /* 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"); |
---|
299 | 281 | hw = clk_hw_register_fixed_factor(NULL, core_name, x2core_name, |
---|
300 | 282 | 0, 1, 2); |
---|
301 | 283 | if (IS_ERR(hw)) { |
---|
.. | .. |
---|
305 | 287 | |
---|
306 | 288 | cp110_clks[CP110_CORE_CORE] = hw; |
---|
307 | 289 | /* 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"); |
---|
309 | 291 | if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK) |
---|
310 | 292 | hw = clk_hw_register_fixed_factor(NULL, nand_name, |
---|
311 | 293 | pll0_name, 0, 2, 5); |
---|
.. | .. |
---|
320 | 302 | cp110_clks[CP110_CORE_NAND] = hw; |
---|
321 | 303 | |
---|
322 | 304 | /* 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"); |
---|
324 | 306 | hw = clk_hw_register_fixed_factor(NULL, sdio_name, |
---|
325 | 307 | pll0_name, 0, 2, 5); |
---|
326 | 308 | if (IS_ERR(hw)) { |
---|
.. | .. |
---|
332 | 314 | |
---|
333 | 315 | /* create the unique name for all the gate clocks */ |
---|
334 | 316 | 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, |
---|
336 | 318 | gate_base_names[i]); |
---|
337 | 319 | |
---|
338 | 320 | for (i = 0; i < ARRAY_SIZE(gate_base_names); i++) { |
---|