2 * linux/arch/arm/kernel/setup.c
4 * Copyright (C) 1995-2001 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/config.h>
11 #include <linux/kernel.h>
12 #include <linux/stddef.h>
13 #include <linux/ioport.h>
14 #include <linux/delay.h>
15 #include <linux/utsname.h>
16 #include <linux/blk.h>
17 #include <linux/console.h>
18 #include <linux/bootmem.h>
19 #include <linux/seq_file.h>
20 #include <linux/init.h>
23 #include <asm/hardware.h>
25 #include <asm/procinfo.h>
26 #include <asm/setup.h>
27 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/irq.h>
33 #define MEM_SIZE (16*1024*1024)
36 #ifndef CONFIG_CMDLINE
37 #define CONFIG_CMDLINE ""
40 #if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE)
43 static int __init fpe_setup(char *line)
45 memcpy(fpe_type, line, 8);
49 __setup("fpe=", fpe_setup);
52 extern unsigned int mem_fclk_21285;
53 extern void paging_init(struct meminfo *, struct machine_desc *desc);
54 extern void convert_to_tag_list(struct param_struct *params, int mem_init);
55 extern void bootmem_init(struct meminfo *);
56 extern void reboot_setup(char *str);
57 extern int root_mountflags;
58 extern int _stext, _text, _etext, _edata, _end;
60 unsigned int processor_id;
62 unsigned int __machine_arch_type;
63 unsigned int system_rev;
64 unsigned int system_serial_low;
65 unsigned int system_serial_high;
66 unsigned int elf_hwcap;
69 struct processor processor;
72 unsigned char aux_device_present;
73 char elf_platform[ELF_PLATFORM_SIZE];
74 char saved_command_line[COMMAND_LINE_SIZE];
76 static struct meminfo meminfo __initdata = { 0, };
77 static struct proc_info_item proc_info;
78 static const char *machine_name;
79 static char command_line[COMMAND_LINE_SIZE];
81 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
82 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
83 #define ENDIANNESS ((char)endian_test.l)
86 * Standard memory resources
88 static struct resource mem_res[] = {
89 { "Video RAM", 0, 0, IORESOURCE_MEM },
90 { "Kernel code", 0, 0, IORESOURCE_MEM },
91 { "Kernel data", 0, 0, IORESOURCE_MEM }
94 #define video_ram mem_res[0]
95 #define kernel_code mem_res[1]
96 #define kernel_data mem_res[2]
98 static struct resource io_res[] = {
99 { "reserved", 0x3bc, 0x3be, IORESOURCE_IO | IORESOURCE_BUSY },
100 { "reserved", 0x378, 0x37f, IORESOURCE_IO | IORESOURCE_BUSY },
101 { "reserved", 0x278, 0x27f, IORESOURCE_IO | IORESOURCE_BUSY }
104 #define lp0 io_res[0]
105 #define lp1 io_res[1]
106 #define lp2 io_res[2]
108 static void __init setup_processor(void)
110 extern struct proc_info_list __proc_info_begin, __proc_info_end;
111 struct proc_info_list *list;
114 * locate processor in the list of supported processor
115 * types. The linker builds this table for us from the
116 * entries in arch/arm/mm/proc-*.S
118 for (list = &__proc_info_begin; list < &__proc_info_end ; list++)
119 if ((processor_id & list->cpu_mask) == list->cpu_val)
123 * If processor type is unrecognised, then we
126 if (list >= &__proc_info_end) {
127 printk("CPU configuration botched (ID %08x), unable "
128 "to continue.\n", processor_id);
132 proc_info = *list->info;
135 processor = *list->proc;
138 printk("Processor: %s %s revision %d\n",
139 proc_info.manufacturer, proc_info.cpu_name,
140 (int)processor_id & 15);
142 sprintf(system_utsname.machine, "%s%c", list->arch_name, ENDIANNESS);
143 sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
144 elf_hwcap = list->elf_hwcap;
149 static struct machine_desc * __init setup_architecture(unsigned int nr)
151 extern struct machine_desc __arch_info_begin, __arch_info_end;
152 struct machine_desc *list;
155 * locate architecture in the list of supported architectures.
157 for (list = &__arch_info_begin; list < &__arch_info_end; list++)
162 * If the architecture type is not recognised, then we
165 if (list >= &__arch_info_end) {
166 printk("Architecture configuration botched (nr %d), unable "
167 "to continue.\n", nr);
171 printk("Architecture: %s\n", list->name);
173 printk(KERN_WARNING "Using compatibility code "
174 "scheduled for removal in v%d.%d.%d\n",
175 compat >> 24, (compat >> 12) & 0x3ff,
182 * Initial parsing of the command line. We need to pick out the
183 * memory size. We look for mem=size@start, where start and size
187 parse_cmdline(struct meminfo *mi, char **cmdline_p, char *from)
189 char c = ' ', *to = command_line;
190 int usermem = 0, len = 0;
193 if (c == ' ' && !memcmp(from, "mem=", 4)) {
194 unsigned long size, start;
196 if (to != command_line)
200 * If the user specifies memory size, we
201 * blow away any automatically generated
210 size = memparse(from + 4, &from);
212 start = memparse(from + 1, &from);
214 mi->bank[mi->nr_banks].start = start;
215 mi->bank[mi->nr_banks].size = size;
216 mi->bank[mi->nr_banks].node = PHYS_TO_NID(start);
222 if (COMMAND_LINE_SIZE <= ++len)
227 *cmdline_p = command_line;
231 setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
233 #ifdef CONFIG_BLK_DEV_RAM
236 rd_image_start = image_start;
248 void __init setup_initrd(unsigned int start, unsigned int size)
250 #ifdef CONFIG_BLK_DEV_INITRD
253 initrd_start = start;
254 initrd_end = start + size;
259 request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
261 struct resource *res;
264 kernel_code.start = __virt_to_phys(init_mm.start_code);
265 kernel_code.end = __virt_to_phys(init_mm.end_code - 1);
266 kernel_data.start = __virt_to_phys(init_mm.end_code);
267 kernel_data.end = __virt_to_phys(init_mm.brk - 1);
269 for (i = 0; i < mi->nr_banks; i++) {
270 unsigned long virt_start, virt_end;
272 if (mi->bank[i].size == 0)
275 virt_start = __phys_to_virt(mi->bank[i].start);
276 virt_end = virt_start + mi->bank[i].size - 1;
278 res = alloc_bootmem_low(sizeof(*res));
279 res->name = "System RAM";
280 res->start = __virt_to_phys(virt_start);
281 res->end = __virt_to_phys(virt_end);
282 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
284 request_resource(&iomem_resource, res);
286 if (kernel_code.start >= res->start &&
287 kernel_code.end <= res->end)
288 request_resource(res, &kernel_code);
289 if (kernel_data.start >= res->start &&
290 kernel_data.end <= res->end)
291 request_resource(res, &kernel_data);
294 if (mdesc->video_start) {
295 video_ram.start = mdesc->video_start;
296 video_ram.end = mdesc->video_end;
297 request_resource(&iomem_resource, &video_ram);
301 * Some machines don't have the possibility of ever
302 * possessing lp0, lp1 or lp2
304 if (mdesc->reserve_lp0)
305 request_resource(&ioport_resource, &lp0);
306 if (mdesc->reserve_lp1)
307 request_resource(&ioport_resource, &lp1);
308 if (mdesc->reserve_lp2)
309 request_resource(&ioport_resource, &lp2);
315 * This is the new way of passing data to the kernel at boot time. Rather
316 * than passing a fixed inflexible structure to the kernel, we pass a list
317 * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE
318 * tag for the list to be recognised (to distinguish the tagged list from
319 * a param_struct). The list is terminated with a zero-length tag (this tag
320 * is not parsed in any way).
322 static int __init parse_tag_core(const struct tag *tag)
324 if (tag->hdr.size > 2) {
325 if ((tag->u.core.flags & 1) == 0)
326 root_mountflags &= ~MS_RDONLY;
327 ROOT_DEV = to_kdev_t(tag->u.core.rootdev);
332 __tagtable(ATAG_CORE, parse_tag_core);
334 static int __init parse_tag_mem32(const struct tag *tag)
336 if (meminfo.nr_banks >= NR_BANKS) {
338 "Ignoring memory bank 0x%08x size %dKB\n",
339 tag->u.mem.start, tag->u.mem.size / 1024);
342 meminfo.bank[meminfo.nr_banks].start = tag->u.mem.start;
343 meminfo.bank[meminfo.nr_banks].size = tag->u.mem.size;
344 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(tag->u.mem.start);
345 meminfo.nr_banks += 1;
350 __tagtable(ATAG_MEM, parse_tag_mem32);
352 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
353 struct screen_info screen_info = {
354 orig_video_lines: 30,
357 orig_video_ega_bx: 0,
362 static int __init parse_tag_videotext(const struct tag *tag)
364 screen_info.orig_x = tag->u.videotext.x;
365 screen_info.orig_y = tag->u.videotext.y;
366 screen_info.orig_video_page = tag->u.videotext.video_page;
367 screen_info.orig_video_mode = tag->u.videotext.video_mode;
368 screen_info.orig_video_cols = tag->u.videotext.video_cols;
369 screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx;
370 screen_info.orig_video_lines = tag->u.videotext.video_lines;
371 screen_info.orig_video_isVGA = tag->u.videotext.video_isvga;
372 screen_info.orig_video_points = tag->u.videotext.video_points;
376 __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
379 static int __init parse_tag_ramdisk(const struct tag *tag)
381 setup_ramdisk((tag->u.ramdisk.flags & 1) == 0,
382 (tag->u.ramdisk.flags & 2) == 0,
383 tag->u.ramdisk.start, tag->u.ramdisk.size);
387 __tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
389 static int __init parse_tag_initrd(const struct tag *tag)
391 setup_initrd(tag->u.initrd.start, tag->u.initrd.size);
395 __tagtable(ATAG_INITRD, parse_tag_initrd);
397 static int __init parse_tag_serialnr(const struct tag *tag)
399 system_serial_low = tag->u.serialnr.low;
400 system_serial_high = tag->u.serialnr.high;
404 __tagtable(ATAG_SERIAL, parse_tag_serialnr);
406 static int __init parse_tag_revision(const struct tag *tag)
408 system_rev = tag->u.revision.rev;
412 __tagtable(ATAG_REVISION, parse_tag_revision);
414 static int __init parse_tag_cmdline(const struct tag *tag)
416 strncpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
417 default_command_line[COMMAND_LINE_SIZE - 1] = '\0';
421 __tagtable(ATAG_CMDLINE, parse_tag_cmdline);
424 * Scan the tag table for this tag, and call its parse function.
425 * The tag table is built by the linker from all the __tagtable
428 static int __init parse_tag(const struct tag *tag)
430 extern struct tagtable __tagtable_begin, __tagtable_end;
433 for (t = &__tagtable_begin; t < &__tagtable_end; t++)
434 if (tag->hdr.tag == t->tag) {
439 return t < &__tagtable_end;
443 * Parse all tags in the list, checking both the global and architecture
444 * specific tag tables.
446 static void __init parse_tags(const struct tag *t)
448 for (; t->hdr.size; t = tag_next(t))
451 "Ignoring unrecognised tag 0x%08x\n",
455 void __init setup_arch(char **cmdline_p)
457 struct tag *tags = NULL;
458 struct machine_desc *mdesc;
459 char *from = default_command_line;
461 ROOT_DEV = MKDEV(0, 255);
464 mdesc = setup_architecture(machine_arch_type);
465 machine_name = mdesc->name;
467 if (mdesc->soft_reboot)
470 if (mdesc->param_offset)
471 tags = phys_to_virt(mdesc->param_offset);
474 * Do the machine-specific fixups before we parse the
475 * parameters or tags.
478 mdesc->fixup(mdesc, (struct param_struct *)tags,
482 * If we have the old style parameters, convert them to
485 if (tags && tags->hdr.tag != ATAG_CORE)
486 convert_to_tag_list((struct param_struct *)tags,
487 meminfo.nr_banks == 0);
489 if (tags && tags->hdr.tag == ATAG_CORE)
492 if (meminfo.nr_banks == 0) {
493 meminfo.nr_banks = 1;
494 meminfo.bank[0].start = PHYS_OFFSET;
495 meminfo.bank[0].size = MEM_SIZE;
498 init_mm.start_code = (unsigned long) &_text;
499 init_mm.end_code = (unsigned long) &_etext;
500 init_mm.end_data = (unsigned long) &_edata;
501 init_mm.brk = (unsigned long) &_end;
503 memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
504 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
505 parse_cmdline(&meminfo, cmdline_p, from);
506 bootmem_init(&meminfo);
507 paging_init(&meminfo, mdesc);
508 request_standard_resources(&meminfo, mdesc);
511 * Set up various architecture-specific pointers
513 init_arch_irq = mdesc->init_irq;
516 #if defined(CONFIG_VGA_CONSOLE)
517 conswitchp = &vga_con;
518 #elif defined(CONFIG_DUMMY_CONSOLE)
519 conswitchp = &dummy_con;
524 static const char *hwcap_str[] = {
536 static int c_show(struct seq_file *m, void *v)
540 seq_printf(m, "Processor\t: %s %s rev %d (%s)\n",
541 proc_info.manufacturer, proc_info.cpu_name,
542 (int)processor_id & 15, elf_platform);
544 seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
545 loops_per_jiffy / (500000/HZ),
546 (loops_per_jiffy / (5000/HZ)) % 100);
548 /* dump out the processor features */
549 seq_puts(m, "Features\t: ");
551 for (i = 0; hwcap_str[i]; i++)
552 if (elf_hwcap & (1 << i))
553 seq_printf(m, "%s ", hwcap_str[i]);
557 seq_printf(m, "Hardware\t: %s\n", machine_name);
558 seq_printf(m, "Revision\t: %04x\n", system_rev);
559 seq_printf(m, "Serial\t\t: %08x%08x\n",
560 system_serial_high, system_serial_low);
565 static void *c_start(struct seq_file *m, loff_t *pos)
567 return *pos < 1 ? (void *)1 : NULL;
570 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
576 static void c_stop(struct seq_file *m, void *v)
580 struct seq_operations cpuinfo_op = {