From: Paul Walmsley <paul@pwsan.com>
To: linux-omap-open-source@linux.omap.com
Subject: [PATCH 25/28] omap2 clock: Standardize DPLL rate recalculation with struct dpll_data
Date: Mon, 20 Aug 2007 03:54:12 -0600 [thread overview]
Message-ID: <20070820095532.428776464@pwsan.com> (raw)
In-Reply-To: 20070820095347.933473149@pwsan.com
[-- Attachment #1: add-dpll-params-to-24xx.h --]
[-- Type: text/plain, Size: 6247 bytes --]
Introduce a new data structure, struct dpll_data, that contains DPLL
multiplier, divider, and autoidle information. Update existing DPLL code
to use struct dpll_data. The goal here is to set up something that will be
usable for OMAP3430 clock tree. Note that this does not affect the SRAM DPLL
assembly code - the DPLL register addresses are still hard-coded there.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/clock.c | 61 ++++++++++++++++++++++++++------------
arch/arm/mach-omap2/clock.h | 10 ++++++
include/asm-arm/arch-omap/clock.h | 9 +++++
3 files changed, 61 insertions(+), 19 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,20 +112,38 @@ static void omap2_init_clksel_parent(str
return;
}
-static u32 omap2_get_dpll_rate(struct clk * tclk)
+/* Returns the DPLL rate */
+static u32 omap2_get_dpll_rate(struct clk *clk)
+{
+ long long dpll_clk;
+ u32 dpll_mult, dpll_div, dpll;
+ const struct dpll_data *dd;
+
+ dd = clk->dpll_data;
+ /* REVISIT: What do we return on error? */
+ if (!dd)
+ return 0;
+
+ dpll = cm_read_reg(dd->mult_div1_reg);
+ dpll_mult = dpll & dd->mult_mask;
+ dpll_mult >>= convert_mask_to_shift(dd->mult_mask);
+ dpll_div = dpll & dd->div1_mask;
+ dpll_div >>= convert_mask_to_shift(dd->div1_mask);
+
+ dpll_clk = (long long)clk->parent->rate * dpll_mult;
+ do_div(dpll_clk, dpll_div + 1);
+
+ return dpll_clk;
+}
+
+/* This actually returns the rate of core_ck, not dpll_ck. */
+static u32 omap2_get_dpll_rate_24xx(struct clk *tclk)
{
long long dpll_clk;
- int dpll_mult, dpll_div, amult;
- u32 dpll;
+ u8 amult;
- dpll = cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
+ dpll_clk = omap2_get_dpll_rate(tclk);
- dpll_mult = dpll & OMAP24XX_DPLL_MULT_MASK;
- dpll_mult >>= OMAP24XX_DPLL_MULT_SHIFT; /* 10 bits */
- dpll_div = dpll & OMAP24XX_DPLL_DIV_MASK;
- dpll_div >>= OMAP24XX_DPLL_DIV_SHIFT; /* 4 bits */
- dpll_clk = (long long)tclk->parent->rate * dpll_mult;
- do_div(dpll_clk, dpll_div + 1);
amult = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
amult &= OMAP24XX_CORE_CLK_SRC_MASK;
dpll_clk *= amult;
@@ -396,7 +414,7 @@ static u32 omap2_dpll_round_rate(unsigne
static void omap2_dpll_recalc(struct clk *clk)
{
- clk->rate = omap2_get_dpll_rate(clk);
+ clk->rate = omap2_get_dpll_rate_24xx(clk);
propagate_rate(clk);
}
@@ -559,10 +577,11 @@ static int omap2_reprogram_dpll(struct c
u32 flags, cur_rate, low, mult, div, valid_rate, done_rate;
u32 bypass = 0;
struct prcm_config tmpset;
+ const struct dpll_data *dd;
int ret = -EINVAL;
local_irq_save(flags);
- cur_rate = omap2_get_dpll_rate(&dpll_ck);
+ cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck);
mult = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
mult &= OMAP24XX_CORE_CLK_SRC_MASK;
@@ -580,9 +599,13 @@ static int omap2_reprogram_dpll(struct c
else
low = curr_prcm_set->dpll_speed / 2;
- tmpset.cm_clksel1_pll = cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
- tmpset.cm_clksel1_pll &= ~(OMAP24XX_DPLL_MULT_MASK |
- OMAP24XX_DPLL_DIV_MASK);
+ dd = clk->dpll_data;
+ if (!dd)
+ goto dpll_exit;
+
+ tmpset.cm_clksel1_pll = cm_read_reg(dd->mult_div1_reg);
+ tmpset.cm_clksel1_pll &= ~(dd->mult_mask |
+ dd->div1_mask);
div = ((curr_prcm_set->xtal_speed / 1000000) - 1);
tmpset.cm_clksel2_pll = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
tmpset.cm_clksel2_pll &= ~OMAP24XX_CORE_CLK_SRC_MASK;
@@ -595,8 +618,8 @@ static int omap2_reprogram_dpll(struct c
mult = (rate / 1000000);
done_rate = CORE_CLK_SRC_DPLL;
}
- tmpset.cm_clksel1_pll |= (div << OMAP24XX_DPLL_DIV_SHIFT);
- tmpset.cm_clksel1_pll |= (mult << OMAP24XX_DPLL_MULT_SHIFT);
+ tmpset.cm_clksel1_pll |= (div << convert_mask_to_shift(dd->mult_mask));
+ tmpset.cm_clksel1_pll |= (mult << convert_mask_to_shift(dd->div1_mask));
/* Worst case */
tmpset.base_sdrc_rfr = V24XX_SDRC_RFR_CTRL_BYPASS;
@@ -950,7 +973,7 @@ static int omap2_select_table_rate(struc
}
curr_prcm_set = prcm;
- cur_rate = omap2_get_dpll_rate(&dpll_ck);
+ cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck);
if (prcm->dpll_speed == cur_rate / 2) {
omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL, 1);
@@ -1137,7 +1160,7 @@ int __init omap2_clk_init(void)
}
/* Check the MPU rate set by bootloader */
- clkrate = omap2_get_dpll_rate(&dpll_ck);
+ clkrate = omap2_get_dpll_rate_24xx(&dpll_ck);
for (prcm = rate_table; prcm->mpu_speed; prcm++) {
if (!(prcm->flags & cpu_mask))
continue;
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
@@ -632,9 +632,19 @@ static struct clk alt_ck = { /* Typical
/* REVISIT: Rate changes on dpll_ck trigger a full set change. ...
* deal with this
*/
+
+static const struct dpll_data dpll_dd = {
+ .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1),
+ .mult_mask = OMAP24XX_DPLL_MULT_MASK,
+ .div1_mask = OMAP24XX_DPLL_DIV_MASK,
+ .auto_idle_mask = OMAP24XX_AUTO_DPLL_MASK,
+ .auto_idle_val = 0x3, /* stop DPLL upon idle */
+};
+
static struct clk dpll_ck = {
.name = "dpll_ck",
.parent = &sys_ck, /* Can be func_32k also */
+ .dpll_data = &dpll_dd,
.flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
RATE_PROPAGATES | ALWAYS_ENABLED,
.recalc = &omap2_dpll_recalc,
Index: linux-omap/include/asm-arm/arch-omap/clock.h
===================================================================
--- linux-omap.orig/include/asm-arm/arch-omap/clock.h
+++ linux-omap/include/asm-arm/arch-omap/clock.h
@@ -29,6 +29,14 @@ struct clksel {
const struct clksel_rate *rates;
};
+struct dpll_data {
+ void __iomem *mult_div1_reg;
+ u32 mult_mask;
+ u32 div1_mask;
+ u32 auto_idle_mask;
+ u8 auto_idle_val;
+};
+
#endif
struct clk {
@@ -53,6 +61,7 @@ struct clk {
void __iomem *clksel_reg;
u32 clksel_mask;
const struct clksel *clksel;
+ const struct dpll_data *dpll_data;
#else
__u8 rate_offset;
__u8 src_offset;
--
next prev 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 ` [PATCH 24/28] omap2 clock: replace omap2_get_crystal_rate() with clock-specific recalc code Paul Walmsley
2007-08-20 9:54 ` Paul Walmsley [this message]
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.428776464@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