setup.c 15.9 KB
Newer Older
1
/*
2
 * arch/xtensa/kernel/setup.c
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1995  Linus Torvalds
 * Copyright (C) 2001 - 2005  Tensilica Inc.
 *
 * Chris Zankel	<chris@zankel.net>
 * Joe Taylor	<joe@tensilica.com, joetylr@yahoo.com>
 * Kevin Chea
 * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
 */

#include <linux/errno.h>
#include <linux/init.h>
19
#include <linux/mm.h>
20
#include <linux/proc_fs.h>
21
#include <linux/screen_info.h>
22 23
#include <linux/bootmem.h>
#include <linux/kernel.h>
M
Max Filippov 已提交
24
#include <linux/percpu.h>
25
#include <linux/clk-provider.h>
M
Max Filippov 已提交
26
#include <linux/cpu.h>
M
Max Filippov 已提交
27 28 29
#include <linux/of_fdt.h>
#include <linux/of_platform.h>

30 31 32 33 34 35 36 37 38 39 40 41 42
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
# include <linux/console.h>
#endif

#ifdef CONFIG_RTC
# include <linux/timex.h>
#endif

#ifdef CONFIG_PROC_FS
# include <linux/seq_file.h>
#endif

#include <asm/bootparam.h>
43
#include <asm/mmu_context.h>
44 45 46 47 48 49
#include <asm/pgtable.h>
#include <asm/processor.h>
#include <asm/timex.h>
#include <asm/platform.h>
#include <asm/page.h>
#include <asm/setup.h>
C
Chris Zankel 已提交
50
#include <asm/param.h>
M
Max Filippov 已提交
51
#include <asm/traps.h>
M
Max Filippov 已提交
52
#include <asm/smp.h>
53
#include <asm/sysmem.h>
54

55 56
#include <platform/hardware.h>

57 58 59 60 61 62 63 64 65 66 67 68 69
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
struct screen_info screen_info = { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
#endif

#ifdef CONFIG_BLK_DEV_FD
extern struct fd_ops no_fd_ops;
struct fd_ops *fd_ops;
#endif

extern struct rtc_ops no_rtc_ops;
struct rtc_ops *rtc_ops;

#ifdef CONFIG_BLK_DEV_INITRD
70 71
extern unsigned long initrd_start;
extern unsigned long initrd_end;
72 73 74 75
int initrd_is_mapped = 0;
extern int initrd_below_start_ok;
#endif

M
Max Filippov 已提交
76 77 78 79
#ifdef CONFIG_OF
void *dtb_start = __dtb_start;
#endif

80 81 82 83 84
unsigned char aux_device_present;
extern unsigned long loops_per_jiffy;

/* Command line specified as configuration option. */

85
static char __initdata command_line[COMMAND_LINE_SIZE];
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

#ifdef CONFIG_CMDLINE_BOOL
static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
#endif

/*
 * Boot parameter parsing.
 *
 * The Xtensa port uses a list of variable-sized tags to pass data to
 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
 * to be recognised. The list is terminated with a zero-sized
 * BP_TAG_LAST tag.
 */

typedef struct tagtable {
	u32 tag;
	int (*parse)(const bp_tag_t*);
} tagtable_t;

#define __tagtable(tag, fn) static tagtable_t __tagtable_##fn 		\
M
Max Filippov 已提交
106
	__attribute__((used, section(".taglist"))) = { tag, fn }
107 108 109

/* parse current tag */

M
Max Filippov 已提交
110 111
static int __init parse_tag_mem(const bp_tag_t *tag)
{
112
	struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);
M
Max Filippov 已提交
113 114 115 116

	if (mi->type != MEMORY_TYPE_CONVENTIONAL)
		return -1;

117
	return add_sysmem_bank(mi->start, mi->end);
M
Max Filippov 已提交
118 119
}

120 121 122 123 124 125
__tagtable(BP_TAG_MEMORY, parse_tag_mem);

#ifdef CONFIG_BLK_DEV_INITRD

static int __init parse_tag_initrd(const bp_tag_t* tag)
{
126 127
	struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);

128 129
	initrd_start = (unsigned long)__va(mi->start);
	initrd_end = (unsigned long)__va(mi->end);
130 131 132 133 134 135

	return 0;
}

__tagtable(BP_TAG_INITRD, parse_tag_initrd);

M
Max Filippov 已提交
136 137 138 139
#ifdef CONFIG_OF

static int __init parse_tag_fdt(const bp_tag_t *tag)
{
140
	dtb_start = __va(tag->data[0]);
M
Max Filippov 已提交
141 142 143 144 145 146 147
	return 0;
}

__tagtable(BP_TAG_FDT, parse_tag_fdt);

#endif /* CONFIG_OF */

148 149 150 151
#endif /* CONFIG_BLK_DEV_INITRD */

static int __init parse_tag_cmdline(const bp_tag_t* tag)
{
M
Max Filippov 已提交
152
	strlcpy(command_line, (char *)(tag->data), COMMAND_LINE_SIZE);
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
	return 0;
}

__tagtable(BP_TAG_COMMAND_LINE, parse_tag_cmdline);

static int __init parse_bootparam(const bp_tag_t* tag)
{
	extern tagtable_t __tagtable_begin, __tagtable_end;
	tagtable_t *t;

	/* Boot parameters must start with a BP_TAG_FIRST tag. */

	if (tag->id != BP_TAG_FIRST) {
		printk(KERN_WARNING "Invalid boot parameters!\n");
		return 0;
	}

	tag = (bp_tag_t*)((unsigned long)tag + sizeof(bp_tag_t) + tag->size);

	/* Parse all tags. */

	while (tag != NULL && tag->id != BP_TAG_LAST) {
	 	for (t = &__tagtable_begin; t < &__tagtable_end; t++) {
			if (tag->id == t->tag) {
				t->parse(tag);
				break;
			}
		}
		if (t == &__tagtable_end)
			printk(KERN_WARNING "Ignoring tag "
			       "0x%08x\n", tag->id);
		tag = (bp_tag_t*)((unsigned long)(tag + 1) + tag->size);
	}

	return 0;
}

M
Max Filippov 已提交
190
#ifdef CONFIG_OF
R
Rob Herring 已提交
191
bool __initdata dt_memory_scan = false;
M
Max Filippov 已提交
192

193
#if !XCHAL_HAVE_PTP_MMU || XCHAL_HAVE_SPANNING_WAY
194 195 196 197 198 199 200
unsigned long xtensa_kio_paddr = XCHAL_KIO_DEFAULT_PADDR;
EXPORT_SYMBOL(xtensa_kio_paddr);

static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
		int depth, void *data)
{
	const __be32 *ranges;
201
	int len;
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228

	if (depth > 1)
		return 0;

	if (!of_flat_dt_is_compatible(node, "simple-bus"))
		return 0;

	ranges = of_get_flat_dt_prop(node, "ranges", &len);
	if (!ranges)
		return 1;
	if (len == 0)
		return 1;

	xtensa_kio_paddr = of_read_ulong(ranges+1, 1);
	/* round down to nearest 256MB boundary */
	xtensa_kio_paddr &= 0xf0000000;

	return 1;
}
#else
static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
		int depth, void *data)
{
	return 1;
}
#endif

M
Max Filippov 已提交
229 230
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
R
Rob Herring 已提交
231 232 233
	if (!dt_memory_scan)
		return;

M
Max Filippov 已提交
234
	size &= PAGE_MASK;
235
	add_sysmem_bank(base, base + size);
M
Max Filippov 已提交
236 237 238 239 240 241 242 243 244
}

void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
{
	return __alloc_bootmem(size, align, 0);
}

void __init early_init_devtree(void *params)
{
R
Rob Herring 已提交
245 246
	if (sysmem.nr_banks == 0)
		dt_memory_scan = true;
M
Max Filippov 已提交
247

R
Rob Herring 已提交
248
	early_init_dt_scan(params);
249
	of_scan_flat_dt(xtensa_dt_io_area, NULL);
M
Max Filippov 已提交
250

R
Rob Herring 已提交
251 252
	if (!command_line[0])
		strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
M
Max Filippov 已提交
253 254 255 256
}

static int __init xtensa_device_probe(void)
{
257
	of_clk_init(NULL);
258
	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
M
Max Filippov 已提交
259 260 261 262 263 264 265
	return 0;
}

device_initcall(xtensa_device_probe);

#endif /* CONFIG_OF */

266 267 268 269 270 271 272 273
/*
 * Initialize architecture. (Early stage)
 */

void __init init_arch(bp_tag_t *bp_start)
{
	/* Parse boot parameters */

274
	if (bp_start)
M
Max Filippov 已提交
275 276 277 278 279
		parse_bootparam(bp_start);

#ifdef CONFIG_OF
	early_init_devtree(dtb_start);
#endif
280 281

	if (sysmem.nr_banks == 0) {
282 283 284
		add_sysmem_bank(PLATFORM_DEFAULT_MEM_START,
				PLATFORM_DEFAULT_MEM_START +
				PLATFORM_DEFAULT_MEM_SIZE);
285 286
	}

M
Max Filippov 已提交
287 288 289 290 291
#ifdef CONFIG_CMDLINE_BOOL
	if (!command_line[0])
		strlcpy(command_line, default_command_line, COMMAND_LINE_SIZE);
#endif

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
	/* Early hook for platforms */

	platform_init(bp_start);

	/* Initialize MMU. */

	init_mmu();
}

/*
 * Initialize system. Setup memory and reserve regions.
 */

extern char _end;
extern char _stext;
extern char _WindowVectors_text_start;
extern char _WindowVectors_text_end;
extern char _DebugInterruptVector_literal_start;
extern char _DebugInterruptVector_text_end;
extern char _KernelExceptionVector_literal_start;
extern char _KernelExceptionVector_text_end;
extern char _UserExceptionVector_literal_start;
extern char _UserExceptionVector_text_end;
extern char _DoubleExceptionVector_literal_start;
extern char _DoubleExceptionVector_text_end;
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
#if XCHAL_EXCM_LEVEL >= 2
extern char _Level2InterruptVector_text_start;
extern char _Level2InterruptVector_text_end;
#endif
#if XCHAL_EXCM_LEVEL >= 3
extern char _Level3InterruptVector_text_start;
extern char _Level3InterruptVector_text_end;
#endif
#if XCHAL_EXCM_LEVEL >= 4
extern char _Level4InterruptVector_text_start;
extern char _Level4InterruptVector_text_end;
#endif
#if XCHAL_EXCM_LEVEL >= 5
extern char _Level5InterruptVector_text_start;
extern char _Level5InterruptVector_text_end;
#endif
#if XCHAL_EXCM_LEVEL >= 6
extern char _Level6InterruptVector_text_start;
extern char _Level6InterruptVector_text_end;
#endif

338

M
Max Filippov 已提交
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367

#ifdef CONFIG_S32C1I_SELFTEST
#if XCHAL_HAVE_S32C1I

static int __initdata rcw_word, rcw_probe_pc, rcw_exc;

/*
 * Basic atomic compare-and-swap, that records PC of S32C1I for probing.
 *
 * If *v == cmp, set *v = set.  Return previous *v.
 */
static inline int probed_compare_swap(int *v, int cmp, int set)
{
	int tmp;

	__asm__ __volatile__(
			"	movi	%1, 1f\n"
			"	s32i	%1, %4, 0\n"
			"	wsr	%2, scompare1\n"
			"1:	s32c1i	%0, %3, 0\n"
			: "=a" (set), "=&a" (tmp)
			: "a" (cmp), "a" (v), "a" (&rcw_probe_pc), "0" (set)
			: "memory"
			);
	return set;
}

/* Handle probed exception */

368 369
static void __init do_probed_exception(struct pt_regs *regs,
		unsigned long exccause)
M
Max Filippov 已提交
370 371 372 373 374 375 376 377 378 379 380
{
	if (regs->pc == rcw_probe_pc) {	/* exception on s32c1i ? */
		regs->pc += 3;		/* skip the s32c1i instruction */
		rcw_exc = exccause;
	} else {
		do_unhandled(regs, exccause);
	}
}

/* Simple test of S32C1I (soc bringup assist) */

381
static int __init check_s32c1i(void)
M
Max Filippov 已提交
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
{
	int n, cause1, cause2;
	void *handbus, *handdata, *handaddr; /* temporarily saved handlers */

	rcw_probe_pc = 0;
	handbus  = trap_set_handler(EXCCAUSE_LOAD_STORE_ERROR,
			do_probed_exception);
	handdata = trap_set_handler(EXCCAUSE_LOAD_STORE_DATA_ERROR,
			do_probed_exception);
	handaddr = trap_set_handler(EXCCAUSE_LOAD_STORE_ADDR_ERROR,
			do_probed_exception);

	/* First try an S32C1I that does not store: */
	rcw_exc = 0;
	rcw_word = 1;
	n = probed_compare_swap(&rcw_word, 0, 2);
	cause1 = rcw_exc;

	/* took exception? */
	if (cause1 != 0) {
		/* unclean exception? */
		if (n != 2 || rcw_word != 1)
			panic("S32C1I exception error");
	} else if (rcw_word != 1 || n != 1) {
		panic("S32C1I compare error");
	}

	/* Then an S32C1I that stores: */
	rcw_exc = 0;
	rcw_word = 0x1234567;
	n = probed_compare_swap(&rcw_word, 0x1234567, 0xabcde);
	cause2 = rcw_exc;

	if (cause2 != 0) {
		/* unclean exception? */
		if (n != 0xabcde || rcw_word != 0x1234567)
			panic("S32C1I exception error (b)");
	} else if (rcw_word != 0xabcde || n != 0x1234567) {
		panic("S32C1I store error");
	}

	/* Verify consistency of exceptions: */
	if (cause1 || cause2) {
		pr_warn("S32C1I took exception %d, %d\n", cause1, cause2);
		/* If emulation of S32C1I upon bus error gets implemented,
		   we can get rid of this panic for single core (not SMP) */
		panic("S32C1I exceptions not currently supported");
	}
	if (cause1 != cause2)
		panic("inconsistent S32C1I exceptions");

	trap_set_handler(EXCCAUSE_LOAD_STORE_ERROR, handbus);
	trap_set_handler(EXCCAUSE_LOAD_STORE_DATA_ERROR, handdata);
	trap_set_handler(EXCCAUSE_LOAD_STORE_ADDR_ERROR, handaddr);
436
	return 0;
M
Max Filippov 已提交
437 438 439 440 441 442
}

#else /* XCHAL_HAVE_S32C1I */

/* This condition should not occur with a commercially deployed processor.
   Display reminder for early engr test or demo chips / FPGA bitstreams */
443
static int __init check_s32c1i(void)
M
Max Filippov 已提交
444 445
{
	pr_warn("Processor configuration lacks atomic compare-and-swap support!\n");
446
	return 0;
M
Max Filippov 已提交
447 448 449
}

#endif /* XCHAL_HAVE_S32C1I */
450
early_initcall(check_s32c1i);
M
Max Filippov 已提交
451 452 453
#endif /* CONFIG_S32C1I_SELFTEST */


454 455
void __init setup_arch(char **cmdline_p)
{
M
Max Filippov 已提交
456
	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
457 458 459 460 461 462 463
	*cmdline_p = command_line;

	/* Reserve some memory regions */

#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start < initrd_end) {
		initrd_is_mapped = mem_reserve(__pa(initrd_start),
464
					       __pa(initrd_end), 0) == 0;
465
		initrd_below_start_ok = 1;
466
	} else {
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
		initrd_start = 0;
	}
#endif

	mem_reserve(__pa(&_stext),__pa(&_end), 1);

	mem_reserve(__pa(&_WindowVectors_text_start),
		    __pa(&_WindowVectors_text_end), 0);

	mem_reserve(__pa(&_DebugInterruptVector_literal_start),
		    __pa(&_DebugInterruptVector_text_end), 0);

	mem_reserve(__pa(&_KernelExceptionVector_literal_start),
		    __pa(&_KernelExceptionVector_text_end), 0);

	mem_reserve(__pa(&_UserExceptionVector_literal_start),
		    __pa(&_UserExceptionVector_text_end), 0);

	mem_reserve(__pa(&_DoubleExceptionVector_literal_start),
		    __pa(&_DoubleExceptionVector_text_end), 0);

488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
#if XCHAL_EXCM_LEVEL >= 2
	mem_reserve(__pa(&_Level2InterruptVector_text_start),
		    __pa(&_Level2InterruptVector_text_end), 0);
#endif
#if XCHAL_EXCM_LEVEL >= 3
	mem_reserve(__pa(&_Level3InterruptVector_text_start),
		    __pa(&_Level3InterruptVector_text_end), 0);
#endif
#if XCHAL_EXCM_LEVEL >= 4
	mem_reserve(__pa(&_Level4InterruptVector_text_start),
		    __pa(&_Level4InterruptVector_text_end), 0);
#endif
#if XCHAL_EXCM_LEVEL >= 5
	mem_reserve(__pa(&_Level5InterruptVector_text_start),
		    __pa(&_Level5InterruptVector_text_end), 0);
#endif
#if XCHAL_EXCM_LEVEL >= 6
	mem_reserve(__pa(&_Level6InterruptVector_text_start),
		    __pa(&_Level6InterruptVector_text_end), 0);
#endif

509
	parse_early_param();
510 511
	bootmem_init();

512
	unflatten_and_copy_device_tree();
513

M
Max Filippov 已提交
514
	platform_setup(cmdline_p);
515

M
Max Filippov 已提交
516 517 518 519
#ifdef CONFIG_SMP
	smp_init_cpus();
#endif

520
	paging_init();
J
Johannes Weiner 已提交
521
	zones_init();
522 523 524 525 526 527 528 529 530

#ifdef CONFIG_VT
# if defined(CONFIG_VGA_CONSOLE)
	conswitchp = &vga_con;
# elif defined(CONFIG_DUMMY_CONSOLE)
	conswitchp = &dummy_con;
# endif
#endif

531
#ifdef CONFIG_PCI
532 533 534 535
	platform_pcibios_init();
#endif
}

M
Max Filippov 已提交
536 537 538 539 540 541 542 543
static DEFINE_PER_CPU(struct cpu, cpu_data);

static int __init topology_init(void)
{
	int i;

	for_each_possible_cpu(i) {
		struct cpu *cpu = &per_cpu(cpu_data, i);
M
Max Filippov 已提交
544
		cpu->hotpluggable = !!i;
M
Max Filippov 已提交
545 546 547 548 549 550 551
		register_cpu(cpu, i);
	}

	return 0;
}
subsys_initcall(topology_init);

552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
void machine_restart(char * cmd)
{
	platform_restart();
}

void machine_halt(void)
{
	platform_halt();
	while (1);
}

void machine_power_off(void)
{
	platform_power_off();
	while (1);
}
#ifdef CONFIG_PROC_FS

/*
 * Display some core information through /proc/cpuinfo.
 */

static int
c_show(struct seq_file *f, void *slot)
{
	/* high-level stuff */
M
Max Filippov 已提交
578
	seq_printf(f, "CPU count\t: %u\n"
579
		      "CPU list\t: %*pbl\n"
M
Max Filippov 已提交
580 581 582 583 584 585 586 587
		      "vendor_id\t: Tensilica\n"
		      "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME "\n"
		      "core ID\t\t: " XCHAL_CORE_ID "\n"
		      "build ID\t: 0x%x\n"
		      "byte order\t: %s\n"
		      "cpu MHz\t\t: %lu.%02lu\n"
		      "bogomips\t: %lu.%02lu\n",
		      num_online_cpus(),
588
		      cpumask_pr_args(cpu_online_mask),
M
Max Filippov 已提交
589 590 591 592 593 594
		      XCHAL_BUILD_UNIQUE_ID,
		      XCHAL_HAVE_BE ?  "big" : "little",
		      ccount_freq/1000000,
		      (ccount_freq/10000) % 100,
		      loops_per_jiffy/(500000/HZ),
		      (loops_per_jiffy/(5000/HZ)) % 100);
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640

	seq_printf(f,"flags\t\t: "
#if XCHAL_HAVE_NMI
		     "nmi "
#endif
#if XCHAL_HAVE_DEBUG
		     "debug "
# if XCHAL_HAVE_OCD
		     "ocd "
# endif
#endif
#if XCHAL_HAVE_DENSITY
	    	     "density "
#endif
#if XCHAL_HAVE_BOOLEANS
		     "boolean "
#endif
#if XCHAL_HAVE_LOOPS
		     "loop "
#endif
#if XCHAL_HAVE_NSA
		     "nsa "
#endif
#if XCHAL_HAVE_MINMAX
		     "minmax "
#endif
#if XCHAL_HAVE_SEXT
		     "sext "
#endif
#if XCHAL_HAVE_CLAMPS
		     "clamps "
#endif
#if XCHAL_HAVE_MAC16
		     "mac16 "
#endif
#if XCHAL_HAVE_MUL16
		     "mul16 "
#endif
#if XCHAL_HAVE_MUL32
		     "mul32 "
#endif
#if XCHAL_HAVE_MUL32_HIGH
		     "mul32h "
#endif
#if XCHAL_HAVE_FP
		     "fpu "
641 642 643
#endif
#if XCHAL_HAVE_S32C1I
		     "s32c1i "
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
#endif
		     "\n");

	/* Registers. */
	seq_printf(f,"physical aregs\t: %d\n"
		     "misc regs\t: %d\n"
		     "ibreak\t\t: %d\n"
		     "dbreak\t\t: %d\n",
		     XCHAL_NUM_AREGS,
		     XCHAL_NUM_MISC_REGS,
		     XCHAL_NUM_IBREAK,
		     XCHAL_NUM_DBREAK);


	/* Interrupt. */
	seq_printf(f,"num ints\t: %d\n"
		     "ext ints\t: %d\n"
		     "int levels\t: %d\n"
		     "timers\t\t: %d\n"
		     "debug level\t: %d\n",
		     XCHAL_NUM_INTERRUPTS,
		     XCHAL_NUM_EXTINTERRUPTS,
		     XCHAL_NUM_INTLEVELS,
		     XCHAL_NUM_TIMERS,
		     XCHAL_DEBUGLEVEL);

	/* Cache */
	seq_printf(f,"icache line size: %d\n"
		     "icache ways\t: %d\n"
		     "icache size\t: %d\n"
		     "icache flags\t: "
#if XCHAL_ICACHE_LINE_LOCKABLE
676
		     "lock "
677 678 679 680 681 682 683
#endif
		     "\n"
		     "dcache line size: %d\n"
		     "dcache ways\t: %d\n"
		     "dcache size\t: %d\n"
		     "dcache flags\t: "
#if XCHAL_DCACHE_IS_WRITEBACK
684
		     "writeback "
685 686
#endif
#if XCHAL_DCACHE_LINE_LOCKABLE
687
		     "lock "
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
#endif
		     "\n",
		     XCHAL_ICACHE_LINESIZE,
		     XCHAL_ICACHE_WAYS,
		     XCHAL_ICACHE_SIZE,
		     XCHAL_DCACHE_LINESIZE,
		     XCHAL_DCACHE_WAYS,
		     XCHAL_DCACHE_SIZE);

	return 0;
}

/*
 * We show only CPU #0 info.
 */
static void *
c_start(struct seq_file *f, loff_t *pos)
{
M
Max Filippov 已提交
706
	return (*pos == 0) ? (void *)1 : NULL;
707 708 709 710 711 712 713 714 715 716 717 718 719
}

static void *
c_next(struct seq_file *f, void *v, loff_t *pos)
{
	return NULL;
}

static void
c_stop(struct seq_file *f, void *v)
{
}

720
const struct seq_operations cpuinfo_op =
721
{
M
Max Filippov 已提交
722 723 724 725
	.start	= c_start,
	.next	= c_next,
	.stop	= c_stop,
	.show	= c_show,
726 727 728
};

#endif /* CONFIG_PROC_FS */