xref: /linux/arch/xtensa/kernel/setup.c (revision 5e4417f921238b5acf101bfcd59a7b3463fb2dbd)
1 /*
2  * arch/xtensa/kernel/setup.c
3  *
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.
7  *
8  * Copyright (C) 1995  Linus Torvalds
9  * Copyright (C) 2001 - 2005  Tensilica Inc.
10  * Copyright (C) 2014 - 2016  Cadence Design Systems Inc.
11  *
12  * Chris Zankel	<chris@zankel.net>
13  * Joe Taylor	<joe@tensilica.com, joetylr@yahoo.com>
14  * Kevin Chea
15  * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
16  */
17 
18 #include <linux/errno.h>
19 #include <linux/init.h>
20 #include <linux/mm.h>
21 #include <linux/proc_fs.h>
22 #include <linux/screen_info.h>
23 #include <linux/kernel.h>
24 #include <linux/percpu.h>
25 #include <linux/cpu.h>
26 #include <linux/of.h>
27 #include <linux/of_fdt.h>
28 
29 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
30 # include <linux/console.h>
31 #endif
32 
33 #ifdef CONFIG_PROC_FS
34 # include <linux/seq_file.h>
35 #endif
36 
37 #include <asm/bootparam.h>
38 #include <asm/kasan.h>
39 #include <asm/mmu_context.h>
40 #include <asm/pgtable.h>
41 #include <asm/processor.h>
42 #include <asm/timex.h>
43 #include <asm/platform.h>
44 #include <asm/page.h>
45 #include <asm/setup.h>
46 #include <asm/param.h>
47 #include <asm/smp.h>
48 #include <asm/sysmem.h>
49 
50 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
51 struct screen_info screen_info = {
52 	.orig_x = 0,
53 	.orig_y = 24,
54 	.orig_video_cols = 80,
55 	.orig_video_lines = 24,
56 	.orig_video_isVGA = 1,
57 	.orig_video_points = 16,
58 };
59 #endif
60 
61 #ifdef CONFIG_BLK_DEV_INITRD
62 extern unsigned long initrd_start;
63 extern unsigned long initrd_end;
64 extern int initrd_below_start_ok;
65 #endif
66 
67 #ifdef CONFIG_OF
68 void *dtb_start = __dtb_start;
69 #endif
70 
71 extern unsigned long loops_per_jiffy;
72 
73 /* Command line specified as configuration option. */
74 
75 static char __initdata command_line[COMMAND_LINE_SIZE];
76 
77 #ifdef CONFIG_CMDLINE_BOOL
78 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
79 #endif
80 
81 #ifdef CONFIG_PARSE_BOOTPARAM
82 /*
83  * Boot parameter parsing.
84  *
85  * The Xtensa port uses a list of variable-sized tags to pass data to
86  * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
87  * to be recognised. The list is terminated with a zero-sized
88  * BP_TAG_LAST tag.
89  */
90 
91 typedef struct tagtable {
92 	u32 tag;
93 	int (*parse)(const bp_tag_t*);
94 } tagtable_t;
95 
96 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn 		\
97 	__attribute__((used, section(".taglist"))) = { tag, fn }
98 
99 /* parse current tag */
100 
101 static int __init parse_tag_mem(const bp_tag_t *tag)
102 {
103 	struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);
104 
105 	if (mi->type != MEMORY_TYPE_CONVENTIONAL)
106 		return -1;
107 
108 	return memblock_add(mi->start, mi->end - mi->start);
109 }
110 
111 __tagtable(BP_TAG_MEMORY, parse_tag_mem);
112 
113 #ifdef CONFIG_BLK_DEV_INITRD
114 
115 static int __init parse_tag_initrd(const bp_tag_t* tag)
116 {
117 	struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);
118 
119 	initrd_start = (unsigned long)__va(mi->start);
120 	initrd_end = (unsigned long)__va(mi->end);
121 
122 	return 0;
123 }
124 
125 __tagtable(BP_TAG_INITRD, parse_tag_initrd);
126 
127 #endif /* CONFIG_BLK_DEV_INITRD */
128 
129 #ifdef CONFIG_OF
130 
131 static int __init parse_tag_fdt(const bp_tag_t *tag)
132 {
133 	dtb_start = __va(tag->data[0]);
134 	return 0;
135 }
136 
137 __tagtable(BP_TAG_FDT, parse_tag_fdt);
138 
139 #endif /* CONFIG_OF */
140 
141 static int __init parse_tag_cmdline(const bp_tag_t* tag)
142 {
143 	strlcpy(command_line, (char *)(tag->data), COMMAND_LINE_SIZE);
144 	return 0;
145 }
146 
147 __tagtable(BP_TAG_COMMAND_LINE, parse_tag_cmdline);
148 
149 static int __init parse_bootparam(const bp_tag_t* tag)
150 {
151 	extern tagtable_t __tagtable_begin, __tagtable_end;
152 	tagtable_t *t;
153 
154 	/* Boot parameters must start with a BP_TAG_FIRST tag. */
155 
156 	if (tag->id != BP_TAG_FIRST) {
157 		pr_warn("Invalid boot parameters!\n");
158 		return 0;
159 	}
160 
161 	tag = (bp_tag_t*)((unsigned long)tag + sizeof(bp_tag_t) + tag->size);
162 
163 	/* Parse all tags. */
164 
165 	while (tag != NULL && tag->id != BP_TAG_LAST) {
166 		for (t = &__tagtable_begin; t < &__tagtable_end; t++) {
167 			if (tag->id == t->tag) {
168 				t->parse(tag);
169 				break;
170 			}
171 		}
172 		if (t == &__tagtable_end)
173 			pr_warn("Ignoring tag 0x%08x\n", tag->id);
174 		tag = (bp_tag_t*)((unsigned long)(tag + 1) + tag->size);
175 	}
176 
177 	return 0;
178 }
179 #else
180 static int __init parse_bootparam(const bp_tag_t *tag)
181 {
182 	pr_info("Ignoring boot parameters at %p\n", tag);
183 	return 0;
184 }
185 #endif
186 
187 #ifdef CONFIG_OF
188 
189 #if !XCHAL_HAVE_PTP_MMU || XCHAL_HAVE_SPANNING_WAY
190 unsigned long xtensa_kio_paddr = XCHAL_KIO_DEFAULT_PADDR;
191 EXPORT_SYMBOL(xtensa_kio_paddr);
192 
193 static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
194 		int depth, void *data)
195 {
196 	const __be32 *ranges;
197 	int len;
198 
199 	if (depth > 1)
200 		return 0;
201 
202 	if (!of_flat_dt_is_compatible(node, "simple-bus"))
203 		return 0;
204 
205 	ranges = of_get_flat_dt_prop(node, "ranges", &len);
206 	if (!ranges)
207 		return 1;
208 	if (len == 0)
209 		return 1;
210 
211 	xtensa_kio_paddr = of_read_ulong(ranges+1, 1);
212 	/* round down to nearest 256MB boundary */
213 	xtensa_kio_paddr &= 0xf0000000;
214 
215 	init_kio();
216 
217 	return 1;
218 }
219 #else
220 static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
221 		int depth, void *data)
222 {
223 	return 1;
224 }
225 #endif
226 
227 void __init early_init_devtree(void *params)
228 {
229 	early_init_dt_scan(params);
230 	of_scan_flat_dt(xtensa_dt_io_area, NULL);
231 
232 	if (!command_line[0])
233 		strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
234 }
235 
236 #endif /* CONFIG_OF */
237 
238 /*
239  * Initialize architecture. (Early stage)
240  */
241 
242 void __init init_arch(bp_tag_t *bp_start)
243 {
244 	/* Initialize MMU. */
245 
246 	init_mmu();
247 
248 	/* Initialize initial KASAN shadow map */
249 
250 	kasan_early_init();
251 
252 	/* Parse boot parameters */
253 
254 	if (bp_start)
255 		parse_bootparam(bp_start);
256 
257 #ifdef CONFIG_OF
258 	early_init_devtree(dtb_start);
259 #endif
260 
261 #ifdef CONFIG_CMDLINE_BOOL
262 	if (!command_line[0])
263 		strlcpy(command_line, default_command_line, COMMAND_LINE_SIZE);
264 #endif
265 
266 	/* Early hook for platforms */
267 
268 	platform_init(bp_start);
269 }
270 
271 /*
272  * Initialize system. Setup memory and reserve regions.
273  */
274 
275 extern char _end[];
276 extern char _stext[];
277 extern char _WindowVectors_text_start;
278 extern char _WindowVectors_text_end;
279 extern char _DebugInterruptVector_text_start;
280 extern char _DebugInterruptVector_text_end;
281 extern char _KernelExceptionVector_text_start;
282 extern char _KernelExceptionVector_text_end;
283 extern char _UserExceptionVector_text_start;
284 extern char _UserExceptionVector_text_end;
285 extern char _DoubleExceptionVector_text_start;
286 extern char _DoubleExceptionVector_text_end;
287 extern char _exception_text_start;
288 extern char _exception_text_end;
289 #if XCHAL_EXCM_LEVEL >= 2
290 extern char _Level2InterruptVector_text_start;
291 extern char _Level2InterruptVector_text_end;
292 #endif
293 #if XCHAL_EXCM_LEVEL >= 3
294 extern char _Level3InterruptVector_text_start;
295 extern char _Level3InterruptVector_text_end;
296 #endif
297 #if XCHAL_EXCM_LEVEL >= 4
298 extern char _Level4InterruptVector_text_start;
299 extern char _Level4InterruptVector_text_end;
300 #endif
301 #if XCHAL_EXCM_LEVEL >= 5
302 extern char _Level5InterruptVector_text_start;
303 extern char _Level5InterruptVector_text_end;
304 #endif
305 #if XCHAL_EXCM_LEVEL >= 6
306 extern char _Level6InterruptVector_text_start;
307 extern char _Level6InterruptVector_text_end;
308 #endif
309 #ifdef CONFIG_SMP
310 extern char _SecondaryResetVector_text_start;
311 extern char _SecondaryResetVector_text_end;
312 #endif
313 #ifdef CONFIG_XIP_KERNEL
314 extern char _xip_start[];
315 extern char _xip_end[];
316 #endif
317 
318 static inline int __init_memblock mem_reserve(unsigned long start,
319 					      unsigned long end)
320 {
321 	return memblock_reserve(start, end - start);
322 }
323 
324 void __init setup_arch(char **cmdline_p)
325 {
326 	pr_info("config ID: %08x:%08x\n",
327 		xtensa_get_sr(SREG_EPC), xtensa_get_sr(SREG_EXCSAVE));
328 	if (xtensa_get_sr(SREG_EPC) != XCHAL_HW_CONFIGID0 ||
329 	    xtensa_get_sr(SREG_EXCSAVE) != XCHAL_HW_CONFIGID1)
330 		pr_info("built for config ID: %08x:%08x\n",
331 			XCHAL_HW_CONFIGID0, XCHAL_HW_CONFIGID1);
332 
333 	*cmdline_p = command_line;
334 	platform_setup(cmdline_p);
335 	strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
336 
337 	/* Reserve some memory regions */
338 
339 #ifdef CONFIG_BLK_DEV_INITRD
340 	if (initrd_start < initrd_end &&
341 	    !mem_reserve(__pa(initrd_start), __pa(initrd_end)))
342 		initrd_below_start_ok = 1;
343 	else
344 		initrd_start = 0;
345 #endif
346 
347 	mem_reserve(__pa(_stext), __pa(_end));
348 #ifdef CONFIG_XIP_KERNEL
349 	mem_reserve(__pa(_xip_start), __pa(_xip_end));
350 #endif
351 
352 #ifdef CONFIG_VECTORS_ADDR
353 	mem_reserve(__pa(&_WindowVectors_text_start),
354 		    __pa(&_WindowVectors_text_end));
355 
356 	mem_reserve(__pa(&_DebugInterruptVector_text_start),
357 		    __pa(&_DebugInterruptVector_text_end));
358 
359 	mem_reserve(__pa(&_KernelExceptionVector_text_start),
360 		    __pa(&_KernelExceptionVector_text_end));
361 
362 	mem_reserve(__pa(&_UserExceptionVector_text_start),
363 		    __pa(&_UserExceptionVector_text_end));
364 
365 	mem_reserve(__pa(&_DoubleExceptionVector_text_start),
366 		    __pa(&_DoubleExceptionVector_text_end));
367 
368 	mem_reserve(__pa(&_exception_text_start),
369 		    __pa(&_exception_text_end));
370 #if XCHAL_EXCM_LEVEL >= 2
371 	mem_reserve(__pa(&_Level2InterruptVector_text_start),
372 		    __pa(&_Level2InterruptVector_text_end));
373 #endif
374 #if XCHAL_EXCM_LEVEL >= 3
375 	mem_reserve(__pa(&_Level3InterruptVector_text_start),
376 		    __pa(&_Level3InterruptVector_text_end));
377 #endif
378 #if XCHAL_EXCM_LEVEL >= 4
379 	mem_reserve(__pa(&_Level4InterruptVector_text_start),
380 		    __pa(&_Level4InterruptVector_text_end));
381 #endif
382 #if XCHAL_EXCM_LEVEL >= 5
383 	mem_reserve(__pa(&_Level5InterruptVector_text_start),
384 		    __pa(&_Level5InterruptVector_text_end));
385 #endif
386 #if XCHAL_EXCM_LEVEL >= 6
387 	mem_reserve(__pa(&_Level6InterruptVector_text_start),
388 		    __pa(&_Level6InterruptVector_text_end));
389 #endif
390 
391 #endif /* CONFIG_VECTORS_ADDR */
392 
393 #ifdef CONFIG_SMP
394 	mem_reserve(__pa(&_SecondaryResetVector_text_start),
395 		    __pa(&_SecondaryResetVector_text_end));
396 #endif
397 	parse_early_param();
398 	bootmem_init();
399 	kasan_init();
400 	unflatten_and_copy_device_tree();
401 
402 #ifdef CONFIG_SMP
403 	smp_init_cpus();
404 #endif
405 
406 	paging_init();
407 	zones_init();
408 
409 #ifdef CONFIG_VT
410 # if defined(CONFIG_VGA_CONSOLE)
411 	conswitchp = &vga_con;
412 # elif defined(CONFIG_DUMMY_CONSOLE)
413 	conswitchp = &dummy_con;
414 # endif
415 #endif
416 }
417 
418 static DEFINE_PER_CPU(struct cpu, cpu_data);
419 
420 static int __init topology_init(void)
421 {
422 	int i;
423 
424 	for_each_possible_cpu(i) {
425 		struct cpu *cpu = &per_cpu(cpu_data, i);
426 		cpu->hotpluggable = !!i;
427 		register_cpu(cpu, i);
428 	}
429 
430 	return 0;
431 }
432 subsys_initcall(topology_init);
433 
434 void cpu_reset(void)
435 {
436 #if XCHAL_HAVE_PTP_MMU && IS_ENABLED(CONFIG_MMU)
437 	local_irq_disable();
438 	/*
439 	 * We have full MMU: all autoload ways, ways 7, 8 and 9 of DTLB must
440 	 * be flushed.
441 	 * Way 4 is not currently used by linux.
442 	 * Ways 5 and 6 shall not be touched on MMUv2 as they are hardwired.
443 	 * Way 5 shall be flushed and way 6 shall be set to identity mapping
444 	 * on MMUv3.
445 	 */
446 	local_flush_tlb_all();
447 	invalidate_page_directory();
448 #if XCHAL_HAVE_SPANNING_WAY
449 	/* MMU v3 */
450 	{
451 		unsigned long vaddr = (unsigned long)cpu_reset;
452 		unsigned long paddr = __pa(vaddr);
453 		unsigned long tmpaddr = vaddr + SZ_512M;
454 		unsigned long tmp0, tmp1, tmp2, tmp3;
455 
456 		/*
457 		 * Find a place for the temporary mapping. It must not be
458 		 * in the same 512MB region with vaddr or paddr, otherwise
459 		 * there may be multihit exception either on entry to the
460 		 * temporary mapping, or on entry to the identity mapping.
461 		 * (512MB is the biggest page size supported by TLB.)
462 		 */
463 		while (((tmpaddr ^ paddr) & -SZ_512M) == 0)
464 			tmpaddr += SZ_512M;
465 
466 		/* Invalidate mapping in the selected temporary area */
467 		if (itlb_probe(tmpaddr) & BIT(ITLB_HIT_BIT))
468 			invalidate_itlb_entry(itlb_probe(tmpaddr));
469 		if (itlb_probe(tmpaddr + PAGE_SIZE) & BIT(ITLB_HIT_BIT))
470 			invalidate_itlb_entry(itlb_probe(tmpaddr + PAGE_SIZE));
471 
472 		/*
473 		 * Map two consecutive pages starting at the physical address
474 		 * of this function to the temporary mapping area.
475 		 */
476 		write_itlb_entry(__pte((paddr & PAGE_MASK) |
477 				       _PAGE_HW_VALID |
478 				       _PAGE_HW_EXEC |
479 				       _PAGE_CA_BYPASS),
480 				 tmpaddr & PAGE_MASK);
481 		write_itlb_entry(__pte(((paddr & PAGE_MASK) + PAGE_SIZE) |
482 				       _PAGE_HW_VALID |
483 				       _PAGE_HW_EXEC |
484 				       _PAGE_CA_BYPASS),
485 				 (tmpaddr & PAGE_MASK) + PAGE_SIZE);
486 
487 		/* Reinitialize TLB */
488 		__asm__ __volatile__ ("movi	%0, 1f\n\t"
489 				      "movi	%3, 2f\n\t"
490 				      "add	%0, %0, %4\n\t"
491 				      "add	%3, %3, %5\n\t"
492 				      "jx	%0\n"
493 				      /*
494 				       * No literal, data or stack access
495 				       * below this point
496 				       */
497 				      "1:\n\t"
498 				      /* Initialize *tlbcfg */
499 				      "movi	%0, 0\n\t"
500 				      "wsr	%0, itlbcfg\n\t"
501 				      "wsr	%0, dtlbcfg\n\t"
502 				      /* Invalidate TLB way 5 */
503 				      "movi	%0, 4\n\t"
504 				      "movi	%1, 5\n"
505 				      "1:\n\t"
506 				      "iitlb	%1\n\t"
507 				      "idtlb	%1\n\t"
508 				      "add	%1, %1, %6\n\t"
509 				      "addi	%0, %0, -1\n\t"
510 				      "bnez	%0, 1b\n\t"
511 				      /* Initialize TLB way 6 */
512 				      "movi	%0, 7\n\t"
513 				      "addi	%1, %9, 3\n\t"
514 				      "addi	%2, %9, 6\n"
515 				      "1:\n\t"
516 				      "witlb	%1, %2\n\t"
517 				      "wdtlb	%1, %2\n\t"
518 				      "add	%1, %1, %7\n\t"
519 				      "add	%2, %2, %7\n\t"
520 				      "addi	%0, %0, -1\n\t"
521 				      "bnez	%0, 1b\n\t"
522 				      "isync\n\t"
523 				      /* Jump to identity mapping */
524 				      "jx	%3\n"
525 				      "2:\n\t"
526 				      /* Complete way 6 initialization */
527 				      "witlb	%1, %2\n\t"
528 				      "wdtlb	%1, %2\n\t"
529 				      /* Invalidate temporary mapping */
530 				      "sub	%0, %9, %7\n\t"
531 				      "iitlb	%0\n\t"
532 				      "add	%0, %0, %8\n\t"
533 				      "iitlb	%0"
534 				      : "=&a"(tmp0), "=&a"(tmp1), "=&a"(tmp2),
535 					"=&a"(tmp3)
536 				      : "a"(tmpaddr - vaddr),
537 					"a"(paddr - vaddr),
538 					"a"(SZ_128M), "a"(SZ_512M),
539 					"a"(PAGE_SIZE),
540 					"a"((tmpaddr + SZ_512M) & PAGE_MASK)
541 				      : "memory");
542 	}
543 #endif
544 #endif
545 	__asm__ __volatile__ ("movi	a2, 0\n\t"
546 			      "wsr	a2, icountlevel\n\t"
547 			      "movi	a2, 0\n\t"
548 			      "wsr	a2, icount\n\t"
549 #if XCHAL_NUM_IBREAK > 0
550 			      "wsr	a2, ibreakenable\n\t"
551 #endif
552 #if XCHAL_HAVE_LOOPS
553 			      "wsr	a2, lcount\n\t"
554 #endif
555 			      "movi	a2, 0x1f\n\t"
556 			      "wsr	a2, ps\n\t"
557 			      "isync\n\t"
558 			      "jx	%0\n\t"
559 			      :
560 			      : "a" (XCHAL_RESET_VECTOR_VADDR)
561 			      : "a2");
562 	for (;;)
563 		;
564 }
565 
566 void machine_restart(char * cmd)
567 {
568 	platform_restart();
569 }
570 
571 void machine_halt(void)
572 {
573 	platform_halt();
574 	while (1);
575 }
576 
577 void machine_power_off(void)
578 {
579 	platform_power_off();
580 	while (1);
581 }
582 #ifdef CONFIG_PROC_FS
583 
584 /*
585  * Display some core information through /proc/cpuinfo.
586  */
587 
588 static int
589 c_show(struct seq_file *f, void *slot)
590 {
591 	/* high-level stuff */
592 	seq_printf(f, "CPU count\t: %u\n"
593 		      "CPU list\t: %*pbl\n"
594 		      "vendor_id\t: Tensilica\n"
595 		      "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME "\n"
596 		      "core ID\t\t: " XCHAL_CORE_ID "\n"
597 		      "build ID\t: 0x%x\n"
598 		      "config ID\t: %08x:%08x\n"
599 		      "byte order\t: %s\n"
600 		      "cpu MHz\t\t: %lu.%02lu\n"
601 		      "bogomips\t: %lu.%02lu\n",
602 		      num_online_cpus(),
603 		      cpumask_pr_args(cpu_online_mask),
604 		      XCHAL_BUILD_UNIQUE_ID,
605 		      xtensa_get_sr(SREG_EPC), xtensa_get_sr(SREG_EXCSAVE),
606 		      XCHAL_HAVE_BE ?  "big" : "little",
607 		      ccount_freq/1000000,
608 		      (ccount_freq/10000) % 100,
609 		      loops_per_jiffy/(500000/HZ),
610 		      (loops_per_jiffy/(5000/HZ)) % 100);
611 	seq_puts(f, "flags\t\t: "
612 #if XCHAL_HAVE_NMI
613 		     "nmi "
614 #endif
615 #if XCHAL_HAVE_DEBUG
616 		     "debug "
617 # if XCHAL_HAVE_OCD
618 		     "ocd "
619 # endif
620 #endif
621 #if XCHAL_HAVE_DENSITY
622 	    	     "density "
623 #endif
624 #if XCHAL_HAVE_BOOLEANS
625 		     "boolean "
626 #endif
627 #if XCHAL_HAVE_LOOPS
628 		     "loop "
629 #endif
630 #if XCHAL_HAVE_NSA
631 		     "nsa "
632 #endif
633 #if XCHAL_HAVE_MINMAX
634 		     "minmax "
635 #endif
636 #if XCHAL_HAVE_SEXT
637 		     "sext "
638 #endif
639 #if XCHAL_HAVE_CLAMPS
640 		     "clamps "
641 #endif
642 #if XCHAL_HAVE_MAC16
643 		     "mac16 "
644 #endif
645 #if XCHAL_HAVE_MUL16
646 		     "mul16 "
647 #endif
648 #if XCHAL_HAVE_MUL32
649 		     "mul32 "
650 #endif
651 #if XCHAL_HAVE_MUL32_HIGH
652 		     "mul32h "
653 #endif
654 #if XCHAL_HAVE_FP
655 		     "fpu "
656 #endif
657 #if XCHAL_HAVE_S32C1I
658 		     "s32c1i "
659 #endif
660 #if XCHAL_HAVE_EXCLUSIVE
661 		     "exclusive "
662 #endif
663 		     "\n");
664 
665 	/* Registers. */
666 	seq_printf(f,"physical aregs\t: %d\n"
667 		     "misc regs\t: %d\n"
668 		     "ibreak\t\t: %d\n"
669 		     "dbreak\t\t: %d\n",
670 		     XCHAL_NUM_AREGS,
671 		     XCHAL_NUM_MISC_REGS,
672 		     XCHAL_NUM_IBREAK,
673 		     XCHAL_NUM_DBREAK);
674 
675 
676 	/* Interrupt. */
677 	seq_printf(f,"num ints\t: %d\n"
678 		     "ext ints\t: %d\n"
679 		     "int levels\t: %d\n"
680 		     "timers\t\t: %d\n"
681 		     "debug level\t: %d\n",
682 		     XCHAL_NUM_INTERRUPTS,
683 		     XCHAL_NUM_EXTINTERRUPTS,
684 		     XCHAL_NUM_INTLEVELS,
685 		     XCHAL_NUM_TIMERS,
686 		     XCHAL_DEBUGLEVEL);
687 
688 	/* Cache */
689 	seq_printf(f,"icache line size: %d\n"
690 		     "icache ways\t: %d\n"
691 		     "icache size\t: %d\n"
692 		     "icache flags\t: "
693 #if XCHAL_ICACHE_LINE_LOCKABLE
694 		     "lock "
695 #endif
696 		     "\n"
697 		     "dcache line size: %d\n"
698 		     "dcache ways\t: %d\n"
699 		     "dcache size\t: %d\n"
700 		     "dcache flags\t: "
701 #if XCHAL_DCACHE_IS_WRITEBACK
702 		     "writeback "
703 #endif
704 #if XCHAL_DCACHE_LINE_LOCKABLE
705 		     "lock "
706 #endif
707 		     "\n",
708 		     XCHAL_ICACHE_LINESIZE,
709 		     XCHAL_ICACHE_WAYS,
710 		     XCHAL_ICACHE_SIZE,
711 		     XCHAL_DCACHE_LINESIZE,
712 		     XCHAL_DCACHE_WAYS,
713 		     XCHAL_DCACHE_SIZE);
714 
715 	return 0;
716 }
717 
718 /*
719  * We show only CPU #0 info.
720  */
721 static void *
722 c_start(struct seq_file *f, loff_t *pos)
723 {
724 	return (*pos == 0) ? (void *)1 : NULL;
725 }
726 
727 static void *
728 c_next(struct seq_file *f, void *v, loff_t *pos)
729 {
730 	return NULL;
731 }
732 
733 static void
734 c_stop(struct seq_file *f, void *v)
735 {
736 }
737 
738 const struct seq_operations cpuinfo_op =
739 {
740 	.start	= c_start,
741 	.next	= c_next,
742 	.stop	= c_stop,
743 	.show	= c_show,
744 };
745 
746 #endif /* CONFIG_PROC_FS */
747