From: Paul Walmsley <paul@pwsan.com>
To: linux-omap@vger.kernel.org
Cc: Paul Walmsley <paul@pwsan.com>
Subject: [PATCH v2 02/23] OMAP clock: move rate recalc, propagation code up to plat-omap/clock.c
Date: Sun, 04 Jan 2009 19:34:47 -0700 [thread overview]
Message-ID: <20090105023446.12661.18057.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090105022953.12661.57701.stgit@localhost.localdomain>
Previously the individual clock recalculation functions handled their
own rate recalculation. This can be handled in the clk_set_rate(),
clk_set_parent(), and recalculate_root_clocks() functions in
plat-omap/clock.c. Removes duplicate code and clarifies the role of the
recalc functions.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap1/clock.c | 14 --------------
arch/arm/mach-omap2/clock.c | 12 ------------
arch/arm/mach-omap2/clock24xx.c | 6 ------
arch/arm/mach-omap2/clock34xx.c | 9 ---------
arch/arm/plat-omap/clock.c | 34 +++++++++++++++++++++++++++-------
5 files changed, 27 insertions(+), 48 deletions(-)
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 4d0c444..ae2b304 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -225,9 +225,6 @@ static void omap1_ckctl_recalc(struct clk * clk)
if (unlikely(clk->rate == clk->parent->rate / dsor))
return; /* No change, quick exit */
clk->rate = clk->parent->rate / dsor;
-
- if (unlikely(clk->flags & RATE_PROPAGATES))
- propagate_rate(clk);
}
static void omap1_ckctl_recalc_dsp_domain(struct clk * clk)
@@ -248,9 +245,6 @@ static void omap1_ckctl_recalc_dsp_domain(struct clk * clk)
if (unlikely(clk->rate == clk->parent->rate / dsor))
return; /* No change, quick exit */
clk->rate = clk->parent->rate / dsor;
-
- if (unlikely(clk->flags & RATE_PROPAGATES))
- propagate_rate(clk);
}
/* MPU virtual clock functions */
@@ -314,9 +308,6 @@ static int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate)
ret = 0;
}
- if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
- propagate_rate(clk);
-
return ret;
}
@@ -423,8 +414,6 @@ static int omap1_set_sossi_rate(struct clk *clk, unsigned long rate)
omap_writel(l, MOD_CONF_CTRL_1);
clk->rate = p_rate / (div + 1);
- if (unlikely(clk->flags & RATE_PROPAGATES))
- propagate_rate(clk);
return 0;
}
@@ -583,9 +572,6 @@ static int omap1_clk_set_rate(struct clk *clk, unsigned long rate)
ret = 0;
}
- if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
- propagate_rate(clk);
-
return ret;
}
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 8a064b3..13db3d5 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -302,9 +302,6 @@ void omap2_fixed_divisor_recalc(struct clk *clk)
WARN_ON(!clk->fixed_div);
clk->rate = clk->parent->rate / clk->fixed_div;
-
- if (clk->flags & RATE_PROPAGATES)
- propagate_rate(clk);
}
/**
@@ -506,9 +503,6 @@ void omap2_clksel_recalc(struct clk *clk)
clk->rate = clk->parent->rate / div;
pr_debug("clock: new clock rate is %ld (div %d)\n", clk->rate, div);
-
- if (clk->flags & RATE_PROPAGATES)
- propagate_rate(clk);
}
/**
@@ -779,9 +773,6 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
if (clk->set_rate != NULL)
ret = clk->set_rate(clk, rate);
- if (ret == 0 && (clk->flags & RATE_PROPAGATES))
- propagate_rate(clk);
-
return ret;
}
@@ -863,9 +854,6 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
clk->name, clk->parent->name, clk->rate);
- if (clk->flags & RATE_PROPAGATES)
- propagate_rate(clk);
-
return 0;
}
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 8567de2..9e1328f 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -178,8 +178,6 @@ static long omap2_dpllcore_round_rate(unsigned long target_rate)
static void omap2_dpllcore_recalc(struct clk *clk)
{
clk->rate = omap2xxx_clk_get_core_rate(clk);
-
- propagate_rate(clk);
}
static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
@@ -250,7 +248,6 @@ static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
omap2xxx_sdrc_init_params(omap2xxx_sdrc_dll_is_unlocked());
omap2xxx_sdrc_reprogram(done_rate, 0);
}
- omap2_dpllcore_recalc(&dpll_ck);
ret = 0;
dpll_exit:
@@ -379,7 +376,6 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate)
local_irq_restore(flags);
}
- omap2_dpllcore_recalc(&dpll_ck);
return 0;
}
@@ -469,13 +465,11 @@ static u32 omap2_get_sysclkdiv(void)
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);
}
/*
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 738a029..22cbcce 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -54,8 +54,6 @@
static void omap3_dpll_recalc(struct clk *clk)
{
clk->rate = omap2_get_dpll_rate(clk);
-
- propagate_rate(clk);
}
/* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
@@ -429,8 +427,6 @@ static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
}
- omap3_dpll_recalc(clk);
-
return 0;
}
@@ -493,8 +489,6 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
sp->actim_ctrlb, new_div);
local_irq_enable();
- omap2_clksel_recalc(clk);
-
return 0;
}
@@ -612,9 +606,6 @@ static void omap3_clkoutx2_recalc(struct clk *clk)
clk->rate = clk->parent->rate;
else
clk->rate = clk->parent->rate * 2;
-
- if (clk->flags & RATE_PROPAGATES)
- propagate_rate(clk);
}
/* Common clock code */
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index d13acd2..9f458cb 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -183,8 +183,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
return ret;
spin_lock_irqsave(&clockfw_lock, flags);
- if (arch_clock->clk_set_rate)
+
+ if (arch_clock->clk_set_rate) {
ret = arch_clock->clk_set_rate(clk, rate);
+ if (ret == 0) {
+ (*clk->recalc)(clk);
+ if (clk->flags & RATE_PROPAGATES)
+ propagate_rate(clk);
+ }
+ }
+
spin_unlock_irqrestore(&clockfw_lock, flags);
return ret;
@@ -200,8 +208,16 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
return ret;
spin_lock_irqsave(&clockfw_lock, flags);
- if (arch_clock->clk_set_parent)
- ret = arch_clock->clk_set_parent(clk, parent);
+
+ if (arch_clock->clk_set_parent) {
+ ret = arch_clock->clk_set_parent(clk, parent);
+ if (ret == 0) {
+ (*clk->recalc)(clk);
+ if (clk->flags & RATE_PROPAGATES)
+ propagate_rate(clk);
+ }
+ }
+
spin_unlock_irqrestore(&clockfw_lock, flags);
return ret;
@@ -256,8 +272,6 @@ void followparent_recalc(struct clk *clk)
return;
clk->rate = clk->parent->rate;
- if (unlikely(clk->flags & RATE_PROPAGATES))
- propagate_rate(clk);
}
/* Propagate rate to children */
@@ -271,8 +285,11 @@ void propagate_rate(struct clk * tclk)
list_for_each_entry(clkp, &clocks, node) {
if (likely(clkp->parent != tclk))
continue;
- if (likely((u32)clkp->recalc))
+ if (likely((u32)clkp->recalc)) {
clkp->recalc(clkp);
+ if (clkp->flags & RATE_PROPAGATES)
+ propagate_rate(clkp);
+ }
}
}
@@ -288,8 +305,11 @@ void recalculate_root_clocks(void)
struct clk *clkp;
list_for_each_entry(clkp, &clocks, node) {
- if (unlikely(!clkp->parent) && likely((u32)clkp->recalc))
+ if (unlikely(!clkp->parent) && likely((u32)clkp->recalc)) {
clkp->recalc(clkp);
+ if (clkp->flags & RATE_PROPAGATES)
+ propagate_rate(clkp);
+ }
}
}
next prev parent reply other threads:[~2009-01-05 3:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-05 2:34 [PATCH v2 00/23] OMAP clock: bug fixes, cleanup, optimization Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 01/23] OMAP2/3 clock: use standard set_rate fn in omap2_clk_arch_init() Paul Walmsley
2009-01-05 2:34 ` Paul Walmsley [this message]
2009-01-05 2:34 ` [PATCH v2 03/23] OMAP2/3 clock: drop recalc function pointers from fixed rate clocks Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 04/23] OMAP clock: support "dry run" rate and parent changes Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 05/23] OMAP clock: track child clocks Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 06/23] OMAP clock: drop the RATE_PROPAGATES flag Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 07/23] OMAP clock: drop RATE_FIXED Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 09/23] OMAP2 clock: drop CONFIG_PARTICIPANT clock flag Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 08/23] OMAP clock: remove VIRTUAL_CLOCK Paul Walmsley
2009-01-06 2:03 ` Kevin Hilman
2009-01-06 2:34 ` Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 10/23] OMAP2/3 clock: remove clk->owner Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 11/23] OMAP clock: rearrange clock.h structure order Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 12/23] OMAP2/3 clock: don't use a barrier after clk_disable() Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 13/23] OMAP2xxx clock: consolidate DELAYED_APP clock commits; fix barrier Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 14/23] OMAP2/3 clock: convert remaining MPU barriers into OCP barriers Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 16/23] OMAP clock: add OMAP chip family-specific clk_register() option Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 15/23] OMAP clock: drop clk_get_usecount() Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 17/23] OMAP2/3 clock: every clock must have a clkdm Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 18/23] OMAP2/3 clock: omap2_clk_enable(): refactor usecount check Paul Walmsley
2009-01-05 2:34 ` [PATCH v2 19/23] OMAP2/3 clock: omap2_clk_enable(): fix bugs in clockdomain handling Paul Walmsley
2009-01-05 2:35 ` [PATCH v2 20/23] OMAP2/3 clock: omap2_clk_enable(): fix usecount decrement bug Paul Walmsley
[not found] ` <2ee9e08d0901060342q36a5ebd2i448d87ba55bb034d@mail.gmail.com>
2009-01-06 11:43 ` Fwd: " Anuj Aggarwal
2009-01-05 2:35 ` [PATCH v2 21/23] OMAP2/3 clock: omap2_clk_enable(): fix logic Paul Walmsley
2009-01-05 2:35 ` [PATCH v2 23/23] OMAP3 SmartReflex: get rid of custom clocks Paul Walmsley
2009-01-05 2:35 ` [PATCH v2 22/23] OMAP2/3 clock: don't tinker with hardirqs when they are supposed to be disabled Paul Walmsley
2009-01-07 15:46 ` [PATCH v2 00/23] OMAP clock: bug fixes, cleanup, optimization Tony Lindgren
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=20090105023446.12661.18057.stgit@localhost.localdomain \
--to=paul@pwsan.com \
--cc=linux-omap@vger.kernel.org \
/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