summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2012-06-07 17:00:50 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-06-30 12:46:55 +0200
commit9ec34264f01cfe87d10efa74872e8116bdc6012a (patch)
treed734425625ca0aab4908ec261ec7428e24b7c408 /arch
parent3e2ed9423f9adfedb02189c91858654b4c502382 (diff)
downloadbarebox-9ec34264f01cfe87d10efa74872e8116bdc6012a.tar.gz
barebox-9ec34264f01cfe87d10efa74872e8116bdc6012a.tar.xz
i.MX clko: Added support for more than one CLKO outputs
Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-imx/clko.c22
-rw-r--r--arch/arm/mach-imx/include/mach/clock.h4
-rw-r--r--arch/arm/mach-imx/speed-imx21.c11
-rw-r--r--arch/arm/mach-imx/speed-imx25.c11
-rw-r--r--arch/arm/mach-imx/speed-imx27.c12
-rw-r--r--arch/arm/mach-imx/speed-imx35.c11
-rw-r--r--arch/arm/mach-imx/speed-imx51.c1
7 files changed, 53 insertions, 19 deletions
diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index 8e568d2631..aeafaa9c41 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,17 +26,19 @@ 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);
- if (ret != div)
- printf("limited divider to %d\n", ret);
+ ret = imx_clko_set_div(num, div);
+ if (ret < 0)
+ printf("CLKO-line %i not supported.\n", num);
+ else if (ret != div)
+ printf("Divider limited to %d.\n", ret);
}
return 0;
@@ -42,7 +47,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 10821782fe..4b8fdd98af 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 6ab1dca3f3..4729583693 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>
@@ -162,9 +163,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 -ENODEV;
+
div--;
div &= 0x7;
@@ -178,11 +183,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 f6dcacb71b..ed14113f76 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>
@@ -111,10 +112,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 -ENODEV;
+
div -= 1;
div &= 0x3f;
@@ -129,10 +133,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 aba50976f6..644fd0462a 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>
@@ -189,9 +190,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 -ENODEV;
+
div--;
div &= 0x7;
@@ -205,10 +210,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 1e1c39ff82..2b707aa07c 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>
@@ -203,10 +204,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 -ENODEV;
+
div -= 1;
div &= 0x3f;
@@ -221,10 +225,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);
diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index 8d1ecf3e40..f3de6bbb2d 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>