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
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>
14 * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
17 #include <linux/errno.h>
18 #include <linux/init.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>
30 # include <linux/timex.h>
34 # include <linux/seq_file.h>
37 #include <asm/bootparam.h>
38 #include <asm/pgtable.h>
39 #include <asm/processor.h>
40 #include <asm/timex.h>
41 #include <asm/platform.h>
43 #include <asm/setup.h>
44 #include <asm/param.h>
46 #include <platform/hardware.h>
48 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
49 struct screen_info screen_info
= { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
52 #ifdef CONFIG_BLK_DEV_FD
53 extern struct fd_ops no_fd_ops
;
54 struct fd_ops
*fd_ops
;
57 extern struct rtc_ops no_rtc_ops
;
58 struct rtc_ops
*rtc_ops
;
60 #ifdef CONFIG_BLK_DEV_INITRD
61 extern void *initrd_start
;
62 extern void *initrd_end
;
63 int initrd_is_mapped
= 0;
64 extern int initrd_below_start_ok
;
67 unsigned char aux_device_present
;
68 extern unsigned long loops_per_jiffy
;
70 /* Command line specified as configuration option. */
72 static char __initdata command_line
[COMMAND_LINE_SIZE
];
74 #ifdef CONFIG_CMDLINE_BOOL
75 static char default_command_line
[COMMAND_LINE_SIZE
] __initdata
= CONFIG_CMDLINE
;
78 sysmem_info_t __initdata sysmem
;
81 extern void init_mmu(void);
83 static inline void init_mmu(void) { }
86 extern void zones_init(void);
89 * Boot parameter parsing.
91 * The Xtensa port uses a list of variable-sized tags to pass data to
92 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
93 * to be recognised. The list is terminated with a zero-sized
97 typedef struct tagtable
{
99 int (*parse
)(const bp_tag_t
*);
102 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
103 __attribute__((unused, __section__(".taglist"))) = { tag, fn }
105 /* parse current tag */
107 static int __init
parse_tag_mem(const bp_tag_t
*tag
)
109 meminfo_t
*mi
= (meminfo_t
*)(tag
->data
);
111 if (mi
->type
!= MEMORY_TYPE_CONVENTIONAL
)
114 if (sysmem
.nr_banks
>= SYSMEM_BANKS_MAX
) {
116 "Ignoring memory bank 0x%08lx size %ldKB\n",
117 (unsigned long)mi
->start
,
118 (unsigned long)mi
->end
- (unsigned long)mi
->start
);
121 sysmem
.bank
[sysmem
.nr_banks
].type
= mi
->type
;
122 sysmem
.bank
[sysmem
.nr_banks
].start
= PAGE_ALIGN(mi
->start
);
123 sysmem
.bank
[sysmem
.nr_banks
].end
= mi
->end
& PAGE_SIZE
;
129 __tagtable(BP_TAG_MEMORY
, parse_tag_mem
);
131 #ifdef CONFIG_BLK_DEV_INITRD
133 static int __init
parse_tag_initrd(const bp_tag_t
* tag
)
136 mi
= (meminfo_t
*)(tag
->data
);
137 initrd_start
= (void*)(mi
->start
);
138 initrd_end
= (void*)(mi
->end
);
143 __tagtable(BP_TAG_INITRD
, parse_tag_initrd
);
145 #endif /* CONFIG_BLK_DEV_INITRD */
147 static int __init
parse_tag_cmdline(const bp_tag_t
* tag
)
149 strncpy(command_line
, (char*)(tag
->data
), COMMAND_LINE_SIZE
);
150 command_line
[COMMAND_LINE_SIZE
- 1] = '\0';
154 __tagtable(BP_TAG_COMMAND_LINE
, parse_tag_cmdline
);
156 static int __init
parse_bootparam(const bp_tag_t
* tag
)
158 extern tagtable_t __tagtable_begin
, __tagtable_end
;
161 /* Boot parameters must start with a BP_TAG_FIRST tag. */
163 if (tag
->id
!= BP_TAG_FIRST
) {
164 printk(KERN_WARNING
"Invalid boot parameters!\n");
168 tag
= (bp_tag_t
*)((unsigned long)tag
+ sizeof(bp_tag_t
) + tag
->size
);
170 /* Parse all tags. */
172 while (tag
!= NULL
&& tag
->id
!= BP_TAG_LAST
) {
173 for (t
= &__tagtable_begin
; t
< &__tagtable_end
; t
++) {
174 if (tag
->id
== t
->tag
) {
179 if (t
== &__tagtable_end
)
180 printk(KERN_WARNING
"Ignoring tag "
181 "0x%08x\n", tag
->id
);
182 tag
= (bp_tag_t
*)((unsigned long)(tag
+ 1) + tag
->size
);
189 * Initialize architecture. (Early stage)
192 void __init
init_arch(bp_tag_t
*bp_start
)
196 #ifdef CONFIG_CMDLINE_BOOL
197 strcpy(command_line
, default_command_line
);
200 /* Parse boot parameters */
203 parse_bootparam(bp_start
);
205 if (sysmem
.nr_banks
== 0) {
207 sysmem
.bank
[0].start
= PLATFORM_DEFAULT_MEM_START
;
208 sysmem
.bank
[0].end
= PLATFORM_DEFAULT_MEM_START
209 + PLATFORM_DEFAULT_MEM_SIZE
;
212 /* Early hook for platforms */
214 platform_init(bp_start
);
216 /* Initialize MMU. */
222 * Initialize system. Setup memory and reserve regions.
227 extern char _WindowVectors_text_start
;
228 extern char _WindowVectors_text_end
;
229 extern char _DebugInterruptVector_literal_start
;
230 extern char _DebugInterruptVector_text_end
;
231 extern char _KernelExceptionVector_literal_start
;
232 extern char _KernelExceptionVector_text_end
;
233 extern char _UserExceptionVector_literal_start
;
234 extern char _UserExceptionVector_text_end
;
235 extern char _DoubleExceptionVector_literal_start
;
236 extern char _DoubleExceptionVector_text_end
;
238 void __init
setup_arch(char **cmdline_p
)
240 extern int mem_reserve(unsigned long, unsigned long, int);
241 extern void bootmem_init(void);
243 memcpy(boot_command_line
, command_line
, COMMAND_LINE_SIZE
);
244 boot_command_line
[COMMAND_LINE_SIZE
-1] = '\0';
245 *cmdline_p
= command_line
;
247 /* Reserve some memory regions */
249 #ifdef CONFIG_BLK_DEV_INITRD
250 if (initrd_start
< initrd_end
) {
251 initrd_is_mapped
= mem_reserve(__pa(initrd_start
),
252 __pa(initrd_end
), 0);
253 initrd_below_start_ok
= 1;
259 mem_reserve(__pa(&_stext
),__pa(&_end
), 1);
261 mem_reserve(__pa(&_WindowVectors_text_start
),
262 __pa(&_WindowVectors_text_end
), 0);
264 mem_reserve(__pa(&_DebugInterruptVector_literal_start
),
265 __pa(&_DebugInterruptVector_text_end
), 0);
267 mem_reserve(__pa(&_KernelExceptionVector_literal_start
),
268 __pa(&_KernelExceptionVector_text_end
), 0);
270 mem_reserve(__pa(&_UserExceptionVector_literal_start
),
271 __pa(&_UserExceptionVector_text_end
), 0);
273 mem_reserve(__pa(&_DoubleExceptionVector_literal_start
),
274 __pa(&_DoubleExceptionVector_text_end
), 0);
278 platform_setup(cmdline_p
);
285 # if defined(CONFIG_VGA_CONSOLE)
286 conswitchp
= &vga_con
;
287 # elif defined(CONFIG_DUMMY_CONSOLE)
288 conswitchp
= &dummy_con
;
293 platform_pcibios_init();
297 void machine_restart(char * cmd
)
302 void machine_halt(void)
308 void machine_power_off(void)
310 platform_power_off();
313 #ifdef CONFIG_PROC_FS
316 * Display some core information through /proc/cpuinfo.
320 c_show(struct seq_file
*f
, void *slot
)
322 /* high-level stuff */
323 seq_printf(f
,"processor\t: 0\n"
324 "vendor_id\t: Tensilica\n"
325 "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME
"\n"
326 "core ID\t\t: " XCHAL_CORE_ID
"\n"
329 "cpu MHz\t\t: %lu.%02lu\n"
330 "bogomips\t: %lu.%02lu\n",
331 XCHAL_BUILD_UNIQUE_ID
,
332 XCHAL_HAVE_BE
? "big" : "little",
333 CCOUNT_PER_JIFFY
/(1000000/HZ
),
334 (CCOUNT_PER_JIFFY
/(10000/HZ
)) % 100,
335 loops_per_jiffy
/(500000/HZ
),
336 (loops_per_jiffy
/(5000/HZ
)) % 100);
338 seq_printf(f
,"flags\t\t: "
348 #if XCHAL_HAVE_DENSITY
351 #if XCHAL_HAVE_BOOLEANS
360 #if XCHAL_HAVE_MINMAX
366 #if XCHAL_HAVE_CLAMPS
378 #if XCHAL_HAVE_MUL32_HIGH
387 seq_printf(f
,"physical aregs\t: %d\n"
398 seq_printf(f
,"num ints\t: %d\n"
402 "debug level\t: %d\n",
403 XCHAL_NUM_INTERRUPTS
,
404 XCHAL_NUM_EXTINTERRUPTS
,
410 seq_printf(f
,"icache line size: %d\n"
411 "icache ways\t: %d\n"
412 "icache size\t: %d\n"
414 #if XCHAL_ICACHE_LINE_LOCKABLE
418 "dcache line size: %d\n"
419 "dcache ways\t: %d\n"
420 "dcache size\t: %d\n"
422 #if XCHAL_DCACHE_IS_WRITEBACK
425 #if XCHAL_DCACHE_LINE_LOCKABLE
429 XCHAL_ICACHE_LINESIZE
,
432 XCHAL_DCACHE_LINESIZE
,
440 * We show only CPU #0 info.
443 c_start(struct seq_file
*f
, loff_t
*pos
)
445 return (void *) ((*pos
== 0) ? (void *)1 : NULL
);
449 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
455 c_stop(struct seq_file
*f
, void *v
)
459 const struct seq_operations cpuinfo_op
=
467 #endif /* CONFIG_PROC_FS */