]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: Add memory.c for memory timings on 24xx
authorTony Lindgren <tony@atomide.com>
Fri, 2 Dec 2005 00:31:45 +0000 (16:31 -0800)
committerTony Lindgren <tony@atomide.com>
Fri, 2 Dec 2005 00:31:45 +0000 (16:31 -0800)
Both clock.c and pm.c will need to access the memory timings

arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/clock.c
arch/arm/mach-omap2/clock.h
arch/arm/mach-omap2/memory.c [new file with mode: 0644]
arch/arm/mach-omap2/memory.h [new file with mode: 0644]

index b017153aa4f7a92bf12a932b7fd10a351349b930..4cc80f77fc9d7c6140ce0ee5f367d6301f4ae249 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 # Common support
-obj-y := irq.o id.o io.o sram-fn.o prcm.o clock.o mux.o devices.o serial.o
+obj-y := irq.o id.o io.o sram-fn.o memory.o prcm.o clock.o mux.o devices.o serial.o
 
 obj-$(CONFIG_OMAP_MPU_TIMER)           += timer-gp.o
 
index e5f6726bd78baf6b0ba2cb57ba0e844392bdf9e1..6f897f307d67fce2d3badfc781f802ec630b54be 100644 (file)
 #include <asm/arch/sram.h>
 
 #include "prcm-regs.h"
+#include "memory.h"
 #include "clock.h"
 
 //#define DOWN_VARIABLE_DPLL 1                 /* Experimental */
 
 static struct prcm_config *curr_prcm_set;
-static struct memory_timings mem_timings;
 static u32 curr_perf_level = PRCM_FULL_SPEED;
 
 /*-------------------------------------------------------------------------
@@ -385,76 +385,23 @@ static u32 omap2_dll_force_needed(void)
                return 0;
 }
 
-static void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
-{
-       unsigned long dll_cnt;
-       u32 fast_dll = 0;
-
-       mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
-
-       /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
-        * In the case of 2422, its ok to use CS1 instead of CS0.
-        */
-
-#if 0  /* FIXME: Enable after 24xx cpu detection works */
-       ctype = get_cpu_type();
-       if (cpu_is_omap2422())
-               mem_timings.base_cs = 1;
-       else
-#endif
-               mem_timings.base_cs = 0;
-
-       if (mem_timings.m_type != M_DDR)
-               return;
-
-       /* With DDR we need to determine the low frequency DLL value */
-       if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL))
-               mem_timings.dll_mode = M_UNLOCK;
-       else
-               mem_timings.dll_mode = M_LOCK;
-
-       if (mem_timings.base_cs == 0) {
-               fast_dll = SDRC_DLLA_CTRL;
-               dll_cnt = SDRC_DLLA_STATUS & 0xff00;
-       } else {
-               fast_dll = SDRC_DLLB_CTRL;
-               dll_cnt = SDRC_DLLB_STATUS & 0xff00;
-       }
-       if (force_lock_to_unlock_mode) {
-               fast_dll &= ~0xff00;
-               fast_dll |= dll_cnt;            /* Current lock mode */
-       }
-       /* set fast timings with DLL filter disabled */
-       mem_timings.fast_dll_ctrl = (fast_dll | (3 << 8));
-
-       /* No disruptions, DDR will be offline & C-ABI not followed */
-       omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl,
-                           mem_timings.fast_dll_ctrl,
-                           mem_timings.base_cs,
-                           force_lock_to_unlock_mode);
-       mem_timings.slow_dll_ctrl &= 0xff00;    /* Keep lock value */
-
-       /* Turn status into unlock ctrl */
-       mem_timings.slow_dll_ctrl |=
-               ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2));
-
-       /* 90 degree phase for anything below 133Mhz + disable DLL filter */
-       mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8));
-}
-
 static u32 omap2_reprogram_sdrc(u32 level, u32 force)
 {
+       u32 slow_dll_ctrl, fast_dll_ctrl, m_type;
        u32 prev = curr_perf_level, flags;
 
        if ((curr_perf_level == level) && !force)
                return prev;
 
+       m_type = omap2_memory_get_type();
+       slow_dll_ctrl = omap2_memory_get_slow_dll_ctrl();
+       fast_dll_ctrl = omap2_memory_get_fast_dll_ctrl();
+
        if (level == PRCM_HALF_SPEED) {
                local_irq_save(flags);
                PRCM_VOLTSETUP = 0xffff;
                omap2_sram_reprogram_sdrc(PRCM_HALF_SPEED,
-                                         mem_timings.slow_dll_ctrl,
-                                         mem_timings.m_type);
+                                         slow_dll_ctrl, m_type);
                curr_perf_level = PRCM_HALF_SPEED;
                local_irq_restore(flags);
        }
@@ -462,8 +409,7 @@ static u32 omap2_reprogram_sdrc(u32 level, u32 force)
                local_irq_save(flags);
                PRCM_VOLTSETUP = 0xffff;
                omap2_sram_reprogram_sdrc(PRCM_FULL_SPEED,
-                                         mem_timings.fast_dll_ctrl,
-                                         mem_timings.m_type);
+                                         fast_dll_ctrl, m_type);
                curr_perf_level = PRCM_FULL_SPEED;
                local_irq_restore(flags);
        }
index 4daf7c8bcedcdec9afddf1e9589abe8fa9240269..07f1efa066772ffe0bb0e67a1d3c9e10b997833b 100644 (file)
@@ -33,20 +33,6 @@ static u32 omap2_clksel_get_divisor(struct clk *clk);
 #define RATE_IN_242X   (1 << 0)
 #define RATE_IN_243X   (1 << 1)
 
-/* Memory timings */
-#define M_DDR          1
-#define M_LOCK_CTRL    (1 << 2)
-#define M_UNLOCK       0
-#define M_LOCK         1
-
-struct memory_timings {
-       u32 m_type;             /* ddr = 1, sdr = 0 */
-       u32 dll_mode;           /* use lock mode = 1, unlock mode = 0 */
-       u32 slow_dll_ctrl;      /* unlock mode, dll value for slow speed */
-       u32 fast_dll_ctrl;      /* unlock mode, dll value for fast speed */
-       u32 base_cs;            /* base chip select to use for calculations */
-};
-
 /* Key dividers which make up a PRCM set. Ratio's for a PRCM are mandated.
  * xtal_speed, dpll_speed, mpu_speed, CM_CLKSEL_MPU,CM_CLKSEL_DSP
  * CM_CLKSEL_GFX, CM_CLKSEL1_CORE, CM_CLKSEL1_PLL CM_CLKSEL2_PLL, CM_CLKSEL_MDM
diff --git a/arch/arm/mach-omap2/memory.c b/arch/arm/mach-omap2/memory.c
new file mode 100644 (file)
index 0000000..bd02353
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * linux/arch/arm/mach-omap2/memory.c
+ *
+ * Memory timing related functions for OMAP24XX
+ *
+ * Copyright (C) 2005 Texas Instruments Inc.
+ * Richard Woodruff <r-woodruff2@ti.com>
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+
+#include <asm/hardware/clock.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/sram.h>
+
+#include "prcm-regs.h"
+#include "memory.h"
+
+static struct memory_timings mem_timings;
+
+u32 omap2_memory_get_slow_dll_ctrl(void)
+{
+       return mem_timings.slow_dll_ctrl;
+}
+
+u32 omap2_memory_get_fast_dll_ctrl(void)
+{
+       return mem_timings.fast_dll_ctrl;
+}
+
+u32 omap2_memory_get_type(void)
+{
+       return mem_timings.m_type;
+}
+
+void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
+{
+       unsigned long dll_cnt;
+       u32 fast_dll = 0;
+
+       mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
+
+       /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
+        * In the case of 2422, its ok to use CS1 instead of CS0.
+        */
+       if (cpu_is_omap2422())
+               mem_timings.base_cs = 1;
+       else
+               mem_timings.base_cs = 0;
+
+       if (mem_timings.m_type != M_DDR)
+               return;
+
+       /* With DDR we need to determine the low frequency DLL value */
+       if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL))
+               mem_timings.dll_mode = M_UNLOCK;
+       else
+               mem_timings.dll_mode = M_LOCK;
+
+       if (mem_timings.base_cs == 0) {
+               fast_dll = SDRC_DLLA_CTRL;
+               dll_cnt = SDRC_DLLA_STATUS & 0xff00;
+       } else {
+               fast_dll = SDRC_DLLB_CTRL;
+               dll_cnt = SDRC_DLLB_STATUS & 0xff00;
+       }
+       if (force_lock_to_unlock_mode) {
+               fast_dll &= ~0xff00;
+               fast_dll |= dll_cnt;            /* Current lock mode */
+       }
+       /* set fast timings with DLL filter disabled */
+       mem_timings.fast_dll_ctrl = (fast_dll | (3 << 8));
+
+       /* No disruptions, DDR will be offline & C-ABI not followed */
+       omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl,
+                           mem_timings.fast_dll_ctrl,
+                           mem_timings.base_cs,
+                           force_lock_to_unlock_mode);
+       mem_timings.slow_dll_ctrl &= 0xff00;    /* Keep lock value */
+
+       /* Turn status into unlock ctrl */
+       mem_timings.slow_dll_ctrl |=
+               ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2));
+
+       /* 90 degree phase for anything below 133Mhz + disable DLL filter */
+       mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8));
+}
diff --git a/arch/arm/mach-omap2/memory.h b/arch/arm/mach-omap2/memory.h
new file mode 100644 (file)
index 0000000..d212eea
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * linux/arch/arm/mach-omap2/memory.h
+ *
+ * Interface for memory timing related functions for OMAP24XX
+ *
+ * Copyright (C) 2005 Texas Instruments Inc.
+ * Richard Woodruff <r-woodruff2@ti.com>
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/* Memory timings */
+#define M_DDR          1
+#define M_LOCK_CTRL    (1 << 2)
+#define M_UNLOCK       0
+#define M_LOCK         1
+
+struct memory_timings {
+       u32 m_type;             /* ddr = 1, sdr = 0 */
+       u32 dll_mode;           /* use lock mode = 1, unlock mode = 0 */
+       u32 slow_dll_ctrl;      /* unlock mode, dll value for slow speed */
+       u32 fast_dll_ctrl;      /* unlock mode, dll value for fast speed */
+       u32 base_cs;            /* base chip select to use for calculations */
+};
+
+extern void omap2_init_memory_params(u32 force_lock_to_unlock_mode);
+extern u32 omap2_memory_get_slow_dll_ctrl(void);
+extern u32 omap2_memory_get_fast_dll_ctrl(void);
+extern u32 omap2_memory_get_type(void);