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