public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Walmsley <paul@pwsan.com>
To: linux-omap-open-source@linux.omap.com
Subject: [PATCH 24/28] omap2 clock: replace omap2_get_crystal_rate() with clock-specific recalc code
Date: Mon, 20 Aug 2007 03:54:11 -0600	[thread overview]
Message-ID: <20070820095532.333952593@pwsan.com> (raw)
In-Reply-To: 20070820095347.933473149@pwsan.com

[-- Attachment #1: use_custom_osc_sys_recalc.patch --]
[-- Type: text/plain, Size: 4226 bytes --]

The OMAP2 clock framework currently uses a nonstandard function to
assign the osc_ck and sys_ck rates, omap2_get_crystal_rate().  By
using custom recalc code for these clocks, we can get rid of it and
rely on the existing clock tree recalculation process.

Signed-off-by: Paul Walmsley <paul@pwsan.com>

---
 arch/arm/mach-omap2/clock.c |   44 ++++++++++++++++++++++++--------------------
 arch/arm/mach-omap2/clock.h |   10 +++++-----
 2 files changed, 29 insertions(+), 25 deletions(-)

Index: linux-omap/arch/arm/mach-omap2/clock.c
Index: linux-omap/arch/arm/mach-omap2/clock.c
===================================================================
--- linux-omap.orig/arch/arm/mach-omap2/clock.c
+++ linux-omap/arch/arm/mach-omap2/clock.c
@@ -112,21 +112,6 @@ static void omap2_init_clksel_parent(str
 	return;
 }
 
-/* Recalculate SYST_CLK */
-static void omap2_sys_clk_recalc(struct clk * clk)
-{
-	u32 div;
-
-	if (!cpu_is_omap34xx()) {
-		div = prm_read_reg(OMAP24XX_PRCM_CLKSRC_CTRL);
-		/* Test if ext clk divided by 1 or 2 */
-		div &= OMAP_SYSCLKDIV_MASK;
-		div >>= OMAP_SYSCLKDIV_SHIFT;
-		clk->rate = (clk->parent->rate / div);
-	}
-	propagate_rate(clk);
-}
-
 static u32 omap2_get_dpll_rate(struct clk * tclk)
 {
 	long long dpll_clk;
@@ -1044,9 +1029,9 @@ static struct clk_functions omap2_clk_fu
 	.clk_disable_unused	= omap2_clk_disable_unused,
 };
 
-static void __init omap2_get_crystal_rate(struct clk *osc, struct clk *sys)
+static u32 omap2_get_apll_clkin(void)
 {
-	u32 div, aplls, sclk = 13000000;
+	u32 aplls, sclk = 0;
 
 	aplls = cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
 	aplls &= OMAP24XX_APLLS_CLKIN_MASK;
@@ -1059,12 +1044,30 @@ static void __init omap2_get_crystal_rat
 	else if (aplls == APLLS_CLKIN_12MHZ)
 		sclk = 12000000;
 
+	return sclk;
+}
+
+static u32 omap2_get_sysclkdiv(void)
+{
+	u32 div;
+
 	div = prm_read_reg(OMAP24XX_PRCM_CLKSRC_CTRL);
 	div &= OMAP_SYSCLKDIV_MASK;
 	div >>= OMAP_SYSCLKDIV_SHIFT;
 
-	osc->rate = sclk * div;
-	sys->rate = sclk;
+	return div;
+}
+
+static void omap2_osc_clk_recalc(struct clk *clk)
+{
+	clk->rate = omap2_get_apll_clkin() * omap2_get_sysclkdiv();
+	propagate_rate(clk);
+}
+
+static void omap2_sys_clk_recalc(struct clk *clk)
+{
+	clk->rate = clk->parent->rate / omap2_get_sysclkdiv();
+	propagate_rate(clk);
 }
 
 /*
@@ -1116,7 +1119,8 @@ int __init omap2_clk_init(void)
 		cpu_mask = RATE_IN_243X;
 
 	clk_init(&omap2_clk_functions);
-	omap2_get_crystal_rate(&osc_ck, &sys_ck);
+
+	omap2_osc_clk_recalc(&osc_ck);
 
 	for (clkp = onchip_clks; clkp < onchip_clks + ARRAY_SIZE(onchip_clks);
 	     clkp++) {
Index: linux-omap/arch/arm/mach-omap2/clock.h
===================================================================
--- linux-omap.orig/arch/arm/mach-omap2/clock.h
+++ linux-omap/arch/arm/mach-omap2/clock.h
@@ -36,6 +36,8 @@ static void omap2_init_clksel_parent(str
 static u32 omap2_clksel_get_divisor(struct clk *clk);
 static u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val);
 static u32 omap2_divisor_to_clksel(struct clk *clk, u32 div);
+static void omap2_osc_clk_recalc(struct clk *clk);
+static void omap2_sys_clk_recalc(struct clk *clk);
 static void omap2_dpll_recalc(struct clk *clk);
 static void omap2_fixed_divisor_recalc(struct clk *clk);
 static int omap2_clk_fixed_enable(struct clk *clk);
@@ -598,21 +600,19 @@ static struct clk func_32k_ck = {
 /* Typical 12/13MHz in standalone mode, will be 26Mhz in chassis mode */
 static struct clk osc_ck = {		/* (*12, *13, 19.2, *26, 38.4)MHz */
 	.name		= "osc_ck",
-	.rate		= 26000000,		/* fixed up in clock init */
 	.flags		= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
-				RATE_FIXED | RATE_PROPAGATES,
+				RATE_PROPAGATES,
 	.enable		= &omap2_enable_osc_ck,
 	.disable	= &omap2_disable_osc_ck,
-	.recalc		= &propagate_rate,
+	.recalc		= &omap2_osc_clk_recalc,
 };
 
 /* With out modem likely 12MHz, with modem likely 13MHz */
 static struct clk sys_ck = {		/* (*12, *13, 19.2, 26, 38.4)MHz */
 	.name		= "sys_ck",		/* ~ ref_clk also */
 	.parent		= &osc_ck,
-	.rate		= 13000000,
 	.flags		= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
-				RATE_FIXED | ALWAYS_ENABLED | RATE_PROPAGATES,
+				ALWAYS_ENABLED | RATE_PROPAGATES,
 	.recalc		= &omap2_sys_clk_recalc,
 };
 

-- 

  parent reply	other threads:[~2007-08-20  9:54 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20  9:53 [PATCH 00/28] omap2 clock: framework generalization, cleanup Paul Walmsley
2007-08-20  9:53 ` [PATCH 01/28] omap2 clock: dsp_ick parent is dsp_fck, not core_ck Paul Walmsley
2007-08-20  9:53 ` [PATCH 02/28] omap2 clock: generalize initial clock rate setup: recalculate_root_clocks() Paul Walmsley
2007-08-20  9:53 ` [PATCH 03/28] omap2 clock: mark onchip_clks as __initdata Paul Walmsley
2007-08-20  9:53 ` [PATCH 05/28] omap2 clock: rename, add comment to omap2_mpu_recalc() Paul Walmsley
2007-08-20  9:53 ` [PATCH 06/28] omap2 clock: add clksel and clksel_rate data Paul Walmsley
2007-08-20  9:53 ` [PATCH 07/28] omap2 clock: init clksel clock parents to hardware reality at clock init Paul Walmsley
2007-08-20 12:27   ` [PATCH 07/28] omap2 clock: init clksel clock parents to hardwarereality " Woodruff, Richard
2007-08-21  6:49     ` Paul Walmsley
2007-08-20  9:53 ` [PATCH 08/28] omap2 clock: convert omap2_clksel_to_divisor and omap2_divisor_to_clksel to use new clksel struct Paul Walmsley
2007-08-20  9:53 ` [PATCH 09/28] omap2 clock: convert omap2_clksel_round_rate " Paul Walmsley
2007-08-20  9:53 ` [PATCH 10/28] omap2 clock: convert omap2_get_clksel " Paul Walmsley
2007-08-20  9:53 ` [PATCH 11/28] omap2 clock: convert omap2_clksel_get_src_field() " Paul Walmsley
2007-08-20  9:53 ` [PATCH 12/28] omap2 clock: stop using clk->src_offset in omap2_clk_set_rate() Paul Walmsley
2007-08-20  9:54 ` [PATCH 13/28] omap2 clock: stop using clk->src_offset in omap2_clk_set_parent() Paul Walmsley
2007-08-20  9:54 ` [PATCH 14/28] omap2 clock: clean out old code from omap2_clksel_recalc() Paul Walmsley
2007-08-20  9:54 ` [PATCH 15/28] omap2 clock: convert remaining clksel clocks to use omap2_clksel_recalc Paul Walmsley
2007-08-20  9:54 ` [PATCH 16/28] omap2 clock: remove all {src, rate}_offset fields from struct clk Paul Walmsley
2007-08-20  9:54 ` [PATCH 17/28] omap2 clock: use the struct clk round_rate field for clksel rate rounding code Paul Walmsley
2007-08-20  9:54 ` [PATCH 19/28] omap2 clock: drop RATE_CKCTL from all OMAP2 clocks Paul Walmsley
2007-08-20  9:54 ` [PATCH 20/28] omap2 clock: remove *_SEL* clock flags Paul Walmsley
2007-08-20  9:54 ` [PATCH 21/28] omap2 clock: call clock-specific enable/disable functions if present Paul Walmsley
2007-08-20  9:54 ` [PATCH 22/28] omap2 clock: use custom osc_ck enable/disable routines Paul Walmsley
2007-08-20  9:54 ` [PATCH 23/28] omap2 clock: use standard clk->enable/disable for APLLs Paul Walmsley
2007-08-20  9:54 ` Paul Walmsley [this message]
2007-08-20  9:54 ` [PATCH 25/28] omap2 clock: Standardize DPLL rate recalculation with struct dpll_data Paul Walmsley
2007-08-20  9:54 ` [PATCH 27/28] omap2 clock: add three missing clocks: gpmc_fck, sdma_{i, f}ck Paul Walmsley
2007-08-20  9:54 ` [PATCH 28/28] omap2 clock: handle (almost) all clock autoidling via the clock framework Paul Walmsley
2007-08-20 12:55   ` [PATCH 28/28] omap2 clock: handle (almost) all clock autoidling viathe " Woodruff, Richard
2007-08-21  7:04     ` Paul Walmsley
2007-08-21 17:29       ` Woodruff, Richard
2007-08-22  9:49         ` Paul Walmsley
2007-08-22 21:25           ` Woodruff, Richard
2007-08-27  7:39             ` Paul Walmsley
2007-08-30 22:21               ` Woodruff, Richard
2007-08-23  9:21     ` [PATCH 28/28] omap2 clock: handle (almost) all clock autoidlingviathe " Tuukka.Tikkanen
2007-08-27  7:56       ` Paul Walmsley
2007-08-27 14:13         ` Tuukka.Tikkanen
2007-08-20 13:18   ` [PATCH 28/28] omap2 clock: handle (almost) all clock autoidling viathe " Woodruff, Richard
2007-08-20 13:30     ` Igor Stoppa
2007-08-20 13:48       ` [PATCH 28/28] omap2 clock: handle (almost) all clockautoidling " Woodruff, Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070820095532.333952593@pwsan.com \
    --to=paul@pwsan.com \
    --cc=linux-omap-open-source@linux.omap.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox