Skip to contentSkip to conversation

OMAP3+: use DPLL's round_rate when setting rate

PATCH New Jon Hunter 3 participants 9 messages Sep 16, 2011 – Oct 7, 2011

Subsystems (3)
lore
Share & tools
lore

Jon Hunter

author
#0 lore raw

PATCH v3 3/6 OMAP3+: use DPLL's round_rate when setting rate

From: Mike Turquette <[email protected]>

omap3_noncore_dpll_set_rate uses omap2_dpll_round_rate explicitly. Instead use the struct clk pointer's round_rate function to allow for DPLL's with special needs.

Also the rounded rate can differ from target rate, so to better reflect reality set clk->rate equal to the rounded rate when setting DPLL frequency. This avoids issues where the DPLL frequency is slightly different than what debugfs clock tree reports using the old target rate.

An example of both of these needs is DPLL_ABE on OMAP4 which can have a 4x multiplier on top of the usual MN dividers depending on register settings. This requires a special round_rate function that might yield a rate different from the initial target.

---
 arch/arm/mach-omap2/dpll3xxx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +1 -1
index f77022b..73a1595 100644
@@ -455,7 +455,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 			new_parent = dd->clk_bypass;
 	} else {
 		if (dd->last_rounded_rate != rate)
-			omap2_dpll_round_rate(clk, rate);
+			rate = clk->round_rate(clk, rate);
 
 		if (dd->last_rounded_rate == 0)
 			return -EINVAL;
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v3 3/6 OMAP3+: use DPLL's round_rate when setting rate

Hi,

Quoted 11 lines · Jon Hunter

From: Mike Turquette <[email protected]>

omap3_noncore_dpll_set_rate uses omap2_dpll_round_rate explicitly. Instead use the struct clk pointer's round_rate function to allow for DPLL's with special needs.

Also the rounded rate can differ from target rate, so to better reflect reality set clk->rate equal to the rounded rate when setting DPLL frequency. This avoids issues where the DPLL frequency is slightly different than what debugfs clock tree reports using the old target rate.

Quoted 7 lines

An example of both of these needs is DPLL_ABE on OMAP4 which can have a 4x multiplier on top of the usual MN dividers depending on register settings. This requires a special round_rate function that might yield a rate different from the initial target.

The two separate changes in this patch have been separated out into two patches - both included below. Please let me know if you have any comments; otherwise, I'll queue for 3.2.

- Paul

From: Mike Turquette <[email protected]>
Date: Wed, 28 Sep 2011 00:00:32 -0600
Subject: [PATCH] ARM: OMAP3+: dpll: use DPLL's round_rate when setting rate

omap3_noncore_dpll_set_rate uses omap2_dpll_round_rate explicitly. Instead use the struct clk pointer's round_rate function to allow for DPLL's with special needs.

An example of a clock that requires this is DPLL_ABE on OMAP4 which can have a 4x multiplier on top of the usual MN dividers depending on register settings. This requires a special round_rate function that might yield a rate different from the initial target.

[paul at pwsan.com: split rate assignment portion into a separate patch]
---
 arch/arm/mach-omap2/dpll3xxx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +1 -1
index f77022b..6b0fa37 100644
@@ -455,7 +455,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 			new_parent = dd->clk_bypass;
 	} else {
 		if (dd->last_rounded_rate != rate)
-			omap2_dpll_round_rate(clk, rate);
+			clk->round_rate(clk, rate);
 
 		if (dd->last_rounded_rate == 0)
 			return -EINVAL;
Signature · 26 lines
1.7.6.3


--------------------

From: Mike Turquette <[email protected]>
Date: Wed, 28 Sep 2011 00:00:32 -0600
Subject: [PATCH] ARM: OMAP3+: dpll: assign clk rate from rounded rate during
 rate set

The rounded rate can differ from target rate, so to better reflect
reality set clk->rate equal to the rounded rate when setting DPLL frequency.
This avoids issues where the DPLL frequency is slightly different than what
debugfs clock tree reports using the old target rate.

An example of a clock that requires this is DPLL_ABE on OMAP4 which
can have a 4x multiplier on top of the usual MN dividers depending on
register settings.  This requires a special round_rate function that
might yield a rate different from the initial target.

Signed-off-by: Mike Turquette <[email protected]>
Signed-off-by: Jon Hunter <[email protected]>
Signed-off-by: Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/dpll3xxx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +1 -1
index 6b0fa37..73a1595 100644
@@ -455,7 +455,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 			new_parent = dd->clk_bypass;
 	} else {
 		if (dd->last_rounded_rate != rate)
-			clk->round_rate(clk, rate);
+			rate = clk->round_rate(clk, rate);
 
 		if (dd->last_rounded_rate == 0)
 			return -EINVAL;
Signature · 1 line
1.7.6.3
author
#2 lore raw

PATCH v3 3/6 OMAP3+: use DPLL's round_rate when setting rate

Hi Paul,

Quoted 20 lines · Paul Walmsley

Hi,

Quoted 16 lines · Jon Hunter

From: Mike Turquette<[email protected]>

omap3_noncore_dpll_set_rate uses omap2_dpll_round_rate explicitly. Instead use the struct clk pointer's round_rate function to allow for DPLL's with special needs.

Also the rounded rate can differ from target rate, so to better reflect reality set clk->rate equal to the rounded rate when setting DPLL frequency. This avoids issues where the DPLL frequency is slightly different than what debugfs clock tree reports using the old target rate.

An example of both of these needs is DPLL_ABE on OMAP4 which can have a 4x multiplier on top of the usual MN dividers depending on register settings. This requires a special round_rate function that might yield a rate different from the initial target.

Quoted 6 lines
Quoted 2 lines

The two separate changes in this patch have been separated out into two patches - both included below. Please let me know if you have any comments; otherwise, I'll queue for 3.2.

Yes, looks good to me. Thanks. Jon

#3 lore raw

PATCH v3 3/6 OMAP3+: use DPLL's round_rate when setting rate

In reply to Paul Walmsley
Quoted 20 lines · Paul Walmsley

Hi,

Quoted 16 lines · Jon Hunter

From: Mike Turquette <[email protected]>

omap3_noncore_dpll_set_rate uses omap2_dpll_round_rate explicitly. ?Instead use the struct clk pointer's round_rate function to allow for DPLL's with special needs.

Also the rounded rate can differ from target rate, so to better reflect reality set clk->rate equal to the rounded rate when setting DPLL frequency. This avoids issues where the DPLL frequency is slightly different than what debugfs clock tree reports using the old target rate.

An example of both of these needs is DPLL_ABE on OMAP4 which can have a 4x multiplier on top of the usual MN dividers depending on register settings. This requires a special round_rate function that might yield a rate different from the initial target.

Quoted 6 lines
Quoted 2 lines

The two separate changes in this patch have been separated out into two patches - both included below. ?Please let me know if you have any comments; otherwise, I'll queue for 3.2.

The split patches look good to me. I have another patch which does a similar thing (converts omap2_get_dpll_rate use to clk->recalc) which fixes yet more bugs that plague DPLL_ABE. Will send across shortly; hopefully can make it into 3.2?

Regards,
Mike

#4 lore raw

PATCH 1/1 OMAP2+: clock: use clock's recalc in DPLL handling

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. If .recalc is NULL then fall back to omap2_dpll_get_rate.

---
 arch/arm/mach-omap2/dpll3xxx.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +4 -2
index f77022b..193868d 100644
@@ -390,7 +390,8 @@ int omap3_noncore_dpll_enable(struct clk *clk)
 	 * propagating?
 	 */
 	if (!r)
-		clk->rate = omap2_get_dpll_rate(clk);
+		clk->rate = (clk->recalc) ? clk->recalc(clk) :
+			omap2_get_dpll_rate(clk);
 
 	return r;
 }
@@ -435,7 +436,8 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 	if (!dd)
 		return -EINVAL;
 
-	if (rate == omap2_get_dpll_rate(clk))
+	if (rate == ((clk->recalc) ? clk->recalc(clk) :
+				omap2_get_dpll_rate(clk)))
 		return 0;
 
 	/*
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 1/1 OMAP2+: clock: use clock's recalc in DPLL handling

Hi

Quoted 12 lines · Mike Turquette

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. If .recalc is NULL then fall back to omap2_dpll_get_rate.

Quoted 2 lines

The conditional in the second hunk of this patch has been simplified for readability. Updated patch below. Please let me know if I screwed something up. Otherwise, queued for 3.2 fixes.

thanks

- Paul

From: Mike Turquette <[email protected]>
Date: Thu, 29 Sep 2011 17:51:28 -0700
Subject: [PATCH] ARM: OMAP2+: clock: use clock's recalc in DPLL handling

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. If .recalc is NULL then fall back to omap2_dpll_get_rate.

[paul at pwsan.com: simplified conditional]
---
 arch/arm/mach-omap2/dpll3xxx.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +5 -2
index f77022b..fe4533f 100644
@@ -390,7 +390,8 @@ int omap3_noncore_dpll_enable(struct clk *clk)
 	 * propagating?
 	 */
 	if (!r)
-		clk->rate = omap2_get_dpll_rate(clk);
+		clk->rate = (clk->recalc) ? clk->recalc(clk) :
+			omap2_get_dpll_rate(clk);
 
 	return r;
 }
@@ -425,6 +426,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 {
 	struct clk *new_parent = NULL;
 	u16 freqsel = 0;
+	unsigned long hw_rate;
 	struct dpll_data *dd;
 	int ret;
 
@@ -435,7 +437,8 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 	if (!dd)
 		return -EINVAL;
 
-	if (rate == omap2_get_dpll_rate(clk))
+	hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
+	if (rate == hw_rate)
 		return 0;
 
 	/*
Signature · 1 line
1.7.6.3
#6 lore raw

PATCH 1/1 OMAP2+: clock: use clock's recalc in DPLL handling

Quoted 16 lines · Paul Walmsley

Hi

Quoted 12 lines · Mike Turquette

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. ?This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. ?If .recalc is NULL then fall back to omap2_dpll_get_rate.

Quoted 6 lines
Quoted 2 lines

The conditional in the second hunk of this patch has been simplified for readability. ?Updated patch below. ?Please let me know if I screwed something up. ?Otherwise, queued for 3.2 fixes.

Looks good to me.

Regards,
Mike

Quoted 65 lines

thanks

- Paul

From: Mike Turquette <[email protected]>
Date: Thu, 29 Sep 2011 17:51:28 -0700
Subject: [PATCH] ARM: OMAP2+: clock: use clock's recalc in DPLL handling

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. ?This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. ?If .recalc is NULL then fall back to omap2_dpll_get_rate.

[paul at pwsan.com: simplified conditional]

---
?arch/arm/mach-omap2/dpll3xxx.c | ? ?7 +++++--
?1 files changed, 5 insertions(+), 2 deletions(-)

arch/arm/mach-omap2/dpll3xxx.c +0 -0
index f77022b..fe4533f 100644
@@ -390,7 +390,8 @@ int omap3_noncore_dpll_enable(struct clk *clk)

? ? ? ? * propagating?
? ? ? ? */
? ? ? ?if (!r)
- ? ? ? ? ? ? ? clk->rate = omap2_get_dpll_rate(clk);
+ ? ? ? ? ? ? ? clk->rate = (clk->recalc) ? clk->recalc(clk) :
+ ? ? ? ? ? ? ? ? ? ? ? omap2_get_dpll_rate(clk);

? ? ? ?return r;
?}

arch/arm/mach-omap2/dpll3xxx.c +3 -1
@@ -425,6 +426,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 ?{
 ? ? ? ?struct clk *new_parent = NULL;
 ? ? ? ?u16 freqsel = 0;
+ ? ? ? unsigned long hw_rate;
 ? ? ? ?struct dpll_data *dd;
 ? ? ? ?int ret;
 
@@ -435,7 +437,8 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 ? ? ? ?if (!dd)
 ? ? ? ? ? ? ? ?return -EINVAL;
 
- ? ? ? if (rate == omap2_get_dpll_rate(clk))
+ ? ? ? hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
+ ? ? ? if (rate == hw_rate)
 ? ? ? ? ? ? ? ?return 0;
 

? ? ? ?/*
--
1.7.6.3

#7 lore raw

PATCH 1/1 OMAP2+: clock: use clock's recalc in DPLL handling

In reply to Mike Turquette
Quoted 12 lines · Mike Turquette

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. If .recalc is NULL then fall back to omap2_dpll_get_rate.

Quoted 2 lines

I've merged this patch with Jon's "ARM: OMAP3+: dpll: use DPLLs recalc function instead of omap2_get_dpll_rate" patch, which does almost exactly the same thing, just without the conditionals on clk->recalc. Updated patch below. Please let me know if you think I should change anything about the changelog.

- Paul

From: Jon Hunter <[email protected]>
Date: Fri, 7 Oct 2011 00:53:01 -0600
Subject: [PATCH] ARM: OMAP3+: dpll: use DPLLs recalc function instead of
omap2_get_dpll_rate

This is a continuation of Mike Turquette's patch "OMAP3+: use DPLL's round_rate when setting rate".

omap3_noncore_dpll_set_rate() and omap3_noncore_dpll_enable() call omap2_get_dpll_rate() explicitly. It may be necessary for some DPLLs to use a different function and so use the DPLLs recalc() function pointer instead.

An example is the DPLL_ABE on OMAP4 which can have a 4X multiplier in addition to the usual MN multipler and dividers and therefore uses a different round_rate and recalc function.

Cc Mike Turquette <[email protected]>
Cc Misael Lopez Cruz <[email protected]>

[paul at pwsan.com: merged this patch with Mike's "use clock's recalc in DPLL
handling" patch; also reported by Misael]

---
 arch/arm/mach-omap2/dpll3xxx.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/dpll3xxx.c +5 -2
index 73a1595..fc56745 100644
@@ -390,7 +390,8 @@ int omap3_noncore_dpll_enable(struct clk *clk)
 	 * propagating?
 	 */
 	if (!r)
-		clk->rate = omap2_get_dpll_rate(clk);
+		clk->rate = (clk->recalc) ? clk->recalc(clk) :
+			omap2_get_dpll_rate(clk);
 
 	return r;
 }
@@ -424,6 +425,7 @@ void omap3_noncore_dpll_disable(struct clk *clk)
 int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 {
 	struct clk *new_parent = NULL;
+	unsigned long hw_rate;
 	u16 freqsel = 0;
 	struct dpll_data *dd;
 	int ret;
@@ -435,7 +437,8 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 	if (!dd)
 		return -EINVAL;
 
-	if (rate == omap2_get_dpll_rate(clk))
+	hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
+	if (rate == hw_rate)
 		return 0;
 
 	/*
Signature · 1 line
1.7.6.3
#8 lore raw

PATCH 1/1 OMAP2+: clock: use clock's recalc in DPLL handling

Quoted 14 lines · Paul Walmsley
Quoted 12 lines · Mike Turquette

Not all DPLLs are identical; some require special consideration such as OMAP4's ABE DPLL, which can have an additional 4x multiplier added to it's clock rate based on programming the REGM4XEN bit in it's CLKMODE register.

Unfortunately the clock framework makes a few assumptions that all DPLLs can have their rates calculated the same way which has led to incorrect rates for OMAP4's DPLL_ABE in some cases. ?This patch fixes the same by replacing explicit calls to omap2_dpll_get_rate with clk->recalc if .recalc is populated for a clock. ?If .recalc is NULL then fall back to omap2_dpll_get_rate.

Quoted 8 lines
Quoted 2 lines

I've merged this patch with Jon's "ARM: OMAP3+: dpll: use DPLLs recalc function instead of omap2_get_dpll_rate" patch, which does almost exactly the same thing, just without the conditionals on clk->recalc. ?Updated patch below. ?Please let me know if you think I should change anything about the changelog.

Heh, I hadn't realized we had overlapping patches like that. Looks fine to me.

Regards,
Mike

Quoted 65 lines

- Paul

From: Jon Hunter <[email protected]>
Date: Fri, 7 Oct 2011 00:53:01 -0600
Subject: [PATCH] ARM: OMAP3+: dpll: use DPLLs recalc function instead of ?omap2_get_dpll_rate

This is a continuation of Mike Turquette's patch "OMAP3+: use DPLL's round_rate when setting rate".

omap3_noncore_dpll_set_rate() and omap3_noncore_dpll_enable() call omap2_get_dpll_rate() explicitly. It may be necessary for some DPLLs to use a different function and so use the DPLLs recalc() function pointer instead.

An example is the DPLL_ABE on OMAP4 which can have a 4X multiplier in addition to the usual MN multipler and dividers and therefore uses a different round_rate and recalc function.

Cc Mike Turquette <[email protected]>
Cc Misael Lopez Cruz <[email protected]>

[paul at pwsan.com: merged this patch with Mike's "use clock's recalc in DPLL ?handling" patch; also reported by Misael]

---
?arch/arm/mach-omap2/dpll3xxx.c | ? ?7 +++++--
?1 files changed, 5 insertions(+), 2 deletions(-)

arch/arm/mach-omap2/dpll3xxx.c +0 -0
index 73a1595..fc56745 100644
@@ -390,7 +390,8 @@ int omap3_noncore_dpll_enable(struct clk *clk)

? ? ? ? * propagating?
? ? ? ? */
? ? ? ?if (!r)
- ? ? ? ? ? ? ? clk->rate = omap2_get_dpll_rate(clk);
+ ? ? ? ? ? ? ? clk->rate = (clk->recalc) ? clk->recalc(clk) :
+ ? ? ? ? ? ? ? ? ? ? ? omap2_get_dpll_rate(clk);

? ? ? ?return r;
?}

arch/arm/mach-omap2/dpll3xxx.c +3 -1
@@ -424,6 +425,7 @@ void omap3_noncore_dpll_disable(struct clk *clk)
 ?int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 ?{
 ? ? ? ?struct clk *new_parent = NULL;
+ ? ? ? unsigned long hw_rate;
 ? ? ? ?u16 freqsel = 0;
 ? ? ? ?struct dpll_data *dd;
 ? ? ? ?int ret;
@@ -435,7 +437,8 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 ? ? ? ?if (!dd)
 ? ? ? ? ? ? ? ?return -EINVAL;
 
- ? ? ? if (rate == omap2_get_dpll_rate(clk))
+ ? ? ? hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
+ ? ? ? if (rate == hw_rate)
 ? ? ? ? ? ? ? ?return 0;
 

? ? ? ?/*
--
1.7.6.3