All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP3: allow setting cam_mclk rate
@ 2009-07-01 11:27 Tuukka.O Toivonen
  2009-07-02  7:44 ` Artem Bityutskiy
  2009-07-02  8:56 ` Tuukka.O Toivonen
  0 siblings, 2 replies; 5+ messages in thread
From: Tuukka.O Toivonen @ 2009-07-01 11:27 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: sailus, camera, Cohen David.A (Nokia-D/Helsinki),
	Hurskainen Mikko (Nokia-D/Helsinki),
	core-review@ok.research.nokia.com, linux-omap

This patch allows drivers to modify cam_mclk rate which is
used for generating external cam_xclka and cam_xclkb for cameras.

Signed-off-by: Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
---
 arch/arm/mach-omap2/clock34xx.c |   18 ++++++++++++++++++
 arch/arm/mach-omap2/clock34xx.h |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 045da92..667a608 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -898,6 +898,24 @@ static unsigned long omap3_clkoutx2_recalc(struct clk *clk)
 	return rate;
 }
 
+/* Clock control for OMAP3 camera */
+
+static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate)
+{
+	const unsigned int dpll4_rate = 864000000; /* Hz */
+	int clksel;
+
+	if (rate <= 0)
+		return -EINVAL;
+
+	clksel = (dpll4_rate + (rate>>1)) / rate;
+	clksel = clamp(clksel, 1, 16);
+	cm_write_mod_reg(clksel, OMAP3430_CAM_MOD, CM_CLKSEL);
+	clk->rate = dpll4_rate / clksel;
+
+	return 0;
+}
+
 /* Common clock code */
 
 /*
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index e433aec..bd09709 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -37,6 +37,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk);
 static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
 static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate);
 static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate);
+static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate);
 
 /* Maximum DPLL multiplier, divider values for OMAP3 */
 #define OMAP3_MAX_DPLL_MULT		2048
@@ -2342,6 +2343,7 @@ static struct clk uart3_fck = {
 	.enable_bit	= OMAP3430_EN_UART3_SHIFT,
 	.clkdm_name	= "per_clkdm",
 	.recalc		= &followparent_recalc,
+	.set_rate	= &omap3_cam_mclk_set_rate,
 };
 
 static struct clk gpt2_fck = {
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ARM: OMAP3: allow setting cam_mclk rate
  2009-07-01 11:27 [PATCH] ARM: OMAP3: allow setting cam_mclk rate Tuukka.O Toivonen
@ 2009-07-02  7:44 ` Artem Bityutskiy
  2009-07-02  8:56 ` Tuukka.O Toivonen
  1 sibling, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2009-07-02  7:44 UTC (permalink / raw)
  To: Högander Jouni
  Cc: Toivonen Tuukka.O (Nokia-D/Oulu), Paul Walmsley,
	linux-omap@vger.kernel.org, core-review@ok.research.nokia.com,
	Hurskainen Mikko (Nokia-D/Helsinki), camera@ok.research.nokia.com

Hi Jouni,

could you please take a quick look at this patch? There is some
pressure to have this applied ASAP, but I'm afraid I do not have
enough competence in this area to review it. Could you take a
brief look and validate it?

Toivonen Tuukka.O (Nokia-D/Oulu) wrote:
> This patch allows drivers to modify cam_mclk rate which is
> used for generating external cam_xclka and cam_xclkb for cameras.
> 
> Signed-off-by: Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
> ---
>  arch/arm/mach-omap2/clock34xx.c |   18 ++++++++++++++++++
>  arch/arm/mach-omap2/clock34xx.h |    2 ++
>  2 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
> index 045da92..667a608 100644
> --- a/arch/arm/mach-omap2/clock34xx.c
> +++ b/arch/arm/mach-omap2/clock34xx.c
> @@ -898,6 +898,24 @@ static unsigned long omap3_clkoutx2_recalc(struct clk *clk)
>  	return rate;
>  }
>  
> +/* Clock control for OMAP3 camera */
> +
> +static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate)
> +{
> +	const unsigned int dpll4_rate = 864000000; /* Hz */
> +	int clksel;
> +
> +	if (rate <= 0)
> +		return -EINVAL;
> +
> +	clksel = (dpll4_rate + (rate>>1)) / rate;
> +	clksel = clamp(clksel, 1, 16);
> +	cm_write_mod_reg(clksel, OMAP3430_CAM_MOD, CM_CLKSEL);
> +	clk->rate = dpll4_rate / clksel;
> +
> +	return 0;
> +}
> +
>  /* Common clock code */
>  
>  /*
> diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
> index e433aec..bd09709 100644
> --- a/arch/arm/mach-omap2/clock34xx.h
> +++ b/arch/arm/mach-omap2/clock34xx.h
> @@ -37,6 +37,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk);
>  static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
>  static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate);
>  static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate);
> +static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate);
>  
>  /* Maximum DPLL multiplier, divider values for OMAP3 */
>  #define OMAP3_MAX_DPLL_MULT		2048
> @@ -2342,6 +2343,7 @@ static struct clk uart3_fck = {
>  	.enable_bit	= OMAP3430_EN_UART3_SHIFT,
>  	.clkdm_name	= "per_clkdm",
>  	.recalc		= &followparent_recalc,
> +	.set_rate	= &omap3_cam_mclk_set_rate,
>  };
>  
>  static struct clk gpt2_fck = {


-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ARM: OMAP3: allow setting cam_mclk rate
  2009-07-01 11:27 [PATCH] ARM: OMAP3: allow setting cam_mclk rate Tuukka.O Toivonen
  2009-07-02  7:44 ` Artem Bityutskiy
@ 2009-07-02  8:56 ` Tuukka.O Toivonen
  2009-07-02  8:59   ` [PATCH take 2] " Tuukka.O Toivonen
  1 sibling, 1 reply; 5+ messages in thread
From: Tuukka.O Toivonen @ 2009-07-02  8:56 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: sailus, camera, Cohen David.A (Nokia-D/Helsinki),
	Hurskainen Mikko (Nokia-D/Helsinki),
	core-review@ok.research.nokia.com, linux-omap

On Wednesday 01 July 2009 14:27:28 Tuukka.O Toivonen wrote:
> This patch allows drivers to modify cam_mclk rate which is
> used for generating external cam_xclka and cam_xclkb for cameras.

I'm terribly sorry, this patch was misapplied to the
kernel tree. I send the patch again.

- Tuukka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH take 2] ARM: OMAP3: allow setting cam_mclk rate
  2009-07-02  8:56 ` Tuukka.O Toivonen
@ 2009-07-02  8:59   ` Tuukka.O Toivonen
  2009-08-06 11:18     ` Paul Walmsley
  0 siblings, 1 reply; 5+ messages in thread
From: Tuukka.O Toivonen @ 2009-07-02  8:59 UTC (permalink / raw)
  To: Paul Walmsley, Hogander Jouni (Nokia-D/Tampere)
  Cc: sailus, Cohen David.A (Nokia-D/Helsinki),
	Hurskainen Mikko (Nokia-D/Helsinki), linux-omap

This patch allows drivers to modify cam_mclk rate which is
used for generating external cam_xclka and cam_xclkb for cameras.

Signed-off-by: Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
---
 arch/arm/mach-omap2/clock34xx.c |   18 ++++++++++++++++++
 arch/arm/mach-omap2/clock34xx.h |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 045da92..667a608 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -898,6 +898,24 @@ static unsigned long omap3_clkoutx2_recalc(struct clk *clk)
 	return rate;
 }
 
+/* Clock control for OMAP3 camera */
+
+static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate)
+{
+	const unsigned int dpll4_rate = 864000000; /* Hz */
+	int clksel;
+
+	if (rate <= 0)
+		return -EINVAL;
+
+	clksel = (dpll4_rate + (rate>>1)) / rate;
+	clksel = clamp(clksel, 1, 16);
+	cm_write_mod_reg(clksel, OMAP3430_CAM_MOD, CM_CLKSEL);
+	clk->rate = dpll4_rate / clksel;
+
+	return 0;
+}
+
 /* Common clock code */
 
 /*
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index e433aec..cd9a0d3 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -37,6 +37,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk);
 static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
 static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate);
 static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate);
+static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate);
 
 /* Maximum DPLL multiplier, divider values for OMAP3 */
 #define OMAP3_MAX_DPLL_MULT		2048
@@ -2089,6 +2090,7 @@ static struct clk cam_mclk = {
 	.enable_bit	= OMAP3430_EN_CAM_SHIFT,
 	.clkdm_name	= "cam_clkdm",
 	.recalc		= &followparent_recalc,
+	.set_rate	= &omap3_cam_mclk_set_rate,
 };
 
 static struct clk cam_ick = {
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH take 2] ARM: OMAP3: allow setting cam_mclk rate
  2009-07-02  8:59   ` [PATCH take 2] " Tuukka.O Toivonen
@ 2009-08-06 11:18     ` Paul Walmsley
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Walmsley @ 2009-08-06 11:18 UTC (permalink / raw)
  To: Tuukka.O Toivonen
  Cc: Hogander Jouni (Nokia-D/Tampere), sailus,
	Cohen David.A (Nokia-D/Helsinki),
	Hurskainen Mikko (Nokia-D/Helsinki), linux-omap

Hello Tuukka,

sorry for the delay.  A few comments:

On Thu, 2 Jul 2009, Tuukka.O Toivonen wrote:

> This patch allows drivers to modify cam_mclk rate which is
> used for generating external cam_xclka and cam_xclkb for cameras.
> 
> Signed-off-by: Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
> ---
>  arch/arm/mach-omap2/clock34xx.c |   18 ++++++++++++++++++
>  arch/arm/mach-omap2/clock34xx.h |    2 ++
>  2 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
> index 045da92..667a608 100644
> --- a/arch/arm/mach-omap2/clock34xx.c
> +++ b/arch/arm/mach-omap2/clock34xx.c
> @@ -898,6 +898,24 @@ static unsigned long omap3_clkoutx2_recalc(struct clk *clk)
>  	return rate;
>  }
>  
> +/* Clock control for OMAP3 camera */
> +
> +static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate)
> +{
> +	const unsigned int dpll4_rate = 864000000; /* Hz */

This does not look right; we should be able to get the clock's parent rate 
via the clock framework.

> +	int clksel;
> +
> +	if (rate <= 0)
> +		return -EINVAL;
> +
> +	clksel = (dpll4_rate + (rate>>1)) / rate;
> +	clksel = clamp(clksel, 1, 16);
> +	cm_write_mod_reg(clksel, OMAP3430_CAM_MOD, CM_CLKSEL);
> +	clk->rate = dpll4_rate / clksel;
> +
> +	return 0;
> +}
> +

Can we just use the existing clksel mechanism for this clock, rather than 
using a custom set_rate function?  Or does this do something that cannot 
be handled by the clksel functions?

I think Jouni put together a draft patch for this.


>  /* Common clock code */
>  
>  /*
> diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
> index e433aec..cd9a0d3 100644
> --- a/arch/arm/mach-omap2/clock34xx.h
> +++ b/arch/arm/mach-omap2/clock34xx.h
> @@ -37,6 +37,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk);
>  static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
>  static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate);
>  static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate);
> +static int omap3_cam_mclk_set_rate(struct clk *clk, unsigned long rate);
>  
>  /* Maximum DPLL multiplier, divider values for OMAP3 */
>  #define OMAP3_MAX_DPLL_MULT		2048
> @@ -2089,6 +2090,7 @@ static struct clk cam_mclk = {
>  	.enable_bit	= OMAP3430_EN_CAM_SHIFT,
>  	.clkdm_name	= "cam_clkdm",
>  	.recalc		= &followparent_recalc,
> +	.set_rate	= &omap3_cam_mclk_set_rate,

This should have a round_rate function also.

>  };
>  
>  static struct clk cam_ick = {
> -- 
> 1.5.4.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


- Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-08-06 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01 11:27 [PATCH] ARM: OMAP3: allow setting cam_mclk rate Tuukka.O Toivonen
2009-07-02  7:44 ` Artem Bityutskiy
2009-07-02  8:56 ` Tuukka.O Toivonen
2009-07-02  8:59   ` [PATCH take 2] " Tuukka.O Toivonen
2009-08-06 11:18     ` Paul Walmsley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.