From: Paul Walmsley <paul@pwsan.com>
To: linux-omap-open-source@linux.omap.com
Subject: [PATCH 10/28] omap2 clock: convert omap2_get_clksel to use new clksel struct
Date: Mon, 20 Aug 2007 03:53:57 -0600 [thread overview]
Message-ID: <20070820095530.950860859@pwsan.com> (raw)
In-Reply-To: 20070820095347.933473149@pwsan.com
[-- Attachment #1: convert_get_clksel.patch --]
[-- Type: text/plain, Size: 4158 bytes --]
Convert omap2_get_clksel to use new struct clksel and struct
clksel_rate data. Also fix its parameter order to conform with the
rest of the clock framework functions (i.e., struct clk first).
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/clock.c | 92 ++++++--------------------------------------
1 file changed, 13 insertions(+), 79 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
@@ -787,89 +787,23 @@ static u32 omap2_divisor_to_clksel(struc
return clkr->val;
}
-/*
- * Returns the CLKSEL divider register value
+/**
+ * omap2_get_clksel - find clksel register addr & field mask for a clk
+ * @clk: struct clk to use
+ * @field_mask: ptr to u32 to store the register field mask
+ *
+ * Returns the address of the clksel register upon success or NULL on error.
*/
-static void __iomem *omap2_get_clksel(u32 *field_mask, struct clk *clk)
+static void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask)
{
- u32 div_off, mask = ~0;
- void __iomem *div_addr = 0;
+ if (unlikely((clk->clksel_reg == 0) || (clk->clksel_mask == 0)))
+ return NULL;
- div_off = clk->rate_offset;
+ *field_mask = clk->clksel_mask;
- switch (clk->flags & SRC_RATE_SEL_MASK) {
- case CM_MPU_SEL1:
- div_addr = OMAP_CM_REGADDR(MPU_MOD, CM_CLKSEL);
- mask = OMAP24XX_CLKSEL_MPU_MASK;
- break;
- case CM_DSP_SEL1:
- div_addr = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_CLKSEL);
- if (cpu_is_omap2420()) {
- if (div_off == OMAP24XX_CLKSEL_DSP_SHIFT)
- mask = OMAP24XX_CLKSEL_DSP_MASK;
- else if (div_off == OMAP2420_CLKSEL_IVA_SHIFT)
- mask = OMAP2420_CLKSEL_IVA_MASK;
- else if (div_off == OMAP24XX_CLKSEL_DSP_IF_SHIFT)
- mask = OMAP24XX_CLKSEL_DSP_IF_MASK;
- } else if (cpu_is_omap2430()) {
- if (div_off == OMAP24XX_CLKSEL_DSP_SHIFT)
- mask = OMAP24XX_CLKSEL_DSP_MASK;
- else if (div_off == OMAP24XX_CLKSEL_DSP_IF_SHIFT)
- mask = OMAP24XX_CLKSEL_DSP_IF_MASK;
- }
- case CM_GFX_SEL1:
- div_addr = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL);
- if (div_off == OMAP_CLKSEL_GFX_SHIFT)
- mask = OMAP_CLKSEL_GFX_MASK;
- break;
- case CM_MODEM_SEL1:
- div_addr = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_CLKSEL);
- if (div_off == OMAP2430_CLKSEL_MDM_SHIFT)
- mask = OMAP2430_CLKSEL_MDM_MASK;
- break;
- case CM_SYSCLKOUT_SEL1:
- div_addr = OMAP24XX_PRCM_CLKOUT_CTRL;
- if (div_off == OMAP24XX_CLKOUT_DIV_SHIFT)
- mask = OMAP24XX_CLKOUT_DIV_MASK;
- else if (div_off == OMAP2420_CLKOUT2_DIV_SHIFT)
- mask = OMAP2420_CLKOUT2_DIV_MASK;
- break;
- case CM_CORE_SEL1:
- div_addr = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1);
- switch (div_off) {
- case OMAP24XX_CLKSEL_L3_SHIFT:
- mask = OMAP24XX_CLKSEL_L3_MASK;
- break;
- case OMAP24XX_CLKSEL_L4_SHIFT:
- mask = OMAP24XX_CLKSEL_L4_MASK;
- break;
- case OMAP24XX_CLKSEL_DSS1_SHIFT:
- mask = OMAP24XX_CLKSEL_DSS1_MASK;
- break;
- case OMAP24XX_CLKSEL_DSS2_SHIFT:
- mask = OMAP24XX_CLKSEL_DSS2_MASK;
- break;
- case OMAP2420_CLKSEL_VLYNQ_SHIFT:
- mask = OMAP2420_CLKSEL_VLYNQ_MASK;
- break;
- case OMAP24XX_CLKSEL_SSI_SHIFT:
- mask = OMAP24XX_CLKSEL_SSI_MASK;
- break;
- case OMAP24XX_CLKSEL_USB_SHIFT:
- mask = OMAP24XX_CLKSEL_USB_MASK;
- break;
- }
- }
-
- if (unlikely((mask == ~0) || (div_addr == 0)))
- return 0;
-
- *field_mask = mask;
-
- return div_addr;
+ return clk->clksel_reg;
}
-
/**
* omap2_clksel_get_divisor - get current divider applied to parent clock.
* @clk: OMAP struct clk to use.
@@ -881,7 +815,7 @@ static u32 omap2_clksel_get_divisor(stru
u32 field_mask, field_val;
void __iomem *div_addr;
- div_addr = omap2_get_clksel(&field_mask, clk);
+ div_addr = omap2_get_clksel(clk, &field_mask);
if (div_addr == 0)
return 0;
@@ -910,7 +844,7 @@ static int omap2_clk_set_rate(struct clk
if (validrate != rate)
return ret;
- div_addr = omap2_get_clksel(&field_mask, clk);
+ div_addr = omap2_get_clksel(clk, &field_mask);
if (div_addr == 0)
return ret;
--
next prev parent reply other threads:[~2007-08-20 9:53 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 ` Paul Walmsley [this message]
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 ` [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=20070820095530.950860859@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