setup-common.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. * Common boot and setup code for both 32-bit and 64-bit.
  3. * Extracted from arch/powerpc/kernel/setup_64.c.
  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/export.h>
  14. #include <linux/string.h>
  15. #include <linux/sched.h>
  16. #include <linux/init.h>
  17. #include <linux/kernel.h>
  18. #include <linux/reboot.h>
  19. #include <linux/delay.h>
  20. #include <linux/initrd.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/ioport.h>
  24. #include <linux/console.h>
  25. #include <linux/screen_info.h>
  26. #include <linux/root_dev.h>
  27. #include <linux/notifier.h>
  28. #include <linux/cpu.h>
  29. #include <linux/unistd.h>
  30. #include <linux/serial.h>
  31. #include <linux/serial_8250.h>
  32. #include <linux/debugfs.h>
  33. #include <linux/percpu.h>
  34. #include <linux/memblock.h>
  35. #include <linux/of_platform.h>
  36. #include <asm/io.h>
  37. #include <asm/paca.h>
  38. #include <asm/prom.h>
  39. #include <asm/processor.h>
  40. #include <asm/vdso_datapage.h>
  41. #include <asm/pgtable.h>
  42. #include <asm/smp.h>
  43. #include <asm/elf.h>
  44. #include <asm/machdep.h>
  45. #include <asm/time.h>
  46. #include <asm/cputable.h>
  47. #include <asm/sections.h>
  48. #include <asm/firmware.h>
  49. #include <asm/btext.h>
  50. #include <asm/nvram.h>
  51. #include <asm/setup.h>
  52. #include <asm/rtas.h>
  53. #include <asm/iommu.h>
  54. #include <asm/serial.h>
  55. #include <asm/cache.h>
  56. #include <asm/page.h>
  57. #include <asm/mmu.h>
  58. #include <asm/xmon.h>
  59. #include <asm/cputhreads.h>
  60. #include <mm/mmu_decl.h>
  61. #include <asm/fadump.h>
  62. #include "setup.h"
  63. #ifdef DEBUG
  64. #include <asm/udbg.h>
  65. #define DBG(fmt...) udbg_printf(fmt)
  66. #else
  67. #define DBG(fmt...)
  68. #endif
  69. /* The main machine-dep calls structure
  70. */
  71. struct machdep_calls ppc_md;
  72. EXPORT_SYMBOL(ppc_md);
  73. struct machdep_calls *machine_id;
  74. EXPORT_SYMBOL(machine_id);
  75. unsigned long klimit = (unsigned long) _end;
  76. char cmd_line[COMMAND_LINE_SIZE];
  77. /*
  78. * This still seems to be needed... -- paulus
  79. */
  80. struct screen_info screen_info = {
  81. .orig_x = 0,
  82. .orig_y = 25,
  83. .orig_video_cols = 80,
  84. .orig_video_lines = 25,
  85. .orig_video_isVGA = 1,
  86. .orig_video_points = 16
  87. };
  88. /* Variables required to store legacy IO irq routing */
  89. int of_i8042_kbd_irq;
  90. EXPORT_SYMBOL_GPL(of_i8042_kbd_irq);
  91. int of_i8042_aux_irq;
  92. EXPORT_SYMBOL_GPL(of_i8042_aux_irq);
  93. #ifdef __DO_IRQ_CANON
  94. /* XXX should go elsewhere eventually */
  95. int ppc_do_canonicalize_irqs;
  96. EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
  97. #endif
  98. /* also used by kexec */
  99. void machine_shutdown(void)
  100. {
  101. #ifdef CONFIG_FA_DUMP
  102. /*
  103. * if fadump is active, cleanup the fadump registration before we
  104. * shutdown.
  105. */
  106. fadump_cleanup();
  107. #endif
  108. if (ppc_md.machine_shutdown)
  109. ppc_md.machine_shutdown();
  110. }
  111. void machine_restart(char *cmd)
  112. {
  113. machine_shutdown();
  114. if (ppc_md.restart)
  115. ppc_md.restart(cmd);
  116. #ifdef CONFIG_SMP
  117. smp_send_stop();
  118. #endif
  119. printk(KERN_EMERG "System Halted, OK to turn off power\n");
  120. local_irq_disable();
  121. while (1) ;
  122. }
  123. void machine_power_off(void)
  124. {
  125. machine_shutdown();
  126. if (ppc_md.power_off)
  127. ppc_md.power_off();
  128. #ifdef CONFIG_SMP
  129. smp_send_stop();
  130. #endif
  131. printk(KERN_EMERG "System Halted, OK to turn off power\n");
  132. local_irq_disable();
  133. while (1) ;
  134. }
  135. /* Used by the G5 thermal driver */
  136. EXPORT_SYMBOL_GPL(machine_power_off);
  137. void (*pm_power_off)(void) = machine_power_off;
  138. EXPORT_SYMBOL_GPL(pm_power_off);
  139. void machine_halt(void)
  140. {
  141. machine_shutdown();
  142. if (ppc_md.halt)
  143. ppc_md.halt();
  144. #ifdef CONFIG_SMP
  145. smp_send_stop();
  146. #endif
  147. printk(KERN_EMERG "System Halted, OK to turn off power\n");
  148. local_irq_disable();
  149. while (1) ;
  150. }
  151. #ifdef CONFIG_TAU
  152. extern u32 cpu_temp(unsigned long cpu);
  153. extern u32 cpu_temp_both(unsigned long cpu);
  154. #endif /* CONFIG_TAU */
  155. #ifdef CONFIG_SMP
  156. DEFINE_PER_CPU(unsigned int, cpu_pvr);
  157. #endif
  158. static void show_cpuinfo_summary(struct seq_file *m)
  159. {
  160. struct device_node *root;
  161. const char *model = NULL;
  162. #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
  163. unsigned long bogosum = 0;
  164. int i;
  165. for_each_online_cpu(i)
  166. bogosum += loops_per_jiffy;
  167. seq_printf(m, "total bogomips\t: %lu.%02lu\n",
  168. bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
  169. #endif /* CONFIG_SMP && CONFIG_PPC32 */
  170. seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
  171. if (ppc_md.name)
  172. seq_printf(m, "platform\t: %s\n", ppc_md.name);
  173. root = of_find_node_by_path("/");
  174. if (root)
  175. model = of_get_property(root, "model", NULL);
  176. if (model)
  177. seq_printf(m, "model\t\t: %s\n", model);
  178. of_node_put(root);
  179. if (ppc_md.show_cpuinfo != NULL)
  180. ppc_md.show_cpuinfo(m);
  181. #ifdef CONFIG_PPC32
  182. /* Display the amount of memory */
  183. seq_printf(m, "Memory\t\t: %d MB\n",
  184. (unsigned int)(total_memory / (1024 * 1024)));
  185. #endif
  186. }
  187. static int show_cpuinfo(struct seq_file *m, void *v)
  188. {
  189. unsigned long cpu_id = (unsigned long)v - 1;
  190. unsigned int pvr;
  191. unsigned short maj;
  192. unsigned short min;
  193. /* We only show online cpus: disable preempt (overzealous, I
  194. * knew) to prevent cpu going down. */
  195. preempt_disable();
  196. if (!cpu_online(cpu_id)) {
  197. preempt_enable();
  198. return 0;
  199. }
  200. #ifdef CONFIG_SMP
  201. pvr = per_cpu(cpu_pvr, cpu_id);
  202. #else
  203. pvr = mfspr(SPRN_PVR);
  204. #endif
  205. maj = (pvr >> 8) & 0xFF;
  206. min = pvr & 0xFF;
  207. seq_printf(m, "processor\t: %lu\n", cpu_id);
  208. seq_printf(m, "cpu\t\t: ");
  209. if (cur_cpu_spec->pvr_mask)
  210. seq_printf(m, "%s", cur_cpu_spec->cpu_name);
  211. else
  212. seq_printf(m, "unknown (%08x)", pvr);
  213. #ifdef CONFIG_ALTIVEC
  214. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  215. seq_printf(m, ", altivec supported");
  216. #endif /* CONFIG_ALTIVEC */
  217. seq_printf(m, "\n");
  218. #ifdef CONFIG_TAU
  219. if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) {
  220. #ifdef CONFIG_TAU_AVERAGE
  221. /* more straightforward, but potentially misleading */
  222. seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
  223. cpu_temp(cpu_id));
  224. #else
  225. /* show the actual temp sensor range */
  226. u32 temp;
  227. temp = cpu_temp_both(cpu_id);
  228. seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
  229. temp & 0xff, temp >> 16);
  230. #endif
  231. }
  232. #endif /* CONFIG_TAU */
  233. /*
  234. * Assume here that all clock rates are the same in a
  235. * smp system. -- Cort
  236. */
  237. if (ppc_proc_freq)
  238. seq_printf(m, "clock\t\t: %lu.%06luMHz\n",
  239. ppc_proc_freq / 1000000, ppc_proc_freq % 1000000);
  240. if (ppc_md.show_percpuinfo != NULL)
  241. ppc_md.show_percpuinfo(m, cpu_id);
  242. /* If we are a Freescale core do a simple check so
  243. * we dont have to keep adding cases in the future */
  244. if (PVR_VER(pvr) & 0x8000) {
  245. switch (PVR_VER(pvr)) {
  246. case 0x8000: /* 7441/7450/7451, Voyager */
  247. case 0x8001: /* 7445/7455, Apollo 6 */
  248. case 0x8002: /* 7447/7457, Apollo 7 */
  249. case 0x8003: /* 7447A, Apollo 7 PM */
  250. case 0x8004: /* 7448, Apollo 8 */
  251. case 0x800c: /* 7410, Nitro */
  252. maj = ((pvr >> 8) & 0xF);
  253. min = PVR_MIN(pvr);
  254. break;
  255. default: /* e500/book-e */
  256. maj = PVR_MAJ(pvr);
  257. min = PVR_MIN(pvr);
  258. break;
  259. }
  260. } else {
  261. switch (PVR_VER(pvr)) {
  262. case 0x0020: /* 403 family */
  263. maj = PVR_MAJ(pvr) + 1;
  264. min = PVR_MIN(pvr);
  265. break;
  266. case 0x1008: /* 740P/750P ?? */
  267. maj = ((pvr >> 8) & 0xFF) - 1;
  268. min = pvr & 0xFF;
  269. break;
  270. default:
  271. maj = (pvr >> 8) & 0xFF;
  272. min = pvr & 0xFF;
  273. break;
  274. }
  275. }
  276. seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
  277. maj, min, PVR_VER(pvr), PVR_REV(pvr));
  278. #ifdef CONFIG_PPC32
  279. seq_printf(m, "bogomips\t: %lu.%02lu\n",
  280. loops_per_jiffy / (500000/HZ),
  281. (loops_per_jiffy / (5000/HZ)) % 100);
  282. #endif
  283. #ifdef CONFIG_SMP
  284. seq_printf(m, "\n");
  285. #endif
  286. preempt_enable();
  287. /* If this is the last cpu, print the summary */
  288. if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
  289. show_cpuinfo_summary(m);
  290. return 0;
  291. }
  292. static void *c_start(struct seq_file *m, loff_t *pos)
  293. {
  294. if (*pos == 0) /* just in case, cpu 0 is not the first */
  295. *pos = cpumask_first(cpu_online_mask);
  296. else
  297. *pos = cpumask_next(*pos - 1, cpu_online_mask);
  298. if ((*pos) < nr_cpu_ids)
  299. return (void *)(unsigned long)(*pos + 1);
  300. return NULL;
  301. }
  302. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  303. {
  304. (*pos)++;
  305. return c_start(m, pos);
  306. }
  307. static void c_stop(struct seq_file *m, void *v)
  308. {
  309. }
  310. const struct seq_operations cpuinfo_op = {
  311. .start =c_start,
  312. .next = c_next,
  313. .stop = c_stop,
  314. .show = show_cpuinfo,
  315. };
  316. void __init check_for_initrd(void)
  317. {
  318. #ifdef CONFIG_BLK_DEV_INITRD
  319. DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
  320. initrd_start, initrd_end);
  321. /* If we were passed an initrd, set the ROOT_DEV properly if the values
  322. * look sensible. If not, clear initrd reference.
  323. */
  324. if (is_kernel_addr(initrd_start) && is_kernel_addr(initrd_end) &&
  325. initrd_end > initrd_start)
  326. ROOT_DEV = Root_RAM0;
  327. else
  328. initrd_start = initrd_end = 0;
  329. if (initrd_start)
  330. printk("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end);
  331. DBG(" <- check_for_initrd()\n");
  332. #endif /* CONFIG_BLK_DEV_INITRD */
  333. }
  334. #ifdef CONFIG_SMP
  335. int threads_per_core, threads_shift;
  336. cpumask_t threads_core_mask;
  337. EXPORT_SYMBOL_GPL(threads_per_core);
  338. EXPORT_SYMBOL_GPL(threads_shift);
  339. EXPORT_SYMBOL_GPL(threads_core_mask);
  340. static void __init cpu_init_thread_core_maps(int tpc)
  341. {
  342. int i;
  343. threads_per_core = tpc;
  344. cpumask_clear(&threads_core_mask);
  345. /* This implementation only supports power of 2 number of threads
  346. * for simplicity and performance
  347. */
  348. threads_shift = ilog2(tpc);
  349. BUG_ON(tpc != (1 << threads_shift));
  350. for (i = 0; i < tpc; i++)
  351. cpumask_set_cpu(i, &threads_core_mask);
  352. printk(KERN_INFO "CPU maps initialized for %d thread%s per core\n",
  353. tpc, tpc > 1 ? "s" : "");
  354. printk(KERN_DEBUG " (thread shift is %d)\n", threads_shift);
  355. }
  356. /**
  357. * setup_cpu_maps - initialize the following cpu maps:
  358. * cpu_possible_mask
  359. * cpu_present_mask
  360. *
  361. * Having the possible map set up early allows us to restrict allocations
  362. * of things like irqstacks to nr_cpu_ids rather than NR_CPUS.
  363. *
  364. * We do not initialize the online map here; cpus set their own bits in
  365. * cpu_online_mask as they come up.
  366. *
  367. * This function is valid only for Open Firmware systems. finish_device_tree
  368. * must be called before using this.
  369. *
  370. * While we're here, we may as well set the "physical" cpu ids in the paca.
  371. *
  372. * NOTE: This must match the parsing done in early_init_dt_scan_cpus.
  373. */
  374. void __init smp_setup_cpu_maps(void)
  375. {
  376. struct device_node *dn = NULL;
  377. int cpu = 0;
  378. int nthreads = 1;
  379. DBG("smp_setup_cpu_maps()\n");
  380. while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < nr_cpu_ids) {
  381. const int *intserv;
  382. int j, len;
  383. DBG(" * %s...\n", dn->full_name);
  384. intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
  385. &len);
  386. if (intserv) {
  387. nthreads = len / sizeof(int);
  388. DBG(" ibm,ppc-interrupt-server#s -> %d threads\n",
  389. nthreads);
  390. } else {
  391. DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n");
  392. intserv = of_get_property(dn, "reg", NULL);
  393. if (!intserv)
  394. intserv = &cpu; /* assume logical == phys */
  395. }
  396. for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
  397. DBG(" thread %d -> cpu %d (hard id %d)\n",
  398. j, cpu, intserv[j]);
  399. set_cpu_present(cpu, true);
  400. set_hard_smp_processor_id(cpu, intserv[j]);
  401. set_cpu_possible(cpu, true);
  402. cpu++;
  403. }
  404. }
  405. /* If no SMT supported, nthreads is forced to 1 */
  406. if (!cpu_has_feature(CPU_FTR_SMT)) {
  407. DBG(" SMT disabled ! nthreads forced to 1\n");
  408. nthreads = 1;
  409. }
  410. #ifdef CONFIG_PPC64
  411. /*
  412. * On pSeries LPAR, we need to know how many cpus
  413. * could possibly be added to this partition.
  414. */
  415. if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) &&
  416. (dn = of_find_node_by_path("/rtas"))) {
  417. int num_addr_cell, num_size_cell, maxcpus;
  418. const unsigned int *ireg;
  419. num_addr_cell = of_n_addr_cells(dn);
  420. num_size_cell = of_n_size_cells(dn);
  421. ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
  422. if (!ireg)
  423. goto out;
  424. maxcpus = ireg[num_addr_cell + num_size_cell];
  425. /* Double maxcpus for processors which have SMT capability */
  426. if (cpu_has_feature(CPU_FTR_SMT))
  427. maxcpus *= nthreads;
  428. if (maxcpus > nr_cpu_ids) {
  429. printk(KERN_WARNING
  430. "Partition configured for %d cpus, "
  431. "operating system maximum is %d.\n",
  432. maxcpus, nr_cpu_ids);
  433. maxcpus = nr_cpu_ids;
  434. } else
  435. printk(KERN_INFO "Partition configured for %d cpus.\n",
  436. maxcpus);
  437. for (cpu = 0; cpu < maxcpus; cpu++)
  438. set_cpu_possible(cpu, true);
  439. out:
  440. of_node_put(dn);
  441. }
  442. vdso_data->processorCount = num_present_cpus();
  443. #endif /* CONFIG_PPC64 */
  444. /* Initialize CPU <=> thread mapping/
  445. *
  446. * WARNING: We assume that the number of threads is the same for
  447. * every CPU in the system. If that is not the case, then some code
  448. * here will have to be reworked
  449. */
  450. cpu_init_thread_core_maps(nthreads);
  451. /* Now that possible cpus are set, set nr_cpu_ids for later use */
  452. setup_nr_cpu_ids();
  453. free_unused_pacas();
  454. }
  455. #endif /* CONFIG_SMP */
  456. #ifdef CONFIG_PCSPKR_PLATFORM
  457. static __init int add_pcspkr(void)
  458. {
  459. struct device_node *np;
  460. struct platform_device *pd;
  461. int ret;
  462. np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
  463. of_node_put(np);
  464. if (!np)
  465. return -ENODEV;
  466. pd = platform_device_alloc("pcspkr", -1);
  467. if (!pd)
  468. return -ENOMEM;
  469. ret = platform_device_add(pd);
  470. if (ret)
  471. platform_device_put(pd);
  472. return ret;
  473. }
  474. device_initcall(add_pcspkr);
  475. #endif /* CONFIG_PCSPKR_PLATFORM */
  476. void probe_machine(void)
  477. {
  478. extern struct machdep_calls __machine_desc_start;
  479. extern struct machdep_calls __machine_desc_end;
  480. /*
  481. * Iterate all ppc_md structures until we find the proper
  482. * one for the current machine type
  483. */
  484. DBG("Probing machine type ...\n");
  485. for (machine_id = &__machine_desc_start;
  486. machine_id < &__machine_desc_end;
  487. machine_id++) {
  488. DBG(" %s ...", machine_id->name);
  489. memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
  490. if (ppc_md.probe()) {
  491. DBG(" match !\n");
  492. break;
  493. }
  494. DBG("\n");
  495. }
  496. /* What can we do if we didn't find ? */
  497. if (machine_id >= &__machine_desc_end) {
  498. DBG("No suitable machine found !\n");
  499. for (;;);
  500. }
  501. printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
  502. }
  503. /* Match a class of boards, not a specific device configuration. */
  504. int check_legacy_ioport(unsigned long base_port)
  505. {
  506. struct device_node *parent, *np = NULL;
  507. int ret = -ENODEV;
  508. switch(base_port) {
  509. case I8042_DATA_REG:
  510. if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
  511. np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
  512. if (np) {
  513. parent = of_get_parent(np);
  514. of_i8042_kbd_irq = irq_of_parse_and_map(parent, 0);
  515. if (!of_i8042_kbd_irq)
  516. of_i8042_kbd_irq = 1;
  517. of_i8042_aux_irq = irq_of_parse_and_map(parent, 1);
  518. if (!of_i8042_aux_irq)
  519. of_i8042_aux_irq = 12;
  520. of_node_put(np);
  521. np = parent;
  522. break;
  523. }
  524. np = of_find_node_by_type(NULL, "8042");
  525. /* Pegasos has no device_type on its 8042 node, look for the
  526. * name instead */
  527. if (!np)
  528. np = of_find_node_by_name(NULL, "8042");
  529. if (np) {
  530. of_i8042_kbd_irq = 1;
  531. of_i8042_aux_irq = 12;
  532. }
  533. break;
  534. case FDC_BASE: /* FDC1 */
  535. np = of_find_node_by_type(NULL, "fdc");
  536. break;
  537. #ifdef CONFIG_PPC_PREP
  538. case _PIDXR:
  539. case _PNPWRP:
  540. case PNPBIOS_BASE:
  541. /* implement me */
  542. #endif
  543. default:
  544. /* ipmi is supposed to fail here */
  545. break;
  546. }
  547. if (!np)
  548. return ret;
  549. parent = of_get_parent(np);
  550. if (parent) {
  551. if (strcmp(parent->type, "isa") == 0)
  552. ret = 0;
  553. of_node_put(parent);
  554. }
  555. of_node_put(np);
  556. return ret;
  557. }
  558. EXPORT_SYMBOL(check_legacy_ioport);
  559. static int ppc_panic_event(struct notifier_block *this,
  560. unsigned long event, void *ptr)
  561. {
  562. /*
  563. * If firmware-assisted dump has been registered then trigger
  564. * firmware-assisted dump and let firmware handle everything else.
  565. */
  566. crash_fadump(NULL, ptr);
  567. ppc_md.panic(ptr); /* May not return */
  568. return NOTIFY_DONE;
  569. }
  570. static struct notifier_block ppc_panic_block = {
  571. .notifier_call = ppc_panic_event,
  572. .priority = INT_MIN /* may not return; must be done last */
  573. };
  574. void __init setup_panic(void)
  575. {
  576. atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
  577. }
  578. #ifdef CONFIG_CHECK_CACHE_COHERENCY
  579. /*
  580. * For platforms that have configurable cache-coherency. This function
  581. * checks that the cache coherency setting of the kernel matches the setting
  582. * left by the firmware, as indicated in the device tree. Since a mismatch
  583. * will eventually result in DMA failures, we print * and error and call
  584. * BUG() in that case.
  585. */
  586. #ifdef CONFIG_NOT_COHERENT_CACHE
  587. #define KERNEL_COHERENCY 0
  588. #else
  589. #define KERNEL_COHERENCY 1
  590. #endif
  591. static int __init check_cache_coherency(void)
  592. {
  593. struct device_node *np;
  594. const void *prop;
  595. int devtree_coherency;
  596. np = of_find_node_by_path("/");
  597. prop = of_get_property(np, "coherency-off", NULL);
  598. of_node_put(np);
  599. devtree_coherency = prop ? 0 : 1;
  600. if (devtree_coherency != KERNEL_COHERENCY) {
  601. printk(KERN_ERR
  602. "kernel coherency:%s != device tree_coherency:%s\n",
  603. KERNEL_COHERENCY ? "on" : "off",
  604. devtree_coherency ? "on" : "off");
  605. BUG();
  606. }
  607. return 0;
  608. }
  609. late_initcall(check_cache_coherency);
  610. #endif /* CONFIG_CHECK_CACHE_COHERENCY */
  611. #ifdef CONFIG_DEBUG_FS
  612. struct dentry *powerpc_debugfs_root;
  613. EXPORT_SYMBOL(powerpc_debugfs_root);
  614. static int powerpc_debugfs_init(void)
  615. {
  616. powerpc_debugfs_root = debugfs_create_dir("powerpc", NULL);
  617. return powerpc_debugfs_root == NULL;
  618. }
  619. arch_initcall(powerpc_debugfs_init);
  620. #endif
  621. void ppc_printk_progress(char *s, unsigned short hex)
  622. {
  623. pr_info("%s\n", s);
  624. }
  625. void arch_setup_pdev_archdata(struct platform_device *pdev)
  626. {
  627. pdev->archdata.dma_mask = DMA_BIT_MASK(32);
  628. pdev->dev.dma_mask = &pdev->archdata.dma_mask;
  629. set_dma_ops(&pdev->dev, &dma_direct_ops);
  630. }