setup-common.c 17 KB

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