diff options
author | Valentine Barshak <vbarshak@ru.mvista.com> | 2009-04-23 06:55:06 -0400 |
---|---|---|
committer | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2009-04-24 09:02:37 -0400 |
commit | 644e28f3426810710b176080cc906995ebc24b63 (patch) | |
tree | 76da9f4ecaca85fbc37e59ab12e06244caf9c0bb /arch | |
parent | 9ae2ccf26416ed52874718e2b0c8e6813253263a (diff) |
powerpc/44x: Correct memory size calculation for denali-based boards
Some U-Boot versions incorrectly set the number of chipselects to two
for Sequoia/Rainier boards while they only have one chipselect hardwired.
This patch adds a workaround for this, hardcoding the number of chipselects
to one for sequioa/rainer board models and reading the actual value from
the memory controller register DDR0_10 otherwise.
It also fixes another error in the way ibm4xx_denali_fixup_memsize
calculates memory size. When testing the DDR_REDUC bit, the polarity is
backwards. A "1" implies 32-bit wide memory while a "0" implies 64-bit
wide memory.
Signed-off-by: Mikhail Zolotaryov <lebon@lebon.org.ua>
Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
Signed-off-by: Steven A. Falco <sfalco@harris.com>
Acked-by: Stefan Roese <sr@denx.de>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/boot/4xx.c | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c index 5c878436f348..325b310573b9 100644 --- a/arch/powerpc/boot/4xx.c +++ b/arch/powerpc/boot/4xx.c | |||
@@ -158,21 +158,33 @@ void ibm440spe_fixup_memsize(void) | |||
158 | 158 | ||
159 | #define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask)) | 159 | #define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask)) |
160 | 160 | ||
161 | void ibm4xx_denali_fixup_memsize(void) | 161 | /* |
162 | * Some U-Boot versions set the number of chipselects to two | ||
163 | * for Sequoia/Rainier boards while they only have one chipselect | ||
164 | * hardwired. Hardcode the number of chipselects to one | ||
165 | * for sequioa/rainer board models or read the actual value | ||
166 | * from the memory controller register DDR0_10 otherwise. | ||
167 | */ | ||
168 | static inline u32 ibm4xx_denali_get_cs(void) | ||
162 | { | 169 | { |
163 | u32 val, max_cs, max_col, max_row; | 170 | void *devp; |
164 | u32 cs, col, row, bank, dpath; | 171 | char model[64]; |
165 | unsigned long memsize; | 172 | u32 val, cs; |
166 | 173 | ||
167 | val = SDRAM0_READ(DDR0_02); | 174 | devp = finddevice("/"); |
168 | if (!DDR_GET_VAL(val, DDR_START, DDR_START_SHIFT)) | 175 | if (!devp) |
169 | fatal("DDR controller is not initialized\n"); | 176 | goto read_cs; |
170 | 177 | ||
171 | /* get maximum cs col and row values */ | 178 | if (getprop(devp, "model", model, sizeof(model)) <= 0) |
172 | max_cs = DDR_GET_VAL(val, DDR_MAX_CS_REG, DDR_MAX_CS_REG_SHIFT); | 179 | goto read_cs; |
173 | max_col = DDR_GET_VAL(val, DDR_MAX_COL_REG, DDR_MAX_COL_REG_SHIFT); | ||
174 | max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT); | ||
175 | 180 | ||
181 | model[sizeof(model)-1] = 0; | ||
182 | |||
183 | if (!strcmp(model, "amcc,sequoia") || | ||
184 | !strcmp(model, "amcc,rainier")) | ||
185 | return 1; | ||
186 | |||
187 | read_cs: | ||
176 | /* get CS value */ | 188 | /* get CS value */ |
177 | val = SDRAM0_READ(DDR0_10); | 189 | val = SDRAM0_READ(DDR0_10); |
178 | 190 | ||
@@ -183,7 +195,25 @@ void ibm4xx_denali_fixup_memsize(void) | |||
183 | cs++; | 195 | cs++; |
184 | val = val >> 1; | 196 | val = val >> 1; |
185 | } | 197 | } |
198 | return cs; | ||
199 | } | ||
200 | |||
201 | void ibm4xx_denali_fixup_memsize(void) | ||
202 | { | ||
203 | u32 val, max_cs, max_col, max_row; | ||
204 | u32 cs, col, row, bank, dpath; | ||
205 | unsigned long memsize; | ||
206 | |||
207 | val = SDRAM0_READ(DDR0_02); | ||
208 | if (!DDR_GET_VAL(val, DDR_START, DDR_START_SHIFT)) | ||
209 | fatal("DDR controller is not initialized\n"); | ||
186 | 210 | ||
211 | /* get maximum cs col and row values */ | ||
212 | max_cs = DDR_GET_VAL(val, DDR_MAX_CS_REG, DDR_MAX_CS_REG_SHIFT); | ||
213 | max_col = DDR_GET_VAL(val, DDR_MAX_COL_REG, DDR_MAX_COL_REG_SHIFT); | ||
214 | max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT); | ||
215 | |||
216 | cs = ibm4xx_denali_get_cs(); | ||
187 | if (!cs) | 217 | if (!cs) |
188 | fatal("No memory installed\n"); | 218 | fatal("No memory installed\n"); |
189 | if (cs > max_cs) | 219 | if (cs > max_cs) |
@@ -193,9 +223,9 @@ void ibm4xx_denali_fixup_memsize(void) | |||
193 | val = SDRAM0_READ(DDR0_14); | 223 | val = SDRAM0_READ(DDR0_14); |
194 | 224 | ||
195 | if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT)) | 225 | if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT)) |
196 | dpath = 8; /* 64 bits */ | ||
197 | else | ||
198 | dpath = 4; /* 32 bits */ | 226 | dpath = 4; /* 32 bits */ |
227 | else | ||
228 | dpath = 8; /* 64 bits */ | ||
199 | 229 | ||
200 | /* get address pins (rows) */ | 230 | /* get address pins (rows) */ |
201 | val = SDRAM0_READ(DDR0_42); | 231 | val = SDRAM0_READ(DDR0_42); |