Lines Matching +full:clock +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI clock support
7 * Tero Kristo <t-kristo@ti.com>
12 #include <linux/clk-provider.h>
25 #include "clock.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
95 * @ops: low level clock ops descriptor
97 * Sets up low level clock operations for TI clock driver. This is used
98 * to provide various callbacks for the clock driver towards platform
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
122 const char *name) in ti_find_clock_provider() argument
130 tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); in ti_find_clock_provider()
134 /* Ignore a possible address for the node name */ 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()
157 /* Fall back to using old node name base provider name */ 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
167 * property, or the clock node name for legacy cases. If any
168 * additional con-id / dev-id -> clock mapping is required, use this
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()
214 child = of_get_child_by_name(parent, "clock"); in ti_dt_clocks_register()
229 c->node_name, i, tags[i]); 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()
256 pr_warn("failed to lookup clock node %s, ret=%ld\n", 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
273 * @node: device node for the clock
275 * @func: init function to be called for the clock
277 * Adds a failed clock init to the retry list. The retry list is parsed
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
300 * @node: device node for the clock
301 * @index: register index from the clock node
304 * Builds clock register address from device tree information, and returns
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()
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()
348 /* Updated clksel clock with a proper reg property */ 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
366 * @node: device node for the clock
368 * Gets the clock register bit shift using the legacy ti,bit-shift
369 * property. Only needed for legacy clock, and can be eventually
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
403 * @syscon: syscon regmap pointer for accessing clock registers
404 * @mem: iomem pointer for the clock provider memory area, only used if
407 * Initializes a master clock IP block. This basically sets up the
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
443 * @index: index for the clock provider
444 * @mem: iomem pointer for the clock provider memory area
446 * Initializes a legacy clock provider memory mapping.
457 io->mem = mem; in omap2_clk_legacy_provider_init()
463 * ti_dt_clk_init_retry_clks - init clocks from the retry list
478 pr_debug("retry-init: %pOFn\n", retry->node); in ti_dt_clk_init_retry_clks()
479 retry->func(retry->user, retry->node); in ti_dt_clk_init_retry_clks()
480 list_del(&retry->link); in ti_dt_clk_init_retry_clks()
483 retries--; in ti_dt_clk_init_retry_clks()
488 { .compatible = "fixed-clock" },
489 { .compatible = "fixed-factor-clock" },
494 * ti_dt_clk_name - init clock name from first output name or node name
497 * Use the first clock-output-name for the clock name if found. Fall back
498 * to legacy naming based on node name.
502 const char *name; in ti_dt_clk_name() local
504 if (!of_property_read_string_index(np, "clock-output-names", 0, in ti_dt_clk_name()
505 &name)) in ti_dt_clk_name()
506 return name; in ti_dt_clk_name()
508 return np->name; in ti_dt_clk_name()
512 * ti_clk_add_aliases - setup clock aliases
514 * Sets up any missing clock aliases. No return value.
532 * ti_clk_setup_features - setup clock features flags
535 * Initializes the clock driver features flags based on platform
544 * ti_clk_get_features - get clock driver features flags
546 * Get TI clock driver features description. Returns a pointer
555 * omap2_clk_enable_init_clocks - prepare & enable a list of clocks
556 * @clk_names: ptr to an array of strings of clock names to enable
557 * @num_clocks: number of clock names in @clk_names
571 if (WARN(IS_ERR(init_clk), "could not find init clock %s\n", in omap2_clk_enable_init_clocks()
579 * ti_clk_add_alias - add a clock alias for a TI clock
580 * @clk: clock handle to create alias for
581 * @con: connection ID for this clock
583 * Creates a clock alias for a TI clock. Allocates the clock lookup entry
599 return -ENOMEM; in ti_clk_add_alias()
601 cl->con_id = con; in ti_clk_add_alias()
602 cl->clk = clk; in ti_clk_add_alias()
610 * of_ti_clk_register - register a TI clock to the common clock framework
611 * @node: device node for this clock
612 * @hw: hardware clock handle
613 * @con: connection ID for this clock
615 * Registers a TI clock to the common clock framework, and adds a clock
616 * alias for it. Returns a handle to the registered clock if successful,
629 clk = hw->clk; in of_ti_clk_register()
640 * of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
641 * @node: device node for this clock
642 * @hw: hardware clock handle
643 * @con: connection ID for this clock
645 * Registers a clk_hw_omap clock to the clock framewor, adds a clock alias
647 * Returns a handle to the registered clock if successful, ERR_PTR value
662 list_add(&oclk->node, &clk_hw_omap_clocks); in of_ti_clk_register_omap_hw()
668 * omap2_clk_for_each - call function for each registered clk_hw_omap
673 * failure. If @fn returns non-zero, the iteration across clocks
674 * will stop and the non-zero return value will be passed to the
692 * omap2_clk_is_hw_omap - check if the provided clk_hw is OMAP clock
693 * @hw: clk_hw to check if it is an omap clock or not
695 * Checks if the provided clk_hw is OMAP clock or not. Returns true if
703 if (&oclk->hw == hw) in omap2_clk_is_hw_omap()