setup.c 34 KB

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