setup.c 34 KB

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