diff options
author | Yi Li <yi.li@analog.com> | 2008-02-08 13:26:01 -0500 |
---|---|---|
committer | Bryan Wu <bryan.wu@analog.com> | 2008-02-08 13:26:01 -0500 |
commit | 856783b37a958086c83ea44544d366affd0c2c4b (patch) | |
tree | 3dd18cc8a023240cd36478a76a55648ae6dde9d5 /arch/blackfin/kernel/setup.c | |
parent | c605999bd9a90a7a9915666f4531c60928cbc368 (diff) |
[Blackfin] arch: add "memmap=nn[KMG]@ss[KMG]" and "memmap=nn[KMG]$ss[KMG]" options to blackfin, based on arch/i386/kernel/e820.c
Signed-off-by: Yi Li <yi.li@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Diffstat (limited to 'arch/blackfin/kernel/setup.c')
-rw-r--r-- | arch/blackfin/kernel/setup.c | 541 |
1 files changed, 427 insertions, 114 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 289ea9d7fcdb..2f156bfc2b2c 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/cpu.h> | 34 | #include <linux/cpu.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/tty.h> | 36 | #include <linux/tty.h> |
37 | #include <linux/pfn.h> | ||
37 | 38 | ||
38 | #include <linux/ext2_fs.h> | 39 | #include <linux/ext2_fs.h> |
39 | #include <linux/cramfs_fs.h> | 40 | #include <linux/cramfs_fs.h> |
@@ -67,6 +68,29 @@ EXPORT_SYMBOL(mtd_size); | |||
67 | 68 | ||
68 | char __initdata command_line[COMMAND_LINE_SIZE]; | 69 | char __initdata command_line[COMMAND_LINE_SIZE]; |
69 | 70 | ||
71 | /* boot memmap, for parsing "memmap=" */ | ||
72 | #define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */ | ||
73 | #define BFIN_MEMMAP_RAM 1 | ||
74 | #define BFIN_MEMMAP_RESERVED 2 | ||
75 | struct bfin_memmap { | ||
76 | int nr_map; | ||
77 | struct bfin_memmap_entry { | ||
78 | unsigned long long addr; /* start of memory segment */ | ||
79 | unsigned long long size; | ||
80 | unsigned long type; | ||
81 | } map[BFIN_MEMMAP_MAX]; | ||
82 | } bfin_memmap __initdata; | ||
83 | |||
84 | /* for memmap sanitization */ | ||
85 | struct change_member { | ||
86 | struct bfin_memmap_entry *pentry; /* pointer to original entry */ | ||
87 | unsigned long long addr; /* address for this change point */ | ||
88 | }; | ||
89 | static struct change_member change_point_list[2*BFIN_MEMMAP_MAX] __initdata; | ||
90 | static struct change_member *change_point[2*BFIN_MEMMAP_MAX] __initdata; | ||
91 | static struct bfin_memmap_entry *overlap_list[BFIN_MEMMAP_MAX] __initdata; | ||
92 | static struct bfin_memmap_entry new_map[BFIN_MEMMAP_MAX] __initdata; | ||
93 | |||
70 | void __init bf53x_cache_init(void) | 94 | void __init bf53x_cache_init(void) |
71 | { | 95 | { |
72 | #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) | 96 | #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) |
@@ -123,12 +147,224 @@ void __init bf53x_relocate_l1_mem(void) | |||
123 | 147 | ||
124 | } | 148 | } |
125 | 149 | ||
150 | /* add_memory_region to memmap */ | ||
151 | static void __init add_memory_region(unsigned long long start, | ||
152 | unsigned long long size, int type) | ||
153 | { | ||
154 | int i; | ||
155 | |||
156 | i = bfin_memmap.nr_map; | ||
157 | |||
158 | if (i == BFIN_MEMMAP_MAX) { | ||
159 | printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | bfin_memmap.map[i].addr = start; | ||
164 | bfin_memmap.map[i].size = size; | ||
165 | bfin_memmap.map[i].type = type; | ||
166 | bfin_memmap.nr_map++; | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | * Sanitize the boot memmap, removing overlaps. | ||
171 | */ | ||
172 | static int __init sanitize_memmap(struct bfin_memmap_entry *map, int *pnr_map) | ||
173 | { | ||
174 | struct change_member *change_tmp; | ||
175 | unsigned long current_type, last_type; | ||
176 | unsigned long long last_addr; | ||
177 | int chgidx, still_changing; | ||
178 | int overlap_entries; | ||
179 | int new_entry; | ||
180 | int old_nr, new_nr, chg_nr; | ||
181 | int i; | ||
182 | |||
183 | /* | ||
184 | Visually we're performing the following (1,2,3,4 = memory types) | ||
185 | |||
186 | Sample memory map (w/overlaps): | ||
187 | ____22__________________ | ||
188 | ______________________4_ | ||
189 | ____1111________________ | ||
190 | _44_____________________ | ||
191 | 11111111________________ | ||
192 | ____________________33__ | ||
193 | ___________44___________ | ||
194 | __________33333_________ | ||
195 | ______________22________ | ||
196 | ___________________2222_ | ||
197 | _________111111111______ | ||
198 | _____________________11_ | ||
199 | _________________4______ | ||
200 | |||
201 | Sanitized equivalent (no overlap): | ||
202 | 1_______________________ | ||
203 | _44_____________________ | ||
204 | ___1____________________ | ||
205 | ____22__________________ | ||
206 | ______11________________ | ||
207 | _________1______________ | ||
208 | __________3_____________ | ||
209 | ___________44___________ | ||
210 | _____________33_________ | ||
211 | _______________2________ | ||
212 | ________________1_______ | ||
213 | _________________4______ | ||
214 | ___________________2____ | ||
215 | ____________________33__ | ||
216 | ______________________4_ | ||
217 | */ | ||
218 | /* if there's only one memory region, don't bother */ | ||
219 | if (*pnr_map < 2) | ||
220 | return -1; | ||
221 | |||
222 | old_nr = *pnr_map; | ||
223 | |||
224 | /* bail out if we find any unreasonable addresses in memmap */ | ||
225 | for (i = 0; i < old_nr; i++) | ||
226 | if (map[i].addr + map[i].size < map[i].addr) | ||
227 | return -1; | ||
228 | |||
229 | /* create pointers for initial change-point information (for sorting) */ | ||
230 | for (i = 0; i < 2*old_nr; i++) | ||
231 | change_point[i] = &change_point_list[i]; | ||
232 | |||
233 | /* record all known change-points (starting and ending addresses), | ||
234 | omitting those that are for empty memory regions */ | ||
235 | chgidx = 0; | ||
236 | for (i = 0; i < old_nr; i++) { | ||
237 | if (map[i].size != 0) { | ||
238 | change_point[chgidx]->addr = map[i].addr; | ||
239 | change_point[chgidx++]->pentry = &map[i]; | ||
240 | change_point[chgidx]->addr = map[i].addr + map[i].size; | ||
241 | change_point[chgidx++]->pentry = &map[i]; | ||
242 | } | ||
243 | } | ||
244 | chg_nr = chgidx; /* true number of change-points */ | ||
245 | |||
246 | /* sort change-point list by memory addresses (low -> high) */ | ||
247 | still_changing = 1; | ||
248 | while (still_changing) { | ||
249 | still_changing = 0; | ||
250 | for (i = 1; i < chg_nr; i++) { | ||
251 | /* if <current_addr> > <last_addr>, swap */ | ||
252 | /* or, if current=<start_addr> & last=<end_addr>, swap */ | ||
253 | if ((change_point[i]->addr < change_point[i-1]->addr) || | ||
254 | ((change_point[i]->addr == change_point[i-1]->addr) && | ||
255 | (change_point[i]->addr == change_point[i]->pentry->addr) && | ||
256 | (change_point[i-1]->addr != change_point[i-1]->pentry->addr)) | ||
257 | ) { | ||
258 | change_tmp = change_point[i]; | ||
259 | change_point[i] = change_point[i-1]; | ||
260 | change_point[i-1] = change_tmp; | ||
261 | still_changing = 1; | ||
262 | } | ||
263 | } | ||
264 | } | ||
265 | |||
266 | /* create a new memmap, removing overlaps */ | ||
267 | overlap_entries = 0; /* number of entries in the overlap table */ | ||
268 | new_entry = 0; /* index for creating new memmap entries */ | ||
269 | last_type = 0; /* start with undefined memory type */ | ||
270 | last_addr = 0; /* start with 0 as last starting address */ | ||
271 | /* loop through change-points, determining affect on the new memmap */ | ||
272 | for (chgidx = 0; chgidx < chg_nr; chgidx++) { | ||
273 | /* keep track of all overlapping memmap entries */ | ||
274 | if (change_point[chgidx]->addr == change_point[chgidx]->pentry->addr) { | ||
275 | /* add map entry to overlap list (> 1 entry implies an overlap) */ | ||
276 | overlap_list[overlap_entries++] = change_point[chgidx]->pentry; | ||
277 | } else { | ||
278 | /* remove entry from list (order independent, so swap with last) */ | ||
279 | for (i = 0; i < overlap_entries; i++) { | ||
280 | if (overlap_list[i] == change_point[chgidx]->pentry) | ||
281 | overlap_list[i] = overlap_list[overlap_entries-1]; | ||
282 | } | ||
283 | overlap_entries--; | ||
284 | } | ||
285 | /* if there are overlapping entries, decide which "type" to use */ | ||
286 | /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */ | ||
287 | current_type = 0; | ||
288 | for (i = 0; i < overlap_entries; i++) | ||
289 | if (overlap_list[i]->type > current_type) | ||
290 | current_type = overlap_list[i]->type; | ||
291 | /* continue building up new memmap based on this information */ | ||
292 | if (current_type != last_type) { | ||
293 | if (last_type != 0) { | ||
294 | new_map[new_entry].size = | ||
295 | change_point[chgidx]->addr - last_addr; | ||
296 | /* move forward only if the new size was non-zero */ | ||
297 | if (new_map[new_entry].size != 0) | ||
298 | if (++new_entry >= BFIN_MEMMAP_MAX) | ||
299 | break; /* no more space left for new entries */ | ||
300 | } | ||
301 | if (current_type != 0) { | ||
302 | new_map[new_entry].addr = change_point[chgidx]->addr; | ||
303 | new_map[new_entry].type = current_type; | ||
304 | last_addr = change_point[chgidx]->addr; | ||
305 | } | ||
306 | last_type = current_type; | ||
307 | } | ||
308 | } | ||
309 | new_nr = new_entry; /* retain count for new entries */ | ||
310 | |||
311 | /* copy new mapping into original location */ | ||
312 | memcpy(map, new_map, new_nr*sizeof(struct bfin_memmap_entry)); | ||
313 | *pnr_map = new_nr; | ||
314 | |||
315 | return 0; | ||
316 | } | ||
317 | |||
318 | static void __init print_memory_map(char *who) | ||
319 | { | ||
320 | int i; | ||
321 | |||
322 | for (i = 0; i < bfin_memmap.nr_map; i++) { | ||
323 | printk(KERN_DEBUG " %s: %016Lx - %016Lx ", who, | ||
324 | bfin_memmap.map[i].addr, | ||
325 | bfin_memmap.map[i].addr + bfin_memmap.map[i].size); | ||
326 | switch (bfin_memmap.map[i].type) { | ||
327 | case BFIN_MEMMAP_RAM: | ||
328 | printk("(usable)\n"); | ||
329 | break; | ||
330 | case BFIN_MEMMAP_RESERVED: | ||
331 | printk("(reserved)\n"); | ||
332 | break; | ||
333 | default: printk("type %lu\n", bfin_memmap.map[i].type); | ||
334 | break; | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | |||
339 | static __init int parse_memmap(char *arg) | ||
340 | { | ||
341 | unsigned long long start_at, mem_size; | ||
342 | |||
343 | if (!arg) | ||
344 | return -EINVAL; | ||
345 | |||
346 | mem_size = memparse(arg, &arg); | ||
347 | if (*arg == '@') { | ||
348 | start_at = memparse(arg+1, &arg); | ||
349 | add_memory_region(start_at, mem_size, BFIN_MEMMAP_RAM); | ||
350 | } else if (*arg == '$') { | ||
351 | start_at = memparse(arg+1, &arg); | ||
352 | add_memory_region(start_at, mem_size, BFIN_MEMMAP_RESERVED); | ||
353 | } | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
126 | /* | 358 | /* |
127 | * Initial parsing of the command line. Currently, we support: | 359 | * Initial parsing of the command line. Currently, we support: |
128 | * - Controlling the linux memory size: mem=xxx[KMG] | 360 | * - Controlling the linux memory size: mem=xxx[KMG] |
129 | * - Controlling the physical memory size: max_mem=xxx[KMG][$][#] | 361 | * - Controlling the physical memory size: max_mem=xxx[KMG][$][#] |
130 | * $ -> reserved memory is dcacheable | 362 | * $ -> reserved memory is dcacheable |
131 | * # -> reserved memory is icacheable | 363 | * # -> reserved memory is icacheable |
364 | * - "memmap=XXX[KkmM][@][$]XXX[KkmM]" defines a memory region | ||
365 | * @ from <start> to <start>+<mem>, type RAM | ||
366 | * $ from <start> to <start>+<mem>, type RESERVED | ||
367 | * | ||
132 | */ | 368 | */ |
133 | static __init void parse_cmdline_early(char *cmdline_p) | 369 | static __init void parse_cmdline_early(char *cmdline_p) |
134 | { | 370 | { |
@@ -136,7 +372,6 @@ static __init void parse_cmdline_early(char *cmdline_p) | |||
136 | unsigned int memsize; | 372 | unsigned int memsize; |
137 | for (;;) { | 373 | for (;;) { |
138 | if (c == ' ') { | 374 | if (c == ' ') { |
139 | |||
140 | if (!memcmp(to, "mem=", 4)) { | 375 | if (!memcmp(to, "mem=", 4)) { |
141 | to += 4; | 376 | to += 4; |
142 | memsize = memparse(to, &to); | 377 | memsize = memparse(to, &to); |
@@ -162,6 +397,9 @@ static __init void parse_cmdline_early(char *cmdline_p) | |||
162 | } else if (!memcmp(to, "earlyprintk=", 12)) { | 397 | } else if (!memcmp(to, "earlyprintk=", 12)) { |
163 | to += 12; | 398 | to += 12; |
164 | setup_early_printk(to); | 399 | setup_early_printk(to); |
400 | } else if (!memcmp(to, "memmap=", 7)) { | ||
401 | to += 7; | ||
402 | parse_memmap(to); | ||
165 | } | 403 | } |
166 | } | 404 | } |
167 | c = *(to++); | 405 | c = *(to++); |
@@ -170,75 +408,32 @@ static __init void parse_cmdline_early(char *cmdline_p) | |||
170 | } | 408 | } |
171 | } | 409 | } |
172 | 410 | ||
173 | void __init setup_arch(char **cmdline_p) | 411 | /* |
412 | * Setup memory defaults from user config. | ||
413 | * The physical memory layout looks like: | ||
414 | * | ||
415 | * [_rambase, _ramstart]: kernel image | ||
416 | * [memory_start, memory_end]: dynamic memory managed by kernel | ||
417 | * [memory_end, _ramend]: reserved memory | ||
418 | * [meory_mtd_start(memory_end), | ||
419 | * memory_mtd_start + mtd_size]: rootfs (if any) | ||
420 | * [_ramend - DMA_UNCACHED_REGION, | ||
421 | * _ramend]: uncached DMA region | ||
422 | * [_ramend, physical_mem_end]: memory not managed by kernel | ||
423 | * | ||
424 | */ | ||
425 | static __init void memory_setup(void) | ||
174 | { | 426 | { |
175 | int bootmap_size; | 427 | _rambase = (unsigned long)_stext; |
176 | unsigned long l1_length, sclk, cclk; | 428 | _ramstart = (unsigned long)__bss_stop; |
177 | #ifdef CONFIG_MTD_UCLINUX | ||
178 | unsigned long mtd_phys = 0; | ||
179 | #endif | ||
180 | |||
181 | #ifdef CONFIG_DUMMY_CONSOLE | ||
182 | conswitchp = &dummy_con; | ||
183 | #endif | ||
184 | |||
185 | #if defined(CONFIG_CMDLINE_BOOL) | ||
186 | strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line)); | ||
187 | command_line[sizeof(command_line) - 1] = 0; | ||
188 | #endif | ||
189 | |||
190 | /* Keep a copy of command line */ | ||
191 | *cmdline_p = &command_line[0]; | ||
192 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | ||
193 | boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; | ||
194 | |||
195 | /* setup memory defaults from the user config */ | ||
196 | physical_mem_end = 0; | ||
197 | _ramend = CONFIG_MEM_SIZE * 1024 * 1024; | ||
198 | |||
199 | parse_cmdline_early(&command_line[0]); | ||
200 | |||
201 | cclk = get_cclk(); | ||
202 | sclk = get_sclk(); | ||
203 | |||
204 | #if !defined(CONFIG_BFIN_KERNEL_CLOCK) | ||
205 | if (ANOMALY_05000273 && cclk == sclk) | ||
206 | panic("ANOMALY 05000273, SCLK can not be same as CCLK"); | ||
207 | #endif | ||
208 | 429 | ||
209 | #ifdef BF561_FAMILY | 430 | if (DMA_UNCACHED_REGION > (_ramend - _ramstart)) { |
210 | if (ANOMALY_05000266) { | 431 | console_init(); |
211 | bfin_read_IMDMA_D0_IRQ_STATUS(); | 432 | panic("DMA region exceeds memory limit: %lu.\n", |
212 | bfin_read_IMDMA_D1_IRQ_STATUS(); | 433 | _ramend - _ramstart); |
213 | } | 434 | } |
214 | #endif | ||
215 | |||
216 | printk(KERN_INFO "Hardware Trace "); | ||
217 | if (bfin_read_TBUFCTL() & 0x1 ) | ||
218 | printk("Active "); | ||
219 | else | ||
220 | printk("Off "); | ||
221 | if (bfin_read_TBUFCTL() & 0x2) | ||
222 | printk("and Enabled\n"); | ||
223 | else | ||
224 | printk("and Disabled\n"); | ||
225 | |||
226 | |||
227 | #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) | ||
228 | /* we need to initialize the Flashrom device here since we might | ||
229 | * do things with flash early on in the boot | ||
230 | */ | ||
231 | flash_probe(); | ||
232 | #endif | ||
233 | |||
234 | if (physical_mem_end == 0) | ||
235 | physical_mem_end = _ramend; | ||
236 | |||
237 | /* by now the stack is part of the init task */ | ||
238 | memory_end = _ramend - DMA_UNCACHED_REGION; | 435 | memory_end = _ramend - DMA_UNCACHED_REGION; |
239 | 436 | ||
240 | _ramstart = (unsigned long)__bss_stop; | ||
241 | _rambase = (unsigned long)_stext; | ||
242 | #ifdef CONFIG_MPU | 437 | #ifdef CONFIG_MPU |
243 | /* Round up to multiple of 4MB. */ | 438 | /* Round up to multiple of 4MB. */ |
244 | memory_start = (_ramstart + 0x3fffff) & ~0x3fffff; | 439 | memory_start = (_ramstart + 0x3fffff) & ~0x3fffff; |
@@ -319,13 +514,178 @@ void __init setup_arch(char **cmdline_p) | |||
319 | #endif | 514 | #endif |
320 | 515 | ||
321 | #if !defined(CONFIG_MTD_UCLINUX) | 516 | #if !defined(CONFIG_MTD_UCLINUX) |
322 | memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/ | 517 | /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/ |
518 | memory_end -= SIZE_4K; | ||
323 | #endif | 519 | #endif |
520 | |||
324 | init_mm.start_code = (unsigned long)_stext; | 521 | init_mm.start_code = (unsigned long)_stext; |
325 | init_mm.end_code = (unsigned long)_etext; | 522 | init_mm.end_code = (unsigned long)_etext; |
326 | init_mm.end_data = (unsigned long)_edata; | 523 | init_mm.end_data = (unsigned long)_edata; |
327 | init_mm.brk = (unsigned long)0; | 524 | init_mm.brk = (unsigned long)0; |
328 | 525 | ||
526 | printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); | ||
527 | printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); | ||
528 | |||
529 | printk( KERN_INFO "Memory map:\n" | ||
530 | KERN_INFO " text = 0x%p-0x%p\n" | ||
531 | KERN_INFO " rodata = 0x%p-0x%p\n" | ||
532 | KERN_INFO " data = 0x%p-0x%p\n" | ||
533 | KERN_INFO " stack = 0x%p-0x%p\n" | ||
534 | KERN_INFO " init = 0x%p-0x%p\n" | ||
535 | KERN_INFO " bss = 0x%p-0x%p\n" | ||
536 | KERN_INFO " available = 0x%p-0x%p\n" | ||
537 | #ifdef CONFIG_MTD_UCLINUX | ||
538 | KERN_INFO " rootfs = 0x%p-0x%p\n" | ||
539 | #endif | ||
540 | #if DMA_UNCACHED_REGION > 0 | ||
541 | KERN_INFO " DMA Zone = 0x%p-0x%p\n" | ||
542 | #endif | ||
543 | , _stext, _etext, | ||
544 | __start_rodata, __end_rodata, | ||
545 | _sdata, _edata, | ||
546 | (void *)&init_thread_union, | ||
547 | (void *)((int)(&init_thread_union) + 0x2000), | ||
548 | __init_begin, __init_end, | ||
549 | __bss_start, __bss_stop, | ||
550 | (void *)_ramstart, (void *)memory_end | ||
551 | #ifdef CONFIG_MTD_UCLINUX | ||
552 | , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size) | ||
553 | #endif | ||
554 | #if DMA_UNCACHED_REGION > 0 | ||
555 | , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend) | ||
556 | #endif | ||
557 | ); | ||
558 | } | ||
559 | |||
560 | static __init void setup_bootmem_allocator(void) | ||
561 | { | ||
562 | int bootmap_size; | ||
563 | int i; | ||
564 | unsigned long min_pfn, max_pfn; | ||
565 | unsigned long curr_pfn, last_pfn, size; | ||
566 | |||
567 | /* mark memory between memory_start and memory_end usable */ | ||
568 | add_memory_region(memory_start, | ||
569 | memory_end - memory_start, BFIN_MEMMAP_RAM); | ||
570 | /* sanity check for overlap */ | ||
571 | sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map); | ||
572 | print_memory_map("boot memmap"); | ||
573 | |||
574 | min_pfn = PAGE_OFFSET >> PAGE_SHIFT; | ||
575 | max_pfn = memory_end >> PAGE_SHIFT; | ||
576 | |||
577 | /* | ||
578 | * give all the memory to the bootmap allocator, tell it to put the | ||
579 | * boot mem_map at the start of memory. | ||
580 | */ | ||
581 | bootmap_size = init_bootmem_node(NODE_DATA(0), | ||
582 | memory_start >> PAGE_SHIFT, /* map goes here */ | ||
583 | min_pfn, max_pfn); | ||
584 | |||
585 | /* register the memmap regions with the bootmem allocator */ | ||
586 | for (i = 0; i < bfin_memmap.nr_map; i++) { | ||
587 | /* | ||
588 | * Reserve usable memory | ||
589 | */ | ||
590 | if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM) | ||
591 | continue; | ||
592 | /* | ||
593 | * We are rounding up the start address of usable memory: | ||
594 | */ | ||
595 | curr_pfn = PFN_UP(bfin_memmap.map[i].addr); | ||
596 | if (curr_pfn >= max_pfn) | ||
597 | continue; | ||
598 | /* | ||
599 | * ... and at the end of the usable range downwards: | ||
600 | */ | ||
601 | last_pfn = PFN_DOWN(bfin_memmap.map[i].addr + | ||
602 | bfin_memmap.map[i].size); | ||
603 | |||
604 | if (last_pfn > max_pfn) | ||
605 | last_pfn = max_pfn; | ||
606 | |||
607 | /* | ||
608 | * .. finally, did all the rounding and playing | ||
609 | * around just make the area go away? | ||
610 | */ | ||
611 | if (last_pfn <= curr_pfn) | ||
612 | continue; | ||
613 | |||
614 | size = last_pfn - curr_pfn; | ||
615 | free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); | ||
616 | } | ||
617 | |||
618 | /* reserve memory before memory_start, including bootmap */ | ||
619 | reserve_bootmem(PAGE_OFFSET, | ||
620 | memory_start + bootmap_size + PAGE_SIZE - 1 - PAGE_OFFSET, | ||
621 | BOOTMEM_DEFAULT); | ||
622 | } | ||
623 | |||
624 | void __init setup_arch(char **cmdline_p) | ||
625 | { | ||
626 | unsigned long l1_length, sclk, cclk; | ||
627 | #ifdef CONFIG_MTD_UCLINUX | ||
628 | unsigned long mtd_phys = 0; | ||
629 | #endif | ||
630 | |||
631 | #ifdef CONFIG_DUMMY_CONSOLE | ||
632 | conswitchp = &dummy_con; | ||
633 | #endif | ||
634 | |||
635 | #if defined(CONFIG_CMDLINE_BOOL) | ||
636 | strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line)); | ||
637 | command_line[sizeof(command_line) - 1] = 0; | ||
638 | #endif | ||
639 | |||
640 | /* Keep a copy of command line */ | ||
641 | *cmdline_p = &command_line[0]; | ||
642 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | ||
643 | boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; | ||
644 | |||
645 | /* setup memory defaults from the user config */ | ||
646 | physical_mem_end = 0; | ||
647 | _ramend = CONFIG_MEM_SIZE * 1024 * 1024; | ||
648 | |||
649 | memset(&bfin_memmap, 0, sizeof(bfin_memmap)); | ||
650 | |||
651 | parse_cmdline_early(&command_line[0]); | ||
652 | |||
653 | if (physical_mem_end == 0) | ||
654 | physical_mem_end = _ramend; | ||
655 | |||
656 | memory_setup(); | ||
657 | |||
658 | cclk = get_cclk(); | ||
659 | sclk = get_sclk(); | ||
660 | |||
661 | #if !defined(CONFIG_BFIN_KERNEL_CLOCK) | ||
662 | if (ANOMALY_05000273 && cclk == sclk) | ||
663 | panic("ANOMALY 05000273, SCLK can not be same as CCLK"); | ||
664 | #endif | ||
665 | |||
666 | #ifdef BF561_FAMILY | ||
667 | if (ANOMALY_05000266) { | ||
668 | bfin_read_IMDMA_D0_IRQ_STATUS(); | ||
669 | bfin_read_IMDMA_D1_IRQ_STATUS(); | ||
670 | } | ||
671 | #endif | ||
672 | printk(KERN_INFO "Hardware Trace "); | ||
673 | if (bfin_read_TBUFCTL() & 0x1) | ||
674 | printk("Active "); | ||
675 | else | ||
676 | printk("Off "); | ||
677 | if (bfin_read_TBUFCTL() & 0x2) | ||
678 | printk("and Enabled\n"); | ||
679 | else | ||
680 | printk("and Disabled\n"); | ||
681 | |||
682 | #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) | ||
683 | /* we need to initialize the Flashrom device here since we might | ||
684 | * do things with flash early on in the boot | ||
685 | */ | ||
686 | flash_probe(); | ||
687 | #endif | ||
688 | |||
329 | _bfin_swrst = bfin_read_SWRST(); | 689 | _bfin_swrst = bfin_read_SWRST(); |
330 | 690 | ||
331 | if (_bfin_swrst & RESET_DOUBLE) | 691 | if (_bfin_swrst & RESET_DOUBLE) |
@@ -361,55 +721,8 @@ void __init setup_arch(char **cmdline_p) | |||
361 | if (ANOMALY_05000273 && (cclk >> 1) <= sclk) | 721 | if (ANOMALY_05000273 && (cclk >> 1) <= sclk) |
362 | printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n"); | 722 | printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n"); |
363 | 723 | ||
364 | printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); | 724 | setup_bootmem_allocator(); |
365 | printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); | ||
366 | |||
367 | printk(KERN_INFO "Memory map:\n" | ||
368 | KERN_INFO " text = 0x%p-0x%p\n" | ||
369 | KERN_INFO " rodata = 0x%p-0x%p\n" | ||
370 | KERN_INFO " data = 0x%p-0x%p\n" | ||
371 | KERN_INFO " stack = 0x%p-0x%p\n" | ||
372 | KERN_INFO " init = 0x%p-0x%p\n" | ||
373 | KERN_INFO " bss = 0x%p-0x%p\n" | ||
374 | KERN_INFO " available = 0x%p-0x%p\n" | ||
375 | #ifdef CONFIG_MTD_UCLINUX | ||
376 | KERN_INFO " rootfs = 0x%p-0x%p\n" | ||
377 | #endif | ||
378 | #if DMA_UNCACHED_REGION > 0 | ||
379 | KERN_INFO " DMA Zone = 0x%p-0x%p\n" | ||
380 | #endif | ||
381 | , _stext, _etext, | ||
382 | __start_rodata, __end_rodata, | ||
383 | _sdata, _edata, | ||
384 | (void *)&init_thread_union, (void *)((int)(&init_thread_union) + 0x2000), | ||
385 | __init_begin, __init_end, | ||
386 | __bss_start, __bss_stop, | ||
387 | (void *)_ramstart, (void *)memory_end | ||
388 | #ifdef CONFIG_MTD_UCLINUX | ||
389 | , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size) | ||
390 | #endif | ||
391 | #if DMA_UNCACHED_REGION > 0 | ||
392 | , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend) | ||
393 | #endif | ||
394 | ); | ||
395 | |||
396 | /* | ||
397 | * give all the memory to the bootmap allocator, tell it to put the | ||
398 | * boot mem_map at the start of memory | ||
399 | */ | ||
400 | bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */ | ||
401 | PAGE_OFFSET >> PAGE_SHIFT, | ||
402 | memory_end >> PAGE_SHIFT); | ||
403 | /* | ||
404 | * free the usable memory, we have to make sure we do not free | ||
405 | * the bootmem bitmap so we then reserve it after freeing it :-) | ||
406 | */ | ||
407 | free_bootmem(memory_start, memory_end - memory_start); | ||
408 | 725 | ||
409 | reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT); | ||
410 | /* | ||
411 | * get kmalloc into gear | ||
412 | */ | ||
413 | paging_init(); | 726 | paging_init(); |
414 | 727 | ||
415 | /* check the size of the l1 area */ | 728 | /* check the size of the l1 area */ |