aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/cpufreq-pxa2xx.c
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2008-06-29 10:53:34 -0400
committerEric Miao <eric.miao@marvell.com>2008-12-02 01:43:47 -0500
commita10c287d393bdd32127d59f3ec8fd7bb80e2fa05 (patch)
tree00b75d4d4839eb4eaa56cc301e84dd207420ed54 /arch/arm/mach-pxa/cpufreq-pxa2xx.c
parent65587f7d154ac58f4ff100c240640c71abec41dd (diff)
[ARM] pxa: cpufreq-pxa2xx: sdram_rows detection support
This patch implements Eric Miao's idea to detect the correct value of sdram_rows by inspecting the MDCNFG register settings. It is only tested on two pxa27x devices with 64MB RAM (magician and hx4700) so far. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch/arm/mach-pxa/cpufreq-pxa2xx.c')
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa2xx.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/arch/arm/mach-pxa/cpufreq-pxa2xx.c b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
index 6bb678db537c..771dd4eac935 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa2xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
@@ -64,7 +64,7 @@ typedef struct {
64 64
65/* Define the refresh period in mSec for the SDRAM and the number of rows */ 65/* Define the refresh period in mSec for the SDRAM and the number of rows */
66#define SDRAM_TREF 64 /* standard 64ms SDRAM */ 66#define SDRAM_TREF 64 /* standard 64ms SDRAM */
67#define SDRAM_ROWS 4096 /* 64MB=8192 32MB=4096 */ 67static unsigned int sdram_rows;
68 68
69#define CCLKCFG_TURBO 0x1 69#define CCLKCFG_TURBO 0x1
70#define CCLKCFG_FCS 0x2 70#define CCLKCFG_FCS 0x2
@@ -73,6 +73,9 @@ typedef struct {
73#define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2) 73#define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2)
74#define MDREFR_DRI_MASK 0xFFF 74#define MDREFR_DRI_MASK 0xFFF
75 75
76#define MDCNFG_DRAC2(mdcnfg) (((mdcnfg) >> 21) & 0x3)
77#define MDCNFG_DRAC0(mdcnfg) (((mdcnfg) >> 5) & 0x3)
78
76/* 79/*
77 * PXA255 definitions 80 * PXA255 definitions
78 */ 81 */
@@ -192,14 +195,28 @@ static void pxa27x_guess_max_freq(void)
192 } 195 }
193} 196}
194 197
198static void init_sdram_rows(void)
199{
200 uint32_t mdcnfg = MDCNFG;
201 unsigned int drac2 = 0, drac0 = 0;
202
203 if (mdcnfg & (MDCNFG_DE2 | MDCNFG_DE3))
204 drac2 = MDCNFG_DRAC2(mdcnfg);
205
206 if (mdcnfg & (MDCNFG_DE0 | MDCNFG_DE1))
207 drac0 = MDCNFG_DRAC0(mdcnfg);
208
209 sdram_rows = 1 << (11 + max(drac0, drac2));
210}
211
195static u32 mdrefr_dri(unsigned int freq) 212static u32 mdrefr_dri(unsigned int freq)
196{ 213{
197 u32 dri = 0; 214 u32 dri = 0;
198 215
199 if (cpu_is_pxa25x()) 216 if (cpu_is_pxa25x())
200 dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS * 32)); 217 dri = ((freq * SDRAM_TREF) / (sdram_rows * 32));
201 if (cpu_is_pxa27x()) 218 if (cpu_is_pxa27x())
202 dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS - 31)) / 32; 219 dri = ((freq * SDRAM_TREF) / (sdram_rows - 31)) / 32;
203 return dri; 220 return dri;
204} 221}
205 222
@@ -334,6 +351,8 @@ static __init int pxa_cpufreq_init(struct cpufreq_policy *policy)
334 if (cpu_is_pxa27x()) 351 if (cpu_is_pxa27x())
335 pxa27x_guess_max_freq(); 352 pxa27x_guess_max_freq();
336 353
354 init_sdram_rows();
355
337 /* set default policy and cpuinfo */ 356 /* set default policy and cpuinfo */
338 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ 357 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
339 policy->cur = get_clk_frequency_khz(0); /* current freq */ 358 policy->cur = get_clk_frequency_khz(0); /* current freq */