Lines Matching +full:idle +full:- +full:wait +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2005-2008, 2015 Texas Instruments, Inc.
6 * Copyright (C) 2004-2010 Nokia Corporation
9 * Richard Woodruff <r-woodruff2@ti.com>
11 * Tero Kristo <t-kristo@ti.com>
16 #include <linux/clk-provider.h>
19 #include <linux/delay.h>
24 * MAX_MODULE_ENABLE_WAIT: maximum of number of microseconds to wait
25 * for a module to indicate that it is no longer in idle
37 * _wait_idlest_generic - wait for a module to leave the idle state
38 * @clk: module clock to wait for (needed for register offsets)
41 * @idlest: idle state indicator (0 or 1) for the clock
44 * Wait for a module to leave idle, where its idle-status register is
45 * not inside the CM module. Returns 1 if the module left idle
46 * promptly, or 0 if the module did not leave idle before the timeout
47 * elapsed. XXX Deprecated - should be moved into drivers for the
58 /* Wait until module enters enabled state */ in _wait_idlest_generic()
60 if ((ti_clk_ll_ops->clk_readl(reg) & mask) == ena) in _wait_idlest_generic()
76 * _omap2_module_wait_ready - wait for an OMAP module to leave IDLE
80 * corresponds to clock @clk are enabled, then wait for the module to
81 * indicate readiness (i.e., to leave IDLE). This code does not
83 * module-dependent code. No return value.
93 if (clk->ops->find_companion) { in _omap2_module_wait_ready()
94 clk->ops->find_companion(clk, &companion_reg, &other_bit); in _omap2_module_wait_ready()
95 if (!(ti_clk_ll_ops->clk_readl(&companion_reg) & in _omap2_module_wait_ready()
100 clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val); in _omap2_module_wait_ready()
101 r = ti_clk_ll_ops->cm_split_idlest_reg(&idlest_reg, &prcm_mod, in _omap2_module_wait_ready()
106 idlest_val, clk_hw_get_name(&clk->hw)); in _omap2_module_wait_ready()
108 ti_clk_ll_ops->cm_wait_module_ready(0, prcm_mod, idlest_reg_id, in _omap2_module_wait_ready()
114 * omap2_clk_dflt_find_companion - find companion clock to @clk
123 * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes it's
131 * associate this type of code with per-module data structures to
138 memcpy(other_reg, &clk->enable_reg, sizeof(*other_reg)); in omap2_clk_dflt_find_companion()
141 * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes in omap2_clk_dflt_find_companion()
144 other_reg->offset ^= (CM_FCLKEN ^ CM_ICLKEN); in omap2_clk_dflt_find_companion()
146 *other_bit = clk->enable_bit; in omap2_clk_dflt_find_companion()
150 * omap2_clk_dflt_find_idlest - find CM_IDLEST reg va, bit shift for @clk
154 * @idlest_val: u8 * to return the idle status indicator
167 memcpy(idlest_reg, &clk->enable_reg, sizeof(*idlest_reg)); in omap2_clk_dflt_find_idlest()
169 idlest_reg->offset &= ~0xf0; in omap2_clk_dflt_find_idlest()
170 idlest_reg->offset |= 0x20; in omap2_clk_dflt_find_idlest()
172 *idlest_bit = clk->enable_bit; in omap2_clk_dflt_find_idlest()
179 *idlest_val = ti_clk_get_features()->cm_idlest_val; in omap2_clk_dflt_find_idlest()
183 * omap2_dflt_clk_enable - enable a clock in the hardware
189 * hardware to enable the clock. Then wait for the IP block that uses
190 * this clock to leave idle (if applicable). Returns the error value
191 * from clkdm_clk_enable() if it terminated with an error, or -EINVAL
201 if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) in omap2_dflt_clk_enable()
208 if (clkdm_control && clk->clkdm) { in omap2_dflt_clk_enable()
209 ret = ti_clk_ll_ops->clkdm_clk_enable(clk->clkdm, hw->clk); in omap2_dflt_clk_enable()
214 clk->clkdm_name, ret); in omap2_dflt_clk_enable()
220 v = ti_clk_ll_ops->clk_readl(&clk->enable_reg); in omap2_dflt_clk_enable()
221 if (clk->flags & INVERT_ENABLE) in omap2_dflt_clk_enable()
222 v &= ~(1 << clk->enable_bit); in omap2_dflt_clk_enable()
224 v |= (1 << clk->enable_bit); in omap2_dflt_clk_enable()
225 ti_clk_ll_ops->clk_writel(v, &clk->enable_reg); in omap2_dflt_clk_enable()
226 v = ti_clk_ll_ops->clk_readl(&clk->enable_reg); /* OCP barrier */ in omap2_dflt_clk_enable()
228 if (clk->ops && clk->ops->find_idlest) in omap2_dflt_clk_enable()
235 * omap2_dflt_clk_disable - disable a clock in the hardware
250 v = ti_clk_ll_ops->clk_readl(&clk->enable_reg); in omap2_dflt_clk_disable()
251 if (clk->flags & INVERT_ENABLE) in omap2_dflt_clk_disable()
252 v |= (1 << clk->enable_bit); in omap2_dflt_clk_disable()
254 v &= ~(1 << clk->enable_bit); in omap2_dflt_clk_disable()
255 ti_clk_ll_ops->clk_writel(v, &clk->enable_reg); in omap2_dflt_clk_disable()
258 if (!(ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) && in omap2_dflt_clk_disable()
259 clk->clkdm) in omap2_dflt_clk_disable()
260 ti_clk_ll_ops->clkdm_clk_disable(clk->clkdm, hw->clk); in omap2_dflt_clk_disable()
264 * omap2_dflt_clk_is_enabled - is clock enabled in the hardware?
276 v = ti_clk_ll_ops->clk_readl(&clk->enable_reg); in omap2_dflt_clk_is_enabled()
278 if (clk->flags & INVERT_ENABLE) in omap2_dflt_clk_is_enabled()
279 v ^= BIT(clk->enable_bit); in omap2_dflt_clk_is_enabled()
281 v &= BIT(clk->enable_bit); in omap2_dflt_clk_is_enabled()