public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] clk: sunxi-ng: minimum multiplier and comment fixes
@ 2017-03-24  8:33 Chen-Yu Tsai
  2017-03-24  8:33 ` [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier Chen-Yu Tsai
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-03-24  8:33 UTC (permalink / raw)
  To: Maxime Ripard, Michael Turquette, Stephen Boyd
  Cc: Chen-Yu Tsai, linux-clk, linux-sunxi

Hi Maxime,

Here's a few fixes I came up with while thinking more about how to
implement some of the tricky clocks on the A83T.

Please have a look. The first 2 might need to go in stable, but I'll
leave the decision to you.

Regards
ChenYu


Chen-Yu Tsai (3):
  clk: sunxi-ng: use 1 as fallback for minimum multiplier
  clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch
  clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code

 drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 3 +--
 drivers/clk/sunxi-ng/ccu_nk.c        | 8 ++++----
 drivers/clk/sunxi-ng/ccu_nkm.c       | 8 ++++----
 drivers/clk/sunxi-ng/ccu_nkmp.c      | 8 ++++----
 drivers/clk/sunxi-ng/ccu_nm.c        | 4 ++--
 5 files changed, 15 insertions(+), 16 deletions(-)

-- 
2.11.0

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

* [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier
  2017-03-24  8:33 [PATCH 0/3] clk: sunxi-ng: minimum multiplier and comment fixes Chen-Yu Tsai
@ 2017-03-24  8:33 ` Chen-Yu Tsai
  2017-03-26 13:11   ` Maxime Ripard
  2017-03-24  8:33 ` [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch Chen-Yu Tsai
  2017-03-24  8:33 ` [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code Chen-Yu Tsai
  2 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-03-24  8:33 UTC (permalink / raw)
  To: Maxime Ripard, Michael Turquette, Stephen Boyd
  Cc: Chen-Yu Tsai, linux-clk, linux-sunxi

A zero multiplier does not make sense for clocks.

Use 1 as the minimum when a multiplier minimum isn't specified.

Fixes: 2beaa601c849 ("clk: sunxi-ng: Implement minimum for multipliers")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi-ng/ccu_nk.c   | 8 ++++----
 drivers/clk/sunxi-ng/ccu_nkm.c  | 8 ++++----
 drivers/clk/sunxi-ng/ccu_nkmp.c | 4 ++--
 drivers/clk/sunxi-ng/ccu_nm.c   | 2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu_nk.c b/drivers/clk/sunxi-ng/ccu_nk.c
index b9e9b8a9d1b4..2485bda87a9a 100644
--- a/drivers/clk/sunxi-ng/ccu_nk.c
+++ b/drivers/clk/sunxi-ng/ccu_nk.c
@@ -102,9 +102,9 @@ static long ccu_nk_round_rate(struct clk_hw *hw, unsigned long rate,
 	if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
 		rate *= nk->fixed_post_div;
 
-	_nk.min_n = nk->n.min;
+	_nk.min_n = nk->n.min ?: 1;
 	_nk.max_n = nk->n.max ?: 1 << nk->n.width;
-	_nk.min_k = nk->k.min;
+	_nk.min_k = nk->k.min ?: 1;
 	_nk.max_k = nk->k.max ?: 1 << nk->k.width;
 
 	ccu_nk_find_best(*parent_rate, rate, &_nk);
@@ -127,9 +127,9 @@ static int ccu_nk_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
 		rate = rate * nk->fixed_post_div;
 
-	_nk.min_n = nk->n.min;
+	_nk.min_n = nk->n.min ?: 1;
 	_nk.max_n = nk->n.max ?: 1 << nk->n.width;
-	_nk.min_k = nk->k.min;
+	_nk.min_k = nk->k.min ?: 1;
 	_nk.max_k = nk->k.max ?: 1 << nk->k.width;
 
 	ccu_nk_find_best(parent_rate, rate, &_nk);
diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
index 71f81e95a061..cba84afe1cf1 100644
--- a/drivers/clk/sunxi-ng/ccu_nkm.c
+++ b/drivers/clk/sunxi-ng/ccu_nkm.c
@@ -109,9 +109,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
 	struct ccu_nkm *nkm = data;
 	struct _ccu_nkm _nkm;
 
-	_nkm.min_n = nkm->n.min;
+	_nkm.min_n = nkm->n.min ?: 1;
 	_nkm.max_n = nkm->n.max ?: 1 << nkm->n.width;
-	_nkm.min_k = nkm->k.min;
+	_nkm.min_k = nkm->k.min ?: 1;
 	_nkm.max_k = nkm->k.max ?: 1 << nkm->k.width;
 	_nkm.min_m = 1;
 	_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
@@ -138,9 +138,9 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate,
 	unsigned long flags;
 	u32 reg;
 
-	_nkm.min_n = nkm->n.min;
+	_nkm.min_n = nkm->n.min ?: 1;
 	_nkm.max_n = nkm->n.max ?: 1 << nkm->n.width;
-	_nkm.min_k = nkm->k.min;
+	_nkm.min_k = nkm->k.min ?: 1;
 	_nkm.max_k = nkm->k.max ?: 1 << nkm->k.width;
 	_nkm.min_m = 1;
 	_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
diff --git a/drivers/clk/sunxi-ng/ccu_nkmp.c b/drivers/clk/sunxi-ng/ccu_nkmp.c
index 488055ed944f..162ff2664f64 100644
--- a/drivers/clk/sunxi-ng/ccu_nkmp.c
+++ b/drivers/clk/sunxi-ng/ccu_nkmp.c
@@ -116,9 +116,9 @@ static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,
 	struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw);
 	struct _ccu_nkmp _nkmp;
 
-	_nkmp.min_n = nkmp->n.min;
+	_nkmp.min_n = nkmp->n.min ?: 1;
 	_nkmp.max_n = nkmp->n.max ?: 1 << nkmp->n.width;
-	_nkmp.min_k = nkmp->k.min;
+	_nkmp.min_k = nkmp->k.min ?: 1;
 	_nkmp.max_k = nkmp->k.max ?: 1 << nkmp->k.width;
 	_nkmp.min_m = 1;
 	_nkmp.max_m = nkmp->m.max ?: 1 << nkmp->m.width;
diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c
index af71b1909cd9..f312c92f2a21 100644
--- a/drivers/clk/sunxi-ng/ccu_nm.c
+++ b/drivers/clk/sunxi-ng/ccu_nm.c
@@ -99,7 +99,7 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
 	struct ccu_nm *nm = hw_to_ccu_nm(hw);
 	struct _ccu_nm _nm;
 
-	_nm.min_n = nm->n.min;
+	_nm.min_n = nm->n.min ?: 1;
 	_nm.max_n = nm->n.max ?: 1 << nm->n.width;
 	_nm.min_m = 1;
 	_nm.max_m = nm->m.max ?: 1 << nm->m.width;
-- 
2.11.0

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

* [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch
  2017-03-24  8:33 [PATCH 0/3] clk: sunxi-ng: minimum multiplier and comment fixes Chen-Yu Tsai
  2017-03-24  8:33 ` [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier Chen-Yu Tsai
@ 2017-03-24  8:33 ` Chen-Yu Tsai
  2017-03-26 13:11   ` Maxime Ripard
  2017-03-24  8:33 ` [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code Chen-Yu Tsai
  2 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-03-24  8:33 UTC (permalink / raw)
  To: Maxime Ripard, Michael Turquette, Stephen Boyd
  Cc: Chen-Yu Tsai, linux-clk, linux-sunxi

In commit 2beaa601c849 ("clk: sunxi-ng: Implement minimum for
multipliers"), the multiplier minimums in the set_rate callback
for NM and NKMP style clocks were not updated.

This patch fixes them to match their round_rate callbacks.

Fixes: 2beaa601c849 ("clk: sunxi-ng: Implement minimum for multipliers")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi-ng/ccu_nkmp.c | 4 ++--
 drivers/clk/sunxi-ng/ccu_nm.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu_nkmp.c b/drivers/clk/sunxi-ng/ccu_nkmp.c
index 162ff2664f64..e58c95787f94 100644
--- a/drivers/clk/sunxi-ng/ccu_nkmp.c
+++ b/drivers/clk/sunxi-ng/ccu_nkmp.c
@@ -138,9 +138,9 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
 	unsigned long flags;
 	u32 reg;
 
-	_nkmp.min_n = 1;
+	_nkmp.min_n = nkmp->n.min ?: 1;
 	_nkmp.max_n = nkmp->n.max ?: 1 << nkmp->n.width;
-	_nkmp.min_k = 1;
+	_nkmp.min_k = nkmp->k.min ?: 1;
 	_nkmp.max_k = nkmp->k.max ?: 1 << nkmp->k.width;
 	_nkmp.min_m = 1;
 	_nkmp.max_m = nkmp->m.max ?: 1 << nkmp->m.width;
diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c
index f312c92f2a21..5e5e90a4a50c 100644
--- a/drivers/clk/sunxi-ng/ccu_nm.c
+++ b/drivers/clk/sunxi-ng/ccu_nm.c
@@ -122,7 +122,7 @@ static int ccu_nm_set_rate(struct clk_hw *hw, unsigned long rate,
 	else
 		ccu_frac_helper_disable(&nm->common, &nm->frac);
 
-	_nm.min_n = 1;
+	_nm.min_n = nm->n.min ?: 1;
 	_nm.max_n = nm->n.max ?: 1 << nm->n.width;
 	_nm.min_m = 1;
 	_nm.max_m = nm->m.max ?: 1 << nm->m.width;
-- 
2.11.0

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

* [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code
  2017-03-24  8:33 [PATCH 0/3] clk: sunxi-ng: minimum multiplier and comment fixes Chen-Yu Tsai
  2017-03-24  8:33 ` [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier Chen-Yu Tsai
  2017-03-24  8:33 ` [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch Chen-Yu Tsai
@ 2017-03-24  8:33 ` Chen-Yu Tsai
  2017-03-26 13:11   ` Maxime Ripard
  2 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-03-24  8:33 UTC (permalink / raw)
  To: Maxime Ripard, Michael Turquette, Stephen Boyd
  Cc: Chen-Yu Tsai, linux-clk, linux-sunxi

We ignore the d1 and d2 dividers in the audio PLL, and force them to
1 (register value 0) at probe time. However the comment preceding the
audio PLL definition says we enforce the default value, which is not
the same.

Fix the preceding comment to match what we do in code.

Fixes: b8eb71dcdd08 ("clk: sunxi-ng: Add A80 CCU")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
index e13e313ce4f5..a031beefa5b5 100644
--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
+++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
@@ -70,8 +70,7 @@ static struct ccu_nm pll_c1cpux_clk = {
 /*
  * The Audio PLL has d1, d2 dividers in addition to the usual N, M
  * factors. Since we only need 2 frequencies from this PLL: 22.5792 MHz
- * and 24.576 MHz, ignore them for now. Enforce the default for them,
- * which is d1 = 0, d2 = 1.
+ * and 24.576 MHz, ignore them for now. Enforce d1 = 0 and d2 = 0.
  */
 #define SUN9I_A80_PLL_AUDIO_REG	0x008
 
-- 
2.11.0

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

* Re: [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier
  2017-03-24  8:33 ` [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier Chen-Yu Tsai
@ 2017-03-26 13:11   ` Maxime Ripard
  0 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2017-03-26 13:11 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

On Fri, Mar 24, 2017 at 04:33:05PM +0800, Chen-Yu Tsai wrote:
> A zero multiplier does not make sense for clocks.
> 
> Use 1 as the minimum when a multiplier minimum isn't specified.
> 
> Fixes: 2beaa601c849 ("clk: sunxi-ng: Implement minimum for multipliers")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch
  2017-03-24  8:33 ` [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch Chen-Yu Tsai
@ 2017-03-26 13:11   ` Maxime Ripard
  0 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2017-03-26 13:11 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

On Fri, Mar 24, 2017 at 04:33:06PM +0800, Chen-Yu Tsai wrote:
> In commit 2beaa601c849 ("clk: sunxi-ng: Implement minimum for
> multipliers"), the multiplier minimums in the set_rate callback
> for NM and NKMP style clocks were not updated.
> 
> This patch fixes them to match their round_rate callbacks.
> 
> Fixes: 2beaa601c849 ("clk: sunxi-ng: Implement minimum for multipliers")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code
  2017-03-24  8:33 ` [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code Chen-Yu Tsai
@ 2017-03-26 13:11   ` Maxime Ripard
  0 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2017-03-26 13:11 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

On Fri, Mar 24, 2017 at 04:33:07PM +0800, Chen-Yu Tsai wrote:
> We ignore the d1 and d2 dividers in the audio PLL, and force them to
> 1 (register value 0) at probe time. However the comment preceding the
> audio PLL definition says we enforce the default value, which is not
> the same.
> 
> Fix the preceding comment to match what we do in code.
> 
> Fixes: b8eb71dcdd08 ("clk: sunxi-ng: Add A80 CCU")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2017-03-26 13:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-24  8:33 [PATCH 0/3] clk: sunxi-ng: minimum multiplier and comment fixes Chen-Yu Tsai
2017-03-24  8:33 ` [PATCH 1/3] clk: sunxi-ng: use 1 as fallback for minimum multiplier Chen-Yu Tsai
2017-03-26 13:11   ` Maxime Ripard
2017-03-24  8:33 ` [PATCH 2/3] clk: sunxi-ng: Fix round_rate/set_rate multiplier minimum mismatch Chen-Yu Tsai
2017-03-26 13:11   ` Maxime Ripard
2017-03-24  8:33 ` [PATCH 3/3] clk: sunxi-ng: a80: Fix audio PLL comment not matching actual code Chen-Yu Tsai
2017-03-26 13:11   ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox