omap_hsmmc: Flush posted write to IRQ
[linux-ginger.git] / arch / xtensa / kernel / setup.c
blob4ec1633c29414f21f551223f4ea0065c95ccfb88
1 /*
2 * arch/xtensa/kernel/setup.c
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 1995 Linus Torvalds
9 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 * Chris Zankel <chris@zankel.net>
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
13 * Kevin Chea
14 * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
17 #include <linux/errno.h>
18 #include <linux/init.h>
19 #include <linux/mm.h>
20 #include <linux/proc_fs.h>
21 #include <linux/screen_info.h>
22 #include <linux/bootmem.h>
23 #include <linux/kernel.h>
25 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
26 # include <linux/console.h>
27 #endif
29 #ifdef CONFIG_RTC
30 # include <linux/timex.h>
31 #endif
33 #ifdef CONFIG_PROC_FS
34 # include <linux/seq_file.h>
35 #endif
37 #include <asm/system.h>
38 #include <asm/bootparam.h>
39 #include <asm/pgtable.h>
40 #include <asm/processor.h>
41 #include <asm/timex.h>
42 #include <asm/platform.h>
43 #include <asm/page.h>
44 #include <asm/setup.h>
45 #include <asm/param.h>
47 #include <platform/hardware.h>
49 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
50 struct screen_info screen_info = { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
51 #endif
53 #ifdef CONFIG_BLK_DEV_FD
54 extern struct fd_ops no_fd_ops;
55 struct fd_ops *fd_ops;
56 #endif
58 extern struct rtc_ops no_rtc_ops;
59 struct rtc_ops *rtc_ops;
61 #ifdef CONFIG_BLK_DEV_INITRD
62 extern void *initrd_start;
63 extern void *initrd_end;
64 extern void *__initrd_start;
65 extern void *__initrd_end;
66 int initrd_is_mapped = 0;
67 extern int initrd_below_start_ok;
68 #endif
70 unsigned char aux_device_present;
71 extern unsigned long loops_per_jiffy;
73 /* Command line specified as configuration option. */
75 static char __initdata command_line[COMMAND_LINE_SIZE];
77 #ifdef CONFIG_CMDLINE_BOOL
78 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
79 #endif
81 sysmem_info_t __initdata sysmem;
83 #ifdef CONFIG_BLK_DEV_INITRD
84 int initrd_is_mapped;
85 #endif
87 extern void init_mmu(void);
90 * Boot parameter parsing.
92 * The Xtensa port uses a list of variable-sized tags to pass data to
93 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
94 * to be recognised. The list is terminated with a zero-sized
95 * BP_TAG_LAST tag.
98 typedef struct tagtable {
99 u32 tag;
100 int (*parse)(const bp_tag_t*);
101 } tagtable_t;
103 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
104 __attribute__((unused, __section__(".taglist"))) = { tag, fn }
106 /* parse current tag */
108 static int __init parse_tag_mem(const bp_tag_t *tag)
110 meminfo_t *mi = (meminfo_t*)(tag->data);
112 if (mi->type != MEMORY_TYPE_CONVENTIONAL)
113 return -1;
115 if (sysmem.nr_banks >= SYSMEM_BANKS_MAX) {
116 printk(KERN_WARNING
117 "Ignoring memory bank 0x%08lx size %ldKB\n",
118 (unsigned long)mi->start,
119 (unsigned long)mi->end - (unsigned long)mi->start);
120 return -EINVAL;
122 sysmem.bank[sysmem.nr_banks].type = mi->type;
123 sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(mi->start);
124 sysmem.bank[sysmem.nr_banks].end = mi->end & PAGE_SIZE;
125 sysmem.nr_banks++;
127 return 0;
130 __tagtable(BP_TAG_MEMORY, parse_tag_mem);
132 #ifdef CONFIG_BLK_DEV_INITRD
134 static int __init parse_tag_initrd(const bp_tag_t* tag)
136 meminfo_t* mi;
137 mi = (meminfo_t*)(tag->data);
138 initrd_start = (void*)(mi->start);
139 initrd_end = (void*)(mi->end);
141 return 0;
144 __tagtable(BP_TAG_INITRD, parse_tag_initrd);
146 #endif /* CONFIG_BLK_DEV_INITRD */
148 static int __init parse_tag_cmdline(const bp_tag_t* tag)
150 strncpy(command_line, (char*)(tag->data), COMMAND_LINE_SIZE);
151 command_line[COMMAND_LINE_SIZE - 1] = '\0';
152 return 0;
155 __tagtable(BP_TAG_COMMAND_LINE, parse_tag_cmdline);
157 static int __init parse_bootparam(const bp_tag_t* tag)
159 extern tagtable_t __tagtable_begin, __tagtable_end;
160 tagtable_t *t;
162 /* Boot parameters must start with a BP_TAG_FIRST tag. */
164 if (tag->id != BP_TAG_FIRST) {
165 printk(KERN_WARNING "Invalid boot parameters!\n");
166 return 0;
169 tag = (bp_tag_t*)((unsigned long)tag + sizeof(bp_tag_t) + tag->size);
171 /* Parse all tags. */
173 while (tag != NULL && tag->id != BP_TAG_LAST) {
174 for (t = &__tagtable_begin; t < &__tagtable_end; t++) {
175 if (tag->id == t->tag) {
176 t->parse(tag);
177 break;
180 if (t == &__tagtable_end)
181 printk(KERN_WARNING "Ignoring tag "
182 "0x%08x\n", tag->id);
183 tag = (bp_tag_t*)((unsigned long)(tag + 1) + tag->size);
186 return 0;
190 * Initialize architecture. (Early stage)
193 void __init init_arch(bp_tag_t *bp_start)
196 #ifdef CONFIG_BLK_DEV_INITRD
197 initrd_start = &__initrd_start;
198 initrd_end = &__initrd_end;
199 #endif
201 sysmem.nr_banks = 0;
203 #ifdef CONFIG_CMDLINE_BOOL
204 strcpy(command_line, default_command_line);
205 #endif
207 /* Parse boot parameters */
209 if (bp_start)
210 parse_bootparam(bp_start);
212 if (sysmem.nr_banks == 0) {
213 sysmem.nr_banks = 1;
214 sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;
215 sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START
216 + PLATFORM_DEFAULT_MEM_SIZE;
219 /* Early hook for platforms */
221 platform_init(bp_start);
223 /* Initialize MMU. */
225 init_mmu();
229 * Initialize system. Setup memory and reserve regions.
232 extern char _end;
233 extern char _stext;
234 extern char _WindowVectors_text_start;
235 extern char _WindowVectors_text_end;
236 extern char _DebugInterruptVector_literal_start;
237 extern char _DebugInterruptVector_text_end;
238 extern char _KernelExceptionVector_literal_start;
239 extern char _KernelExceptionVector_text_end;
240 extern char _UserExceptionVector_literal_start;
241 extern char _UserExceptionVector_text_end;
242 extern char _DoubleExceptionVector_literal_start;
243 extern char _DoubleExceptionVector_text_end;
245 void __init setup_arch(char **cmdline_p)
247 extern int mem_reserve(unsigned long, unsigned long, int);
248 extern void bootmem_init(void);
250 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
251 boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
252 *cmdline_p = command_line;
254 /* Reserve some memory regions */
256 #ifdef CONFIG_BLK_DEV_INITRD
257 if (initrd_start < initrd_end) {
258 initrd_is_mapped = mem_reserve(__pa(initrd_start),
259 __pa(initrd_end), 0);
260 initrd_below_start_ok = 1;
261 } else {
262 initrd_start = 0;
264 #endif
266 mem_reserve(__pa(&_stext),__pa(&_end), 1);
268 mem_reserve(__pa(&_WindowVectors_text_start),
269 __pa(&_WindowVectors_text_end), 0);
271 mem_reserve(__pa(&_DebugInterruptVector_literal_start),
272 __pa(&_DebugInterruptVector_text_end), 0);
274 mem_reserve(__pa(&_KernelExceptionVector_literal_start),
275 __pa(&_KernelExceptionVector_text_end), 0);
277 mem_reserve(__pa(&_UserExceptionVector_literal_start),
278 __pa(&_UserExceptionVector_text_end), 0);
280 mem_reserve(__pa(&_DoubleExceptionVector_literal_start),
281 __pa(&_DoubleExceptionVector_text_end), 0);
283 bootmem_init();
285 platform_setup(cmdline_p);
288 paging_init();
290 #ifdef CONFIG_VT
291 # if defined(CONFIG_VGA_CONSOLE)
292 conswitchp = &vga_con;
293 # elif defined(CONFIG_DUMMY_CONSOLE)
294 conswitchp = &dummy_con;
295 # endif
296 #endif
298 #ifdef CONFIG_PCI
299 platform_pcibios_init();
300 #endif
303 void machine_restart(char * cmd)
305 platform_restart();
308 void machine_halt(void)
310 platform_halt();
311 while (1);
314 void machine_power_off(void)
316 platform_power_off();
317 while (1);
319 #ifdef CONFIG_PROC_FS
322 * Display some core information through /proc/cpuinfo.
325 static int
326 c_show(struct seq_file *f, void *slot)
328 /* high-level stuff */
329 seq_printf(f,"processor\t: 0\n"
330 "vendor_id\t: Tensilica\n"
331 "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME "\n"
332 "core ID\t\t: " XCHAL_CORE_ID "\n"
333 "build ID\t: 0x%x\n"
334 "byte order\t: %s\n"
335 "cpu MHz\t\t: %lu.%02lu\n"
336 "bogomips\t: %lu.%02lu\n",
337 XCHAL_BUILD_UNIQUE_ID,
338 XCHAL_HAVE_BE ? "big" : "little",
339 CCOUNT_PER_JIFFY/(1000000/HZ),
340 (CCOUNT_PER_JIFFY/(10000/HZ)) % 100,
341 loops_per_jiffy/(500000/HZ),
342 (loops_per_jiffy/(5000/HZ)) % 100);
344 seq_printf(f,"flags\t\t: "
345 #if XCHAL_HAVE_NMI
346 "nmi "
347 #endif
348 #if XCHAL_HAVE_DEBUG
349 "debug "
350 # if XCHAL_HAVE_OCD
351 "ocd "
352 # endif
353 #endif
354 #if XCHAL_HAVE_DENSITY
355 "density "
356 #endif
357 #if XCHAL_HAVE_BOOLEANS
358 "boolean "
359 #endif
360 #if XCHAL_HAVE_LOOPS
361 "loop "
362 #endif
363 #if XCHAL_HAVE_NSA
364 "nsa "
365 #endif
366 #if XCHAL_HAVE_MINMAX
367 "minmax "
368 #endif
369 #if XCHAL_HAVE_SEXT
370 "sext "
371 #endif
372 #if XCHAL_HAVE_CLAMPS
373 "clamps "
374 #endif
375 #if XCHAL_HAVE_MAC16
376 "mac16 "
377 #endif
378 #if XCHAL_HAVE_MUL16
379 "mul16 "
380 #endif
381 #if XCHAL_HAVE_MUL32
382 "mul32 "
383 #endif
384 #if XCHAL_HAVE_MUL32_HIGH
385 "mul32h "
386 #endif
387 #if XCHAL_HAVE_FP
388 "fpu "
389 #endif
390 "\n");
392 /* Registers. */
393 seq_printf(f,"physical aregs\t: %d\n"
394 "misc regs\t: %d\n"
395 "ibreak\t\t: %d\n"
396 "dbreak\t\t: %d\n",
397 XCHAL_NUM_AREGS,
398 XCHAL_NUM_MISC_REGS,
399 XCHAL_NUM_IBREAK,
400 XCHAL_NUM_DBREAK);
403 /* Interrupt. */
404 seq_printf(f,"num ints\t: %d\n"
405 "ext ints\t: %d\n"
406 "int levels\t: %d\n"
407 "timers\t\t: %d\n"
408 "debug level\t: %d\n",
409 XCHAL_NUM_INTERRUPTS,
410 XCHAL_NUM_EXTINTERRUPTS,
411 XCHAL_NUM_INTLEVELS,
412 XCHAL_NUM_TIMERS,
413 XCHAL_DEBUGLEVEL);
415 /* Cache */
416 seq_printf(f,"icache line size: %d\n"
417 "icache ways\t: %d\n"
418 "icache size\t: %d\n"
419 "icache flags\t: "
420 #if XCHAL_ICACHE_LINE_LOCKABLE
421 "lock"
422 #endif
423 "\n"
424 "dcache line size: %d\n"
425 "dcache ways\t: %d\n"
426 "dcache size\t: %d\n"
427 "dcache flags\t: "
428 #if XCHAL_DCACHE_IS_WRITEBACK
429 "writeback"
430 #endif
431 #if XCHAL_DCACHE_LINE_LOCKABLE
432 "lock"
433 #endif
434 "\n",
435 XCHAL_ICACHE_LINESIZE,
436 XCHAL_ICACHE_WAYS,
437 XCHAL_ICACHE_SIZE,
438 XCHAL_DCACHE_LINESIZE,
439 XCHAL_DCACHE_WAYS,
440 XCHAL_DCACHE_SIZE);
442 return 0;
446 * We show only CPU #0 info.
448 static void *
449 c_start(struct seq_file *f, loff_t *pos)
451 return (void *) ((*pos == 0) ? (void *)1 : NULL);
454 static void *
455 c_next(struct seq_file *f, void *v, loff_t *pos)
457 return NULL;
460 static void
461 c_stop(struct seq_file *f, void *v)
465 const struct seq_operations cpuinfo_op =
467 start: c_start,
468 next: c_next,
469 stop: c_stop,
470 show: c_show
473 #endif /* CONFIG_PROC_FS */