aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/mm/fsl_booke_mmu.c79
1 files changed, 31 insertions, 48 deletions
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c
index 1971e4ee3d6e..1dabe1a1751b 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -56,7 +56,7 @@
56 56
57extern void loadcam_entry(unsigned int index); 57extern void loadcam_entry(unsigned int index);
58unsigned int tlbcam_index; 58unsigned int tlbcam_index;
59static unsigned long __cam0, __cam1, __cam2; 59static unsigned long cam[3];
60 60
61#define NUM_TLBCAMS (16) 61#define NUM_TLBCAMS (16)
62 62
@@ -152,19 +152,19 @@ void invalidate_tlbcam_entry(int index)
152 loadcam_entry(index); 152 loadcam_entry(index);
153} 153}
154 154
155void __init cam_mapin_ram(unsigned long cam0, unsigned long cam1, 155unsigned long __init mmu_mapin_ram(void)
156 unsigned long cam2)
157{ 156{
158 settlbcam(0, PAGE_OFFSET, memstart_addr, cam0, _PAGE_KERNEL, 0); 157 unsigned long virt = PAGE_OFFSET;
159 tlbcam_index++; 158 phys_addr_t phys = memstart_addr;
160 if (cam1) { 159
161 tlbcam_index++; 160 while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) {
162 settlbcam(1, PAGE_OFFSET+cam0, memstart_addr+cam0, cam1, _PAGE_KERNEL, 0); 161 settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], _PAGE_KERNEL, 0);
163 } 162 virt += cam[tlbcam_index];
164 if (cam2) { 163 phys += cam[tlbcam_index];
165 tlbcam_index++; 164 tlbcam_index++;
166 settlbcam(2, PAGE_OFFSET+cam0+cam1, memstart_addr+cam0+cam1, cam2, _PAGE_KERNEL, 0);
167 } 165 }
166
167 return virt - PAGE_OFFSET;
168} 168}
169 169
170/* 170/*
@@ -175,51 +175,34 @@ void __init MMU_init_hw(void)
175 flush_instruction_cache(); 175 flush_instruction_cache();
176} 176}
177 177
178unsigned long __init mmu_mapin_ram(void)
179{
180 cam_mapin_ram(__cam0, __cam1, __cam2);
181
182 return __cam0 + __cam1 + __cam2;
183}
184
185
186void __init 178void __init
187adjust_total_lowmem(void) 179adjust_total_lowmem(void)
188{ 180{
189 phys_addr_t max_lowmem_size = __max_low_memory;
190 phys_addr_t cam_max_size = 0x10000000;
191 phys_addr_t ram; 181 phys_addr_t ram;
182 unsigned int max_cam = 28; /* 2^28 = 256 Mb */
183 char buf[ARRAY_SIZE(cam) * 5 + 1], *p = buf;
184 int i;
192 185
193 /* adjust CAM size to max_lowmem_size */ 186 /* adjust lowmem size to __max_low_memory */
194 if (max_lowmem_size < cam_max_size) 187 ram = min((phys_addr_t)__max_low_memory, (phys_addr_t)total_lowmem);
195 cam_max_size = max_lowmem_size;
196
197 /* adjust lowmem size to max_lowmem_size */
198 ram = min(max_lowmem_size, total_lowmem);
199 188
200 /* Calculate CAM values */ 189 /* Calculate CAM values */
201 __cam0 = 1UL << 2 * (__ilog2(ram) / 2); 190 __max_low_memory = 0;
202 if (__cam0 > cam_max_size) 191 for (i = 0; ram && i < ARRAY_SIZE(cam); i++) {
203 __cam0 = cam_max_size; 192 unsigned int camsize = __ilog2(ram) & ~1U;
204 ram -= __cam0; 193 if (camsize > max_cam)
205 if (ram) { 194 camsize = max_cam;
206 __cam1 = 1UL << 2 * (__ilog2(ram) / 2); 195 cam[i] = 1UL << camsize;
207 if (__cam1 > cam_max_size) 196 ram -= cam[i];
208 __cam1 = cam_max_size; 197 __max_low_memory += cam[i];
209 ram -= __cam1; 198
210 } 199 p += sprintf(p, "%lu/", cam[i] >> 20);
211 if (ram) {
212 __cam2 = 1UL << 2 * (__ilog2(ram) / 2);
213 if (__cam2 > cam_max_size)
214 __cam2 = cam_max_size;
215 ram -= __cam2;
216 } 200 }
201 for (; i < ARRAY_SIZE(cam); i++)
202 p += sprintf(p, "0/");
203 p[-1] = '\0';
217 204
218 printk(KERN_INFO "Memory CAM mapping: CAM0=%ldMb, CAM1=%ldMb," 205 pr_info("Memory CAM mapping: %s Mb, residual: %ldMb\n", buf,
219 " CAM2=%ldMb residual: %ldMb\n", 206 (total_lowmem - __max_low_memory) >> 20);
220 __cam0 >> 20, __cam1 >> 20, __cam2 >> 20,
221 (long int)((total_lowmem - __cam0 - __cam1 - __cam2)
222 >> 20));
223 __max_low_memory = __cam0 + __cam1 + __cam2;
224 __initial_memory_limit_addr = memstart_addr + __max_low_memory; 207 __initial_memory_limit_addr = memstart_addr + __max_low_memory;
225} 208}