diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2008-04-15 15:52:23 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-04-16 17:46:13 -0400 |
commit | 0aef996b37d08757562ecf0bb0c1f6998e634c8b (patch) | |
tree | aaf590eeabc3c6bf0bcfa4ea1402e9c27a164213 /arch/powerpc/mm/fsl_booke_mmu.c | |
parent | d7917ba7051e3fd12ebe2d5a09b29fb3a2b38190 (diff) |
[POWERPC] 85xx: Cleanup TLB initialization
* Determine the RPN we are running the kernel at runtime rather
than using compile time constant for initial TLB
* Cleanup adjust_total_lowmem() to respect memstart_addr and
be a bit more clear on variables that are sizes vs addresses.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/mm/fsl_booke_mmu.c')
-rw-r--r-- | arch/powerpc/mm/fsl_booke_mmu.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c index 3dd0c8189bae..59f6649ae42a 100644 --- a/arch/powerpc/mm/fsl_booke_mmu.c +++ b/arch/powerpc/mm/fsl_booke_mmu.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <asm/mmu.h> | 49 | #include <asm/mmu.h> |
50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
51 | #include <asm/smp.h> | 51 | #include <asm/smp.h> |
52 | #include <asm/bootx.h> | ||
53 | #include <asm/machdep.h> | 52 | #include <asm/machdep.h> |
54 | #include <asm/setup.h> | 53 | #include <asm/setup.h> |
55 | 54 | ||
@@ -59,7 +58,6 @@ extern void loadcam_entry(unsigned int index); | |||
59 | unsigned int tlbcam_index; | 58 | unsigned int tlbcam_index; |
60 | unsigned int num_tlbcam_entries; | 59 | unsigned int num_tlbcam_entries; |
61 | static unsigned long __cam0, __cam1, __cam2; | 60 | static unsigned long __cam0, __cam1, __cam2; |
62 | #define MAX_LOW_MEM CONFIG_LOWMEM_SIZE | ||
63 | 61 | ||
64 | #define NUM_TLBCAMS (16) | 62 | #define NUM_TLBCAMS (16) |
65 | 63 | ||
@@ -195,35 +193,32 @@ unsigned long __init mmu_mapin_ram(void) | |||
195 | void __init | 193 | void __init |
196 | adjust_total_lowmem(void) | 194 | adjust_total_lowmem(void) |
197 | { | 195 | { |
198 | unsigned long max_low_mem = MAX_LOW_MEM; | 196 | phys_addr_t max_lowmem_size = __max_low_memory; |
199 | unsigned long cam_max = 0x10000000; | 197 | phys_addr_t cam_max_size = 0x10000000; |
200 | unsigned long ram; | 198 | phys_addr_t ram; |
201 | 199 | ||
202 | /* adjust CAM size to max_low_mem */ | 200 | /* adjust CAM size to max_lowmem_size */ |
203 | if (max_low_mem < cam_max) | 201 | if (max_lowmem_size < cam_max_size) |
204 | cam_max = max_low_mem; | 202 | cam_max_size = max_lowmem_size; |
205 | 203 | ||
206 | /* adjust lowmem size to max_low_mem */ | 204 | /* adjust lowmem size to max_lowmem_size */ |
207 | if (max_low_mem < total_lowmem) | 205 | ram = min(max_lowmem_size, total_lowmem); |
208 | ram = max_low_mem; | ||
209 | else | ||
210 | ram = total_lowmem; | ||
211 | 206 | ||
212 | /* Calculate CAM values */ | 207 | /* Calculate CAM values */ |
213 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); | 208 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); |
214 | if (__cam0 > cam_max) | 209 | if (__cam0 > cam_max_size) |
215 | __cam0 = cam_max; | 210 | __cam0 = cam_max_size; |
216 | ram -= __cam0; | 211 | ram -= __cam0; |
217 | if (ram) { | 212 | if (ram) { |
218 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); | 213 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); |
219 | if (__cam1 > cam_max) | 214 | if (__cam1 > cam_max_size) |
220 | __cam1 = cam_max; | 215 | __cam1 = cam_max_size; |
221 | ram -= __cam1; | 216 | ram -= __cam1; |
222 | } | 217 | } |
223 | if (ram) { | 218 | if (ram) { |
224 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); | 219 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); |
225 | if (__cam2 > cam_max) | 220 | if (__cam2 > cam_max_size) |
226 | __cam2 = cam_max; | 221 | __cam2 = cam_max_size; |
227 | ram -= __cam2; | 222 | ram -= __cam2; |
228 | } | 223 | } |
229 | 224 | ||
@@ -231,6 +226,6 @@ adjust_total_lowmem(void) | |||
231 | " CAM2=%ldMb residual: %ldMb\n", | 226 | " CAM2=%ldMb residual: %ldMb\n", |
232 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, | 227 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, |
233 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); | 228 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); |
234 | __max_low_memory = max_low_mem = __cam0 + __cam1 + __cam2; | 229 | __max_low_memory = __cam0 + __cam1 + __cam2; |
235 | __initial_memory_limit = __max_low_memory; | 230 | __initial_memory_limit = memstart_addr + __max_low_memory; |
236 | } | 231 | } |