Lines Matching +full:bt1 +full:- +full:ccu +full:- +full:sys

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Baikal-T1 CCU Dividers clock driver
12 #define pr_fmt(fmt) "bt1-ccu-div: " fmt
18 #include <linux/clk-provider.h>
19 #include <linux/reset-controller.h>
26 #include <dt-bindings/clock/bt1-ccu.h>
28 #include "ccu-div.h"
29 #include "ccu-rst.h"
124 * AXI Main Interconnect (axi_main_clk) and DDR AXI-bus (axi_ddr_clk) clocks
127 * the later is clocking the AXI-bus between DDR controller and the Main
169 * APB-bus clock is marked as critical since it's a main communication bus
170 * for the SoC devices registers IO-operations.
234 struct device_node *np = data->np; in ccu_div_set_data()
236 if (of_device_is_compatible(np, "baikal,bt1-ccu-axi")) in ccu_div_set_data()
238 else if (of_device_is_compatible(np, "baikal,bt1-ccu-sys")) in ccu_div_set_data()
246 if (of_device_is_compatible(np, "baikal,bt1-ccu-axi")) in ccu_div_get_data()
248 else if (of_device_is_compatible(np, "baikal,bt1-ccu-sys")) in ccu_div_get_data()
261 for (idx = 0; idx < data->divs_num; ++idx) { in ccu_div_find_desc()
262 if (data->divs_info[idx].id == clk_id) in ccu_div_find_desc()
263 return data->divs[idx]; in ccu_div_find_desc()
266 return ERR_PTR(-EINVAL); in ccu_div_find_desc()
276 return ERR_PTR(-ENOMEM); in ccu_div_create_data()
278 data->np = np; in ccu_div_create_data()
279 if (of_device_is_compatible(np, "baikal,bt1-ccu-axi")) { in ccu_div_create_data()
280 data->divs_num = ARRAY_SIZE(axi_info); in ccu_div_create_data()
281 data->divs_info = axi_info; in ccu_div_create_data()
282 } else if (of_device_is_compatible(np, "baikal,bt1-ccu-sys")) { in ccu_div_create_data()
283 data->divs_num = ARRAY_SIZE(sys_info); in ccu_div_create_data()
284 data->divs_info = sys_info; in ccu_div_create_data()
288 ret = -EINVAL; in ccu_div_create_data()
292 data->divs = kcalloc(data->divs_num, sizeof(*data->divs), GFP_KERNEL); in ccu_div_create_data()
293 if (!data->divs) { in ccu_div_create_data()
294 ret = -ENOMEM; in ccu_div_create_data()
308 kfree(data->divs); in ccu_div_free_data()
315 data->sys_regs = syscon_node_to_regmap(data->np->parent); in ccu_div_find_sys_regs()
316 if (IS_ERR(data->sys_regs)) { in ccu_div_find_sys_regs()
318 of_node_full_name(data->np)); in ccu_div_find_sys_regs()
319 return PTR_ERR(data->sys_regs); in ccu_div_find_sys_regs()
332 clk_id = clkspec->args[0]; in ccu_div_of_clk_hw_get()
335 if (div != ERR_PTR(-EPROBE_DEFER)) in ccu_div_of_clk_hw_get()
348 for (idx = 0; idx < data->divs_num; ++idx) { in ccu_div_clk_register()
349 const struct ccu_div_info *info = &data->divs_info[idx]; in ccu_div_clk_register()
352 if (!!(info->features & CCU_DIV_BASIC) ^ defer) { in ccu_div_clk_register()
353 if (!data->divs[idx]) in ccu_div_clk_register()
354 data->divs[idx] = ERR_PTR(-EPROBE_DEFER); in ccu_div_clk_register()
359 init.id = info->id; in ccu_div_clk_register()
360 init.name = info->name; in ccu_div_clk_register()
361 init.parent_name = info->parent_name; in ccu_div_clk_register()
362 init.np = data->np; in ccu_div_clk_register()
363 init.type = info->type; in ccu_div_clk_register()
364 init.flags = info->flags; in ccu_div_clk_register()
365 init.features = info->features; in ccu_div_clk_register()
368 init.base = info->base; in ccu_div_clk_register()
369 init.sys_regs = data->sys_regs; in ccu_div_clk_register()
370 init.width = info->width; in ccu_div_clk_register()
372 init.base = info->base; in ccu_div_clk_register()
373 init.sys_regs = data->sys_regs; in ccu_div_clk_register()
374 init.divider = info->divider; in ccu_div_clk_register()
376 init.base = info->base; in ccu_div_clk_register()
377 init.sys_regs = data->sys_regs; in ccu_div_clk_register()
379 init.divider = info->divider; in ccu_div_clk_register()
382 data->divs[idx] = ccu_div_hw_register(&init); in ccu_div_clk_register()
383 if (IS_ERR(data->divs[idx])) { in ccu_div_clk_register()
384 ret = PTR_ERR(data->divs[idx]); in ccu_div_clk_register()
394 for (--idx; idx >= 0; --idx) { in ccu_div_clk_register()
395 if (!!(data->divs_info[idx].features & CCU_DIV_BASIC) ^ defer) in ccu_div_clk_register()
398 ccu_div_hw_unregister(data->divs[idx]); in ccu_div_clk_register()
409 for (idx = 0; idx < data->divs_num; ++idx) { in ccu_div_clk_unregister()
410 if (!!(data->divs_info[idx].features & CCU_DIV_BASIC) ^ defer) in ccu_div_clk_unregister()
413 ccu_div_hw_unregister(data->divs[idx]); in ccu_div_clk_unregister()
421 ret = of_clk_add_hw_provider(data->np, ccu_div_of_clk_hw_get, data); in ccu_div_of_register()
424 of_node_full_name(data->np)); in ccu_div_of_register()
434 init.sys_regs = data->sys_regs; in ccu_div_rst_register()
435 init.np = data->np; in ccu_div_rst_register()
437 data->rsts = ccu_rst_hw_register(&init); in ccu_div_rst_register()
438 if (IS_ERR(data->rsts)) { in ccu_div_rst_register()
440 of_node_full_name(data->np)); in ccu_div_rst_register()
441 return PTR_ERR(data->rsts); in ccu_div_rst_register()
452 data = ccu_div_get_data(dev_of_node(&pdev->dev)); in ccu_div_probe()
454 return -EINVAL; in ccu_div_probe()
473 { .compatible = "baikal,bt1-ccu-axi" },
474 { .compatible = "baikal,bt1-ccu-sys" },
481 .name = "clk-ccu-div",
519 CLK_OF_DECLARE_DRIVER(ccu_axi, "baikal,bt1-ccu-axi", ccu_div_init);
520 CLK_OF_DECLARE_DRIVER(ccu_sys, "baikal,bt1-ccu-sys", ccu_div_init);