Lines Matching +full:parent +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Tero Kristo <t-[email protected]>
11 #include <linux/clk.h>
12 #include <linux/clk-provider.h>
14 #include <linux/clk/ti.h>
45 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_writel()
47 if (reg->ptr) in clk_memmap_writel()
48 writel_relaxed(val, reg->ptr); in clk_memmap_writel()
49 else if (io->regmap) in clk_memmap_writel()
50 regmap_write(io->regmap, reg->offset, val); in clk_memmap_writel()
52 writel_relaxed(val, io->mem + reg->offset); in clk_memmap_writel()
67 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_rmw()
69 if (reg->ptr) { in clk_memmap_rmw()
70 _clk_rmw(val, mask, reg->ptr); in clk_memmap_rmw()
71 } else if (io->regmap) { in clk_memmap_rmw()
72 regmap_update_bits(io->regmap, reg->offset, mask, val); in clk_memmap_rmw()
74 _clk_rmw(val, mask, io->mem + reg->offset); in clk_memmap_rmw()
81 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_readl()
83 if (reg->ptr) in clk_memmap_readl()
84 val = readl_relaxed(reg->ptr); in clk_memmap_readl()
85 else if (io->regmap) in clk_memmap_readl()
86 regmap_read(io->regmap, reg->offset, &val); in clk_memmap_readl()
88 val = readl_relaxed(io->mem + reg->offset); in clk_memmap_readl()
94 * ti_clk_setup_ll_ops - setup low level clock operations
99 * specific code. Returns 0 on success, -EBUSY if ll_ops have been
106 return -EBUSY; in ti_clk_setup_ll_ops()
110 ops->clk_readl = clk_memmap_readl; in ti_clk_setup_ll_ops()
111 ops->clk_writel = clk_memmap_writel; in ti_clk_setup_ll_ops()
112 ops->clk_rmw = clk_memmap_rmw; in ti_clk_setup_ll_ops()
118 * Eventually we could standardize to using '_' for clk-*.c files to follow the
130 tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); in ti_find_clock_provider()
139 /* Node named "clock" with "clock-output-names" */ in ti_find_clock_provider()
141 if (of_property_read_string_index(np, "clock-output-names", in ti_find_clock_provider()
162 * ti_dt_clocks_register - register DT alias clocks during boot
165 * Register alias or non-standard DT clock entries during boot. By
166 * default, DT clocks are found based on their clock-output-names
168 * additional con-id / dev-id -> clock mapping is required, use this
174 struct device_node *node, *parent, *child; in ti_dt_clocks_register() local
175 struct clk *clk; in ti_dt_clocks_register() local
187 compat_mode = ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT; in ti_dt_clocks_register()
189 for (c = oclks; c->node_name != NULL; c++) { in ti_dt_clocks_register()
190 strcpy(buf, c->node_name); in ti_dt_clocks_register()
199 c->node_name); in ti_dt_clocks_register()
213 parent = node; in ti_dt_clocks_register()
214 child = of_get_child_by_name(parent, "clock"); in ti_dt_clocks_register()
216 child = of_get_child_by_name(parent, "clk"); in ti_dt_clocks_register()
218 of_node_put(parent); in ti_dt_clocks_register()
229 c->node_name, i, tags[i]); in ti_dt_clocks_register()
234 clk = of_clk_get_from_provider(&clkspec); in ti_dt_clocks_register()
236 if (!IS_ERR(clk)) { in ti_dt_clocks_register()
237 c->lk.clk = clk; in ti_dt_clocks_register()
238 clkdev_add(&c->lk); in ti_dt_clocks_register()
257 c->node_name, PTR_ERR(clk)); in ti_dt_clocks_register()
272 * ti_clk_retry_init - retries a failed clock init at later phase
288 return -ENOMEM; in ti_clk_retry_init()
290 retry->node = node; in ti_clk_retry_init()
291 retry->func = func; in ti_clk_retry_init()
292 retry->user = user; in ti_clk_retry_init()
293 list_add(&retry->link, &retry_list); in ti_clk_retry_init()
299 * ti_clk_get_reg_addr - get register address for a clock register
316 if (clocks_node_ptr[i] == node->parent) in ti_clk_get_reg_addr()
318 if (clocks_node_ptr[i] == node->parent->parent) in ti_clk_get_reg_addr()
323 pr_err("clk-provider not found for %pOFn!\n", node); in ti_clk_get_reg_addr()
324 return -ENOENT; in ti_clk_get_reg_addr()
327 reg->index = i; in ti_clk_get_reg_addr()
329 if (of_device_is_compatible(node->parent, "ti,clksel")) { in ti_clk_get_reg_addr()
330 err = of_property_read_u32_index(node->parent, "reg", index, &clksel_addr); in ti_clk_get_reg_addr()
332 pr_err("%pOFn parent clksel must have reg[%d]!\n", node, index); in ti_clk_get_reg_addr()
333 return -EINVAL; in ti_clk_get_reg_addr()
340 /* Legacy clksel with no reg and a possible ti,bit-shift property */ in ti_clk_get_reg_addr()
341 reg->offset = clksel_addr; in ti_clk_get_reg_addr()
342 reg->bit = ti_clk_get_legacy_bit_shift(node); in ti_clk_get_reg_addr()
343 reg->ptr = NULL; in ti_clk_get_reg_addr()
350 reg->offset = clksel_addr; in ti_clk_get_reg_addr()
351 reg->bit = val; in ti_clk_get_reg_addr()
352 reg->ptr = NULL; in ti_clk_get_reg_addr()
356 /* Other clocks that may or may not have ti,bit-shift property */ in ti_clk_get_reg_addr()
357 reg->offset = val; in ti_clk_get_reg_addr()
358 reg->bit = ti_clk_get_legacy_bit_shift(node); in ti_clk_get_reg_addr()
359 reg->ptr = NULL; in ti_clk_get_reg_addr()
365 * ti_clk_get_legacy_bit_shift - get bit shift for a clock register
368 * Gets the clock register bit shift using the legacy ti,bit-shift
378 err = of_property_read_u32(node, "ti,bit-shift", &val); in ti_clk_get_legacy_bit_shift()
394 ti_clk_ll_ops->clk_rmw(latch, latch, reg); in ti_clk_latch()
395 ti_clk_ll_ops->clk_rmw(0, latch, reg); in ti_clk_latch()
396 ti_clk_ll_ops->clk_readl(reg); /* OCP barrier */ in ti_clk_latch()
400 * omap2_clk_provider_init - init master clock provider
401 * @parent: master node
413 int __init omap2_clk_provider_init(struct device_node *parent, int index, in omap2_clk_provider_init() argument
419 /* get clocks for this parent */ in omap2_clk_provider_init()
420 clocks = of_get_child_by_name(parent, "clocks"); in omap2_clk_provider_init()
422 pr_err("%pOFn missing 'clocks' child node.\n", parent); in omap2_clk_provider_init()
423 return -EINVAL; in omap2_clk_provider_init()
431 return -ENOMEM; in omap2_clk_provider_init()
433 io->regmap = syscon; in omap2_clk_provider_init()
434 io->mem = mem; in omap2_clk_provider_init()
442 * omap2_clk_legacy_provider_init - initialize a legacy clock provider
454 io->mem = mem; in omap2_clk_legacy_provider_init()
460 * ti_dt_clk_init_retry_clks - init clocks from the retry list
463 * reasons being missing parent node(s) during earlier init. This
465 * parent clocks ready during init.
475 pr_debug("retry-init: %pOFn\n", retry->node); in ti_dt_clk_init_retry_clks()
476 retry->func(retry->user, retry->node); in ti_dt_clk_init_retry_clks()
477 list_del(&retry->link); in ti_dt_clk_init_retry_clks()
480 retries--; in ti_dt_clk_init_retry_clks()
485 { .compatible = "fixed-clock" },
486 { .compatible = "fixed-factor-clock" },
491 * ti_dt_clk_name - init clock name from first output name or node name
494 * Use the first clock-output-name for the clock name if found. Fall back
501 if (!of_property_read_string_index(np, "clock-output-names", 0, in ti_dt_clk_name()
505 return np->name; in ti_dt_clk_name()
509 * ti_clk_add_aliases - setup clock aliases
516 struct clk *clk; in ti_clk_add_aliases() local
522 clk = of_clk_get_from_provider(&clkspec); in ti_clk_add_aliases()
524 ti_clk_add_alias(clk, ti_dt_clk_name(np)); in ti_clk_add_aliases()
529 * ti_clk_setup_features - setup clock features flags
541 * ti_clk_get_features - get clock driver features flags
552 * omap2_clk_enable_init_clocks - prepare & enable a list of clocks
563 struct clk *init_clk; in omap2_clk_enable_init_clocks()
576 * ti_clk_add_alias - add a clock alias for a TI clock
577 * @clk: clock handle to create alias for
584 int ti_clk_add_alias(struct clk *clk, const char *con) in ti_clk_add_alias() argument
588 if (!clk) in ti_clk_add_alias()
591 if (IS_ERR(clk)) in ti_clk_add_alias()
592 return PTR_ERR(clk); in ti_clk_add_alias()
596 return -ENOMEM; in ti_clk_add_alias()
598 cl->con_id = con; in ti_clk_add_alias()
599 cl->clk = clk; in ti_clk_add_alias()
607 * of_ti_clk_register - register a TI clock to the common clock framework
616 struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, in of_ti_clk_register()
619 struct clk *clk; in of_ti_clk_register() local
626 clk = hw->clk; in of_ti_clk_register()
627 ret = ti_clk_add_alias(clk, con); in of_ti_clk_register()
629 clk_unregister(clk); in of_ti_clk_register()
633 return clk; in of_ti_clk_register()
637 * of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
647 struct clk *of_ti_clk_register_omap_hw(struct device_node *node, in of_ti_clk_register_omap_hw()
650 struct clk *clk; in of_ti_clk_register_omap_hw() local
653 clk = of_ti_clk_register(node, hw, con); in of_ti_clk_register_omap_hw()
654 if (IS_ERR(clk)) in of_ti_clk_register_omap_hw()
655 return clk; in of_ti_clk_register_omap_hw()
659 list_add(&oclk->node, &clk_hw_omap_clocks); in of_ti_clk_register_omap_hw()
661 return clk; in of_ti_clk_register_omap_hw()
665 * omap2_clk_for_each - call function for each registered clk_hw_omap
670 * failure. If @fn returns non-zero, the iteration across clocks
671 * will stop and the non-zero return value will be passed to the
689 * omap2_clk_is_hw_omap - check if the provided clk_hw is OMAP clock
700 if (&oclk->hw == hw) in omap2_clk_is_hw_omap()