mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source
@ 2012-06-07 13:00 Alexander Shiyan
  2012-06-07 13:00 ` [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs Alexander Shiyan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexander Shiyan @ 2012-06-07 13:00 UTC (permalink / raw)
  To: barebox


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/clko.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index 0e4fbcc..8e568d2 100644
--- a/arch/arm/mach-imx/clko.c
+++ b/arch/arm/mach-imx/clko.c
@@ -14,7 +14,7 @@ static int do_clko(int argc, char *argv[])
 			div = simple_strtoul(optarg, NULL, 0);
 			break;
 		case 's':
-			src = simple_strtoul(optarg, NULL, 0);
+			src = simple_strtol(optarg, NULL, 0);
 			break;
 		}
 	}
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs
  2012-06-07 13:00 [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Alexander Shiyan
@ 2012-06-07 13:00 ` Alexander Shiyan
  2012-06-25  7:26   ` Sascha Hauer
  2012-06-07 13:00 ` [PATCH 3/3] i.MX51: Added support for "clko" command Alexander Shiyan
  2012-06-07 17:35 ` [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Sascha Hauer
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Shiyan @ 2012-06-07 13:00 UTC (permalink / raw)
  To: barebox


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/clko.c               |   16 ++++++++++------
 arch/arm/mach-imx/include/mach/clock.h |    4 ++--
 arch/arm/mach-imx/speed-imx21.c        |   10 +++++++---
 arch/arm/mach-imx/speed-imx25.c        |   10 ++++++++--
 arch/arm/mach-imx/speed-imx27.c        |   11 +++++++++--
 arch/arm/mach-imx/speed-imx35.c        |   10 ++++++++--
 6 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index 8e568d2..4c5df71 100644
--- a/arch/arm/mach-imx/clko.c
+++ b/arch/arm/mach-imx/clko.c
@@ -6,10 +6,13 @@
 
 static int do_clko(int argc, char *argv[])
 {
-	int opt, div = 0, src = -2, ret;
+	int opt, div = 0, src = -2, num = 1, ret;
 
-	while((opt = getopt(argc, argv, "d:s:")) > 0) {
+	while((opt = getopt(argc, argv, "n:d:s:")) > 0) {
 		switch(opt) {
+		case 'n':
+			num = simple_strtoul(optarg, NULL, 0);
+			break;
 		case 'd':
 			div = simple_strtoul(optarg, NULL, 0);
 			break;
@@ -23,15 +26,15 @@ static int do_clko(int argc, char *argv[])
 		return COMMAND_ERROR_USAGE;
 
 	if (src == -1) {
-		imx_clko_set_src(-1);
+		imx_clko_set_src(num, -1);
 		return 0;
 	}
 
 	if (src != -2)
-		imx_clko_set_src(src);
+		imx_clko_set_src(num, src);
 
 	if (div != 0) {
-		ret = imx_clko_set_div(div);
+		ret = imx_clko_set_div(num, div);
 		if (ret != div)
 			printf("limited divider to %d\n", ret);
 	}
@@ -42,7 +45,8 @@ static int do_clko(int argc, char *argv[])
 static __maybe_unused char cmd_clko_help[] =
 "Usage: clko [OPTION]...\n"
 "Route different signals to the i.MX clko pin\n"
-"  -d  <div>	Divider\n"
+"  -n  <num>    Number of CLKO-line (Default 1)\n"
+"  -d  <div>    Divider\n"
 "  -s  <source> Clock select. See Ref. Manual for valid sources. Use -1\n"
 "               for disabling clock output\n";
 
diff --git a/arch/arm/mach-imx/include/mach/clock.h b/arch/arm/mach-imx/include/mach/clock.h
index 1082178..4b8fdd9 100644
--- a/arch/arm/mach-imx/include/mach/clock.h
+++ b/arch/arm/mach-imx/include/mach/clock.h
@@ -31,8 +31,8 @@ ulong imx_get_i2cclk(void);
 ulong imx_get_mmcclk(void);
 ulong imx_get_cspiclk(void);
 
-int imx_clko_set_div(int div);
-void imx_clko_set_src(int src);
+int imx_clko_set_div(int num, int div);
+void imx_clko_set_src(int num, int src);
 
 void imx_dump_clocks(void);
 
diff --git a/arch/arm/mach-imx/speed-imx21.c b/arch/arm/mach-imx/speed-imx21.c
index 6ab1dca..6b44efa 100644
--- a/arch/arm/mach-imx/speed-imx21.c
+++ b/arch/arm/mach-imx/speed-imx21.c
@@ -162,9 +162,13 @@ void imx_dump_clocks(void)
  * Returns the new divider (which may be smaller
  * than the desired one)
  */
-int imx_clko_set_div(int div)
+int imx_clko_set_div(int num, int div)
 {
 	ulong pcdr;
+
+	if (num != 1)
+		return;
+
 	div--;
 	div &= 0x7;
 
@@ -178,11 +182,11 @@ int imx_clko_set_div(int div)
 /*
  * Set the clock source for the CLKO pin
  */
-void imx_clko_set_src(int src)
+void imx_clko_set_src(int num, int src)
 {
 	unsigned long ccsr;
 
-	if (src < 0) {
+	if (src < 0 || num != 1) {
 		return;
 	}
 
diff --git a/arch/arm/mach-imx/speed-imx25.c b/arch/arm/mach-imx/speed-imx25.c
index f6dcacb..b5c9822 100644
--- a/arch/arm/mach-imx/speed-imx25.c
+++ b/arch/arm/mach-imx/speed-imx25.c
@@ -111,10 +111,13 @@ void imx_dump_clocks(void)
  * the new divider (which may be smaller
  * than the desired one)
  */
-int imx_clko_set_div(int div)
+int imx_clko_set_div(int num, int div)
 {
 	unsigned long mcr = readl(IMX_CCM_BASE + 0x64);
 
+	if (num != 1)
+		return;
+
 	div -= 1;
 	div &= 0x3f;
 
@@ -129,10 +132,13 @@ int imx_clko_set_div(int div)
 /*
  * Set the clock source for the CLKO pin
  */
-void imx_clko_set_src(int src)
+void imx_clko_set_src(int num, int src)
 {
 	unsigned long mcr = readl(IMX_CCM_BASE + 0x64);
 
+	if (num != 1)
+		return;
+
 	if (src < 0) {
 		mcr &= ~(1 << 30);
 		writel(mcr, IMX_CCM_BASE + 0x64);
diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
index aba5097..6c66344 100644
--- a/arch/arm/mach-imx/speed-imx27.c
+++ b/arch/arm/mach-imx/speed-imx27.c
@@ -189,9 +189,13 @@ void imx_dump_clocks(void)
  * the new divider (which may be smaller
  * than the desired one)
  */
-int imx_clko_set_div(int div)
+int imx_clko_set_div(int num, int div)
 {
 	ulong pcdr;
+
+	if (num != 1)
+		return;
+
 	div--;
 	div &= 0x7;
 
@@ -205,10 +209,13 @@ int imx_clko_set_div(int div)
 /*
  * Set the clock source for the CLKO pin
  */
-void imx_clko_set_src(int src)
+void imx_clko_set_src(int num, int src)
 {
 	unsigned long ccsr;
 
+	if (num != 1)
+		return;
+
 	if (src < 0) {
 		PCDR0 &= ~(1 << 25);
 		return;
diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
index 1e1c39f..28cd1b1 100644
--- a/arch/arm/mach-imx/speed-imx35.c
+++ b/arch/arm/mach-imx/speed-imx35.c
@@ -203,10 +203,13 @@ void imx_dump_clocks(void)
  * the new divider (which may be smaller
  * than the desired one)
  */
-int imx_clko_set_div(int div)
+int imx_clko_set_div(int num, int div)
 {
 	unsigned long cosr = readl(IMX_CCM_BASE + CCM_COSR);
 
+	if (num != 1)
+		return;
+
 	div -= 1;
 	div &= 0x3f;
 
@@ -221,10 +224,13 @@ int imx_clko_set_div(int div)
 /*
  * Set the clock source for the CLKO pin
  */
-void imx_clko_set_src(int src)
+void imx_clko_set_src(int num, int src)
 {
 	unsigned long cosr = readl(IMX_CCM_BASE + CCM_COSR);
 
+	if (num != 1)
+		return;
+
 	if (src < 0) {
 		cosr &= ~(1 << 5);
 		writel(cosr, IMX_CCM_BASE + CCM_COSR);
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] i.MX51: Added support for "clko" command
  2012-06-07 13:00 [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Alexander Shiyan
  2012-06-07 13:00 ` [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs Alexander Shiyan
@ 2012-06-07 13:00 ` Alexander Shiyan
  2012-06-07 17:35 ` [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Sascha Hauer
  2 siblings, 0 replies; 9+ messages in thread
From: Alexander Shiyan @ 2012-06-07 13:00 UTC (permalink / raw)
  To: barebox


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/Kconfig       |    2 +-
 arch/arm/mach-imx/speed-imx51.c |   69 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 564e2fe..3d84d63 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -517,7 +517,7 @@ menu "i.MX specific settings        "
 
 config IMX_CLKO
 	bool "clko command"
-	depends on ARCH_IMX21 || ARCH_IMX27 || ARCH_IMX35 || ARCH_IMX25
+	depends on ARCH_IMX21 || ARCH_IMX27 || ARCH_IMX35 || ARCH_IMX25 || ARCH_IMX51
 	help
 	  The i.MX SoCs have a Pin which can output different reference frequencies.
 	  Say y here if you want to have the clko command which lets you select the
diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index 8d1ecf3..f716346 100644
--- a/arch/arm/mach-imx/speed-imx51.c
+++ b/arch/arm/mach-imx/speed-imx51.c
@@ -9,6 +9,11 @@ static u32 ccm_readl(u32 ofs)
 	return readl(MX51_CCM_BASE_ADDR + ofs);
 }
 
+static void ccm_writel(u32 val, u32 ofs)
+{
+	writel(val, MX51_CCM_BASE_ADDR + ofs);
+}
+
 static unsigned long ckil_get_rate(void)
 {
 	return 32768;
@@ -221,6 +226,70 @@ unsigned long imx_get_usbclk(void)
 	return rate / (prediv * podf);
 }
 
+/*
+ * Set the divider of the CLKO pin. Returns
+ * the new divider (which may be smaller
+ * than the desired one)
+ */
+int imx_clko_set_div(int num, int div)
+{
+	u32 ccosr = ccm_readl(MX5_CCM_CCOSR);
+
+	div--;
+
+	switch (num) {
+	case 1:
+		div &= 0x7;
+		ccosr &= ~(0x7 << 4);
+		ccosr |= div << 4;
+		ccm_writel(ccosr, MX5_CCM_CCOSR);
+		break;
+	case 2:
+		div &= 0x7;
+		ccosr &= ~(0x7 << 21);
+		ccosr |= div << 21;
+		ccm_writel(ccosr, MX5_CCM_CCOSR);
+		break;
+	default:
+		break;
+	}
+
+	return div + 1;
+}
+
+/*
+ * Set the clock source for the CLKO pin
+ */
+void imx_clko_set_src(int num, int src)
+{
+	u32 ccosr = ccm_readl(MX5_CCM_CCOSR);
+
+	switch (num) {
+	case 1:
+		if (src < 0) {
+			ccosr &= ~(1 << 7);
+			break;
+		}
+		ccosr &= ~0xf;
+		ccosr |= src & 0xf;
+		ccosr |= 1 << 7;
+		break;
+	case 2:
+		if (src < 0) {
+			ccosr &= ~(1 << 24);
+			break;
+		}
+		ccosr &= ~(0x1f << 16);
+		ccosr |= (src & 0x1f) << 16;
+		ccosr |= 1 << 24;
+		break;
+	default:
+		return;
+	}
+
+	ccm_writel(ccosr, MX5_CCM_CCOSR);
+}
+
 void imx_dump_clocks(void)
 {
 	printf("pll1:   %ld\n", pll1_main_get_rate());
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source
  2012-06-07 13:00 [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Alexander Shiyan
  2012-06-07 13:00 ` [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs Alexander Shiyan
  2012-06-07 13:00 ` [PATCH 3/3] i.MX51: Added support for "clko" command Alexander Shiyan
@ 2012-06-07 17:35 ` Sascha Hauer
  2012-06-08  6:29   ` Alexander Shiyan
  2 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2012-06-07 17:35 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Thu, Jun 07, 2012 at 05:00:49PM +0400, Alexander Shiyan wrote:
> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  arch/arm/mach-imx/clko.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>

Can you please add an explanation why this change is done? I assume that
-1 can be used to disable clko, but the commit log should mention this.

Sascha

> diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
> index 0e4fbcc..8e568d2 100644
> --- a/arch/arm/mach-imx/clko.c
> +++ b/arch/arm/mach-imx/clko.c
> @@ -14,7 +14,7 @@ static int do_clko(int argc, char *argv[])
>  			div = simple_strtoul(optarg, NULL, 0);
>  			break;
>  		case 's':
> -			src = simple_strtoul(optarg, NULL, 0);
> +			src = simple_strtol(optarg, NULL, 0);
>  			break;
>  		}
>  	}
> -- 
> 1.7.3.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source
  2012-06-07 17:35 ` [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Sascha Hauer
@ 2012-06-08  6:29   ` Alexander Shiyan
  2012-06-08  6:35     ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Shiyan @ 2012-06-08  6:29 UTC (permalink / raw)
  To: barebox

This change is necessary because valid source argument for the clko command
can be negative.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/clko.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index 0e4fbcc..8e568d2 100644
--- a/arch/arm/mach-imx/clko.c
+++ b/arch/arm/mach-imx/clko.c
@@ -14,7 +14,7 @@ static int do_clko(int argc, char *argv[])
 			div = simple_strtoul(optarg, NULL, 0);
 			break;
 		case 's':
-			src = simple_strtoul(optarg, NULL, 0);
+			src = simple_strtol(optarg, NULL, 0);
 			break;
 		}
 	}
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source
  2012-06-08  6:29   ` Alexander Shiyan
@ 2012-06-08  6:35     ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2012-06-08  6:35 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Fri, Jun 08, 2012 at 10:29:52AM +0400, Alexander Shiyan wrote:
> This change is necessary because valid source argument for the clko command
> can be negative.
> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>

Applied, thanks

Sascha

> ---
>  arch/arm/mach-imx/clko.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
> index 0e4fbcc..8e568d2 100644
> --- a/arch/arm/mach-imx/clko.c
> +++ b/arch/arm/mach-imx/clko.c
> @@ -14,7 +14,7 @@ static int do_clko(int argc, char *argv[])
>  			div = simple_strtoul(optarg, NULL, 0);
>  			break;
>  		case 's':
> -			src = simple_strtoul(optarg, NULL, 0);
> +			src = simple_strtol(optarg, NULL, 0);
>  			break;
>  		}
>  	}
> -- 
> 1.7.3.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs
  2012-06-07 13:00 ` [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs Alexander Shiyan
@ 2012-06-25  7:26   ` Sascha Hauer
  2012-06-25  8:54     ` [PATCH] i.MX clko: Checking for clko-line properly Alexander Shiyan
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2012-06-25  7:26 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

Hi Alexander,

This patch introduces several build warnings and also has a problem
with error checking. Could you update it?

Thanks
 Sascha

On Thu, Jun 07, 2012 at 05:00:50PM +0400, Alexander Shiyan wrote:
> 
> ---
>  	if (div != 0) {
> -		ret = imx_clko_set_div(div);
> +		ret = imx_clko_set_div(num, div);
>  		if (ret != div)
>  			printf("limited divider to %d\n", ret);

Up to this patch imx_clko_set_div only returned the real divider, but
with this patch it can also return errors, so you have to check for
them. "limited divider to -22" would be quite confusing for the reader.

> +++ b/arch/arm/mach-imx/speed-imx21.c
> @@ -162,9 +162,13 @@ void imx_dump_clocks(void)
>   * Returns the new divider (which may be smaller
>   * than the desired one)
>   */
> -int imx_clko_set_div(int div)
> +int imx_clko_set_div(int num, int div)
>  {
>  	ulong pcdr;
> +
> +	if (num != 1)
> +		return;
> +

arch/arm/mach-imx/speed-imx21.c: In function 'imx_clko_set_div':                                                           arch/arm/mach-imx/speed-imx21.c:170:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]

> diff --git a/arch/arm/mach-imx/speed-imx25.c b/arch/arm/mach-imx/speed-imx25.c
> index f6dcacb..b5c9822 100644
> --- a/arch/arm/mach-imx/speed-imx25.c
> +++ b/arch/arm/mach-imx/speed-imx25.c
> @@ -111,10 +111,13 @@ void imx_dump_clocks(void)
>   * the new divider (which may be smaller
>   * than the desired one)
>   */
> -int imx_clko_set_div(int div)
> +int imx_clko_set_div(int num, int div)
>  {
>  	unsigned long mcr = readl(IMX_CCM_BASE + 0x64);
>  
> +	if (num != 1)
> +		return;

arch/arm/mach-imx/speed-imx25.c: In function 'imx_clko_set_div':                                                           arch/arm/mach-imx/speed-imx25.c:119:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]

> diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
> index aba5097..6c66344 100644
> --- a/arch/arm/mach-imx/speed-imx27.c
> +++ b/arch/arm/mach-imx/speed-imx27.c
> @@ -189,9 +189,13 @@ void imx_dump_clocks(void)
>   * the new divider (which may be smaller
>   * than the desired one)
>   */
> -int imx_clko_set_div(int div)
> +int imx_clko_set_div(int num, int div)
>  {
>  	ulong pcdr;
> +
> +	if (num != 1)
> +		return;

arch/arm/mach-imx/speed-imx27.c: In function 'imx_clko_set_div':
arch/arm/mach-imx/speed-imx27.c:197:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]

> diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
> index 1e1c39f..28cd1b1 100644
> --- a/arch/arm/mach-imx/speed-imx35.c
> +++ b/arch/arm/mach-imx/speed-imx35.c
> @@ -203,10 +203,13 @@ void imx_dump_clocks(void)
>   * the new divider (which may be smaller
>   * than the desired one)
>   */
> -int imx_clko_set_div(int div)
> +int imx_clko_set_div(int num, int div)
>  {
>  	unsigned long cosr = readl(IMX_CCM_BASE + CCM_COSR);
>  
> +	if (num != 1)
> +		return;

arch/arm/mach-imx/speed-imx35.c: In function 'imx_clko_set_div':
arch/arm/mach-imx/speed-imx35.c:211:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]


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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] i.MX clko: Checking for clko-line properly
  2012-06-25  7:26   ` Sascha Hauer
@ 2012-06-25  8:54     ` Alexander Shiyan
  2012-06-25 12:21       ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Shiyan @ 2012-06-25  8:54 UTC (permalink / raw)
  To: barebox

This patch adds a check for the correct number of CLKO-line.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/clko.c        |    6 ++++--
 arch/arm/mach-imx/speed-imx21.c |    3 ++-
 arch/arm/mach-imx/speed-imx25.c |    3 ++-
 arch/arm/mach-imx/speed-imx27.c |    3 ++-
 arch/arm/mach-imx/speed-imx35.c |    3 ++-
 arch/arm/mach-imx/speed-imx51.c |    3 ++-
 6 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index 4c5df71..aeafaa9 100644
--- a/arch/arm/mach-imx/clko.c
+++ b/arch/arm/mach-imx/clko.c
@@ -35,8 +35,10 @@ static int do_clko(int argc, char *argv[])
 
 	if (div != 0) {
 		ret = imx_clko_set_div(num, div);
-		if (ret != div)
-			printf("limited divider to %d\n", ret);
+		if (ret < 0)
+			printf("CLKO-line %i not supported.\n", num);
+		else if (ret != div)
+			printf("Divider limited to %d.\n", ret);
 	}
 
 	return 0;
diff --git a/arch/arm/mach-imx/speed-imx21.c b/arch/arm/mach-imx/speed-imx21.c
index 6b44efa..4729583 100644
--- a/arch/arm/mach-imx/speed-imx21.c
+++ b/arch/arm/mach-imx/speed-imx21.c
@@ -16,6 +16,7 @@
  */
 
 #include <common.h>
+#include <asm-generic/errno.h>
 #include <mach/imx-regs.h>
 #include <mach/generic.h>
 #include <mach/clock.h>
@@ -167,7 +168,7 @@ int imx_clko_set_div(int num, int div)
 	ulong pcdr;
 
 	if (num != 1)
-		return;
+		return -ENODEV;
 
 	div--;
 	div &= 0x7;
diff --git a/arch/arm/mach-imx/speed-imx25.c b/arch/arm/mach-imx/speed-imx25.c
index b5c9822..ed14113 100644
--- a/arch/arm/mach-imx/speed-imx25.c
+++ b/arch/arm/mach-imx/speed-imx25.c
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <asm-generic/errno.h>
 #include <mach/imx-regs.h>
 #include <io.h>
 #include <mach/clock.h>
@@ -116,7 +117,7 @@ int imx_clko_set_div(int num, int div)
 	unsigned long mcr = readl(IMX_CCM_BASE + 0x64);
 
 	if (num != 1)
-		return;
+		return -ENODEV;
 
 	div -= 1;
 	div &= 0x3f;
diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
index 6c66344..644fd04 100644
--- a/arch/arm/mach-imx/speed-imx27.c
+++ b/arch/arm/mach-imx/speed-imx27.c
@@ -16,6 +16,7 @@
  */
 
 #include <common.h>
+#include <asm-generic/errno.h>
 #include <mach/imx-regs.h>
 #include <mach/generic.h>
 #include <mach/clock.h>
@@ -194,7 +195,7 @@ int imx_clko_set_div(int num, int div)
 	ulong pcdr;
 
 	if (num != 1)
-		return;
+		return -ENODEV;
 
 	div--;
 	div &= 0x7;
diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
index 28cd1b1..2b707aa 100644
--- a/arch/arm/mach-imx/speed-imx35.c
+++ b/arch/arm/mach-imx/speed-imx35.c
@@ -16,6 +16,7 @@
  */
 
 #include <common.h>
+#include <asm-generic/errno.h>
 #include <mach/imx-regs.h>
 #include <io.h>
 #include <mach/clock.h>
@@ -208,7 +209,7 @@ int imx_clko_set_div(int num, int div)
 	unsigned long cosr = readl(IMX_CCM_BASE + CCM_COSR);
 
 	if (num != 1)
-		return;
+		return -ENODEV;
 
 	div -= 1;
 	div &= 0x3f;
diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index f716346..63d4932 100644
--- a/arch/arm/mach-imx/speed-imx51.c
+++ b/arch/arm/mach-imx/speed-imx51.c
@@ -1,6 +1,7 @@
 #include <common.h>
 #include <io.h>
 #include <asm-generic/div64.h>
+#include <asm-generic/errno.h>
 #include <mach/imx51-regs.h>
 #include <mach/clock-imx51_53.h>
 
@@ -251,7 +252,7 @@ int imx_clko_set_div(int num, int div)
 		ccm_writel(ccosr, MX5_CCM_CCOSR);
 		break;
 	default:
-		break;
+		return -ENODEV;
 	}
 
 	return div + 1;
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] i.MX clko: Checking for clko-line properly
  2012-06-25  8:54     ` [PATCH] i.MX clko: Checking for clko-line properly Alexander Shiyan
@ 2012-06-25 12:21       ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2012-06-25 12:21 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Mon, Jun 25, 2012 at 12:54:58PM +0400, Alexander Shiyan wrote:
> This patch adds a check for the correct number of CLKO-line.

Squashed into the original commit causing the failure

Thanks
 Sascha

> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  arch/arm/mach-imx/clko.c        |    6 ++++--
>  arch/arm/mach-imx/speed-imx21.c |    3 ++-
>  arch/arm/mach-imx/speed-imx25.c |    3 ++-
>  arch/arm/mach-imx/speed-imx27.c |    3 ++-
>  arch/arm/mach-imx/speed-imx35.c |    3 ++-
>  arch/arm/mach-imx/speed-imx51.c |    3 ++-
>  6 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
> index 4c5df71..aeafaa9 100644
> --- a/arch/arm/mach-imx/clko.c
> +++ b/arch/arm/mach-imx/clko.c
> @@ -35,8 +35,10 @@ static int do_clko(int argc, char *argv[])
>  
>  	if (div != 0) {
>  		ret = imx_clko_set_div(num, div);
> -		if (ret != div)
> -			printf("limited divider to %d\n", ret);
> +		if (ret < 0)
> +			printf("CLKO-line %i not supported.\n", num);
> +		else if (ret != div)
> +			printf("Divider limited to %d.\n", ret);
>  	}
>  
>  	return 0;
> diff --git a/arch/arm/mach-imx/speed-imx21.c b/arch/arm/mach-imx/speed-imx21.c
> index 6b44efa..4729583 100644
> --- a/arch/arm/mach-imx/speed-imx21.c
> +++ b/arch/arm/mach-imx/speed-imx21.c
> @@ -16,6 +16,7 @@
>   */
>  
>  #include <common.h>
> +#include <asm-generic/errno.h>
>  #include <mach/imx-regs.h>
>  #include <mach/generic.h>
>  #include <mach/clock.h>
> @@ -167,7 +168,7 @@ int imx_clko_set_div(int num, int div)
>  	ulong pcdr;
>  
>  	if (num != 1)
> -		return;
> +		return -ENODEV;
>  
>  	div--;
>  	div &= 0x7;
> diff --git a/arch/arm/mach-imx/speed-imx25.c b/arch/arm/mach-imx/speed-imx25.c
> index b5c9822..ed14113 100644
> --- a/arch/arm/mach-imx/speed-imx25.c
> +++ b/arch/arm/mach-imx/speed-imx25.c
> @@ -1,4 +1,5 @@
>  #include <common.h>
> +#include <asm-generic/errno.h>
>  #include <mach/imx-regs.h>
>  #include <io.h>
>  #include <mach/clock.h>
> @@ -116,7 +117,7 @@ int imx_clko_set_div(int num, int div)
>  	unsigned long mcr = readl(IMX_CCM_BASE + 0x64);
>  
>  	if (num != 1)
> -		return;
> +		return -ENODEV;
>  
>  	div -= 1;
>  	div &= 0x3f;
> diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
> index 6c66344..644fd04 100644
> --- a/arch/arm/mach-imx/speed-imx27.c
> +++ b/arch/arm/mach-imx/speed-imx27.c
> @@ -16,6 +16,7 @@
>   */
>  
>  #include <common.h>
> +#include <asm-generic/errno.h>
>  #include <mach/imx-regs.h>
>  #include <mach/generic.h>
>  #include <mach/clock.h>
> @@ -194,7 +195,7 @@ int imx_clko_set_div(int num, int div)
>  	ulong pcdr;
>  
>  	if (num != 1)
> -		return;
> +		return -ENODEV;
>  
>  	div--;
>  	div &= 0x7;
> diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
> index 28cd1b1..2b707aa 100644
> --- a/arch/arm/mach-imx/speed-imx35.c
> +++ b/arch/arm/mach-imx/speed-imx35.c
> @@ -16,6 +16,7 @@
>   */
>  
>  #include <common.h>
> +#include <asm-generic/errno.h>
>  #include <mach/imx-regs.h>
>  #include <io.h>
>  #include <mach/clock.h>
> @@ -208,7 +209,7 @@ int imx_clko_set_div(int num, int div)
>  	unsigned long cosr = readl(IMX_CCM_BASE + CCM_COSR);
>  
>  	if (num != 1)
> -		return;
> +		return -ENODEV;
>  
>  	div -= 1;
>  	div &= 0x3f;
> diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
> index f716346..63d4932 100644
> --- a/arch/arm/mach-imx/speed-imx51.c
> +++ b/arch/arm/mach-imx/speed-imx51.c
> @@ -1,6 +1,7 @@
>  #include <common.h>
>  #include <io.h>
>  #include <asm-generic/div64.h>
> +#include <asm-generic/errno.h>
>  #include <mach/imx51-regs.h>
>  #include <mach/clock-imx51_53.h>
>  
> @@ -251,7 +252,7 @@ int imx_clko_set_div(int num, int div)
>  		ccm_writel(ccosr, MX5_CCM_CCOSR);
>  		break;
>  	default:
> -		break;
> +		return -ENODEV;
>  	}
>  
>  	return div + 1;
> -- 
> 1.7.3.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-06-25 12:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07 13:00 [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Alexander Shiyan
2012-06-07 13:00 ` [PATCH 2/3] i.MX clko: Added support for more than one CLKO outputs Alexander Shiyan
2012-06-25  7:26   ` Sascha Hauer
2012-06-25  8:54     ` [PATCH] i.MX clko: Checking for clko-line properly Alexander Shiyan
2012-06-25 12:21       ` Sascha Hauer
2012-06-07 13:00 ` [PATCH 3/3] i.MX51: Added support for "clko" command Alexander Shiyan
2012-06-07 17:35 ` [PATCH 1/3] I.MX clko: Using strtol function instead strtoul for getting argument for clko source Sascha Hauer
2012-06-08  6:29   ` Alexander Shiyan
2012-06-08  6:35     ` Sascha Hauer

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