setup.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*
  2. * arch/xtensa/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. *
  11. * Chris Zankel <chris@zankel.net>
  12. * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
  13. * Kevin Chea
  14. * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
  15. */
  16. #include <linux/config.h>
  17. #include <linux/errno.h>
  18. #include <linux/init.h>
  19. #include <linux/proc_fs.h>
  20. #include <linux/tty.h>
  21. #include <linux/bootmem.h>
  22. #include <linux/kernel.h>
  23. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
  24. # include <linux/console.h>
  25. #endif
  26. #ifdef CONFIG_RTC
  27. # include <linux/timex.h>
  28. #endif
  29. #ifdef CONFIG_PROC_FS
  30. # include <linux/seq_file.h>
  31. #endif
  32. #include <asm/system.h>
  33. #include <asm/bootparam.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/processor.h>
  36. #include <asm/timex.h>
  37. #include <asm/platform.h>
  38. #include <asm/page.h>
  39. #include <asm/setup.h>
  40. #include <xtensa/config/system.h>
  41. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
  42. struct screen_info screen_info = { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
  43. #endif
  44. #ifdef CONFIG_BLK_DEV_FD
  45. extern struct fd_ops no_fd_ops;
  46. struct fd_ops *fd_ops;
  47. #endif
  48. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  49. extern struct ide_ops no_ide_ops;
  50. struct ide_ops *ide_ops;
  51. #endif
  52. extern struct rtc_ops no_rtc_ops;
  53. struct rtc_ops *rtc_ops;
  54. #ifdef CONFIG_PC_KEYB
  55. extern struct kbd_ops no_kbd_ops;
  56. struct kbd_ops *kbd_ops;
  57. #endif
  58. #ifdef CONFIG_BLK_DEV_INITRD
  59. extern void *initrd_start;
  60. extern void *initrd_end;
  61. extern void *__initrd_start;
  62. extern void *__initrd_end;
  63. int initrd_is_mapped = 0;
  64. extern int initrd_below_start_ok;
  65. #endif
  66. unsigned char aux_device_present;
  67. extern unsigned long loops_per_jiffy;
  68. /* Command line specified as configuration option. */
  69. static char command_line[COMMAND_LINE_SIZE];
  70. #ifdef CONFIG_CMDLINE_BOOL
  71. static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
  72. #endif
  73. sysmem_info_t __initdata sysmem;
  74. #ifdef CONFIG_BLK_DEV_INITRD
  75. int initrd_is_mapped;
  76. #endif
  77. extern void init_mmu(void);
  78. /*
  79. * Boot parameter parsing.
  80. *
  81. * The Xtensa port uses a list of variable-sized tags to pass data to
  82. * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
  83. * to be recognised. The list is terminated with a zero-sized
  84. * BP_TAG_LAST tag.
  85. */
  86. typedef struct tagtable {
  87. u32 tag;
  88. int (*parse)(const bp_tag_t*);
  89. } tagtable_t;
  90. #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
  91. __attribute__((unused, __section__(".taglist"))) = { tag, fn }
  92. /* parse current tag */
  93. static int __init parse_tag_mem(const bp_tag_t *tag)
  94. {
  95. meminfo_t *mi = (meminfo_t*)(tag->data);
  96. if (mi->type != MEMORY_TYPE_CONVENTIONAL)
  97. return -1;
  98. if (sysmem.nr_banks >= SYSMEM_BANKS_MAX) {
  99. printk(KERN_WARNING
  100. "Ignoring memory bank 0x%08lx size %ldKB\n",
  101. (unsigned long)mi->start,
  102. (unsigned long)mi->end - (unsigned long)mi->start);
  103. return -EINVAL;
  104. }
  105. sysmem.bank[sysmem.nr_banks].type = mi->type;
  106. sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(mi->start);
  107. sysmem.bank[sysmem.nr_banks].end = mi->end & PAGE_SIZE;
  108. sysmem.nr_banks++;
  109. return 0;
  110. }
  111. __tagtable(BP_TAG_MEMORY, parse_tag_mem);
  112. #ifdef CONFIG_BLK_DEV_INITRD
  113. static int __init parse_tag_initrd(const bp_tag_t* tag)
  114. {
  115. meminfo_t* mi;
  116. mi = (meminfo_t*)(tag->data);
  117. initrd_start = (void*)(mi->start);
  118. initrd_end = (void*)(mi->end);
  119. return 0;
  120. }
  121. __tagtable(BP_TAG_INITRD, parse_tag_initrd);
  122. #endif /* CONFIG_BLK_DEV_INITRD */
  123. static int __init parse_tag_cmdline(const bp_tag_t* tag)
  124. {
  125. strncpy(command_line, (char*)(tag->data), COMMAND_LINE_SIZE);
  126. command_line[COMMAND_LINE_SIZE - 1] = '\0';
  127. return 0;
  128. }
  129. __tagtable(BP_TAG_COMMAND_LINE, parse_tag_cmdline);
  130. static int __init parse_bootparam(const bp_tag_t* tag)
  131. {
  132. extern tagtable_t __tagtable_begin, __tagtable_end;
  133. tagtable_t *t;
  134. /* Boot parameters must start with a BP_TAG_FIRST tag. */
  135. if (tag->id != BP_TAG_FIRST) {
  136. printk(KERN_WARNING "Invalid boot parameters!\n");
  137. return 0;
  138. }
  139. tag = (bp_tag_t*)((unsigned long)tag + sizeof(bp_tag_t) + tag->size);
  140. /* Parse all tags. */
  141. while (tag != NULL && tag->id != BP_TAG_LAST) {
  142. for (t = &__tagtable_begin; t < &__tagtable_end; t++) {
  143. if (tag->id == t->tag) {
  144. t->parse(tag);
  145. break;
  146. }
  147. }
  148. if (t == &__tagtable_end)
  149. printk(KERN_WARNING "Ignoring tag "
  150. "0x%08x\n", tag->id);
  151. tag = (bp_tag_t*)((unsigned long)(tag + 1) + tag->size);
  152. }
  153. return 0;
  154. }
  155. /*
  156. * Initialize architecture. (Early stage)
  157. */
  158. void __init init_arch(bp_tag_t *bp_start)
  159. {
  160. #ifdef CONFIG_BLK_DEV_INITRD
  161. initrd_start = &__initrd_start;
  162. initrd_end = &__initrd_end;
  163. #endif
  164. sysmem.nr_banks = 0;
  165. #ifdef CONFIG_CMDLINE_BOOL
  166. strcpy(command_line, default_command_line);
  167. #endif
  168. /* Parse boot parameters */
  169. if (bp_start)
  170. parse_bootparam(bp_start);
  171. if (sysmem.nr_banks == 0) {
  172. sysmem.nr_banks = 1;
  173. sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;
  174. sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START
  175. + PLATFORM_DEFAULT_MEM_SIZE;
  176. }
  177. /* Early hook for platforms */
  178. platform_init(bp_start);
  179. /* Initialize MMU. */
  180. init_mmu();
  181. }
  182. /*
  183. * Initialize system. Setup memory and reserve regions.
  184. */
  185. extern char _end;
  186. extern char _stext;
  187. extern char _WindowVectors_text_start;
  188. extern char _WindowVectors_text_end;
  189. extern char _DebugInterruptVector_literal_start;
  190. extern char _DebugInterruptVector_text_end;
  191. extern char _KernelExceptionVector_literal_start;
  192. extern char _KernelExceptionVector_text_end;
  193. extern char _UserExceptionVector_literal_start;
  194. extern char _UserExceptionVector_text_end;
  195. extern char _DoubleExceptionVector_literal_start;
  196. extern char _DoubleExceptionVector_text_end;
  197. void __init setup_arch(char **cmdline_p)
  198. {
  199. extern int mem_reserve(unsigned long, unsigned long, int);
  200. extern void bootmem_init(void);
  201. memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
  202. saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
  203. *cmdline_p = command_line;
  204. /* Reserve some memory regions */
  205. #ifdef CONFIG_BLK_DEV_INITRD
  206. if (initrd_start < initrd_end) {
  207. initrd_is_mapped = mem_reserve(__pa(initrd_start),
  208. __pa(initrd_end), 0);
  209. initrd_below_start_ok = 1;
  210. } else {
  211. initrd_start = 0;
  212. }
  213. #endif
  214. mem_reserve(__pa(&_stext),__pa(&_end), 1);
  215. mem_reserve(__pa(&_WindowVectors_text_start),
  216. __pa(&_WindowVectors_text_end), 0);
  217. mem_reserve(__pa(&_DebugInterruptVector_literal_start),
  218. __pa(&_DebugInterruptVector_text_end), 0);
  219. mem_reserve(__pa(&_KernelExceptionVector_literal_start),
  220. __pa(&_KernelExceptionVector_text_end), 0);
  221. mem_reserve(__pa(&_UserExceptionVector_literal_start),
  222. __pa(&_UserExceptionVector_text_end), 0);
  223. mem_reserve(__pa(&_DoubleExceptionVector_literal_start),
  224. __pa(&_DoubleExceptionVector_text_end), 0);
  225. bootmem_init();
  226. platform_setup(cmdline_p);
  227. paging_init();
  228. #ifdef CONFIG_VT
  229. # if defined(CONFIG_VGA_CONSOLE)
  230. conswitchp = &vga_con;
  231. # elif defined(CONFIG_DUMMY_CONSOLE)
  232. conswitchp = &dummy_con;
  233. # endif
  234. #endif
  235. #if CONFIG_PCI
  236. platform_pcibios_init();
  237. #endif
  238. }
  239. void machine_restart(char * cmd)
  240. {
  241. platform_restart();
  242. }
  243. void machine_halt(void)
  244. {
  245. platform_halt();
  246. while (1);
  247. }
  248. void machine_power_off(void)
  249. {
  250. platform_power_off();
  251. while (1);
  252. }
  253. #ifdef CONFIG_PROC_FS
  254. /*
  255. * Display some core information through /proc/cpuinfo.
  256. */
  257. static int
  258. c_show(struct seq_file *f, void *slot)
  259. {
  260. /* high-level stuff */
  261. seq_printf(f,"processor\t: 0\n"
  262. "vendor_id\t: Tensilica\n"
  263. "model\t\t: Xtensa " XCHAL_HW_RELEASE_NAME "\n"
  264. "core ID\t\t: " XCHAL_CORE_ID "\n"
  265. "build ID\t: 0x%x\n"
  266. "byte order\t: %s\n"
  267. "cpu MHz\t\t: %lu.%02lu\n"
  268. "bogomips\t: %lu.%02lu\n",
  269. XCHAL_BUILD_UNIQUE_ID,
  270. XCHAL_HAVE_BE ? "big" : "little",
  271. CCOUNT_PER_JIFFY/(1000000/HZ),
  272. (CCOUNT_PER_JIFFY/(10000/HZ)) % 100,
  273. loops_per_jiffy/(500000/HZ),
  274. (loops_per_jiffy/(5000/HZ)) % 100);
  275. seq_printf(f,"flags\t\t: "
  276. #if XCHAL_HAVE_NMI
  277. "nmi "
  278. #endif
  279. #if XCHAL_HAVE_DEBUG
  280. "debug "
  281. # if XCHAL_HAVE_OCD
  282. "ocd "
  283. # endif
  284. #endif
  285. #if XCHAL_HAVE_DENSITY
  286. "density "
  287. #endif
  288. #if XCHAL_HAVE_BOOLEANS
  289. "boolean "
  290. #endif
  291. #if XCHAL_HAVE_LOOPS
  292. "loop "
  293. #endif
  294. #if XCHAL_HAVE_NSA
  295. "nsa "
  296. #endif
  297. #if XCHAL_HAVE_MINMAX
  298. "minmax "
  299. #endif
  300. #if XCHAL_HAVE_SEXT
  301. "sext "
  302. #endif
  303. #if XCHAL_HAVE_CLAMPS
  304. "clamps "
  305. #endif
  306. #if XCHAL_HAVE_MAC16
  307. "mac16 "
  308. #endif
  309. #if XCHAL_HAVE_MUL16
  310. "mul16 "
  311. #endif
  312. #if XCHAL_HAVE_MUL32
  313. "mul32 "
  314. #endif
  315. #if XCHAL_HAVE_MUL32_HIGH
  316. "mul32h "
  317. #endif
  318. #if XCHAL_HAVE_FP
  319. "fpu "
  320. #endif
  321. "\n");
  322. /* Registers. */
  323. seq_printf(f,"physical aregs\t: %d\n"
  324. "misc regs\t: %d\n"
  325. "ibreak\t\t: %d\n"
  326. "dbreak\t\t: %d\n",
  327. XCHAL_NUM_AREGS,
  328. XCHAL_NUM_MISC_REGS,
  329. XCHAL_NUM_IBREAK,
  330. XCHAL_NUM_DBREAK);
  331. /* Interrupt. */
  332. seq_printf(f,"num ints\t: %d\n"
  333. "ext ints\t: %d\n"
  334. "int levels\t: %d\n"
  335. "timers\t\t: %d\n"
  336. "debug level\t: %d\n",
  337. XCHAL_NUM_INTERRUPTS,
  338. XCHAL_NUM_EXTINTERRUPTS,
  339. XCHAL_NUM_INTLEVELS,
  340. XCHAL_NUM_TIMERS,
  341. XCHAL_DEBUGLEVEL);
  342. /* Coprocessors */
  343. #if XCHAL_HAVE_CP
  344. seq_printf(f, "coprocessors\t: %d\n", XCHAL_CP_NUM);
  345. #else
  346. seq_printf(f, "coprocessors\t: none\n");
  347. #endif
  348. /* {I,D}{RAM,ROM} and XLMI */
  349. seq_printf(f,"inst ROMs\t: %d\n"
  350. "inst RAMs\t: %d\n"
  351. "data ROMs\t: %d\n"
  352. "data RAMs\t: %d\n"
  353. "XLMI ports\t: %d\n",
  354. XCHAL_NUM_IROM,
  355. XCHAL_NUM_IRAM,
  356. XCHAL_NUM_DROM,
  357. XCHAL_NUM_DRAM,
  358. XCHAL_NUM_XLMI);
  359. /* Cache */
  360. seq_printf(f,"icache line size: %d\n"
  361. "icache ways\t: %d\n"
  362. "icache size\t: %d\n"
  363. "icache flags\t: "
  364. #if XCHAL_ICACHE_LINE_LOCKABLE
  365. "lock"
  366. #endif
  367. "\n"
  368. "dcache line size: %d\n"
  369. "dcache ways\t: %d\n"
  370. "dcache size\t: %d\n"
  371. "dcache flags\t: "
  372. #if XCHAL_DCACHE_IS_WRITEBACK
  373. "writeback"
  374. #endif
  375. #if XCHAL_DCACHE_LINE_LOCKABLE
  376. "lock"
  377. #endif
  378. "\n",
  379. XCHAL_ICACHE_LINESIZE,
  380. XCHAL_ICACHE_WAYS,
  381. XCHAL_ICACHE_SIZE,
  382. XCHAL_DCACHE_LINESIZE,
  383. XCHAL_DCACHE_WAYS,
  384. XCHAL_DCACHE_SIZE);
  385. /* MMU */
  386. seq_printf(f,"ASID bits\t: %d\n"
  387. "ASID invalid\t: %d\n"
  388. "ASID kernel\t: %d\n"
  389. "rings\t\t: %d\n"
  390. "itlb ways\t: %d\n"
  391. "itlb AR ways\t: %d\n"
  392. "dtlb ways\t: %d\n"
  393. "dtlb AR ways\t: %d\n",
  394. XCHAL_MMU_ASID_BITS,
  395. XCHAL_MMU_ASID_INVALID,
  396. XCHAL_MMU_ASID_KERNEL,
  397. XCHAL_MMU_RINGS,
  398. XCHAL_ITLB_WAYS,
  399. XCHAL_ITLB_ARF_WAYS,
  400. XCHAL_DTLB_WAYS,
  401. XCHAL_DTLB_ARF_WAYS);
  402. return 0;
  403. }
  404. /*
  405. * We show only CPU #0 info.
  406. */
  407. static void *
  408. c_start(struct seq_file *f, loff_t *pos)
  409. {
  410. return (void *) ((*pos == 0) ? (void *)1 : NULL);
  411. }
  412. static void *
  413. c_next(struct seq_file *f, void *v, loff_t *pos)
  414. {
  415. return NULL;
  416. }
  417. static void
  418. c_stop(struct seq_file *f, void *v)
  419. {
  420. }
  421. struct seq_operations cpuinfo_op =
  422. {
  423. start: c_start,
  424. next: c_next,
  425. stop: c_stop,
  426. show: c_show
  427. };
  428. #endif /* CONFIG_PROC_FS */