setup.c 34 KB

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