]> err.no Git - linux-2.6/blobdiff - arch/arm/mach-omap2/gpmc.c
Merge branch 'audit.b51' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[linux-2.6] / arch / arm / mach-omap2 / gpmc.c
index 6d6b25c46b1f21b2ccdfae69686a52e2e5ce5a27..02cede295e89795b02e77f9167c70f375c06fd48 100644 (file)
 
 #undef DEBUG
 
+#ifdef CONFIG_ARCH_OMAP2420
 #define GPMC_BASE              0x6800a000
+#endif
+
+#ifdef CONFIG_ARCH_OMAP2430
+#define GPMC_BASE              0x6E000000
+#endif
+
 #define GPMC_REVISION          0x00
 #define GPMC_SYSCONFIG         0x10
 #define GPMC_SYSSTATUS         0x14
@@ -62,7 +69,7 @@ static void __iomem *gpmc_base =
 static void __iomem *gpmc_cs_base =
        (void __iomem *) IO_ADDRESS(GPMC_BASE) + GPMC_CS0;
 
-static struct clk *gpmc_l3_clk;
+static struct clk *gpmc_fck;
 
 static void gpmc_write_reg(int idx, u32 val)
 {
@@ -87,11 +94,10 @@ u32 gpmc_cs_read_reg(int cs, int idx)
        return __raw_readl(gpmc_cs_base + (cs * GPMC_CS_SIZE) + idx);
 }
 
-/* TODO: Add support for gpmc_fck to clock framework and use it */
 unsigned long gpmc_get_fclk_period(void)
 {
        /* In picoseconds */
-       return 1000000000 / ((clk_get_rate(gpmc_l3_clk)) / 1000);
+       return 1000000000 / ((clk_get_rate(gpmc_fck)) / 1000);
 }
 
 unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
@@ -104,6 +110,13 @@ unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
        return (time_ns * 1000 + tick_ps - 1) / tick_ps;
 }
 
+unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns)
+{
+       unsigned long ticks = gpmc_ns_to_ticks(time_ns);
+
+       return ticks * gpmc_get_fclk_period() / 1000;
+}
+
 #ifdef DEBUG
 static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
                               int time, const char *name)
@@ -384,8 +397,11 @@ void __init gpmc_init(void)
 {
        u32 l;
 
-       gpmc_l3_clk = clk_get(NULL, "core_l3_ck");
-       BUG_ON(IS_ERR(gpmc_l3_clk));
+       gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
+       if (IS_ERR(gpmc_fck))
+               WARN_ON(1);
+       else
+               clk_enable(gpmc_fck);
 
        l = gpmc_read_reg(GPMC_REVISION);
        printk(KERN_INFO "GPMC revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f);