Skip to content

Commit 4353654

Browse files
KeerthyjTero Kristo
authored andcommitted
clk: clk: Add clk_gate_restore_context function
The clock gate restore context function enables or disables the gate clocks based on the enable_count. This is done in cases where the clock context is lost and based on the enable_count the clock either needs to be enabled/disabled. Signed-off-by: Keerthy <j-keerthy@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Tero Kristo <t-kristo@ti.com>
1 parent 8b95d1c commit 4353654

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/clk/clk.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,25 @@ static int clk_core_enable_lock(struct clk_core *core)
923923
return ret;
924924
}
925925

926+
/**
927+
* clk_gate_restore_context - restore context for poweroff
928+
* @hw: the clk_hw pointer of clock whose state is to be restored
929+
*
930+
* The clock gate restore context function enables or disables
931+
* the gate clocks based on the enable_count. This is done in cases
932+
* where the clock context is lost and based on the enable_count
933+
* the clock either needs to be enabled/disabled. This
934+
* helps restore the state of gate clocks.
935+
*/
936+
void clk_gate_restore_context(struct clk_hw *hw)
937+
{
938+
if (hw->clk->core->enable_count)
939+
hw->clk->core->ops->enable(hw);
940+
else
941+
hw->clk->core->ops->disable(hw);
942+
}
943+
EXPORT_SYMBOL_GPL(clk_gate_restore_context);
944+
926945
static int _clk_save_context(struct clk_core *clk)
927946
{
928947
struct clk_core *child;

include/linux/clk-provider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,5 +1018,7 @@ static inline void clk_writel(u32 val, u32 __iomem *reg)
10181018

10191019
#endif /* platform dependent I/O accessors */
10201020

1021+
void clk_gate_restore_context(struct clk_hw *hw);
1022+
10211023
#endif /* CONFIG_COMMON_CLK */
10221024
#endif /* CLK_PROVIDER_H */

0 commit comments

Comments
 (0)