From 212f86f4aba2b430458a9886f9d0e72a8ff00c08 Mon Sep 17 00:00:00 2001 From: Paul Walmsley Date: Mon, 27 Aug 2007 02:39:18 -0600 Subject: [PATCH] omap2 clock: use custom osc_ck enable/disable routines Now that we're paying attention to the .enable/.disable fields in struct clk, convert the osc_ck enable and disable code to use this standard mechanism. (osc_ck enable/disable does not technically enable or disable the osc_ck; it actually enables/disables autoidling.) Signed-off-by: Paul Walmsley Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/clock.c | 32 +++++++++++++++----------------- arch/arm/mach-omap2/clock.h | 5 ++++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index ad84869226a..f389e9d7923 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c @@ -163,18 +163,26 @@ static void omap2_fixed_divisor_recalc(struct clk *clk) propagate_rate(clk); } -static void omap2_set_osc_ck(int enable) +static int omap2_enable_osc_ck(struct clk *clk) { u32 pcc; pcc = prm_read_reg(OMAP24XX_PRCM_CLKSRC_CTRL); - if (enable) - prm_write_reg(pcc & ~OMAP_AUTOEXTCLKMODE_MASK, - OMAP24XX_PRCM_CLKSRC_CTRL); - else - prm_write_reg(pcc | OMAP_AUTOEXTCLKMODE_MASK, - OMAP24XX_PRCM_CLKSRC_CTRL); + prm_write_reg(pcc & ~OMAP_AUTOEXTCLKMODE_MASK, + OMAP24XX_PRCM_CLKSRC_CTRL); + + return 0; +} + +static void omap2_disable_osc_ck(struct clk *clk) +{ + u32 pcc; + + pcc = prm_read_reg(OMAP24XX_PRCM_CLKSRC_CTRL); + + prm_write_reg(pcc | OMAP_AUTOEXTCLKMODE_MASK, + OMAP24XX_PRCM_CLKSRC_CTRL); } /* @@ -272,11 +280,6 @@ static int _omap2_clk_enable(struct clk * clk) if (clk->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)) return 0; - if (unlikely(clk == &osc_ck)) { - omap2_set_osc_ck(1); - return 0; - } - if (clk->enable) return clk->enable(clk); @@ -324,11 +327,6 @@ static void _omap2_clk_disable(struct clk *clk) return; } - if (unlikely(clk == &osc_ck)) { - omap2_set_osc_ck(0); - return; - } - if (clk->enable_reg == 0) { /* * 'Independent' here refers to a clock which is not diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index 1243201e19c..bd64fba6d15 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h @@ -26,7 +26,6 @@ #include "prm_regbits_24xx.h" #include "cm_regbits_24xx.h" -static void omap2_sys_clk_recalc(struct clk * clk); static void omap2_clksel_recalc(struct clk * clk); static void omap2_table_mpu_recalc(struct clk *clk); static int omap2_select_table_rate(struct clk * clk, unsigned long rate); @@ -42,6 +41,8 @@ static void omap2_fixed_divisor_recalc(struct clk *clk); static long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate); static int omap2_clksel_set_rate(struct clk *clk, unsigned long rate); static int omap2_reprogram_dpll(struct clk *clk, unsigned long rate); +static int omap2_enable_osc_ck(struct clk *clk); +static void omap2_disable_osc_ck(struct clk *clk); /* Key dividers which make up a PRCM set. Ratio's for a PRCM are mandated. * xtal_speed, dpll_speed, mpu_speed, CM_CLKSEL_MPU,CM_CLKSEL_DSP @@ -598,6 +599,8 @@ static struct clk osc_ck = { /* (*12, *13, 19.2, *26, 38.4)MHz */ .rate = 26000000, /* fixed up in clock init */ .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | RATE_FIXED | RATE_PROPAGATES, + .enable = &omap2_enable_osc_ck, + .disable = &omap2_disable_osc_ck, .recalc = &propagate_rate, }; -- 2.41.1