diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2008-06-29 10:53:34 -0400 |
---|---|---|
committer | Eric Miao <eric.miao@marvell.com> | 2008-12-02 01:43:47 -0500 |
commit | a10c287d393bdd32127d59f3ec8fd7bb80e2fa05 (patch) | |
tree | 00b75d4d4839eb4eaa56cc301e84dd207420ed54 | |
parent | 65587f7d154ac58f4ff100c240640c71abec41dd (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>
-rw-r--r-- | arch/arm/mach-pxa/cpufreq-pxa2xx.c | 25 | ||||
-rw-r--r-- | arch/arm/mach-pxa/include/mach/pxa2xx-regs.h | 5 |
2 files changed, 27 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 */ | 67 | static 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 | ||
198 | static 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 | |||
195 | static u32 mdrefr_dri(unsigned int freq) | 212 | static 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 */ |
diff --git a/arch/arm/mach-pxa/include/mach/pxa2xx-regs.h b/arch/arm/mach-pxa/include/mach/pxa2xx-regs.h index 2b71d87c898f..77102d695cc7 100644 --- a/arch/arm/mach-pxa/include/mach/pxa2xx-regs.h +++ b/arch/arm/mach-pxa/include/mach/pxa2xx-regs.h | |||
@@ -49,6 +49,11 @@ | |||
49 | #define MECR_NOS (1 << 0) /* Number Of Sockets: 0 -> 1 sock, 1 -> 2 sock */ | 49 | #define MECR_NOS (1 << 0) /* Number Of Sockets: 0 -> 1 sock, 1 -> 2 sock */ |
50 | #define MECR_CIT (1 << 1) /* Card Is There: 0 -> no card, 1 -> card inserted */ | 50 | #define MECR_CIT (1 << 1) /* Card Is There: 0 -> no card, 1 -> card inserted */ |
51 | 51 | ||
52 | #define MDCNFG_DE0 (1 << 0) /* SDRAM Bank 0 Enable */ | ||
53 | #define MDCNFG_DE1 (1 << 1) /* SDRAM Bank 1 Enable */ | ||
54 | #define MDCNFG_DE2 (1 << 16) /* SDRAM Bank 2 Enable */ | ||
55 | #define MDCNFG_DE3 (1 << 17) /* SDRAM Bank 3 Enable */ | ||
56 | |||
52 | #define MDREFR_K0DB4 (1 << 29) /* SDCLK0 Divide by 4 Control/Status */ | 57 | #define MDREFR_K0DB4 (1 << 29) /* SDCLK0 Divide by 4 Control/Status */ |
53 | #define MDREFR_K2FREE (1 << 25) /* SDRAM Free-Running Control */ | 58 | #define MDREFR_K2FREE (1 << 25) /* SDRAM Free-Running Control */ |
54 | #define MDREFR_K1FREE (1 << 24) /* SDRAM Free-Running Control */ | 59 | #define MDREFR_K1FREE (1 << 24) /* SDRAM Free-Running Control */ |