clk: clk: Add clk_gate_restore_context function
authorKeerthy <j-keerthy@ti.com>
Tue, 4 Sep 2018 06:49:36 +0000 (12:19 +0530)
committerTero Kristo <t-kristo@ti.com>
Wed, 3 Oct 2018 12:29:15 +0000 (15:29 +0300)
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>
drivers/clk/clk.c
include/linux/clk-provider.h

index 8a0254a1c3037e52604a96c217880d420865e157..dd775771a7cc079f93e070c8816025d1b8dd189a 100644 (file)
@@ -923,6 +923,25 @@ static int clk_core_enable_lock(struct clk_core *core)
        return ret;
 }
 
+/**
+ * clk_gate_restore_context - restore context for poweroff
+ * @hw: the clk_hw pointer of clock whose state is to be restored
+ *
+ * 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. This
+ * helps restore the state of gate clocks.
+ */
+void clk_gate_restore_context(struct clk_hw *hw)
+{
+       if (hw->clk->core->enable_count)
+               hw->clk->core->ops->enable(hw);
+       else
+               hw->clk->core->ops->disable(hw);
+}
+EXPORT_SYMBOL_GPL(clk_gate_restore_context);
+
 static int _clk_save_context(struct clk_core *clk)
 {
        struct clk_core *child;
index df7379da62695ec44d75ffe428a09d11604b1bcb..60c51871b04be87b67235c952edb85f8b26b6217 100644 (file)
@@ -1018,5 +1018,7 @@ static inline void clk_writel(u32 val, u32 __iomem *reg)
 
 #endif /* platform dependent I/O accessors */
 
+void clk_gate_restore_context(struct clk_hw *hw);
+
 #endif /* CONFIG_COMMON_CLK */
 #endif /* CLK_PROVIDER_H */