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/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>
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};
53 #ifdef CONFIG_BLK_DEV_FD
54 extern struct fd_ops no_fd_ops
;
55 struct fd_ops
*fd_ops
;
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
;
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
;
81 sysmem_info_t __initdata sysmem
;
83 #ifdef CONFIG_BLK_DEV_INITRD
88 extern void init_mmu(void);
90 static inline void init_mmu(void) { }
93 extern void zones_init(void);
96 * Boot parameter parsing.
98 * The Xtensa port uses a list of variable-sized tags to pass data to
99 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
100 * to be recognised. The list is terminated with a zero-sized
104 typedef struct tagtable
{
106 int (*parse
)(const bp_tag_t
*);
109 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
110 __attribute__((unused, __section__(".taglist"))) = { tag, fn }
112 /* parse current tag */
114 static int __init
parse_tag_mem(const bp_tag_t
*tag
)
116 meminfo_t
*mi
= (meminfo_t
*)(tag
->data
);
118 if (mi
->type
!= MEMORY_TYPE_CONVENTIONAL
)
121 if (sysmem
.nr_banks
>= SYSMEM_BANKS_MAX
) {
123 "Ignoring memory bank 0x%08lx size %ldKB\n",
124 (unsigned long)mi
->start
,
125 (unsigned long)mi
->end
- (unsigned long)mi
->start
);
128 sysmem
.bank
[sysmem
.nr_banks
].type
= mi
->type
;
129 sysmem
.bank
[sysmem
.nr_banks
].start
= PAGE_ALIGN(mi
->start
);
130 sysmem
.bank
[sysmem
.nr_banks
].end
= mi
->end
& PAGE_SIZE
;
136 __tagtable(BP_TAG_MEMORY
, parse_tag_mem
);
138 #ifdef CONFIG_BLK_DEV_INITRD
140 static int __init
parse_tag_initrd(const bp_tag_t
* tag
)
143 mi
= (meminfo_t
*)(tag
->data
);
144 initrd_start
= (void*)(mi
->start
);
145 initrd_end
= (void*)(mi
->end
);
150 __tagtable(BP_TAG_INITRD
, parse_tag_initrd
);
152 #endif /* CONFIG_BLK_DEV_INITRD */
154 static int __init
parse_tag_cmdline(const bp_tag_t
* tag
)
156 strncpy(command_line
, (char*)(tag
->data
), COMMAND_LINE_SIZE
);
157 command_line
[COMMAND_LINE_SIZE
- 1] = '\0';
161 __tagtable(BP_TAG_COMMAND_LINE
, parse_tag_cmdline
);
163 static int __init
parse_bootparam(const bp_tag_t
* tag
)
165 extern tagtable_t __tagtable_begin
, __tagtable_end
;
168 /* Boot parameters must start with a BP_TAG_FIRST tag. */
170 if (tag
->id
!= BP_TAG_FIRST
) {
171 printk(KERN_WARNING
"Invalid boot parameters!\n");
175 tag
= (bp_tag_t
*)((unsigned long)tag
+ sizeof(bp_tag_t
) + tag
->size
);
177 /* Parse all tags. */
179 while (tag
!= NULL
&& tag
->id
!= BP_TAG_LAST
) {
180 for (t
= &__tagtable_begin
; t
< &__tagtable_end
; t
++) {
181 if (tag
->id
== t
->tag
) {
186 if (t
== &__tagtable_end
)
187 printk(KERN_WARNING
"Ignoring tag "
188 "0x%08x\n", tag
->id
);
189 tag
= (bp_tag_t
*)((unsigned long)(tag
+ 1) + tag
->size
);
196 * Initialize architecture. (Early stage)
199 void __init
init_arch(bp_tag_t
*bp_start
)
202 #ifdef CONFIG_BLK_DEV_INITRD
203 initrd_start
= &__initrd_start
;
204 initrd_end
= &__initrd_end
;
209 #ifdef CONFIG_CMDLINE_BOOL
210 strcpy(command_line
, default_command_line
);
213 /* Parse boot parameters */
216 parse_bootparam(bp_start
);
218 if (sysmem
.nr_banks
== 0) {
220 sysmem
.bank
[0].start
= PLATFORM_DEFAULT_MEM_START
;
221 sysmem
.bank
[0].end
= PLATFORM_DEFAULT_MEM_START
222 + PLATFORM_DEFAULT_MEM_SIZE
;
225 /* Early hook for platforms */
227 platform_init(bp_start
);
229 /* Initialize MMU. */
235 * Initialize system. Setup memory and reserve regions.
240 extern char _WindowVectors_text_start
;
241 extern char _WindowVectors_text_end
;
242 extern char _DebugInterruptVector_literal_start
;
243 extern char _DebugInterruptVector_text_end
;
244 extern char _KernelExceptionVector_literal_start
;
245 extern char _KernelExceptionVector_text_end
;
246 extern char _UserExceptionVector_literal_start
;
247 extern char _UserExceptionVector_text_end
;
248 extern char _DoubleExceptionVector_literal_start
;
249 extern char _DoubleExceptionVector_text_end
;
251 void __init
setup_arch(char **cmdline_p
)
253 extern int mem_reserve(unsigned long, unsigned long, int);
254 extern void bootmem_init(void);
256 memcpy(boot_command_line
, command_line
, COMMAND_LINE_SIZE
);
257 boot_command_line
[COMMAND_LINE_SIZE
-1] = '\0';
258 *cmdline_p
= command_line
;
260 /* Reserve some memory regions */
262 #ifdef CONFIG_BLK_DEV_INITRD
263 if (initrd_start
< initrd_end
) {
264 initrd_is_mapped
= mem_reserve(__pa(initrd_start
),
265 __pa(initrd_end
), 0);
266 initrd_below_start_ok
= 1;
272 mem_reserve(__pa(&_stext
),__pa(&_end
), 1);
274 mem_reserve(__pa(&_WindowVectors_text_start
),
275 __pa(&_WindowVectors_text_end
), 0);
277 mem_reserve(__pa(&_DebugInterruptVector_literal_start
),
278 __pa(&_DebugInterruptVector_text_end
), 0);
280 mem_reserve(__pa(&_KernelExceptionVector_literal_start
),
281 __pa(&_KernelExceptionVector_text_end
), 0);
283 mem_reserve(__pa(&_UserExceptionVector_literal_start
),
284 __pa(&_UserExceptionVector_text_end
), 0);
286 mem_reserve(__pa(&_DoubleExceptionVector_literal_start
),
287 __pa(&_DoubleExceptionVector_text_end
), 0);
291 platform_setup(cmdline_p
);
298 # if defined(CONFIG_VGA_CONSOLE)
299 conswitchp
= &vga_con
;
300 # elif defined(CONFIG_DUMMY_CONSOLE)
301 conswitchp
= &dummy_con
;
306 platform_pcibios_init();
310 void machine_restart(char * cmd
)
315 void machine_halt(void)
321 void machine_power_off(void)
323 platform_power_off();
326 #ifdef CONFIG_PROC_FS
329 * Display some core information through /proc/cpuinfo.
333 c_show(struct seq_file
*f
, void *slot
)
335 /* high-level stuff */
336 seq_printf(f
,"processor\t: 0\n"
337 "vendor_id\t: Tensilica\n"
338 "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME
"\n"
339 "core ID\t\t: " XCHAL_CORE_ID
"\n"
342 "cpu MHz\t\t: %lu.%02lu\n"
343 "bogomips\t: %lu.%02lu\n",
344 XCHAL_BUILD_UNIQUE_ID
,
345 XCHAL_HAVE_BE
? "big" : "little",
346 CCOUNT_PER_JIFFY
/(1000000/HZ
),
347 (CCOUNT_PER_JIFFY
/(10000/HZ
)) % 100,
348 loops_per_jiffy
/(500000/HZ
),
349 (loops_per_jiffy
/(5000/HZ
)) % 100);
351 seq_printf(f
,"flags\t\t: "
361 #if XCHAL_HAVE_DENSITY
364 #if XCHAL_HAVE_BOOLEANS
373 #if XCHAL_HAVE_MINMAX
379 #if XCHAL_HAVE_CLAMPS
391 #if XCHAL_HAVE_MUL32_HIGH
400 seq_printf(f
,"physical aregs\t: %d\n"
411 seq_printf(f
,"num ints\t: %d\n"
415 "debug level\t: %d\n",
416 XCHAL_NUM_INTERRUPTS
,
417 XCHAL_NUM_EXTINTERRUPTS
,
423 seq_printf(f
,"icache line size: %d\n"
424 "icache ways\t: %d\n"
425 "icache size\t: %d\n"
427 #if XCHAL_ICACHE_LINE_LOCKABLE
431 "dcache line size: %d\n"
432 "dcache ways\t: %d\n"
433 "dcache size\t: %d\n"
435 #if XCHAL_DCACHE_IS_WRITEBACK
438 #if XCHAL_DCACHE_LINE_LOCKABLE
442 XCHAL_ICACHE_LINESIZE
,
445 XCHAL_DCACHE_LINESIZE
,
453 * We show only CPU #0 info.
456 c_start(struct seq_file
*f
, loff_t
*pos
)
458 return (void *) ((*pos
== 0) ? (void *)1 : NULL
);
462 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
468 c_stop(struct seq_file
*f
, void *v
)
472 const struct seq_operations cpuinfo_op
=
480 #endif /* CONFIG_PROC_FS */