From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] i.MX51: Added support for "clko" command
Date: Thu, 7 Jun 2012 17:00:51 +0400 [thread overview]
Message-ID: <1339074051-9781-3-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1339074051-9781-1-git-send-email-shc_work@mail.ru>
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
next prev parent reply other threads:[~2012-06-07 13:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Alexander Shiyan [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339074051-9781-3-git-send-email-shc_work@mail.ru \
--to=shc_work@mail.ru \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox