mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christoph Fritz <chf.fritz@googlemail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>, barebox@lists.infradead.org
Subject: [PATCH] ARM omap: add omap4_get_sysclk()
Date: Thu, 04 Apr 2013 08:42:35 +0200	[thread overview]
Message-ID: <1365057755.3836.17.camel@mars> (raw)

This patch adds a function to get actual system clock.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 arch/arm/mach-omap/include/mach/omap4-clock.h |    4 ++++
 arch/arm/mach-omap/omap4_clock.c              |   19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/arm/mach-omap/include/mach/omap4-clock.h b/arch/arm/mach-omap/include/mach/omap4-clock.h
index 8f49aa3..9e53e16 100644
--- a/arch/arm/mach-omap/include/mach/omap4-clock.h
+++ b/arch/arm/mach-omap/include/mach/omap4-clock.h
@@ -4,7 +4,10 @@
 /* PRCM */
 #define CM_SYS_CLKSEL				0x4a306110
 
+#define CM_SYS_CLKSEL_12M		0x1
+#define CM_SYS_CLKSEL_16M8		0x3
 #define CM_SYS_CLKSEL_19M2		0x4
+#define CM_SYS_CLKSEL_26M		0x5
 #define CM_SYS_CLKSEL_38M4		0x7
 
 /* PRM.CKGEN module registers */
@@ -341,5 +344,6 @@ void omap4_enable_gpio1_wup_clocks(void);
 void omap4_enable_gpio_clocks(void);
 void omap4_enable_all_clocks(void);
 void omap4_do_scale_tps62361(u32 reg, u32 volt_mv);
+int omap4_get_sysclk(void);
 
 #endif /* __MACH_OMAP4_CLOCK_H */
diff --git a/arch/arm/mach-omap/omap4_clock.c b/arch/arm/mach-omap/omap4_clock.c
index 889d1f9..37af756 100644
--- a/arch/arm/mach-omap/omap4_clock.c
+++ b/arch/arm/mach-omap/omap4_clock.c
@@ -413,3 +413,22 @@ void omap4_do_scale_tps62361(u32 reg, u32 volt_mv)
 				OMAP44XX_PRM_VC_VAL_BYPASS, LDELAY))
 		debug("Scaling voltage failed for vdd_mpu from TPS\n");
 }
+
+int omap4_get_sysclk(void)
+{
+	int omap4_cm_sys_clks[] = {
+		-1,
+		12000000, /* CM_SYS_CLKSEL_12M */
+		-1,
+		16800000, /* CM_SYS_CLKSEL_16M8 */
+		19200000, /* CM_SYS_CLKSEL_19M2 */
+		26000000, /* CM_SYS_CLKSEL_26M */
+		-1,
+		38400000, /* CM_SYS_CLKSEL_38M4 */
+	};
+	int v = __raw_readl(CM_SYS_CLKSEL);
+
+	if (v >= ARRAY_SIZE(omap4_cm_sys_clks))
+		return -1;
+	return omap4_cm_sys_clks[v];
+}
-- 
1.7.10.4




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

                 reply	other threads:[~2013-04-04  6:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1365057755.3836.17.camel@mars \
    --to=chf.fritz@googlemail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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