Skip to content

Commit 50d4da9

Browse files
Sowjanya Komatinenithierryreding
authored andcommitted
clk: tegra: Support for OSC context save and restore
This patch adds support for saving OSC clock frequency and the drive-strength during OSC clock init and creates an API to restore OSC control register value from the saved context. This API is invoked by Tegra210 clock driver during system resume to restore the OSC clock settings. Acked-by: Thierry Reding <[email protected]> Signed-off-by: Sowjanya Komatineni <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent bc0b3a6 commit 50d4da9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/clk/tegra/clk-tegra-fixed.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#define OSC_CTRL 0x50
1818
#define OSC_CTRL_OSC_FREQ_SHIFT 28
1919
#define OSC_CTRL_PLL_REF_DIV_SHIFT 26
20+
#define OSC_CTRL_MASK (0x3f2 | \
21+
(0xf << OSC_CTRL_OSC_FREQ_SHIFT))
22+
23+
static u32 osc_ctrl_ctx;
2024

2125
int __init tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks,
2226
unsigned long *input_freqs, unsigned int num,
@@ -29,6 +33,7 @@ int __init tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks,
2933
unsigned osc_idx;
3034

3135
val = readl_relaxed(clk_base + OSC_CTRL);
36+
osc_ctrl_ctx = val & OSC_CTRL_MASK;
3237
osc_idx = val >> OSC_CTRL_OSC_FREQ_SHIFT;
3338

3439
if (osc_idx < num)
@@ -96,3 +101,13 @@ void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks)
96101
*dt_clk = clk;
97102
}
98103
}
104+
105+
void tegra_clk_osc_resume(void __iomem *clk_base)
106+
{
107+
u32 val;
108+
109+
val = readl_relaxed(clk_base + OSC_CTRL) & ~OSC_CTRL_MASK;
110+
val |= osc_ctrl_ctx;
111+
writel_relaxed(val, clk_base + OSC_CTRL);
112+
fence_udelay(2, clk_base);
113+
}

drivers/clk/tegra/clk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ u16 tegra_pll_get_fixed_mdiv(struct clk_hw *hw, unsigned long input_rate);
829829
int tegra_pll_p_div_to_hw(struct tegra_clk_pll *pll, u8 p_div);
830830
int div_frac_get(unsigned long rate, unsigned parent_rate, u8 width,
831831
u8 frac_width, u8 flags);
832+
void tegra_clk_osc_resume(void __iomem *clk_base);
832833

833834

834835
/* Combined read fence with delay */

0 commit comments

Comments
 (0)