setup.c 16 KB

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