Lines Matching +full:clock +full:- +full:output +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI clock support
7 * Tero Kristo <t-kristo@ti.com>
11 #include <linux/clk-provider.h>
23 #include "clock.h"
43 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_writel()
45 if (reg->ptr) in clk_memmap_writel()
46 writel_relaxed(val, reg->ptr); in clk_memmap_writel()
47 else if (io->regmap) in clk_memmap_writel()
48 regmap_write(io->regmap, reg->offset, val); in clk_memmap_writel()
50 writel_relaxed(val, io->mem + reg->offset); in clk_memmap_writel()
65 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_rmw()
67 if (reg->ptr) { in clk_memmap_rmw()
68 _clk_rmw(val, mask, reg->ptr); in clk_memmap_rmw()
69 } else if (io->regmap) { in clk_memmap_rmw()
70 regmap_update_bits(io->regmap, reg->offset, mask, val); in clk_memmap_rmw()
72 _clk_rmw(val, mask, io->mem + reg->offset); in clk_memmap_rmw()
79 struct clk_iomap *io = clk_memmaps[reg->index]; in clk_memmap_readl()
81 if (reg->ptr) in clk_memmap_readl()
82 val = readl_relaxed(reg->ptr); in clk_memmap_readl()
83 else if (io->regmap) in clk_memmap_readl()
84 regmap_read(io->regmap, reg->offset, &val); in clk_memmap_readl()
86 val = readl_relaxed(io->mem + reg->offset); in clk_memmap_readl()
92 * ti_clk_setup_ll_ops - setup low level clock operations
93 * @ops: low level clock ops descriptor
95 * Sets up low level clock operations for TI clock driver. This is used
96 * to provide various callbacks for the clock driver towards platform
97 * specific code. Returns 0 on success, -EBUSY if ll_ops have been
104 return -EBUSY; in ti_clk_setup_ll_ops()
108 ops->clk_readl = clk_memmap_readl; in ti_clk_setup_ll_ops()
109 ops->clk_writel = clk_memmap_writel; in ti_clk_setup_ll_ops()
110 ops->clk_rmw = clk_memmap_rmw; in ti_clk_setup_ll_ops()
116 * Eventually we could standardize to using '_' for clk-*.c files to follow the
117 * TRM naming and leave out the tmp name here.
120 const char *name) in ti_find_clock_provider() argument
127 tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); in ti_find_clock_provider()
131 /* Node named "clock" with "clock-output-names" */ in ti_find_clock_provider()
133 if (of_property_read_string_index(np, "clock-output-names", in ti_find_clock_provider()
150 /* Fall back to using old node name base provider name */ in ti_find_clock_provider()
151 return of_find_node_by_name(from, name); in ti_find_clock_provider()
155 * ti_dt_clocks_register - register DT alias clocks during boot
158 * Register alias or non-standard DT clock entries during boot. By
159 * default, DT clocks are found based on their clock-output-names
160 * property, or the clock node name for legacy cases. If any
161 * additional con-id / dev-id -> clock mapping is required, use this
180 compat_mode = ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT; in ti_dt_clocks_register()
182 for (c = oclks; c->node_name != NULL; c++) { in ti_dt_clocks_register()
183 strcpy(buf, c->node_name); in ti_dt_clocks_register()
192 c->node_name); in ti_dt_clocks_register()
207 child = of_get_child_by_name(parent, "clock"); in ti_dt_clocks_register()
222 c->node_name, i, tags[i]); in ti_dt_clocks_register()
230 c->lk.clk = clk; in ti_dt_clocks_register()
231 clkdev_add(&c->lk); in ti_dt_clocks_register()
249 pr_warn("failed to lookup clock node %s, ret=%ld\n", in ti_dt_clocks_register()
250 c->node_name, PTR_ERR(clk)); in ti_dt_clocks_register()
265 * ti_clk_retry_init - retries a failed clock init at later phase
266 * @node: device node for the clock
268 * @func: init function to be called for the clock
270 * Adds a failed clock init to the retry list. The retry list is parsed
281 return -ENOMEM; in ti_clk_retry_init()
283 retry->node = node; in ti_clk_retry_init()
284 retry->func = func; in ti_clk_retry_init()
285 retry->user = user; in ti_clk_retry_init()
286 list_add(&retry->link, &retry_list); in ti_clk_retry_init()
292 * ti_clk_get_reg_addr - get register address for a clock register
293 * @node: device node for the clock
294 * @index: register index from the clock node
297 * Builds clock register address from device tree information, and returns
298 * the data via the provided output pointer @reg. Returns 0 on success,
308 if (clocks_node_ptr[i] == node->parent) in ti_clk_get_reg_addr()
310 if (clocks_node_ptr[i] == node->parent->parent) in ti_clk_get_reg_addr()
315 pr_err("clk-provider not found for %pOFn!\n", node); in ti_clk_get_reg_addr()
316 return -ENOENT; in ti_clk_get_reg_addr()
319 reg->index = i; in ti_clk_get_reg_addr()
322 if (of_property_read_u32_index(node->parent, "reg", in ti_clk_get_reg_addr()
326 return -EINVAL; in ti_clk_get_reg_addr()
330 reg->offset = val; in ti_clk_get_reg_addr()
331 reg->ptr = NULL; in ti_clk_get_reg_addr()
345 ti_clk_ll_ops->clk_rmw(latch, latch, reg); in ti_clk_latch()
346 ti_clk_ll_ops->clk_rmw(0, latch, reg); in ti_clk_latch()
347 ti_clk_ll_ops->clk_readl(reg); /* OCP barrier */ in ti_clk_latch()
351 * omap2_clk_provider_init - init master clock provider
354 * @syscon: syscon regmap pointer for accessing clock registers
355 * @mem: iomem pointer for the clock provider memory area, only used if
358 * Initializes a master clock IP block. This basically sets up the
374 return -EINVAL; in omap2_clk_provider_init()
382 return -ENOMEM; in omap2_clk_provider_init()
384 io->regmap = syscon; in omap2_clk_provider_init()
385 io->mem = mem; in omap2_clk_provider_init()
393 * omap2_clk_legacy_provider_init - initialize a legacy clock provider
394 * @index: index for the clock provider
395 * @mem: iomem pointer for the clock provider memory area
397 * Initializes a legacy clock provider memory mapping.
408 io->mem = mem; in omap2_clk_legacy_provider_init()
414 * ti_dt_clk_init_retry_clks - init clocks from the retry list
429 pr_debug("retry-init: %pOFn\n", retry->node); in ti_dt_clk_init_retry_clks()
430 retry->func(retry->user, retry->node); in ti_dt_clk_init_retry_clks()
431 list_del(&retry->link); in ti_dt_clk_init_retry_clks()
434 retries--; in ti_dt_clk_init_retry_clks()
439 { .compatible = "fixed-clock" },
440 { .compatible = "fixed-factor-clock" },
445 * ti_dt_clk_name - init clock name from first output name or node name
448 * Use the first clock-output-name for the clock name if found. Fall back
449 * to legacy naming based on node name.
453 const char *name; in ti_dt_clk_name() local
455 if (!of_property_read_string_index(np, "clock-output-names", 0, in ti_dt_clk_name()
456 &name)) in ti_dt_clk_name()
457 return name; in ti_dt_clk_name()
459 return np->name; in ti_dt_clk_name()
463 * ti_clk_add_aliases - setup clock aliases
465 * Sets up any missing clock aliases. No return value.
483 * ti_clk_setup_features - setup clock features flags
486 * Initializes the clock driver features flags based on platform
495 * ti_clk_get_features - get clock driver features flags
497 * Get TI clock driver features description. Returns a pointer
506 * omap2_clk_enable_init_clocks - prepare & enable a list of clocks
507 * @clk_names: ptr to an array of strings of clock names to enable
508 * @num_clocks: number of clock names in @clk_names
522 if (WARN(IS_ERR(init_clk), "could not find init clock %s\n", in omap2_clk_enable_init_clocks()
530 * ti_clk_add_alias - add a clock alias for a TI clock
531 * @clk: clock handle to create alias for
532 * @con: connection ID for this clock
534 * Creates a clock alias for a TI clock. Allocates the clock lookup entry
550 return -ENOMEM; in ti_clk_add_alias()
552 cl->con_id = con; in ti_clk_add_alias()
553 cl->clk = clk; in ti_clk_add_alias()
561 * of_ti_clk_register - register a TI clock to the common clock framework
562 * @node: device node for this clock
563 * @hw: hardware clock handle
564 * @con: connection ID for this clock
566 * Registers a TI clock to the common clock framework, and adds a clock
567 * alias for it. Returns a handle to the registered clock if successful,
580 clk = hw->clk; in of_ti_clk_register()
591 * of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
592 * @node: device node for this clock
593 * @hw: hardware clock handle
594 * @con: connection ID for this clock
596 * Registers a clk_hw_omap clock to the clock framewor, adds a clock alias
598 * Returns a handle to the registered clock if successful, ERR_PTR value
613 list_add(&oclk->node, &clk_hw_omap_clocks); in of_ti_clk_register_omap_hw()
619 * omap2_clk_for_each - call function for each registered clk_hw_omap
624 * failure. If @fn returns non-zero, the iteration across clocks
625 * will stop and the non-zero return value will be passed to the
643 * omap2_clk_is_hw_omap - check if the provided clk_hw is OMAP clock
644 * @hw: clk_hw to check if it is an omap clock or not
646 * Checks if the provided clk_hw is OMAP clock or not. Returns true if
654 if (&oclk->hw == hw) in omap2_clk_is_hw_omap()