setup.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  1. /*
  2. *
  3. * Common boot and setup code.
  4. *
  5. * Copyright (C) 2001 PPC64 Team, IBM Corp
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #undef DEBUG
  13. #include <linux/config.h>
  14. #include <linux/module.h>
  15. #include <linux/string.h>
  16. #include <linux/sched.h>
  17. #include <linux/init.h>
  18. #include <linux/kernel.h>
  19. #include <linux/reboot.h>
  20. #include <linux/delay.h>
  21. #include <linux/initrd.h>
  22. #include <linux/ide.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/ioport.h>
  25. #include <linux/console.h>
  26. #include <linux/version.h>
  27. #include <linux/tty.h>
  28. #include <linux/root_dev.h>
  29. #include <linux/notifier.h>
  30. #include <linux/cpu.h>
  31. #include <linux/unistd.h>
  32. #include <linux/serial.h>
  33. #include <linux/serial_8250.h>
  34. #include <asm/io.h>
  35. #include <asm/prom.h>
  36. #include <asm/processor.h>
  37. #include <asm/pgtable.h>
  38. #include <asm/bootinfo.h>
  39. #include <asm/smp.h>
  40. #include <asm/elf.h>
  41. #include <asm/machdep.h>
  42. #include <asm/iSeries/LparData.h>
  43. #include <asm/paca.h>
  44. #include <asm/ppcdebug.h>
  45. #include <asm/time.h>
  46. #include <asm/cputable.h>
  47. #include <asm/sections.h>
  48. #include <asm/btext.h>
  49. #include <asm/nvram.h>
  50. #include <asm/setup.h>
  51. #include <asm/system.h>
  52. #include <asm/rtas.h>
  53. #include <asm/iommu.h>
  54. #include <asm/serial.h>
  55. #include <asm/cache.h>
  56. #include <asm/page.h>
  57. #include <asm/mmu.h>
  58. #ifdef DEBUG
  59. #define DBG(fmt...) udbg_printf(fmt)
  60. #else
  61. #define DBG(fmt...)
  62. #endif
  63. /*
  64. * Here are some early debugging facilities. You can enable one
  65. * but your kernel will not boot on anything else if you do so
  66. */
  67. /* This one is for use on LPAR machines that support an HVC console
  68. * on vterm 0
  69. */
  70. extern void udbg_init_debug_lpar(void);
  71. /* This one is for use on Apple G5 machines
  72. */
  73. extern void udbg_init_pmac_realmode(void);
  74. /* That's RTAS panel debug */
  75. extern void call_rtas_display_status_delay(unsigned char c);
  76. /* Here's maple real mode debug */
  77. extern void udbg_init_maple_realmode(void);
  78. #define EARLY_DEBUG_INIT() do {} while(0)
  79. #if 0
  80. #define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
  81. #define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
  82. #define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
  83. #define EARLY_DEBUG_INIT() \
  84. do { ppc_md.udbg_putc = call_rtas_display_status_delay; } while(0)
  85. #endif
  86. /* extern void *stab; */
  87. extern unsigned long klimit;
  88. extern void mm_init_ppc64(void);
  89. extern int idle_setup(void);
  90. extern void stab_initialize(unsigned long stab);
  91. extern void htab_initialize(void);
  92. extern void early_init_devtree(void *flat_dt);
  93. extern void unflatten_device_tree(void);
  94. extern void smp_release_cpus(void);
  95. int have_of = 1;
  96. int boot_cpuid = 0;
  97. int boot_cpuid_phys = 0;
  98. dev_t boot_dev;
  99. u64 ppc64_pft_size;
  100. u64 ppc64_debug_switch;
  101. struct ppc64_caches ppc64_caches;
  102. EXPORT_SYMBOL_GPL(ppc64_caches);
  103. /*
  104. * These are used in binfmt_elf.c to put aux entries on the stack
  105. * for each elf executable being started.
  106. */
  107. int dcache_bsize;
  108. int icache_bsize;
  109. int ucache_bsize;
  110. /* The main machine-dep calls structure
  111. */
  112. struct machdep_calls ppc_md;
  113. EXPORT_SYMBOL(ppc_md);
  114. #ifdef CONFIG_MAGIC_SYSRQ
  115. unsigned long SYSRQ_KEY;
  116. #endif /* CONFIG_MAGIC_SYSRQ */
  117. static int ppc64_panic_event(struct notifier_block *, unsigned long, void *);
  118. static struct notifier_block ppc64_panic_block = {
  119. .notifier_call = ppc64_panic_event,
  120. .priority = INT_MIN /* may not return; must be done last */
  121. };
  122. /*
  123. * Perhaps we can put the pmac screen_info[] here
  124. * on pmac as well so we don't need the ifdef's.
  125. * Until we get multiple-console support in here
  126. * that is. -- Cort
  127. * Maybe tie it to serial consoles, since this is really what
  128. * these processors use on existing boards. -- Dan
  129. */
  130. struct screen_info screen_info = {
  131. .orig_x = 0,
  132. .orig_y = 25,
  133. .orig_video_cols = 80,
  134. .orig_video_lines = 25,
  135. .orig_video_isVGA = 1,
  136. .orig_video_points = 16
  137. };
  138. /*
  139. * Initialize the PPCDBG state. Called before relocation has been enabled.
  140. */
  141. void __init ppcdbg_initialize(void)
  142. {
  143. ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */
  144. /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;
  145. }
  146. /*
  147. * Early boot console based on udbg
  148. */
  149. static struct console udbg_console = {
  150. .name = "udbg",
  151. .write = udbg_console_write,
  152. .flags = CON_PRINTBUFFER,
  153. .index = -1,
  154. };
  155. static int early_console_initialized;
  156. void __init disable_early_printk(void)
  157. {
  158. if (!early_console_initialized)
  159. return;
  160. unregister_console(&udbg_console);
  161. early_console_initialized = 0;
  162. }
  163. #if defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP)
  164. static int smt_enabled_cmdline;
  165. /* Look for ibm,smt-enabled OF option */
  166. static void check_smt_enabled(void)
  167. {
  168. struct device_node *dn;
  169. char *smt_option;
  170. /* Allow the command line to overrule the OF option */
  171. if (smt_enabled_cmdline)
  172. return;
  173. dn = of_find_node_by_path("/options");
  174. if (dn) {
  175. smt_option = (char *)get_property(dn, "ibm,smt-enabled", NULL);
  176. if (smt_option) {
  177. if (!strcmp(smt_option, "on"))
  178. smt_enabled_at_boot = 1;
  179. else if (!strcmp(smt_option, "off"))
  180. smt_enabled_at_boot = 0;
  181. }
  182. }
  183. }
  184. /* Look for smt-enabled= cmdline option */
  185. static int __init early_smt_enabled(char *p)
  186. {
  187. smt_enabled_cmdline = 1;
  188. if (!p)
  189. return 0;
  190. if (!strcmp(p, "on") || !strcmp(p, "1"))
  191. smt_enabled_at_boot = 1;
  192. else if (!strcmp(p, "off") || !strcmp(p, "0"))
  193. smt_enabled_at_boot = 0;
  194. return 0;
  195. }
  196. early_param("smt-enabled", early_smt_enabled);
  197. /**
  198. * setup_cpu_maps - initialize the following cpu maps:
  199. * cpu_possible_map
  200. * cpu_present_map
  201. * cpu_sibling_map
  202. *
  203. * Having the possible map set up early allows us to restrict allocations
  204. * of things like irqstacks to num_possible_cpus() rather than NR_CPUS.
  205. *
  206. * We do not initialize the online map here; cpus set their own bits in
  207. * cpu_online_map as they come up.
  208. *
  209. * This function is valid only for Open Firmware systems. finish_device_tree
  210. * must be called before using this.
  211. *
  212. * While we're here, we may as well set the "physical" cpu ids in the paca.
  213. */
  214. static void __init setup_cpu_maps(void)
  215. {
  216. struct device_node *dn = NULL;
  217. int cpu = 0;
  218. int swap_cpuid = 0;
  219. check_smt_enabled();
  220. while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) {
  221. u32 *intserv;
  222. int j, len = sizeof(u32), nthreads;
  223. intserv = (u32 *)get_property(dn, "ibm,ppc-interrupt-server#s",
  224. &len);
  225. if (!intserv)
  226. intserv = (u32 *)get_property(dn, "reg", NULL);
  227. nthreads = len / sizeof(u32);
  228. for (j = 0; j < nthreads && cpu < NR_CPUS; j++) {
  229. cpu_set(cpu, cpu_present_map);
  230. set_hard_smp_processor_id(cpu, intserv[j]);
  231. if (intserv[j] == boot_cpuid_phys)
  232. swap_cpuid = cpu;
  233. cpu_set(cpu, cpu_possible_map);
  234. cpu++;
  235. }
  236. }
  237. /* Swap CPU id 0 with boot_cpuid_phys, so we can always assume that
  238. * boot cpu is logical 0.
  239. */
  240. if (boot_cpuid_phys != get_hard_smp_processor_id(0)) {
  241. u32 tmp;
  242. tmp = get_hard_smp_processor_id(0);
  243. set_hard_smp_processor_id(0, boot_cpuid_phys);
  244. set_hard_smp_processor_id(swap_cpuid, tmp);
  245. }
  246. /*
  247. * On pSeries LPAR, we need to know how many cpus
  248. * could possibly be added to this partition.
  249. */
  250. if (systemcfg->platform == PLATFORM_PSERIES_LPAR &&
  251. (dn = of_find_node_by_path("/rtas"))) {
  252. int num_addr_cell, num_size_cell, maxcpus;
  253. unsigned int *ireg;
  254. num_addr_cell = prom_n_addr_cells(dn);
  255. num_size_cell = prom_n_size_cells(dn);
  256. ireg = (unsigned int *)
  257. get_property(dn, "ibm,lrdr-capacity", NULL);
  258. if (!ireg)
  259. goto out;
  260. maxcpus = ireg[num_addr_cell + num_size_cell];
  261. /* Double maxcpus for processors which have SMT capability */
  262. if (cpu_has_feature(CPU_FTR_SMT))
  263. maxcpus *= 2;
  264. if (maxcpus > NR_CPUS) {
  265. printk(KERN_WARNING
  266. "Partition configured for %d cpus, "
  267. "operating system maximum is %d.\n",
  268. maxcpus, NR_CPUS);
  269. maxcpus = NR_CPUS;
  270. } else
  271. printk(KERN_INFO "Partition configured for %d cpus.\n",
  272. maxcpus);
  273. for (cpu = 0; cpu < maxcpus; cpu++)
  274. cpu_set(cpu, cpu_possible_map);
  275. out:
  276. of_node_put(dn);
  277. }
  278. /*
  279. * Do the sibling map; assume only two threads per processor.
  280. */
  281. for_each_cpu(cpu) {
  282. cpu_set(cpu, cpu_sibling_map[cpu]);
  283. if (cpu_has_feature(CPU_FTR_SMT))
  284. cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
  285. }
  286. systemcfg->processorCount = num_present_cpus();
  287. }
  288. #endif /* defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP) */
  289. #ifdef CONFIG_PPC_MULTIPLATFORM
  290. extern struct machdep_calls pSeries_md;
  291. extern struct machdep_calls pmac_md;
  292. extern struct machdep_calls maple_md;
  293. /* Ultimately, stuff them in an elf section like initcalls... */
  294. static struct machdep_calls __initdata *machines[] = {
  295. #ifdef CONFIG_PPC_PSERIES
  296. &pSeries_md,
  297. #endif /* CONFIG_PPC_PSERIES */
  298. #ifdef CONFIG_PPC_PMAC
  299. &pmac_md,
  300. #endif /* CONFIG_PPC_PMAC */
  301. #ifdef CONFIG_PPC_MAPLE
  302. &maple_md,
  303. #endif /* CONFIG_PPC_MAPLE */
  304. NULL
  305. };
  306. /*
  307. * Early initialization entry point. This is called by head.S
  308. * with MMU translation disabled. We rely on the "feature" of
  309. * the CPU that ignores the top 2 bits of the address in real
  310. * mode so we can access kernel globals normally provided we
  311. * only toy with things in the RMO region. From here, we do
  312. * some early parsing of the device-tree to setup out LMB
  313. * data structures, and allocate & initialize the hash table
  314. * and segment tables so we can start running with translation
  315. * enabled.
  316. *
  317. * It is this function which will call the probe() callback of
  318. * the various platform types and copy the matching one to the
  319. * global ppc_md structure. Your platform can eventually do
  320. * some very early initializations from the probe() routine, but
  321. * this is not recommended, be very careful as, for example, the
  322. * device-tree is not accessible via normal means at this point.
  323. */
  324. void __init early_setup(unsigned long dt_ptr)
  325. {
  326. struct paca_struct *lpaca = get_paca();
  327. static struct machdep_calls **mach;
  328. /*
  329. * Enable early debugging if any specified (see top of
  330. * this file)
  331. */
  332. EARLY_DEBUG_INIT();
  333. DBG(" -> early_setup()\n");
  334. /*
  335. * Fill the default DBG level (do we want to keep
  336. * that old mecanism around forever ?)
  337. */
  338. ppcdbg_initialize();
  339. /*
  340. * Do early initializations using the flattened device
  341. * tree, like retreiving the physical memory map or
  342. * calculating/retreiving the hash table size
  343. */
  344. early_init_devtree(__va(dt_ptr));
  345. /*
  346. * Iterate all ppc_md structures until we find the proper
  347. * one for the current machine type
  348. */
  349. DBG("Probing machine type for platform %x...\n",
  350. systemcfg->platform);
  351. for (mach = machines; *mach; mach++) {
  352. if ((*mach)->probe(systemcfg->platform))
  353. break;
  354. }
  355. /* What can we do if we didn't find ? */
  356. if (*mach == NULL) {
  357. DBG("No suitable machine found !\n");
  358. for (;;);
  359. }
  360. ppc_md = **mach;
  361. /* our udbg callbacks got overriden by the above, let's put them
  362. * back in. Ultimately, I want those things to be split from the
  363. * main ppc_md
  364. */
  365. EARLY_DEBUG_INIT();
  366. DBG("Found, Initializing memory management...\n");
  367. /*
  368. * Initialize stab / SLB management
  369. */
  370. stab_initialize(lpaca->stab_real);
  371. /*
  372. * Initialize the MMU Hash table and create the linear mapping
  373. * of memory
  374. */
  375. htab_initialize();
  376. DBG(" <- early_setup()\n");
  377. }
  378. /*
  379. * Initialize some remaining members of the ppc64_caches and systemcfg structures
  380. * (at least until we get rid of them completely). This is mostly some
  381. * cache informations about the CPU that will be used by cache flush
  382. * routines and/or provided to userland
  383. */
  384. static void __init initialize_cache_info(void)
  385. {
  386. struct device_node *np;
  387. unsigned long num_cpus = 0;
  388. DBG(" -> initialize_cache_info()\n");
  389. for (np = NULL; (np = of_find_node_by_type(np, "cpu"));) {
  390. num_cpus += 1;
  391. /* We're assuming *all* of the CPUs have the same
  392. * d-cache and i-cache sizes... -Peter
  393. */
  394. if ( num_cpus == 1 ) {
  395. u32 *sizep, *lsizep;
  396. u32 size, lsize;
  397. const char *dc, *ic;
  398. /* Then read cache informations */
  399. if (systemcfg->platform == PLATFORM_POWERMAC) {
  400. dc = "d-cache-block-size";
  401. ic = "i-cache-block-size";
  402. } else {
  403. dc = "d-cache-line-size";
  404. ic = "i-cache-line-size";
  405. }
  406. size = 0;
  407. lsize = cur_cpu_spec->dcache_bsize;
  408. sizep = (u32 *)get_property(np, "d-cache-size", NULL);
  409. if (sizep != NULL)
  410. size = *sizep;
  411. lsizep = (u32 *) get_property(np, dc, NULL);
  412. if (lsizep != NULL)
  413. lsize = *lsizep;
  414. if (sizep == 0 || lsizep == 0)
  415. DBG("Argh, can't find dcache properties ! "
  416. "sizep: %p, lsizep: %p\n", sizep, lsizep);
  417. systemcfg->dcache_size = ppc64_caches.dsize = size;
  418. systemcfg->dcache_line_size =
  419. ppc64_caches.dline_size = lsize;
  420. ppc64_caches.log_dline_size = __ilog2(lsize);
  421. ppc64_caches.dlines_per_page = PAGE_SIZE / lsize;
  422. size = 0;
  423. lsize = cur_cpu_spec->icache_bsize;
  424. sizep = (u32 *)get_property(np, "i-cache-size", NULL);
  425. if (sizep != NULL)
  426. size = *sizep;
  427. lsizep = (u32 *)get_property(np, ic, NULL);
  428. if (lsizep != NULL)
  429. lsize = *lsizep;
  430. if (sizep == 0 || lsizep == 0)
  431. DBG("Argh, can't find icache properties ! "
  432. "sizep: %p, lsizep: %p\n", sizep, lsizep);
  433. systemcfg->icache_size = ppc64_caches.isize = size;
  434. systemcfg->icache_line_size =
  435. ppc64_caches.iline_size = lsize;
  436. ppc64_caches.log_iline_size = __ilog2(lsize);
  437. ppc64_caches.ilines_per_page = PAGE_SIZE / lsize;
  438. }
  439. }
  440. /* Add an eye catcher and the systemcfg layout version number */
  441. strcpy(systemcfg->eye_catcher, "SYSTEMCFG:PPC64");
  442. systemcfg->version.major = SYSTEMCFG_MAJOR;
  443. systemcfg->version.minor = SYSTEMCFG_MINOR;
  444. systemcfg->processor = mfspr(SPRN_PVR);
  445. DBG(" <- initialize_cache_info()\n");
  446. }
  447. static void __init check_for_initrd(void)
  448. {
  449. #ifdef CONFIG_BLK_DEV_INITRD
  450. u64 *prop;
  451. DBG(" -> check_for_initrd()\n");
  452. prop = (u64 *)get_property(of_chosen, "linux,initrd-start", NULL);
  453. if (prop != NULL) {
  454. initrd_start = (unsigned long)__va(*prop);
  455. prop = (u64 *)get_property(of_chosen, "linux,initrd-end", NULL);
  456. if (prop != NULL) {
  457. initrd_end = (unsigned long)__va(*prop);
  458. initrd_below_start_ok = 1;
  459. } else
  460. initrd_start = 0;
  461. }
  462. /* If we were passed an initrd, set the ROOT_DEV properly if the values
  463. * look sensible. If not, clear initrd reference.
  464. */
  465. if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE &&
  466. initrd_end > initrd_start)
  467. ROOT_DEV = Root_RAM0;
  468. else
  469. initrd_start = initrd_end = 0;
  470. if (initrd_start)
  471. printk("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end);
  472. DBG(" <- check_for_initrd()\n");
  473. #endif /* CONFIG_BLK_DEV_INITRD */
  474. }
  475. #endif /* CONFIG_PPC_MULTIPLATFORM */
  476. /*
  477. * Do some initial setup of the system. The parameters are those which
  478. * were passed in from the bootloader.
  479. */
  480. void __init setup_system(void)
  481. {
  482. DBG(" -> setup_system()\n");
  483. #ifdef CONFIG_PPC_ISERIES
  484. /* pSeries systems are identified in prom.c via OF. */
  485. if (itLpNaca.xLparInstalled == 1)
  486. systemcfg->platform = PLATFORM_ISERIES_LPAR;
  487. ppc_md.init_early();
  488. #else /* CONFIG_PPC_ISERIES */
  489. /*
  490. * Unflatten the device-tree passed by prom_init or kexec
  491. */
  492. unflatten_device_tree();
  493. /*
  494. * Fill the ppc64_caches & systemcfg structures with informations
  495. * retreived from the device-tree. Need to be called before
  496. * finish_device_tree() since the later requires some of the
  497. * informations filled up here to properly parse the interrupt
  498. * tree.
  499. * It also sets up the cache line sizes which allows to call
  500. * routines like flush_icache_range (used by the hash init
  501. * later on).
  502. */
  503. initialize_cache_info();
  504. #ifdef CONFIG_PPC_RTAS
  505. /*
  506. * Initialize RTAS if available
  507. */
  508. rtas_initialize();
  509. #endif /* CONFIG_PPC_RTAS */
  510. /*
  511. * Check if we have an initrd provided via the device-tree
  512. */
  513. check_for_initrd();
  514. /*
  515. * Do some platform specific early initializations, that includes
  516. * setting up the hash table pointers. It also sets up some interrupt-mapping
  517. * related options that will be used by finish_device_tree()
  518. */
  519. ppc_md.init_early();
  520. /*
  521. * "Finish" the device-tree, that is do the actual parsing of
  522. * some of the properties like the interrupt map
  523. */
  524. finish_device_tree();
  525. /*
  526. * Initialize xmon
  527. */
  528. #ifdef CONFIG_XMON_DEFAULT
  529. xmon_init();
  530. #endif
  531. /*
  532. * Register early console
  533. */
  534. early_console_initialized = 1;
  535. register_console(&udbg_console);
  536. /* Save unparsed command line copy for /proc/cmdline */
  537. strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
  538. parse_early_param();
  539. #endif /* !CONFIG_PPC_ISERIES */
  540. #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES)
  541. /*
  542. * iSeries has already initialized the cpu maps at this point.
  543. */
  544. setup_cpu_maps();
  545. /* Release secondary cpus out of their spinloops at 0x60 now that
  546. * we can map physical -> logical CPU ids
  547. */
  548. smp_release_cpus();
  549. #endif /* defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES) */
  550. printk("Starting Linux PPC64 %s\n", UTS_RELEASE);
  551. printk("-----------------------------------------------------\n");
  552. printk("ppc64_pft_size = 0x%lx\n", ppc64_pft_size);
  553. printk("ppc64_debug_switch = 0x%lx\n", ppc64_debug_switch);
  554. printk("ppc64_interrupt_controller = 0x%ld\n", ppc64_interrupt_controller);
  555. printk("systemcfg = 0x%p\n", systemcfg);
  556. printk("systemcfg->platform = 0x%x\n", systemcfg->platform);
  557. printk("systemcfg->processorCount = 0x%lx\n", systemcfg->processorCount);
  558. printk("systemcfg->physicalMemorySize = 0x%lx\n", systemcfg->physicalMemorySize);
  559. printk("ppc64_caches.dcache_line_size = 0x%x\n",
  560. ppc64_caches.dline_size);
  561. printk("ppc64_caches.icache_line_size = 0x%x\n",
  562. ppc64_caches.iline_size);
  563. printk("htab_address = 0x%p\n", htab_address);
  564. printk("htab_hash_mask = 0x%lx\n", htab_hash_mask);
  565. printk("-----------------------------------------------------\n");
  566. mm_init_ppc64();
  567. DBG(" <- setup_system()\n");
  568. }
  569. void machine_restart(char *cmd)
  570. {
  571. if (ppc_md.nvram_sync)
  572. ppc_md.nvram_sync();
  573. ppc_md.restart(cmd);
  574. }
  575. EXPORT_SYMBOL(machine_restart);
  576. void machine_power_off(void)
  577. {
  578. if (ppc_md.nvram_sync)
  579. ppc_md.nvram_sync();
  580. ppc_md.power_off();
  581. }
  582. EXPORT_SYMBOL(machine_power_off);
  583. void machine_halt(void)
  584. {
  585. if (ppc_md.nvram_sync)
  586. ppc_md.nvram_sync();
  587. ppc_md.halt();
  588. }
  589. EXPORT_SYMBOL(machine_halt);
  590. unsigned long ppc_proc_freq;
  591. unsigned long ppc_tb_freq;
  592. static int ppc64_panic_event(struct notifier_block *this,
  593. unsigned long event, void *ptr)
  594. {
  595. ppc_md.panic((char *)ptr); /* May not return */
  596. return NOTIFY_DONE;
  597. }
  598. #ifdef CONFIG_SMP
  599. DEFINE_PER_CPU(unsigned int, pvr);
  600. #endif
  601. static int show_cpuinfo(struct seq_file *m, void *v)
  602. {
  603. unsigned long cpu_id = (unsigned long)v - 1;
  604. unsigned int pvr;
  605. unsigned short maj;
  606. unsigned short min;
  607. if (cpu_id == NR_CPUS) {
  608. seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
  609. if (ppc_md.get_cpuinfo != NULL)
  610. ppc_md.get_cpuinfo(m);
  611. return 0;
  612. }
  613. /* We only show online cpus: disable preempt (overzealous, I
  614. * knew) to prevent cpu going down. */
  615. preempt_disable();
  616. if (!cpu_online(cpu_id)) {
  617. preempt_enable();
  618. return 0;
  619. }
  620. #ifdef CONFIG_SMP
  621. pvr = per_cpu(pvr, cpu_id);
  622. #else
  623. pvr = mfspr(SPRN_PVR);
  624. #endif
  625. maj = (pvr >> 8) & 0xFF;
  626. min = pvr & 0xFF;
  627. seq_printf(m, "processor\t: %lu\n", cpu_id);
  628. seq_printf(m, "cpu\t\t: ");
  629. if (cur_cpu_spec->pvr_mask)
  630. seq_printf(m, "%s", cur_cpu_spec->cpu_name);
  631. else
  632. seq_printf(m, "unknown (%08x)", pvr);
  633. #ifdef CONFIG_ALTIVEC
  634. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  635. seq_printf(m, ", altivec supported");
  636. #endif /* CONFIG_ALTIVEC */
  637. seq_printf(m, "\n");
  638. /*
  639. * Assume here that all clock rates are the same in a
  640. * smp system. -- Cort
  641. */
  642. seq_printf(m, "clock\t\t: %lu.%06luMHz\n", ppc_proc_freq / 1000000,
  643. ppc_proc_freq % 1000000);
  644. seq_printf(m, "revision\t: %hd.%hd\n\n", maj, min);
  645. preempt_enable();
  646. return 0;
  647. }
  648. static void *c_start(struct seq_file *m, loff_t *pos)
  649. {
  650. return *pos <= NR_CPUS ? (void *)((*pos)+1) : NULL;
  651. }
  652. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  653. {
  654. ++*pos;
  655. return c_start(m, pos);
  656. }
  657. static void c_stop(struct seq_file *m, void *v)
  658. {
  659. }
  660. struct seq_operations cpuinfo_op = {
  661. .start =c_start,
  662. .next = c_next,
  663. .stop = c_stop,
  664. .show = show_cpuinfo,
  665. };
  666. /*
  667. * These three variables are used to save values passed to us by prom_init()
  668. * via the device tree. The TCE variables are needed because with a memory_limit
  669. * in force we may need to explicitly map the TCE are at the top of RAM.
  670. */
  671. unsigned long memory_limit;
  672. unsigned long tce_alloc_start;
  673. unsigned long tce_alloc_end;
  674. #ifdef CONFIG_PPC_ISERIES
  675. /*
  676. * On iSeries we just parse the mem=X option from the command line.
  677. * On pSeries it's a bit more complicated, see prom_init_mem()
  678. */
  679. static int __init early_parsemem(char *p)
  680. {
  681. if (!p)
  682. return 0;
  683. memory_limit = ALIGN(memparse(p, &p), PAGE_SIZE);
  684. return 0;
  685. }
  686. early_param("mem", early_parsemem);
  687. #endif /* CONFIG_PPC_ISERIES */
  688. #ifdef CONFIG_PPC_MULTIPLATFORM
  689. static int __init set_preferred_console(void)
  690. {
  691. struct device_node *prom_stdout = NULL;
  692. char *name;
  693. u32 *spd;
  694. int offset = 0;
  695. DBG(" -> set_preferred_console()\n");
  696. /* The user has requested a console so this is already set up. */
  697. if (strstr(saved_command_line, "console=")) {
  698. DBG(" console was specified !\n");
  699. return -EBUSY;
  700. }
  701. if (!of_chosen) {
  702. DBG(" of_chosen is NULL !\n");
  703. return -ENODEV;
  704. }
  705. /* We are getting a weird phandle from OF ... */
  706. /* ... So use the full path instead */
  707. name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
  708. if (name == NULL) {
  709. DBG(" no linux,stdout-path !\n");
  710. return -ENODEV;
  711. }
  712. prom_stdout = of_find_node_by_path(name);
  713. if (!prom_stdout) {
  714. DBG(" can't find stdout package %s !\n", name);
  715. return -ENODEV;
  716. }
  717. DBG("stdout is %s\n", prom_stdout->full_name);
  718. name = (char *)get_property(prom_stdout, "name", NULL);
  719. if (!name) {
  720. DBG(" stdout package has no name !\n");
  721. goto not_found;
  722. }
  723. spd = (u32 *)get_property(prom_stdout, "current-speed", NULL);
  724. if (0)
  725. ;
  726. #ifdef CONFIG_SERIAL_8250_CONSOLE
  727. else if (strcmp(name, "serial") == 0) {
  728. int i;
  729. u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
  730. if (i > 8) {
  731. switch (reg[1]) {
  732. case 0x3f8:
  733. offset = 0;
  734. break;
  735. case 0x2f8:
  736. offset = 1;
  737. break;
  738. case 0x898:
  739. offset = 2;
  740. break;
  741. case 0x890:
  742. offset = 3;
  743. break;
  744. default:
  745. /* We dont recognise the serial port */
  746. goto not_found;
  747. }
  748. }
  749. }
  750. #endif /* CONFIG_SERIAL_8250_CONSOLE */
  751. #ifdef CONFIG_PPC_PSERIES
  752. else if (strcmp(name, "vty") == 0) {
  753. u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL);
  754. char *compat = (char *)get_property(prom_stdout, "compatible", NULL);
  755. if (reg && compat && (strcmp(compat, "hvterm-protocol") == 0)) {
  756. /* Host Virtual Serial Interface */
  757. int offset;
  758. switch (reg[0]) {
  759. case 0x30000000:
  760. offset = 0;
  761. break;
  762. case 0x30000001:
  763. offset = 1;
  764. break;
  765. default:
  766. goto not_found;
  767. }
  768. of_node_put(prom_stdout);
  769. DBG("Found hvsi console at offset %d\n", offset);
  770. return add_preferred_console("hvsi", offset, NULL);
  771. } else {
  772. /* pSeries LPAR virtual console */
  773. of_node_put(prom_stdout);
  774. DBG("Found hvc console\n");
  775. return add_preferred_console("hvc", 0, NULL);
  776. }
  777. }
  778. #endif /* CONFIG_PPC_PSERIES */
  779. #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
  780. else if (strcmp(name, "ch-a") == 0)
  781. offset = 0;
  782. else if (strcmp(name, "ch-b") == 0)
  783. offset = 1;
  784. #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
  785. else
  786. goto not_found;
  787. of_node_put(prom_stdout);
  788. DBG("Found serial console at ttyS%d\n", offset);
  789. if (spd) {
  790. static char __initdata opt[16];
  791. sprintf(opt, "%d", *spd);
  792. return add_preferred_console("ttyS", offset, opt);
  793. } else
  794. return add_preferred_console("ttyS", offset, NULL);
  795. not_found:
  796. DBG("No preferred console found !\n");
  797. of_node_put(prom_stdout);
  798. return -ENODEV;
  799. }
  800. console_initcall(set_preferred_console);
  801. #endif /* CONFIG_PPC_MULTIPLATFORM */
  802. #ifdef CONFIG_IRQSTACKS
  803. static void __init irqstack_early_init(void)
  804. {
  805. unsigned int i;
  806. /*
  807. * interrupt stacks must be under 256MB, we cannot afford to take
  808. * SLB misses on them.
  809. */
  810. for_each_cpu(i) {
  811. softirq_ctx[i] = (struct thread_info *)__va(lmb_alloc_base(THREAD_SIZE,
  812. THREAD_SIZE, 0x10000000));
  813. hardirq_ctx[i] = (struct thread_info *)__va(lmb_alloc_base(THREAD_SIZE,
  814. THREAD_SIZE, 0x10000000));
  815. }
  816. }
  817. #else
  818. #define irqstack_early_init()
  819. #endif
  820. /*
  821. * Stack space used when we detect a bad kernel stack pointer, and
  822. * early in SMP boots before relocation is enabled.
  823. */
  824. static void __init emergency_stack_init(void)
  825. {
  826. unsigned long limit;
  827. unsigned int i;
  828. /*
  829. * Emergency stacks must be under 256MB, we cannot afford to take
  830. * SLB misses on them. The ABI also requires them to be 128-byte
  831. * aligned.
  832. *
  833. * Since we use these as temporary stacks during secondary CPU
  834. * bringup, we need to get at them in real mode. This means they
  835. * must also be within the RMO region.
  836. */
  837. limit = min(0x10000000UL, lmb.rmo_size);
  838. for_each_cpu(i)
  839. paca[i].emergency_sp = __va(lmb_alloc_base(PAGE_SIZE, 128,
  840. limit)) + PAGE_SIZE;
  841. }
  842. /*
  843. * Called from setup_arch to initialize the bitmap of available
  844. * syscalls in the systemcfg page
  845. */
  846. void __init setup_syscall_map(void)
  847. {
  848. unsigned int i, count64 = 0, count32 = 0;
  849. extern unsigned long *sys_call_table;
  850. extern unsigned long *sys_call_table32;
  851. extern unsigned long sys_ni_syscall;
  852. for (i = 0; i < __NR_syscalls; i++) {
  853. if (sys_call_table[i] == sys_ni_syscall)
  854. continue;
  855. count64++;
  856. systemcfg->syscall_map_64[i >> 5] |= 0x80000000UL >> (i & 0x1f);
  857. }
  858. for (i = 0; i < __NR_syscalls; i++) {
  859. if (sys_call_table32[i] == sys_ni_syscall)
  860. continue;
  861. count32++;
  862. systemcfg->syscall_map_32[i >> 5] |= 0x80000000UL >> (i & 0x1f);
  863. }
  864. printk(KERN_INFO "Syscall map setup, %d 32 bits and %d 64 bits syscalls\n",
  865. count32, count64);
  866. }
  867. /*
  868. * Called into from start_kernel, after lock_kernel has been called.
  869. * Initializes bootmem, which is unsed to manage page allocation until
  870. * mem_init is called.
  871. */
  872. void __init setup_arch(char **cmdline_p)
  873. {
  874. extern void do_init_bootmem(void);
  875. ppc64_boot_msg(0x12, "Setup Arch");
  876. *cmdline_p = cmd_line;
  877. /*
  878. * Set cache line size based on type of cpu as a default.
  879. * Systems with OF can look in the properties on the cpu node(s)
  880. * for a possibly more accurate value.
  881. */
  882. dcache_bsize = ppc64_caches.dline_size;
  883. icache_bsize = ppc64_caches.iline_size;
  884. /* reboot on panic */
  885. panic_timeout = 180;
  886. if (ppc_md.panic)
  887. notifier_chain_register(&panic_notifier_list, &ppc64_panic_block);
  888. init_mm.start_code = PAGE_OFFSET;
  889. init_mm.end_code = (unsigned long) _etext;
  890. init_mm.end_data = (unsigned long) _edata;
  891. init_mm.brk = klimit;
  892. irqstack_early_init();
  893. emergency_stack_init();
  894. /* set up the bootmem stuff with available memory */
  895. do_init_bootmem();
  896. /* initialize the syscall map in systemcfg */
  897. setup_syscall_map();
  898. ppc_md.setup_arch();
  899. /* Select the correct idle loop for the platform. */
  900. idle_setup();
  901. paging_init();
  902. ppc64_boot_msg(0x15, "Setup Done");
  903. }
  904. /* ToDo: do something useful if ppc_md is not yet setup. */
  905. #define PPC64_LINUX_FUNCTION 0x0f000000
  906. #define PPC64_IPL_MESSAGE 0xc0000000
  907. #define PPC64_TERM_MESSAGE 0xb0000000
  908. #define PPC64_ATTN_MESSAGE 0xa0000000
  909. #define PPC64_DUMP_MESSAGE 0xd0000000
  910. static void ppc64_do_msg(unsigned int src, const char *msg)
  911. {
  912. if (ppc_md.progress) {
  913. char buf[32];
  914. sprintf(buf, "%08x \n", src);
  915. ppc_md.progress(buf, 0);
  916. sprintf(buf, "%-16s", msg);
  917. ppc_md.progress(buf, 0);
  918. }
  919. }
  920. /* Print a boot progress message. */
  921. void ppc64_boot_msg(unsigned int src, const char *msg)
  922. {
  923. ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_IPL_MESSAGE|src, msg);
  924. printk("[boot]%04x %s\n", src, msg);
  925. }
  926. /* Print a termination message (print only -- does not stop the kernel) */
  927. void ppc64_terminate_msg(unsigned int src, const char *msg)
  928. {
  929. ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);
  930. printk("[terminate]%04x %s\n", src, msg);
  931. }
  932. /* Print something that needs attention (device error, etc) */
  933. void ppc64_attention_msg(unsigned int src, const char *msg)
  934. {
  935. ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);
  936. printk("[attention]%04x %s\n", src, msg);
  937. }
  938. /* Print a dump progress message. */
  939. void ppc64_dump_msg(unsigned int src, const char *msg)
  940. {
  941. ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);
  942. printk("[dump]%04x %s\n", src, msg);
  943. }
  944. /* This should only be called on processor 0 during calibrate decr */
  945. void setup_default_decr(void)
  946. {
  947. struct paca_struct *lpaca = get_paca();
  948. lpaca->default_decr = tb_ticks_per_jiffy;
  949. lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy;
  950. }
  951. #ifndef CONFIG_PPC_ISERIES
  952. /*
  953. * This function can be used by platforms to "find" legacy serial ports.
  954. * It works for "serial" nodes under an "isa" node, and will try to
  955. * respect the "ibm,aix-loc" property if any. It works with up to 8
  956. * ports.
  957. */
  958. #define MAX_LEGACY_SERIAL_PORTS 8
  959. static struct plat_serial8250_port serial_ports[MAX_LEGACY_SERIAL_PORTS+1];
  960. static unsigned int old_serial_count;
  961. void __init generic_find_legacy_serial_ports(u64 *physport,
  962. unsigned int *default_speed)
  963. {
  964. struct device_node *np;
  965. u32 *sizeprop;
  966. struct isa_reg_property {
  967. u32 space;
  968. u32 address;
  969. u32 size;
  970. };
  971. struct pci_reg_property {
  972. struct pci_address addr;
  973. u32 size_hi;
  974. u32 size_lo;
  975. };
  976. DBG(" -> generic_find_legacy_serial_port()\n");
  977. *physport = 0;
  978. if (default_speed)
  979. *default_speed = 0;
  980. np = of_find_node_by_path("/");
  981. if (!np)
  982. return;
  983. /* First fill our array */
  984. for (np = NULL; (np = of_find_node_by_type(np, "serial"));) {
  985. struct device_node *isa, *pci;
  986. struct isa_reg_property *reg;
  987. unsigned long phys_size, addr_size, io_base;
  988. u32 *rangesp;
  989. u32 *interrupts, *clk, *spd;
  990. char *typep;
  991. int index, rlen, rentsize;
  992. /* Ok, first check if it's under an "isa" parent */
  993. isa = of_get_parent(np);
  994. if (!isa || strcmp(isa->name, "isa")) {
  995. DBG("%s: no isa parent found\n", np->full_name);
  996. continue;
  997. }
  998. /* Now look for an "ibm,aix-loc" property that gives us ordering
  999. * if any...
  1000. */
  1001. typep = (char *)get_property(np, "ibm,aix-loc", NULL);
  1002. /* Get the ISA port number */
  1003. reg = (struct isa_reg_property *)get_property(np, "reg", NULL);
  1004. if (reg == NULL)
  1005. goto next_port;
  1006. /* We assume the interrupt number isn't translated ... */
  1007. interrupts = (u32 *)get_property(np, "interrupts", NULL);
  1008. /* get clock freq. if present */
  1009. clk = (u32 *)get_property(np, "clock-frequency", NULL);
  1010. /* get default speed if present */
  1011. spd = (u32 *)get_property(np, "current-speed", NULL);
  1012. /* Default to locate at end of array */
  1013. index = old_serial_count; /* end of the array by default */
  1014. /* If we have a location index, then use it */
  1015. if (typep && *typep == 'S') {
  1016. index = simple_strtol(typep+1, NULL, 0) - 1;
  1017. /* if index is out of range, use end of array instead */
  1018. if (index >= MAX_LEGACY_SERIAL_PORTS)
  1019. index = old_serial_count;
  1020. /* if our index is still out of range, that mean that
  1021. * array is full, we could scan for a free slot but that
  1022. * make little sense to bother, just skip the port
  1023. */
  1024. if (index >= MAX_LEGACY_SERIAL_PORTS)
  1025. goto next_port;
  1026. if (index >= old_serial_count)
  1027. old_serial_count = index + 1;
  1028. /* Check if there is a port who already claimed our slot */
  1029. if (serial_ports[index].iobase != 0) {
  1030. /* if we still have some room, move it, else override */
  1031. if (old_serial_count < MAX_LEGACY_SERIAL_PORTS) {
  1032. DBG("Moved legacy port %d -> %d\n", index,
  1033. old_serial_count);
  1034. serial_ports[old_serial_count++] =
  1035. serial_ports[index];
  1036. } else {
  1037. DBG("Replacing legacy port %d\n", index);
  1038. }
  1039. }
  1040. }
  1041. if (index >= MAX_LEGACY_SERIAL_PORTS)
  1042. goto next_port;
  1043. if (index >= old_serial_count)
  1044. old_serial_count = index + 1;
  1045. /* Now fill the entry */
  1046. memset(&serial_ports[index], 0, sizeof(struct plat_serial8250_port));
  1047. serial_ports[index].uartclk = clk ? *clk : BASE_BAUD * 16;
  1048. serial_ports[index].iobase = reg->address;
  1049. serial_ports[index].irq = interrupts ? interrupts[0] : 0;
  1050. serial_ports[index].flags = ASYNC_BOOT_AUTOCONF;
  1051. DBG("Added legacy port, index: %d, port: %x, irq: %d, clk: %d\n",
  1052. index,
  1053. serial_ports[index].iobase,
  1054. serial_ports[index].irq,
  1055. serial_ports[index].uartclk);
  1056. /* Get phys address of IO reg for port 1 */
  1057. if (index != 0)
  1058. goto next_port;
  1059. pci = of_get_parent(isa);
  1060. if (!pci) {
  1061. DBG("%s: no pci parent found\n", np->full_name);
  1062. goto next_port;
  1063. }
  1064. rangesp = (u32 *)get_property(pci, "ranges", &rlen);
  1065. if (rangesp == NULL) {
  1066. of_node_put(pci);
  1067. goto next_port;
  1068. }
  1069. rlen /= 4;
  1070. /* we need the #size-cells of the PCI bridge node itself */
  1071. phys_size = 1;
  1072. sizeprop = (u32 *)get_property(pci, "#size-cells", NULL);
  1073. if (sizeprop != NULL)
  1074. phys_size = *sizeprop;
  1075. /* we need the parent #addr-cells */
  1076. addr_size = prom_n_addr_cells(pci);
  1077. rentsize = 3 + addr_size + phys_size;
  1078. io_base = 0;
  1079. for (;rlen >= rentsize; rlen -= rentsize,rangesp += rentsize) {
  1080. if (((rangesp[0] >> 24) & 0x3) != 1)
  1081. continue; /* not IO space */
  1082. io_base = rangesp[3];
  1083. if (addr_size == 2)
  1084. io_base = (io_base << 32) | rangesp[4];
  1085. }
  1086. if (io_base != 0) {
  1087. *physport = io_base + reg->address;
  1088. if (default_speed && spd)
  1089. *default_speed = *spd;
  1090. }
  1091. of_node_put(pci);
  1092. next_port:
  1093. of_node_put(isa);
  1094. }
  1095. DBG(" <- generic_find_legacy_serial_port()\n");
  1096. }
  1097. static struct platform_device serial_device = {
  1098. .name = "serial8250",
  1099. .id = 0,
  1100. .dev = {
  1101. .platform_data = serial_ports,
  1102. },
  1103. };
  1104. static int __init serial_dev_init(void)
  1105. {
  1106. return platform_device_register(&serial_device);
  1107. }
  1108. arch_initcall(serial_dev_init);
  1109. #endif /* CONFIG_PPC_ISERIES */
  1110. int check_legacy_ioport(unsigned long base_port)
  1111. {
  1112. if (ppc_md.check_legacy_ioport == NULL)
  1113. return 0;
  1114. return ppc_md.check_legacy_ioport(base_port);
  1115. }
  1116. EXPORT_SYMBOL(check_legacy_ioport);
  1117. #ifdef CONFIG_XMON
  1118. static int __init early_xmon(char *p)
  1119. {
  1120. /* ensure xmon is enabled */
  1121. if (p) {
  1122. if (strncmp(p, "on", 2) == 0)
  1123. xmon_init();
  1124. if (strncmp(p, "early", 5) != 0)
  1125. return 0;
  1126. }
  1127. xmon_init();
  1128. debugger(NULL);
  1129. return 0;
  1130. }
  1131. early_param("xmon", early_xmon);
  1132. #endif
  1133. void cpu_die(void)
  1134. {
  1135. if (ppc_md.cpu_die)
  1136. ppc_md.cpu_die();
  1137. }