setup-common.c 16 KB

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