Lines Matching +full:baikal +full:- +full:t1
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
9 * Baikal-T1 CCU Dividers clock driver
12 #define pr_fmt(fmt) "bt1-ccu-div: " fmt
17 #include <linux/clk-provider.h>
18 #include <linux/reset-controller.h>
26 #include <dt-bindings/clock/bt1-ccu.h>
27 #include <dt-bindings/reset/bt1-ccu.h>
29 #include "ccu-div.h"
128 * AXI Main Interconnect (axi_main_clk) and DDR AXI-bus (axi_ddr_clk) clocks
131 * the later is clocking the AXI-bus between DDR controller and the Main
187 * APB-bus clock is marked as critical since it's a main communication bus
188 * for the SoC devices registers IO-operations.
253 for (idx = 0; idx < data->divs_num; ++idx) { in ccu_div_find_desc()
254 div = data->divs[idx]; in ccu_div_find_desc()
255 if (div && div->id == clk_id) in ccu_div_find_desc()
259 return ERR_PTR(-EINVAL); in ccu_div_find_desc()
270 for (idx = 0, map = data->rst_map; idx < data->rst_num; ++idx, ++map) { in ccu_div_reset()
271 if (map->rst_id == rst_id) in ccu_div_reset()
274 if (idx == data->rst_num) { in ccu_div_reset()
276 return -EINVAL; in ccu_div_reset()
279 div = ccu_div_find_desc(data, map->clk_id); in ccu_div_reset()
281 pr_err("Invalid clock ID %d in mapping\n", map->clk_id); in ccu_div_reset()
305 return ERR_PTR(-ENOMEM); in ccu_div_create_data()
307 data->np = np; in ccu_div_create_data()
308 if (of_device_is_compatible(np, "baikal,bt1-ccu-axi")) { in ccu_div_create_data()
309 data->divs_num = ARRAY_SIZE(axi_info); in ccu_div_create_data()
310 data->divs_info = axi_info; in ccu_div_create_data()
311 data->rst_num = ARRAY_SIZE(axi_rst_map); in ccu_div_create_data()
312 data->rst_map = axi_rst_map; in ccu_div_create_data()
313 } else if (of_device_is_compatible(np, "baikal,bt1-ccu-sys")) { in ccu_div_create_data()
314 data->divs_num = ARRAY_SIZE(sys_info); in ccu_div_create_data()
315 data->divs_info = sys_info; in ccu_div_create_data()
316 data->rst_num = ARRAY_SIZE(sys_rst_map); in ccu_div_create_data()
317 data->rst_map = sys_rst_map; in ccu_div_create_data()
321 ret = -EINVAL; in ccu_div_create_data()
325 data->divs = kcalloc(data->divs_num, sizeof(*data->divs), GFP_KERNEL); in ccu_div_create_data()
326 if (!data->divs) { in ccu_div_create_data()
327 ret = -ENOMEM; in ccu_div_create_data()
341 kfree(data->divs); in ccu_div_free_data()
348 data->sys_regs = syscon_node_to_regmap(data->np->parent); in ccu_div_find_sys_regs()
349 if (IS_ERR(data->sys_regs)) { in ccu_div_find_sys_regs()
351 of_node_full_name(data->np)); in ccu_div_find_sys_regs()
352 return PTR_ERR(data->sys_regs); in ccu_div_find_sys_regs()
365 clk_id = clkspec->args[0]; in ccu_div_of_clk_hw_get()
379 for (idx = 0; idx < data->divs_num; ++idx) { in ccu_div_clk_register()
380 const struct ccu_div_info *info = &data->divs_info[idx]; in ccu_div_clk_register()
383 init.id = info->id; in ccu_div_clk_register()
384 init.name = info->name; in ccu_div_clk_register()
385 init.parent_name = info->parent_name; in ccu_div_clk_register()
386 init.np = data->np; in ccu_div_clk_register()
387 init.type = info->type; in ccu_div_clk_register()
388 init.flags = info->flags; in ccu_div_clk_register()
389 init.features = info->features; in ccu_div_clk_register()
392 init.base = info->base; in ccu_div_clk_register()
393 init.sys_regs = data->sys_regs; in ccu_div_clk_register()
394 init.width = info->width; in ccu_div_clk_register()
396 init.base = info->base; in ccu_div_clk_register()
397 init.sys_regs = data->sys_regs; in ccu_div_clk_register()
398 init.divider = info->divider; in ccu_div_clk_register()
400 init.divider = info->divider; in ccu_div_clk_register()
403 data->divs[idx] = ccu_div_hw_register(&init); in ccu_div_clk_register()
404 if (IS_ERR(data->divs[idx])) { in ccu_div_clk_register()
405 ret = PTR_ERR(data->divs[idx]); in ccu_div_clk_register()
412 ret = of_clk_add_hw_provider(data->np, ccu_div_of_clk_hw_get, data); in ccu_div_clk_register()
415 of_node_full_name(data->np)); in ccu_div_clk_register()
422 for (--idx; idx >= 0; --idx) in ccu_div_clk_register()
423 ccu_div_hw_unregister(data->divs[idx]); in ccu_div_clk_register()
432 of_clk_del_provider(data->np); in ccu_div_clk_unregister()
434 for (idx = 0; idx < data->divs_num; ++idx) in ccu_div_clk_unregister()
435 ccu_div_hw_unregister(data->divs[idx]); in ccu_div_clk_unregister()
442 data->rcdev.ops = &ccu_div_rst_ops; in ccu_div_rst_register()
443 data->rcdev.of_node = data->np; in ccu_div_rst_register()
444 data->rcdev.nr_resets = data->rst_num; in ccu_div_rst_register()
446 ret = reset_controller_register(&data->rcdev); in ccu_div_rst_register()
449 of_node_full_name(data->np)); in ccu_div_rst_register()
484 CLK_OF_DECLARE(ccu_axi, "baikal,bt1-ccu-axi", ccu_div_init);
485 CLK_OF_DECLARE(ccu_sys, "baikal,bt1-ccu-sys", ccu_div_init);