linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* ARM: mx51/53: fix _clk_max_* misuse and add esdhc round_rate
@ 2011-12-08  1:28 Richard Zhao
  2011-12-08  1:28 ` [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable Richard Zhao
  2011-12-08  1:28 ` [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks Richard Zhao
  0 siblings, 2 replies; 7+ messages in thread
From: Richard Zhao @ 2011-12-08  1:28 UTC (permalink / raw)
  To: linux-arm-kernel

Changes since v1:
-split into two patch. one for  _clk_max_*, the other for esdhc round_rate
-rebase onto arm-soc for-next

Thanks
Richard

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

* [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable
  2011-12-08  1:28 ARM: mx51/53: fix _clk_max_* misuse and add esdhc round_rate Richard Zhao
@ 2011-12-08  1:28 ` Richard Zhao
  2011-12-08  9:55   ` Sascha Hauer
  2011-12-08  1:28 ` [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks Richard Zhao
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Zhao @ 2011-12-08  1:28 UTC (permalink / raw)
  To: linux-arm-kernel

_clk_max_enable and _clk_max_disable should only be used by ahb_max_clk,
rather not unrelated clocks.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
---
 arch/arm/mach-imx/clock-mx51-mx53.c |   40 +++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-imx/clock-mx51-mx53.c b/arch/arm/mach-imx/clock-mx51-mx53.c
index 0847050..716533b 100644
--- a/arch/arm/mach-imx/clock-mx51-mx53.c
+++ b/arch/arm/mach-imx/clock-mx51-mx53.c
@@ -1013,7 +1013,7 @@ static struct clk mipi_hsp_clk = {
 		.secondary	= s,			\
 	}
 
-#define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s)	\
+#define DEFINE_CLOCK_ESDHC(name, i, er, es, pfx, p, s)	\
 	static struct clk name = {			\
 		.id		= i,			\
 		.enable_reg	= er,			\
@@ -1021,8 +1021,8 @@ static struct clk mipi_hsp_clk = {
 		.get_rate	= pfx##_get_rate,	\
 		.set_rate	= pfx##_set_rate,	\
 		.set_parent	= pfx##_set_parent,	\
-		.enable		= _clk_max_enable,	\
-		.disable	= _clk_max_disable,	\
+		.enable		= _clk_ccgr_enable,	\
+		.disable	= _clk_ccgr_disable,	\
 		.parent		= p,			\
 		.secondary	= s,			\
 	}
@@ -1341,18 +1341,18 @@ DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET,
 
 /* eSDHC */
 DEFINE_CLOCK_FULL(esdhc1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG0_OFFSET,
-	NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
-DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
+	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
+DEFINE_CLOCK_ESDHC(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
 	clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk);
 DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET,
-	NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
+	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
 DEFINE_CLOCK_FULL(esdhc3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG4_OFFSET,
-	NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
+	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
 DEFINE_CLOCK_FULL(esdhc4_ipg_clk, 3, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG6_OFFSET,
-	NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
+	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
 
 /* mx51 specific */
-DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
+DEFINE_CLOCK_ESDHC(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
 	clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk);
 
 static struct clk esdhc3_clk = {
@@ -1361,8 +1361,8 @@ static struct clk esdhc3_clk = {
 	.set_parent = clk_esdhc3_set_parent,
 	.enable_reg = MXC_CCM_CCGR3,
 	.enable_shift = MXC_CCM_CCGRx_CG5_OFFSET,
-	.enable  = _clk_max_enable,
-	.disable = _clk_max_disable,
+	.enable  = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable,
 	.secondary = &esdhc3_ipg_clk,
 };
 static struct clk esdhc4_clk = {
@@ -1371,8 +1371,8 @@ static struct clk esdhc4_clk = {
 	.set_parent = clk_esdhc4_set_parent,
 	.enable_reg = MXC_CCM_CCGR3,
 	.enable_shift = MXC_CCM_CCGRx_CG7_OFFSET,
-	.enable  = _clk_max_enable,
-	.disable = _clk_max_disable,
+	.enable  = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable,
 	.secondary = &esdhc4_ipg_clk,
 };
 
@@ -1383,12 +1383,12 @@ static struct clk esdhc2_mx53_clk = {
 	.set_parent = clk_esdhc2_mx53_set_parent,
 	.enable_reg = MXC_CCM_CCGR3,
 	.enable_shift = MXC_CCM_CCGRx_CG3_OFFSET,
-	.enable  = _clk_max_enable,
-	.disable = _clk_max_disable,
+	.enable  = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable,
 	.secondary = &esdhc3_ipg_clk,
 };
 
-DEFINE_CLOCK_MAX(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET,
+DEFINE_CLOCK_ESDHC(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET,
 	clk_esdhc3_mx53, &pll2_sw_clk, &esdhc2_ipg_clk);
 
 static struct clk esdhc4_mx53_clk = {
@@ -1397,17 +1397,17 @@ static struct clk esdhc4_mx53_clk = {
 	.set_parent = clk_esdhc4_mx53_set_parent,
 	.enable_reg = MXC_CCM_CCGR3,
 	.enable_shift = MXC_CCM_CCGRx_CG7_OFFSET,
-	.enable  = _clk_max_enable,
-	.disable = _clk_max_disable,
+	.enable  = _clk_ccgr_enable,
+	.disable = _clk_ccgr_disable,
 	.secondary = &esdhc4_ipg_clk,
 };
 
 static struct clk sata_clk = {
 	.parent = &ipg_clk,
-	.enable = _clk_max_enable,
+	.enable = _clk_ccgr_enable,
 	.enable_reg = MXC_CCM_CCGR4,
 	.enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
-	.disable = _clk_max_disable,
+	.disable = _clk_ccgr_disable,
 };
 
 static struct clk ahci_phy_clk = {
-- 
1.7.5.4

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

* [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks
  2011-12-08  1:28 ARM: mx51/53: fix _clk_max_* misuse and add esdhc round_rate Richard Zhao
  2011-12-08  1:28 ` [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable Richard Zhao
@ 2011-12-08  1:28 ` Richard Zhao
  2011-12-08  9:33   ` Sascha Hauer
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Zhao @ 2011-12-08  1:28 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
---
 arch/arm/mach-imx/clock-mx51-mx53.c |   42 ++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-imx/clock-mx51-mx53.c b/arch/arm/mach-imx/clock-mx51-mx53.c
index 716533b..7df85ba 100644
--- a/arch/arm/mach-imx/clock-mx51-mx53.c
+++ b/arch/arm/mach-imx/clock-mx51-mx53.c
@@ -1013,20 +1013,6 @@ static struct clk mipi_hsp_clk = {
 		.secondary	= s,			\
 	}
 
-#define DEFINE_CLOCK_ESDHC(name, i, er, es, pfx, p, s)	\
-	static struct clk name = {			\
-		.id		= i,			\
-		.enable_reg	= er,			\
-		.enable_shift	= es,			\
-		.get_rate	= pfx##_get_rate,	\
-		.set_rate	= pfx##_set_rate,	\
-		.set_parent	= pfx##_set_parent,	\
-		.enable		= _clk_ccgr_enable,	\
-		.disable	= _clk_ccgr_disable,	\
-		.parent		= p,			\
-		.secondary	= s,			\
-	}
-
 #define CLK_GET_RATE(name, nr, bitsname)				\
 static unsigned long clk_##name##_get_rate(struct clk *clk)		\
 {									\
@@ -1088,6 +1074,25 @@ static int clk_##name##_set_rate(struct clk *clk, unsigned long rate)	\
 	return 0;							\
 }
 
+#define CLK_ROUND_RATE(name , nr, bitsname)				\
+static unsigned long clk_##name##_round_rate(struct clk *clk,		\
+						unsigned long rate)	\
+{									\
+	u32 div, parent_rate;						\
+	u32 pre = 0, post = 0;						\
+									\
+	parent_rate = clk_get_rate(clk->parent);			\
+	div = DIV_ROUND_UP(parent_rate, rate);				\
+									\
+	__calc_pre_post_dividers(div, &pre, &post,			\
+		(MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK >>	\
+		MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET) + 1,	\
+		(MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK >>	\
+		MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET) + 1);	\
+									\
+	return parent_rate / pre / post;				\
+}
+
 /* UART */
 CLK_GET_RATE(uart, 1, UART)
 CLK_SET_PARENT(uart, 1, UART)
@@ -1157,11 +1162,13 @@ static struct clk ecspi_main_clk = {
 CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1)
 CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1)
 CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1)
+CLK_ROUND_RATE(esdhc1, 1, ESDHC1_MSHC1)
 
 /* mx51 specific */
 CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2)
 CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2)
 CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2)
+CLK_ROUND_RATE(esdhc2, 1, ESDHC2_MSHC2)
 
 static int clk_esdhc3_set_parent(struct clk *clk, struct clk *parent)
 {
@@ -1215,6 +1222,7 @@ static int clk_esdhc2_mx53_set_parent(struct clk *clk, struct clk *parent)
 CLK_GET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
 CLK_SET_PARENT(esdhc3_mx53, 1, ESDHC3_MX53)
 CLK_SET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
+CLK_ROUND_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
 
 static int clk_esdhc4_mx53_set_parent(struct clk *clk, struct clk *parent)
 {
@@ -1342,7 +1350,7 @@ DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET,
 /* eSDHC */
 DEFINE_CLOCK_FULL(esdhc1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG0_OFFSET,
 	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
-DEFINE_CLOCK_ESDHC(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
+DEFINE_CLOCK_CCGR(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
 	clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk);
 DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET,
 	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
@@ -1352,7 +1360,7 @@ DEFINE_CLOCK_FULL(esdhc4_ipg_clk, 3, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG6_OFFSET,
 	NULL,  NULL, _clk_ccgr_enable, _clk_ccgr_disable, &ipg_clk, NULL);
 
 /* mx51 specific */
-DEFINE_CLOCK_ESDHC(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
+DEFINE_CLOCK_CCGR(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
 	clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk);
 
 static struct clk esdhc3_clk = {
@@ -1388,7 +1396,7 @@ static struct clk esdhc2_mx53_clk = {
 	.secondary = &esdhc3_ipg_clk,
 };
 
-DEFINE_CLOCK_ESDHC(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET,
+DEFINE_CLOCK_CCGR(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET,
 	clk_esdhc3_mx53, &pll2_sw_clk, &esdhc2_ipg_clk);
 
 static struct clk esdhc4_mx53_clk = {
-- 
1.7.5.4

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

* [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks
  2011-12-08  1:28 ` [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks Richard Zhao
@ 2011-12-08  9:33   ` Sascha Hauer
  2011-12-08 12:18     ` Richard Zhao
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2011-12-08  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Richard,

On Thu, Dec 08, 2011 at 09:28:34AM +0800, Richard Zhao wrote:
> Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
> ---
>  arch/arm/mach-imx/clock-mx51-mx53.c |   42 ++++++++++++++++++++--------------
>  1 files changed, 25 insertions(+), 17 deletions(-)
> 

Is it worth it to queue this one given that you are working on generic
clock support for i.MX5?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable
  2011-12-08  1:28 ` [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable Richard Zhao
@ 2011-12-08  9:55   ` Sascha Hauer
  2011-12-08 12:21     ` Richard Zhao
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2011-12-08  9:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 09:28:33AM +0800, Richard Zhao wrote:
> _clk_max_enable and _clk_max_disable should only be used by ahb_max_clk,
> rather not unrelated clocks.

Since you based this onto arm-soc/for-net I assume applying it for
next is ok for you?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks
  2011-12-08  9:33   ` Sascha Hauer
@ 2011-12-08 12:18     ` Richard Zhao
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Zhao @ 2011-12-08 12:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 10:33:10AM +0100, Sascha Hauer wrote:
> Hi Richard,
> 
> On Thu, Dec 08, 2011 at 09:28:34AM +0800, Richard Zhao wrote:
> > Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
> > ---
> >  arch/arm/mach-imx/clock-mx51-mx53.c |   42 ++++++++++++++++++++--------------
> >  1 files changed, 25 insertions(+), 17 deletions(-)
> > 
> 
> Is it worth it to queue this one given that you are working on generic
> clock support for i.MX5?
I think yes. I don't know when generic clock go into mainline,
at leat in serveral months.

Thanks
Richard
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable
  2011-12-08  9:55   ` Sascha Hauer
@ 2011-12-08 12:21     ` Richard Zhao
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Zhao @ 2011-12-08 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 10:55:08AM +0100, Sascha Hauer wrote:
> On Thu, Dec 08, 2011 at 09:28:33AM +0800, Richard Zhao wrote:
> > _clk_max_enable and _clk_max_disable should only be used by ahb_max_clk,
> > rather not unrelated clocks.
> 
> Since you based this onto arm-soc/for-net I assume applying it for
> next is ok for you?
It's up to you. Applying for-next probably avoid merge conflicts.

Thanks
Richard
> 
> Sascha

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

end of thread, other threads:[~2011-12-08 12:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08  1:28 ARM: mx51/53: fix _clk_max_* misuse and add esdhc round_rate Richard Zhao
2011-12-08  1:28 ` [PATCH V2 1/2] ARM: mx51/53: correct misuse of _clk_max_enable and _clk_max_disable Richard Zhao
2011-12-08  9:55   ` Sascha Hauer
2011-12-08 12:21     ` Richard Zhao
2011-12-08  1:28 ` [PATCH V2 2/2] ARM: mx51/53: add round_rate for esdhc clocks Richard Zhao
2011-12-08  9:33   ` Sascha Hauer
2011-12-08 12:18     ` Richard Zhao

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).