setup.c 17 KB

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