Skip to content

Commit 2209b72

Browse files
author
Tero Kristo
committed
clk: ti: clkctrl: add new exported API for checking standby info
Standby status is provided for certain clkctrl clocks to see if the given module has entered standby or not. This is mostly needed by remoteproc code to see if the remoteproc has entered standby and the clock can be turned off safely. Signed-off-by: Tero Kristo <[email protected]>
1 parent 22a6564 commit 2209b72

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/clk/ti/clkctrl.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
#define OMAP4_IDLEST_MASK (0x3 << 16)
3535
#define OMAP4_IDLEST_SHIFT 16
3636

37+
#define OMAP4_STBYST_MASK BIT(18)
38+
#define OMAP4_STBYST_SHIFT 18
39+
3740
#define CLKCTRL_IDLEST_FUNCTIONAL 0x0
3841
#define CLKCTRL_IDLEST_INTERFACE_IDLE 0x2
3942
#define CLKCTRL_IDLEST_DISABLED 0x3
@@ -647,3 +650,33 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
647650
}
648651
CLK_OF_DECLARE(ti_omap4_clkctrl_clock, "ti,clkctrl",
649652
_ti_omap4_clkctrl_setup);
653+
654+
/**
655+
* ti_clk_is_in_standby - Check if clkctrl clock is in standby or not
656+
* @clk: clock to check standby status for
657+
*
658+
* Finds whether the provided clock is in standby mode or not. Returns
659+
* true if the provided clock is a clkctrl type clock and it is in standby,
660+
* false otherwise.
661+
*/
662+
bool ti_clk_is_in_standby(struct clk *clk)
663+
{
664+
struct clk_hw *hw;
665+
struct clk_hw_omap *hwclk;
666+
u32 val;
667+
668+
hw = __clk_get_hw(clk);
669+
670+
if (!omap2_clk_is_hw_omap(hw))
671+
return false;
672+
673+
hwclk = to_clk_hw_omap(hw);
674+
675+
val = ti_clk_ll_ops->clk_readl(&hwclk->enable_reg);
676+
677+
if (val & OMAP4_STBYST_MASK)
678+
return true;
679+
680+
return false;
681+
}
682+
EXPORT_SYMBOL_GPL(ti_clk_is_in_standby);

include/linux/clk/ti.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ struct ti_clk_features {
298298

299299
void ti_clk_setup_features(struct ti_clk_features *features);
300300
const struct ti_clk_features *ti_clk_get_features(void);
301+
bool ti_clk_is_in_standby(struct clk *clk);
301302
int omap3_noncore_dpll_save_context(struct clk_hw *hw);
302303
void omap3_noncore_dpll_restore_context(struct clk_hw *hw);
303304

0 commit comments

Comments
 (0)