linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ARM: AM335x: LCDC platform support
@ 2013-01-22 16:44 Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value Afzal Mohammed
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Afzal Mohammed @ 2013-01-22 16:44 UTC (permalink / raw)
  To: linux-omap, linux-arm-kernel, linux-kernel
  Cc: Paul Walmsley, Tony Lindgren, Russell King, Mike Turquette

Hi,

This series make am335x lcdc capable of providing display.
Certain changes were required in generic OMAP clock handling
to attain it. Clock nodes in LCDC path is marked such that
rate can get propogated to upstream clocks till display PLL.

Based on 3.8-rc3.

Tested on AM335x EVM.

To test on AM335x based boards, tree
@ git://gitorious.org/x0148406-public/linux-kernel.git tags/da8xx-fb-dt-v3

Regards
Afzal

Afzal Mohammed (4):
  ARM: OMAP2+: dpll: round rate to closest value
  ARM: OMAP2+: dpll: am335x - avoid freqsel
  ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper
  ARM: AM33XX: clock: SET_RATE_PARENT in lcd path

 arch/arm/mach-omap2/cclock33xx_data.c | 11 ++++++-----
 arch/arm/mach-omap2/clkt_dpll.c       | 12 +++++++-----
 arch/arm/mach-omap2/clock.h           | 11 +++++++++++
 arch/arm/mach-omap2/dpll3xxx.c        |  5 +++--
 4 files changed, 27 insertions(+), 12 deletions(-)

-- 
1.7.12


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

* [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value
  2013-01-22 16:44 [PATCH 0/4] ARM: AM335x: LCDC platform support Afzal Mohammed
@ 2013-01-22 16:44 ` Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel Afzal Mohammed
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Afzal Mohammed @ 2013-01-22 16:44 UTC (permalink / raw)
  To: linux-omap, linux-arm-kernel, linux-kernel
  Cc: Paul Walmsley, Tony Lindgren, Russell King, Mike Turquette

Currently round rate function would return proper rate iff requested
rate exactly matches the PLL lockable rate. This causes set_rate to
fail if exact rate could not be set. Instead round rate may return
closest rate possible (less than the requested). And if any user is
badly in need of exact rate, then return value of round rate could
be used to decide whether to invoke set rate or not.

Modify round rate so that it return closest possible rate.

This was required to get display working on am335x. Without this
display rate could not be set (taking help of SET_RATE_PARENT). Couple
of the downstream clocks of display PLL are basic clock dividers and
they do MULT_ROUND_UP before requesting rate on PLL causing values
that mostly could not be locked by PLL. And even otherwise, if
requested rate for a particular pixel clock could not be satisfied by
PLL, display would not work. This change will resolve the issue.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
---
 arch/arm/mach-omap2/clkt_dpll.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
index 924c230..15e6d41 100644
--- a/arch/arm/mach-omap2/clkt_dpll.c
+++ b/arch/arm/mach-omap2/clkt_dpll.c
@@ -345,20 +345,22 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
 		pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n",
 			 clk_name, m, n, new_rate);
 
-		if (target_rate == new_rate) {
+		if ((new_rate <= target_rate) &&
+		    (new_rate > dd->last_rounded_rate)) {
 			dd->last_rounded_m = m;
 			dd->last_rounded_n = n;
-			dd->last_rounded_rate = target_rate;
-			break;
+			dd->last_rounded_rate = new_rate;
+			if (new_rate == target_rate)
+				break;
 		}
 	}
 
-	if (target_rate != new_rate) {
+	if (!dd->last_rounded_rate) {
 		pr_debug("clock: %s: cannot round to rate %ld\n",
 			 clk_name, target_rate);
 		return ~0;
 	}
 
-	return target_rate;
+	return dd->last_rounded_rate;
 }
 
-- 
1.7.12


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

* [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel
  2013-01-22 16:44 [PATCH 0/4] ARM: AM335x: LCDC platform support Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value Afzal Mohammed
@ 2013-01-22 16:44 ` Afzal Mohammed
  2013-01-25  8:44   ` Paul Walmsley
  2013-01-22 16:44 ` [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path Afzal Mohammed
  3 siblings, 1 reply; 9+ messages in thread
From: Afzal Mohammed @ 2013-01-22 16:44 UTC (permalink / raw)
  To: linux-omap, linux-arm-kernel, linux-kernel
  Cc: Paul Walmsley, Tony Lindgren, Russell King, Mike Turquette

am335x does not have freqsel, avoid it.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
---
 arch/arm/mach-omap2/dpll3xxx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index 0a02aab5..3aed4b0 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -500,8 +500,9 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate,
 		if (dd->last_rounded_rate == 0)
 			return -EINVAL;
 
-		/* No freqsel on OMAP4 and OMAP3630 */
-		if (!cpu_is_omap44xx() && !cpu_is_omap3630()) {
+		/* No freqsel on AM335x, OMAP4 and OMAP3630 */
+		if (!soc_is_am33xx() && !cpu_is_omap44xx() &&
+		    !cpu_is_omap3630()) {
 			freqsel = _omap3_dpll_compute_freqsel(clk,
 						dd->last_rounded_n);
 			WARN_ON(!freqsel);
-- 
1.7.12


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

* [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper
  2013-01-22 16:44 [PATCH 0/4] ARM: AM335x: LCDC platform support Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value Afzal Mohammed
  2013-01-22 16:44 ` [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel Afzal Mohammed
@ 2013-01-22 16:44 ` Afzal Mohammed
  2013-01-31 16:25   ` Paul Walmsley
  2013-01-22 16:44 ` [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path Afzal Mohammed
  3 siblings, 1 reply; 9+ messages in thread
From: Afzal Mohammed @ 2013-01-22 16:44 UTC (permalink / raw)
  To: linux-omap, linux-arm-kernel, linux-kernel
  Cc: Paul Walmsley, Tony Lindgren, Russell King, Mike Turquette

DEFINE_STRUCT_CLK does not have the capability to set flags, define
DEFINE_STRUCT_CLK_FLAGS to handle flags. This is needed to add
SET_RATE_PARENT flag in statically defined lcd clock in am335x.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
---
 arch/arm/mach-omap2/clock.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index b402048..60ddd86 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -65,6 +65,17 @@ struct clockdomain;
 		.ops = &_clkops_name,				\
 	};
 
+#define DEFINE_STRUCT_CLK_FLAGS(_name, _parent_array_name,	\
+				_clkops_name, _flags)		\
+	static struct clk _name = {				\
+		.name = #_name,					\
+		.hw = &_name##_hw.hw,				\
+		.parent_names = _parent_array_name,		\
+		.num_parents = ARRAY_SIZE(_parent_array_name),	\
+		.ops = &_clkops_name,				\
+		.flags = _flags,				\
+	};
+
 #define DEFINE_STRUCT_CLK_HW_OMAP(_name, _clkdm_name)		\
 	static struct clk_hw_omap _name##_hw = {		\
 		.hw = {						\
-- 
1.7.12


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

* [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path
  2013-01-22 16:44 [PATCH 0/4] ARM: AM335x: LCDC platform support Afzal Mohammed
                   ` (2 preceding siblings ...)
  2013-01-22 16:44 ` [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper Afzal Mohammed
@ 2013-01-22 16:44 ` Afzal Mohammed
  2013-01-31 16:26   ` Paul Walmsley
  3 siblings, 1 reply; 9+ messages in thread
From: Afzal Mohammed @ 2013-01-22 16:44 UTC (permalink / raw)
  To: linux-omap, linux-arm-kernel, linux-kernel
  Cc: Paul Walmsley, Tony Lindgren, Russell King, Mike Turquette

LCDC clock node is a one that does not have set rate capability. It
just passes on the rate that is sent downstream by it's parent. While
lcdc clock parent and it's grand parent - dpll_disp_m2_ck and
dpll_disp_ck has the capability to configure rate.

And the default rates provided by LCDC clock's ancestors are not
sufficient to obtain pixel clock for current LCDC use cases, hence
currently display would not work on AM335x SoC's (with driver
modifications in platfrom independent way).

Hence inform clock framework to propogate set rate for LCDC clock as
well as it's parent - dpll_disp_m2_ck. With this change, set rate on
LCDC clock would get propogated till dpll_disp_ck via dpll_disp_m2_ck,
hence allowing the driver (same driver is used in DaVinci too) to set
rates using LCDC clock without worrying about platform dependent clock
details.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
---
 arch/arm/mach-omap2/cclock33xx_data.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock33xx_data.c b/arch/arm/mach-omap2/cclock33xx_data.c
index 8f7c60d..0519e91 100644
--- a/arch/arm/mach-omap2/cclock33xx_data.c
+++ b/arch/arm/mach-omap2/cclock33xx_data.c
@@ -286,10 +286,10 @@ DEFINE_STRUCT_CLK(dpll_disp_ck, dpll_core_ck_parents, dpll_ddr_ck_ops);
  * TODO: Add clksel here (sys_clkin, CORE_CLKOUTM6, PER_CLKOUTM2
  * and ALT_CLK1/2)
  */
-DEFINE_CLK_DIVIDER(dpll_disp_m2_ck, "dpll_disp_ck", &dpll_disp_ck, 0x0,
-		   AM33XX_CM_DIV_M2_DPLL_DISP, AM33XX_DPLL_CLKOUT_DIV_SHIFT,
-		   AM33XX_DPLL_CLKOUT_DIV_WIDTH, CLK_DIVIDER_MIN_DIV_DEFAULT,
-		   CLK_DIVIDER_ONE_BASED, NULL);
+DEFINE_CLK_DIVIDER(dpll_disp_m2_ck, "dpll_disp_ck", &dpll_disp_ck,
+		   CLK_SET_RATE_PARENT, AM33XX_CM_DIV_M2_DPLL_DISP,
+		   AM33XX_DPLL_CLKOUT_DIV_SHIFT, AM33XX_DPLL_CLKOUT_DIV_WIDTH,
+		   CLK_DIVIDER_MIN_DIV_DEFAULT, CLK_DIVIDER_ONE_BASED, NULL);
 
 /* DPLL_PER */
 static struct dpll_data dpll_per_dd = {
@@ -726,7 +726,8 @@ static struct clk_hw_omap lcd_gclk_hw = {
 	.clksel_mask	= AM33XX_CLKSEL_0_1_MASK,
 };
 
-DEFINE_STRUCT_CLK(lcd_gclk, lcd_ck_parents, gpio_fck_ops);
+DEFINE_STRUCT_CLK_FLAGS(lcd_gclk, lcd_ck_parents,
+			gpio_fck_ops, CLK_SET_RATE_PARENT);
 
 DEFINE_CLK_FIXED_FACTOR(mmc_clk, "dpll_per_m2_ck", &dpll_per_m2_ck, 0x0, 1, 2);
 
-- 
1.7.12


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

* Re: [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel
  2013-01-22 16:44 ` [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel Afzal Mohammed
@ 2013-01-25  8:44   ` Paul Walmsley
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Walmsley @ 2013-01-25  8:44 UTC (permalink / raw)
  To: Afzal Mohammed
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Tony Lindgren,
	Russell King, Mike Turquette

On Tue, 22 Jan 2013, Afzal Mohammed wrote:

> am335x does not have freqsel, avoid it.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>

Thanks, queued for 3.9.

- Paul

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

* Re: [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper
  2013-01-22 16:44 ` [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper Afzal Mohammed
@ 2013-01-31 16:25   ` Paul Walmsley
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Walmsley @ 2013-01-31 16:25 UTC (permalink / raw)
  To: Afzal Mohammed
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Tony Lindgren,
	Russell King, Mike Turquette

On Tue, 22 Jan 2013, Afzal Mohammed wrote:

> DEFINE_STRUCT_CLK does not have the capability to set flags, define
> DEFINE_STRUCT_CLK_FLAGS to handle flags. This is needed to add
> SET_RATE_PARENT flag in statically defined lcd clock in am335x.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>

Thanks, queued for 3.9.


- Paul

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

* Re: [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path
  2013-01-22 16:44 ` [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path Afzal Mohammed
@ 2013-01-31 16:26   ` Paul Walmsley
  2013-01-31 16:29     ` Paul Walmsley
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Walmsley @ 2013-01-31 16:26 UTC (permalink / raw)
  To: Afzal Mohammed
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Tony Lindgren,
	Russell King, Mike Turquette

On Tue, 22 Jan 2013, Afzal Mohammed wrote:

> LCDC clock node is a one that does not have set rate capability. It
> just passes on the rate that is sent downstream by it's parent. While
> lcdc clock parent and it's grand parent - dpll_disp_m2_ck and
> dpll_disp_ck has the capability to configure rate.
> 
> And the default rates provided by LCDC clock's ancestors are not
> sufficient to obtain pixel clock for current LCDC use cases, hence
> currently display would not work on AM335x SoC's (with driver
> modifications in platfrom independent way).
> 
> Hence inform clock framework to propogate set rate for LCDC clock as
> well as it's parent - dpll_disp_m2_ck. With this change, set rate on
> LCDC clock would get propogated till dpll_disp_ck via dpll_disp_m2_ck,
> hence allowing the driver (same driver is used in DaVinci too) to set
> rates using LCDC clock without worrying about platform dependent clock
> details.
> 
> Signed-off-by: Afzal Mohammed <afzal@ti.com>

This one doesn't apply for me on v3.8-rc5 + your patches 2 and 3.  Could 
you please update it and re-send?


- Paul

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

* Re: [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path
  2013-01-31 16:26   ` Paul Walmsley
@ 2013-01-31 16:29     ` Paul Walmsley
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Walmsley @ 2013-01-31 16:29 UTC (permalink / raw)
  To: Afzal Mohammed
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Tony Lindgren,
	Russell King, Mike Turquette

On Thu, 31 Jan 2013, Paul Walmsley wrote:

> This one doesn't apply for me on v3.8-rc5 + your patches 2 and 3.  Could 
> you please update it and re-send?

Oops, looks like I accidentally tried to apply the first version of this 
patch rather than the second one.  The second one applies cleanly, so it's 
queued now for 3.9.


- Paul

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

end of thread, other threads:[~2013-01-31 16:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-22 16:44 [PATCH 0/4] ARM: AM335x: LCDC platform support Afzal Mohammed
2013-01-22 16:44 ` [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value Afzal Mohammed
2013-01-22 16:44 ` [PATCH 2/4] ARM: OMAP2+: dpll: am335x - avoid freqsel Afzal Mohammed
2013-01-25  8:44   ` Paul Walmsley
2013-01-22 16:44 ` [PATCH 3/4] ARM: OMAP2+: clock: DEFINE_STRUCT_CLK_FLAGS helper Afzal Mohammed
2013-01-31 16:25   ` Paul Walmsley
2013-01-22 16:44 ` [PATCH 4/4] ARM: AM33XX: clock: SET_RATE_PARENT in lcd path Afzal Mohammed
2013-01-31 16:26   ` Paul Walmsley
2013-01-31 16:29     ` Paul Walmsley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).