Skip to content

Commit f8fd975

Browse files
Sowjanya Komatinenithierryreding
authored andcommitted
clk: tegra: clk-super: Add restore-context support
This patch implements restore_context for clk_super_mux and clk_super. During system supend, core power goes off the and context of Tegra CAR registers is lost. So on system resume, context of super clock registers are restored to have them in same state as before suspend. Acked-by: Thierry Reding <[email protected]> Signed-off-by: Sowjanya Komatineni <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 68a14a5 commit f8fd975

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/clk/tegra/clk-super.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,21 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
124124
return err;
125125
}
126126

127+
static void clk_super_mux_restore_context(struct clk_hw *hw)
128+
{
129+
int parent_id;
130+
131+
parent_id = clk_hw_get_parent_index(hw);
132+
if (WARN_ON(parent_id < 0))
133+
return;
134+
135+
clk_super_set_parent(hw, parent_id);
136+
}
137+
127138
static const struct clk_ops tegra_clk_super_mux_ops = {
128139
.get_parent = clk_super_get_parent,
129140
.set_parent = clk_super_set_parent,
141+
.restore_context = clk_super_mux_restore_context,
130142
};
131143

132144
static long clk_super_round_rate(struct clk_hw *hw, unsigned long rate,
@@ -162,12 +174,27 @@ static int clk_super_set_rate(struct clk_hw *hw, unsigned long rate,
162174
return super->div_ops->set_rate(div_hw, rate, parent_rate);
163175
}
164176

177+
static void clk_super_restore_context(struct clk_hw *hw)
178+
{
179+
struct tegra_clk_super_mux *super = to_clk_super_mux(hw);
180+
struct clk_hw *div_hw = &super->frac_div.hw;
181+
int parent_id;
182+
183+
parent_id = clk_hw_get_parent_index(hw);
184+
if (WARN_ON(parent_id < 0))
185+
return;
186+
187+
super->div_ops->restore_context(div_hw);
188+
clk_super_set_parent(hw, parent_id);
189+
}
190+
165191
const struct clk_ops tegra_clk_super_ops = {
166192
.get_parent = clk_super_get_parent,
167193
.set_parent = clk_super_set_parent,
168194
.set_rate = clk_super_set_rate,
169195
.round_rate = clk_super_round_rate,
170196
.recalc_rate = clk_super_recalc_rate,
197+
.restore_context = clk_super_restore_context,
171198
};
172199

173200
struct clk *tegra_clk_register_super_mux(const char *name,

0 commit comments

Comments
 (0)