Blackfin arch: add functions for converting between sclks and usecs
authorMike Frysinger <michael.frysinger@analog.com>
Sun, 21 Oct 2007 14:59:49 +0000 (22:59 +0800)
committerBryan Wu <bryan.wu@analog.com>
Sun, 21 Oct 2007 14:59:49 +0000 (22:59 +0800)
Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
arch/blackfin/kernel/setup.c
include/asm-blackfin/bfin-global.h

index 6b85145f848886c01cd365e17cb947f33c3320e9..0e746449c29b1f2e75cbe232d73cfc28566e46f4 100644 (file)
@@ -459,7 +459,7 @@ static u_long get_vco(void)
        return vco;
 }
 
-/*Get the Core clock*/
+/* Get the Core clock */
 u_long get_cclk(void)
 {
        u_long csel, ssel;
@@ -493,6 +493,18 @@ u_long get_sclk(void)
 }
 EXPORT_SYMBOL(get_sclk);
 
+unsigned long sclk_to_usecs(unsigned long sclk)
+{
+       return (USEC_PER_SEC * (u64)sclk) / get_sclk();
+}
+EXPORT_SYMBOL(sclk_to_usecs);
+
+unsigned long usecs_to_sclk(unsigned long usecs)
+{
+       return get_sclk() / (USEC_PER_SEC * (u64)usecs);
+}
+EXPORT_SYMBOL(usecs_to_sclk);
+
 /*
  *     Get CPU information for use by the procfs.
  */
index a006353a43105a5d0e0cf866531e040118f6209c..14cb8d35924e7c3505126057d3f9648d927435fe 100644 (file)
@@ -47,6 +47,8 @@
 
 extern unsigned long get_cclk(void);
 extern unsigned long get_sclk(void);
+extern unsigned long sclk_to_usecs(unsigned long sclk);
+extern unsigned long usecs_to_sclk(unsigned long usecs);
 
 extern void dump_thread(struct pt_regs *regs, struct user *dump);
 extern void dump_bfin_regs(struct pt_regs *fp, void *retaddr);