aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/microblaze/Kconfig17
-rw-r--r--arch/microblaze/include/asm/irq.h24
-rw-r--r--arch/microblaze/include/asm/of_device.h44
-rw-r--r--arch/microblaze/include/asm/of_platform.h54
-rw-r--r--arch/microblaze/include/asm/page.h7
-rw-r--r--arch/microblaze/include/asm/pci-bridge.h5
-rw-r--r--arch/microblaze/include/asm/prom.h115
-rw-r--r--arch/microblaze/include/asm/topology.h10
-rw-r--r--arch/microblaze/kernel/Makefile4
-rw-r--r--arch/microblaze/kernel/irq.c14
-rw-r--r--arch/microblaze/kernel/of_device.c112
-rw-r--r--arch/microblaze/kernel/of_platform.c200
-rw-r--r--arch/microblaze/kernel/prom_parse.c877
-rw-r--r--arch/microblaze/kernel/reset.c12
-rw-r--r--arch/microblaze/kernel/setup.c6
-rw-r--r--arch/powerpc/Kconfig18
-rw-r--r--arch/powerpc/include/asm/irq.h28
-rw-r--r--arch/powerpc/include/asm/macio.h2
-rw-r--r--arch/powerpc/include/asm/of_device.h27
-rw-r--r--arch/powerpc/include/asm/of_platform.h29
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h5
-rw-r--r--arch/powerpc/include/asm/prom.h133
-rw-r--r--arch/powerpc/include/asm/smu.h4
-rw-r--r--arch/powerpc/include/asm/topology.h7
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c8
-rw-r--r--arch/powerpc/kernel/ibmebus.c8
-rw-r--r--arch/powerpc/kernel/irq.c14
-rw-r--r--arch/powerpc/kernel/legacy_serial.c1
-rw-r--r--arch/powerpc/kernel/of_device.c133
-rw-r--r--arch/powerpc/kernel/of_platform.c203
-rw-r--r--arch/powerpc/kernel/pci-common.c1
-rw-r--r--arch/powerpc/kernel/prom_parse.c924
-rw-r--r--arch/powerpc/kernel/setup-common.c7
-rw-r--r--arch/powerpc/platforms/512x/clock.c2
-rw-r--r--arch/powerpc/platforms/52xx/lite5200.c1
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_gpio.c36
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_gpt.c33
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c6
-rw-r--r--arch/powerpc/platforms/82xx/ep8248e.c4
-rw-r--r--arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c40
-rw-r--r--arch/powerpc/platforms/83xx/suspend.c6
-rw-r--r--arch/powerpc/platforms/86xx/gef_gpio.c24
-rw-r--r--arch/powerpc/platforms/amigaone/setup.c3
-rw-r--r--arch/powerpc/platforms/cell/axon_msi.c4
-rw-r--r--arch/powerpc/platforms/cell/beat_iommu.c2
-rw-r--r--arch/powerpc/platforms/cell/iommu.c2
-rw-r--r--arch/powerpc/platforms/cell/qpace_setup.c14
-rw-r--r--arch/powerpc/platforms/cell/setup.c14
-rw-r--r--arch/powerpc/platforms/iseries/mf.c1
-rw-r--r--arch/powerpc/platforms/pasemi/gpio_mdio.c4
-rw-r--r--arch/powerpc/platforms/powermac/feature.c2
-rw-r--r--arch/powerpc/platforms/powermac/pic.c72
-rw-r--r--arch/powerpc/sysdev/axonram.c12
-rw-r--r--arch/powerpc/sysdev/bestcomm/bestcomm.c7
-rw-r--r--arch/powerpc/sysdev/bestcomm/sram.c1
-rw-r--r--arch/powerpc/sysdev/cpm1.c10
-rw-r--r--arch/powerpc/sysdev/cpm_common.c5
-rw-r--r--arch/powerpc/sysdev/fsl_gtm.c1
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c4
-rw-r--r--arch/powerpc/sysdev/fsl_pmc.c3
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c4
-rw-r--r--arch/powerpc/sysdev/mpc8xxx_gpio.c5
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c7
-rw-r--r--arch/powerpc/sysdev/pmi.c6
-rw-r--r--arch/powerpc/sysdev/ppc4xx_gpio.c5
-rw-r--r--arch/powerpc/sysdev/qe_lib/gpio.c31
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c5
-rw-r--r--arch/powerpc/sysdev/simple_gpio.c5
-rw-r--r--arch/sparc/Kconfig4
-rw-r--r--arch/sparc/include/asm/device.h11
-rw-r--r--arch/sparc/include/asm/floppy_64.h10
-rw-r--r--arch/sparc/include/asm/of_device.h38
-rw-r--r--arch/sparc/include/asm/of_platform.h18
-rw-r--r--arch/sparc/include/asm/parport.h12
-rw-r--r--arch/sparc/include/asm/prom.h10
-rw-r--r--arch/sparc/kernel/apc.c6
-rw-r--r--arch/sparc/kernel/auxio_64.c5
-rw-r--r--arch/sparc/kernel/central.c8
-rw-r--r--arch/sparc/kernel/chmc.c16
-rw-r--r--arch/sparc/kernel/ioport.c2
-rw-r--r--arch/sparc/kernel/of_device_32.c63
-rw-r--r--arch/sparc/kernel/of_device_64.c61
-rw-r--r--arch/sparc/kernel/of_device_common.c35
-rw-r--r--arch/sparc/kernel/pci.c6
-rw-r--r--arch/sparc/kernel/pci_fire.c6
-rw-r--r--arch/sparc/kernel/pci_impl.h2
-rw-r--r--arch/sparc/kernel/pci_psycho.c16
-rw-r--r--arch/sparc/kernel/pci_sabre.c16
-rw-r--r--arch/sparc/kernel/pci_schizo.c32
-rw-r--r--arch/sparc/kernel/pci_sun4v.c6
-rw-r--r--arch/sparc/kernel/pmc.c4
-rw-r--r--arch/sparc/kernel/power.c6
-rw-r--r--arch/sparc/kernel/prom.h8
-rw-r--r--arch/sparc/kernel/prom_64.c6
-rw-r--r--arch/sparc/kernel/prom_common.c2
-rw-r--r--arch/sparc/kernel/prom_irqtrans.c2
-rw-r--r--arch/sparc/kernel/psycho_common.c2
-rw-r--r--arch/sparc/kernel/psycho_common.h2
-rw-r--r--arch/sparc/kernel/sbus.c16
-rw-r--r--arch/sparc/kernel/time_32.c4
-rw-r--r--arch/sparc/kernel/time_64.c12
-rw-r--r--arch/sparc/mm/io-unit.c4
-rw-r--r--arch/sparc/mm/iommu.c4
104 files changed, 447 insertions, 3444 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index be3855250db6..9bd64b4b2b0c 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -18,6 +18,8 @@ config MICROBLAZE
18 select HAVE_DMA_ATTRS 18 select HAVE_DMA_ATTRS
19 select HAVE_DMA_API_DEBUG 19 select HAVE_DMA_API_DEBUG
20 select TRACING_SUPPORT 20 select TRACING_SUPPORT
21 select OF
22 select OF_FLATTREE
21 23
22config SWAP 24config SWAP
23 def_bool n 25 def_bool n
@@ -76,9 +78,6 @@ config LOCKDEP_SUPPORT
76config HAVE_LATENCYTOP_SUPPORT 78config HAVE_LATENCYTOP_SUPPORT
77 def_bool y 79 def_bool y
78 80
79config DTC
80 def_bool y
81
82source "init/Kconfig" 81source "init/Kconfig"
83 82
84source "kernel/Kconfig.freezer" 83source "kernel/Kconfig.freezer"
@@ -125,18 +124,6 @@ config CMDLINE_FORCE
125 Set this to have arguments from the default kernel command string 124 Set this to have arguments from the default kernel command string
126 override those passed by the boot loader. 125 override those passed by the boot loader.
127 126
128config OF
129 def_bool y
130 select OF_FLATTREE
131
132config PROC_DEVICETREE
133 bool "Support for device tree in /proc"
134 depends on PROC_FS
135 help
136 This option adds a device-tree directory under /proc which contains
137 an image of the device tree that the kernel copies from Open
138 Firmware or other boot firmware. If unsure, say Y here.
139
140endmenu 127endmenu
141 128
142menu "Advanced setup" 129menu "Advanced setup"
diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
index 31a35c33df63..ec5583d6111c 100644
--- a/arch/microblaze/include/asm/irq.h
+++ b/arch/microblaze/include/asm/irq.h
@@ -27,17 +27,6 @@ extern unsigned int nr_irq;
27struct pt_regs; 27struct pt_regs;
28extern void do_IRQ(struct pt_regs *regs); 28extern void do_IRQ(struct pt_regs *regs);
29 29
30/**
31 * irq_of_parse_and_map - Parse and Map an interrupt into linux virq space
32 * @device: Device node of the device whose interrupt is to be mapped
33 * @index: Index of the interrupt to map
34 *
35 * This function is a wrapper that chains of_irq_map_one() and
36 * irq_create_of_mapping() to make things easier to callers
37 */
38struct device_node;
39extern unsigned int irq_of_parse_and_map(struct device_node *dev, int index);
40
41/** FIXME - not implement 30/** FIXME - not implement
42 * irq_dispose_mapping - Unmap an interrupt 31 * irq_dispose_mapping - Unmap an interrupt
43 * @virq: linux virq number of the interrupt to unmap 32 * @virq: linux virq number of the interrupt to unmap
@@ -62,17 +51,4 @@ struct irq_host;
62extern unsigned int irq_create_mapping(struct irq_host *host, 51extern unsigned int irq_create_mapping(struct irq_host *host,
63 irq_hw_number_t hwirq); 52 irq_hw_number_t hwirq);
64 53
65/**
66 * irq_create_of_mapping - Map a hardware interrupt into linux virq space
67 * @controller: Device node of the interrupt controller
68 * @inspec: Interrupt specifier from the device-tree
69 * @intsize: Size of the interrupt specifier from the device-tree
70 *
71 * This function is identical to irq_create_mapping except that it takes
72 * as input informations straight from the device-tree (typically the results
73 * of the of_irq_map_*() functions.
74 */
75extern unsigned int irq_create_of_mapping(struct device_node *controller,
76 u32 *intspec, unsigned int intsize);
77
78#endif /* _ASM_MICROBLAZE_IRQ_H */ 54#endif /* _ASM_MICROBLAZE_IRQ_H */
diff --git a/arch/microblaze/include/asm/of_device.h b/arch/microblaze/include/asm/of_device.h
deleted file mode 100644
index 73cb98040982..000000000000
--- a/arch/microblaze/include/asm/of_device.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu>
3 *
4 * based on PowerPC of_device.h
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_MICROBLAZE_OF_DEVICE_H
12#define _ASM_MICROBLAZE_OF_DEVICE_H
13#ifdef __KERNEL__
14
15#include <linux/device.h>
16#include <linux/of.h>
17
18/*
19 * The of_device is a kind of "base class" that is a superset of
20 * struct device for use by devices attached to an OF node and
21 * probed using OF properties.
22 */
23struct of_device {
24 struct device dev; /* Generic device interface */
25 struct pdev_archdata archdata;
26};
27
28extern ssize_t of_device_get_modalias(struct of_device *ofdev,
29 char *str, ssize_t len);
30
31extern struct of_device *of_device_alloc(struct device_node *np,
32 const char *bus_id,
33 struct device *parent);
34
35extern int of_device_uevent(struct device *dev,
36 struct kobj_uevent_env *env);
37
38extern void of_device_make_bus_id(struct of_device *dev);
39
40/* This is just here during the transition */
41#include <linux/of_device.h>
42
43#endif /* __KERNEL__ */
44#endif /* _ASM_MICROBLAZE_OF_DEVICE_H */
diff --git a/arch/microblaze/include/asm/of_platform.h b/arch/microblaze/include/asm/of_platform.h
deleted file mode 100644
index 37491276c6ca..000000000000
--- a/arch/microblaze/include/asm/of_platform.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#ifndef _ASM_MICROBLAZE_OF_PLATFORM_H
12#define _ASM_MICROBLAZE_OF_PLATFORM_H
13
14/* This is just here during the transition */
15#include <linux/of_platform.h>
16
17/*
18 * The list of OF IDs below is used for matching bus types in the
19 * system whose devices are to be exposed as of_platform_devices.
20 *
21 * This is the default list valid for most platforms. This file provides
22 * functions who can take an explicit list if necessary though
23 *
24 * The search is always performed recursively looking for children of
25 * the provided device_node and recursively if such a children matches
26 * a bus type in the list
27 */
28
29static const struct of_device_id of_default_bus_ids[] = {
30 { .type = "soc", },
31 { .compatible = "soc", },
32 { .type = "plb5", },
33 { .type = "plb4", },
34 { .type = "opb", },
35 { .type = "simple", },
36 {},
37};
38
39/* Platform devices and busses creation */
40extern struct of_device *of_platform_device_create(struct device_node *np,
41 const char *bus_id,
42 struct device *parent);
43/* pseudo "matches" value to not do deep probe */
44#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
45
46extern int of_platform_bus_probe(struct device_node *root,
47 const struct of_device_id *matches,
48 struct device *parent);
49
50extern struct of_device *of_find_device_by_phandle(phandle ph);
51
52extern void of_instantiate_rtc(void);
53
54#endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index c12c6dfafd9f..4f268faa0126 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -47,13 +47,6 @@
47#define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) 47#define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
48#define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) 48#define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1)))
49 49
50/* align addr on a size boundary - adjust address up/down if needed */
51#define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1)))
52#define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1)))
53
54/* align addr on a size boundary - adjust address up if needed */
55#define _ALIGN(addr, size) _ALIGN_UP(addr, size)
56
57#ifndef CONFIG_MMU 50#ifndef CONFIG_MMU
58/* 51/*
59 * PAGE_OFFSET -- the first address of the first page of memory. When not 52 * PAGE_OFFSET -- the first address of the first page of memory. When not
diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h
index 0c77cda9f5d8..0c68764ab547 100644
--- a/arch/microblaze/include/asm/pci-bridge.h
+++ b/arch/microblaze/include/asm/pci-bridge.h
@@ -172,13 +172,8 @@ static inline int pci_has_flag(int flag)
172 172
173extern struct list_head hose_list; 173extern struct list_head hose_list;
174 174
175extern unsigned long pci_address_to_pio(phys_addr_t address);
176extern int pcibios_vaddr_is_ioport(void __iomem *address); 175extern int pcibios_vaddr_is_ioport(void __iomem *address);
177#else 176#else
178static inline unsigned long pci_address_to_pio(phys_addr_t address)
179{
180 return (unsigned long)-1;
181}
182static inline int pcibios_vaddr_is_ioport(void __iomem *address) 177static inline int pcibios_vaddr_is_ioport(void __iomem *address)
183{ 178{
184 return 0; 179 return 0;
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index e7d67a329bd7..101fa098f62a 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -20,9 +20,6 @@
20#ifndef __ASSEMBLY__ 20#ifndef __ASSEMBLY__
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/of_fdt.h>
24#include <linux/proc_fs.h>
25#include <linux/platform_device.h>
26#include <asm/irq.h> 23#include <asm/irq.h>
27#include <asm/atomic.h> 24#include <asm/atomic.h>
28 25
@@ -50,29 +47,10 @@ extern void pci_create_OF_bus_map(void);
50 * OF address retreival & translation 47 * OF address retreival & translation
51 */ 48 */
52 49
53/* Translate an OF address block into a CPU physical address 50#ifdef CONFIG_PCI
54 */ 51extern unsigned long pci_address_to_pio(phys_addr_t address);
55extern u64 of_translate_address(struct device_node *np, const u32 *addr); 52#define pci_address_to_pio pci_address_to_pio
56 53#endif /* CONFIG_PCI */
57/* Extract an address from a device, returns the region size and
58 * the address space flags too. The PCI version uses a BAR number
59 * instead of an absolute index
60 */
61extern const u32 *of_get_address(struct device_node *dev, int index,
62 u64 *size, unsigned int *flags);
63extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
64 u64 *size, unsigned int *flags);
65
66/* Get an address as a resource. Note that if your address is
67 * a PIO address, the conversion will fail if the physical address
68 * can't be internally converted to an IO token with
69 * pci_address_to_pio(), that is because it's either called to early
70 * or it can't be matched to any host bridge IO space
71 */
72extern int of_address_to_resource(struct device_node *dev, int index,
73 struct resource *r);
74extern int of_pci_address_to_resource(struct device_node *dev, int bar,
75 struct resource *r);
76 54
77/* Parse the ibm,dma-window property of an OF node into the busno, phys and 55/* Parse the ibm,dma-window property of an OF node into the busno, phys and
78 * size parameters. 56 * size parameters.
@@ -88,69 +66,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
88/* Get the MAC address */ 66/* Get the MAC address */
89extern const void *of_get_mac_address(struct device_node *np); 67extern const void *of_get_mac_address(struct device_node *np);
90 68
91/*
92 * OF interrupt mapping
93 */
94
95/* This structure is returned when an interrupt is mapped. The controller
96 * field needs to be put() after use
97 */
98
99#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
100
101struct of_irq {
102 struct device_node *controller; /* Interrupt controller node */
103 u32 size; /* Specifier size */
104 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
105};
106
107/**
108 * of_irq_map_init - Initialize the irq remapper
109 * @flags: flags defining workarounds to enable
110 *
111 * Some machines have bugs in the device-tree which require certain workarounds
112 * to be applied. Call this before any interrupt mapping attempts to enable
113 * those workarounds.
114 */
115#define OF_IMAP_OLDWORLD_MAC 0x00000001
116#define OF_IMAP_NO_PHANDLE 0x00000002
117
118extern void of_irq_map_init(unsigned int flags);
119
120/**
121 * of_irq_map_raw - Low level interrupt tree parsing
122 * @parent: the device interrupt parent
123 * @intspec: interrupt specifier ("interrupts" property of the device)
124 * @ointsize: size of the passed in interrupt specifier
125 * @addr: address specifier (start of "reg" property of the device)
126 * @out_irq: structure of_irq filled by this function
127 *
128 * Returns 0 on success and a negative number on error
129 *
130 * This function is a low-level interrupt tree walking function. It
131 * can be used to do a partial walk with synthetized reg and interrupts
132 * properties, for example when resolving PCI interrupts when no device
133 * node exist for the parent.
134 *
135 */
136
137extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
138 u32 ointsize, const u32 *addr,
139 struct of_irq *out_irq);
140
141/**
142 * of_irq_map_one - Resolve an interrupt for a device
143 * @device: the device whose interrupt is to be resolved
144 * @index: index of the interrupt to resolve
145 * @out_irq: structure of_irq filled by this function
146 *
147 * This function resolves an interrupt, walking the tree, for a given
148 * device-tree node. It's the high level pendant to of_irq_map_raw().
149 * It also implements the workarounds for OldWolrd Macs.
150 */
151extern int of_irq_map_one(struct device_node *device, int index,
152 struct of_irq *out_irq);
153
154/** 69/**
155 * of_irq_map_pci - Resolve the interrupt for a PCI device 70 * of_irq_map_pci - Resolve the interrupt for a PCI device
156 * @pdev: the device whose interrupt is to be resolved 71 * @pdev: the device whose interrupt is to be resolved
@@ -163,20 +78,18 @@ extern int of_irq_map_one(struct device_node *device, int index,
163 * resolving using the OF tree walking. 78 * resolving using the OF tree walking.
164 */ 79 */
165struct pci_dev; 80struct pci_dev;
81struct of_irq;
166extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); 82extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
167 83
168extern int of_irq_to_resource(struct device_node *dev, int index,
169 struct resource *r);
170
171/**
172 * of_iomap - Maps the memory mapped IO for a given device_node
173 * @device: the device whose io range will be mapped
174 * @index: index of the io range
175 *
176 * Returns a pointer to the mapped memory
177 */
178extern void __iomem *of_iomap(struct device_node *device, int index);
179
180#endif /* __ASSEMBLY__ */ 84#endif /* __ASSEMBLY__ */
181#endif /* __KERNEL__ */ 85#endif /* __KERNEL__ */
86
87/* These includes are put at the bottom because they may contain things
88 * that are overridden by this file. Ideally they shouldn't be included
89 * by this file, but there are a bunch of .c files that currently depend
90 * on it. Eventually they will be cleaned up. */
91#include <linux/of_fdt.h>
92#include <linux/of_irq.h>
93#include <linux/platform_device.h>
94
182#endif /* _ASM_MICROBLAZE_PROM_H */ 95#endif /* _ASM_MICROBLAZE_PROM_H */
diff --git a/arch/microblaze/include/asm/topology.h b/arch/microblaze/include/asm/topology.h
index 96bcea5a9920..5428f333a02c 100644
--- a/arch/microblaze/include/asm/topology.h
+++ b/arch/microblaze/include/asm/topology.h
@@ -1,11 +1 @@
1#include <asm-generic/topology.h> #include <asm-generic/topology.h>
2
3#ifndef _ASM_MICROBLAZE_TOPOLOGY_H
4#define _ASM_MICROBLAZE_TOPOLOGY_H
5
6struct device_node;
7static inline int of_node_to_nid(struct device_node *device)
8{
9 return 0;
10}
11#endif /* _ASM_MICROBLAZE_TOPOLOGY_H */
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
index 5eecc9f1fbd9..f0cb5c26c81c 100644
--- a/arch/microblaze/kernel/Makefile
+++ b/arch/microblaze/kernel/Makefile
@@ -15,8 +15,8 @@ endif
15extra-y := head.o vmlinux.lds 15extra-y := head.o vmlinux.lds
16 16
17obj-y += dma.o exceptions.o \ 17obj-y += dma.o exceptions.o \
18 hw_exception_handler.o init_task.o intc.o irq.o of_device.o \ 18 hw_exception_handler.o init_task.o intc.o irq.o \
19 of_platform.o process.o prom.o prom_parse.o ptrace.o \ 19 process.o prom.o prom_parse.o ptrace.o \
20 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o 20 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
21 21
22obj-y += cpu/ 22obj-y += cpu/
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
index 598f1fd61c89..a9345fb4906a 100644
--- a/arch/microblaze/kernel/irq.c
+++ b/arch/microblaze/kernel/irq.c
@@ -17,20 +17,10 @@
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/kernel_stat.h> 18#include <linux/kernel_stat.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/of_irq.h>
20 21
21#include <asm/prom.h> 22#include <asm/prom.h>
22 23
23unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
24{
25 struct of_irq oirq;
26
27 if (of_irq_map_one(dev, index, &oirq))
28 return NO_IRQ;
29
30 return oirq.specifier[0];
31}
32EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
33
34static u32 concurrent_irq; 24static u32 concurrent_irq;
35 25
36void __irq_entry do_IRQ(struct pt_regs *regs) 26void __irq_entry do_IRQ(struct pt_regs *regs)
@@ -106,7 +96,7 @@ unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq)
106EXPORT_SYMBOL_GPL(irq_create_mapping); 96EXPORT_SYMBOL_GPL(irq_create_mapping);
107 97
108unsigned int irq_create_of_mapping(struct device_node *controller, 98unsigned int irq_create_of_mapping(struct device_node *controller,
109 u32 *intspec, unsigned int intsize) 99 const u32 *intspec, unsigned int intsize)
110{ 100{
111 return intspec[0]; 101 return intspec[0];
112} 102}
diff --git a/arch/microblaze/kernel/of_device.c b/arch/microblaze/kernel/of_device.c
deleted file mode 100644
index b372787886ed..000000000000
--- a/arch/microblaze/kernel/of_device.c
+++ /dev/null
@@ -1,112 +0,0 @@
1#include <linux/string.h>
2#include <linux/kernel.h>
3#include <linux/of.h>
4#include <linux/init.h>
5#include <linux/module.h>
6#include <linux/mod_devicetable.h>
7#include <linux/slab.h>
8#include <linux/of_device.h>
9
10#include <linux/errno.h>
11
12void of_device_make_bus_id(struct of_device *dev)
13{
14 static atomic_t bus_no_reg_magic;
15 struct device_node *node = dev->dev.of_node;
16 const u32 *reg;
17 u64 addr;
18 int magic;
19
20 /*
21 * For MMIO, get the physical address
22 */
23 reg = of_get_property(node, "reg", NULL);
24 if (reg) {
25 addr = of_translate_address(node, reg);
26 if (addr != OF_BAD_ADDR) {
27 dev_set_name(&dev->dev, "%llx.%s",
28 (unsigned long long)addr, node->name);
29 return;
30 }
31 }
32
33 /*
34 * No BusID, use the node name and add a globally incremented
35 * counter (and pray...)
36 */
37 magic = atomic_add_return(1, &bus_no_reg_magic);
38 dev_set_name(&dev->dev, "%s.%d", node->name, magic - 1);
39}
40EXPORT_SYMBOL(of_device_make_bus_id);
41
42struct of_device *of_device_alloc(struct device_node *np,
43 const char *bus_id,
44 struct device *parent)
45{
46 struct of_device *dev;
47
48 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
49 if (!dev)
50 return NULL;
51
52 dev->dev.of_node = of_node_get(np);
53 dev->dev.dma_mask = &dev->archdata.dma_mask;
54 dev->dev.parent = parent;
55 dev->dev.release = of_release_dev;
56
57 if (bus_id)
58 dev_set_name(&dev->dev, bus_id);
59 else
60 of_device_make_bus_id(dev);
61
62 return dev;
63}
64EXPORT_SYMBOL(of_device_alloc);
65
66int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
67{
68 struct of_device *ofdev;
69 const char *compat;
70 int seen = 0, cplen, sl;
71
72 if (!dev)
73 return -ENODEV;
74
75 ofdev = to_of_device(dev);
76
77 if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
78 return -ENOMEM;
79
80 if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
81 return -ENOMEM;
82
83 /* Since the compatible field can contain pretty much anything
84 * it's not really legal to split it out with commas. We split it
85 * up using a number of environment variables instead. */
86
87 compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
88 while (compat && *compat && cplen > 0) {
89 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
90 return -ENOMEM;
91
92 sl = strlen(compat) + 1;
93 compat += sl;
94 cplen -= sl;
95 seen++;
96 }
97
98 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen))
99 return -ENOMEM;
100
101 /* modalias is trickier, we add it in 2 steps */
102 if (add_uevent_var(env, "MODALIAS="))
103 return -ENOMEM;
104 sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1],
105 sizeof(env->buf) - env->buflen);
106 if (sl >= (sizeof(env->buf) - env->buflen))
107 return -ENOMEM;
108 env->buflen += sl;
109
110 return 0;
111}
112EXPORT_SYMBOL(of_device_uevent);
diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c
deleted file mode 100644
index ccf6f4257f4b..000000000000
--- a/arch/microblaze/kernel/of_platform.c
+++ /dev/null
@@ -1,200 +0,0 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 * and Arnd Bergmann, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#undef DEBUG
14
15#include <linux/string.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/mod_devicetable.h>
20#include <linux/pci.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
23#include <linux/of_platform.h>
24
25#include <linux/errno.h>
26#include <linux/topology.h>
27#include <asm/atomic.h>
28
29struct bus_type of_platform_bus_type = {
30 .uevent = of_device_uevent,
31};
32EXPORT_SYMBOL(of_platform_bus_type);
33
34static int __init of_bus_driver_init(void)
35{
36 return of_bus_type_init(&of_platform_bus_type, "of_platform");
37}
38postcore_initcall(of_bus_driver_init);
39
40struct of_device *of_platform_device_create(struct device_node *np,
41 const char *bus_id,
42 struct device *parent)
43{
44 struct of_device *dev;
45
46 dev = of_device_alloc(np, bus_id, parent);
47 if (!dev)
48 return NULL;
49
50 dev->archdata.dma_mask = 0xffffffffUL;
51 dev->dev.bus = &of_platform_bus_type;
52
53 /* We do not fill the DMA ops for platform devices by default.
54 * This is currently the responsibility of the platform code
55 * to do such, possibly using a device notifier
56 */
57
58 if (of_device_register(dev) != 0) {
59 of_device_free(dev);
60 return NULL;
61 }
62
63 return dev;
64}
65EXPORT_SYMBOL(of_platform_device_create);
66
67/**
68 * of_platform_bus_create - Create an OF device for a bus node and all its
69 * children. Optionally recursively instanciate matching busses.
70 * @bus: device node of the bus to instanciate
71 * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to
72 * disallow recursive creation of child busses
73 */
74static int of_platform_bus_create(const struct device_node *bus,
75 const struct of_device_id *matches,
76 struct device *parent)
77{
78 struct device_node *child;
79 struct of_device *dev;
80 int rc = 0;
81
82 for_each_child_of_node(bus, child) {
83 pr_debug(" create child: %s\n", child->full_name);
84 dev = of_platform_device_create(child, NULL, parent);
85 if (dev == NULL)
86 rc = -ENOMEM;
87 else if (!of_match_node(matches, child))
88 continue;
89 if (rc == 0) {
90 pr_debug(" and sub busses\n");
91 rc = of_platform_bus_create(child, matches, &dev->dev);
92 }
93 if (rc) {
94 of_node_put(child);
95 break;
96 }
97 }
98 return rc;
99}
100
101
102/**
103 * of_platform_bus_probe - Probe the device-tree for platform busses
104 * @root: parent of the first level to probe or NULL for the root of the tree
105 * @matches: match table, NULL to use the default
106 * @parent: parent to hook devices from, NULL for toplevel
107 *
108 * Note that children of the provided root are not instanciated as devices
109 * unless the specified root itself matches the bus list and is not NULL.
110 */
111
112int of_platform_bus_probe(struct device_node *root,
113 const struct of_device_id *matches,
114 struct device *parent)
115{
116 struct device_node *child;
117 struct of_device *dev;
118 int rc = 0;
119
120 if (matches == NULL)
121 matches = of_default_bus_ids;
122 if (matches == OF_NO_DEEP_PROBE)
123 return -EINVAL;
124 if (root == NULL)
125 root = of_find_node_by_path("/");
126 else
127 of_node_get(root);
128
129 pr_debug("of_platform_bus_probe()\n");
130 pr_debug(" starting at: %s\n", root->full_name);
131
132 /* Do a self check of bus type, if there's a match, create
133 * children
134 */
135 if (of_match_node(matches, root)) {
136 pr_debug(" root match, create all sub devices\n");
137 dev = of_platform_device_create(root, NULL, parent);
138 if (dev == NULL) {
139 rc = -ENOMEM;
140 goto bail;
141 }
142 pr_debug(" create all sub busses\n");
143 rc = of_platform_bus_create(root, matches, &dev->dev);
144 goto bail;
145 }
146 for_each_child_of_node(root, child) {
147 if (!of_match_node(matches, child))
148 continue;
149
150 pr_debug(" match: %s\n", child->full_name);
151 dev = of_platform_device_create(child, NULL, parent);
152 if (dev == NULL)
153 rc = -ENOMEM;
154 else
155 rc = of_platform_bus_create(child, matches, &dev->dev);
156 if (rc) {
157 of_node_put(child);
158 break;
159 }
160 }
161 bail:
162 of_node_put(root);
163 return rc;
164}
165EXPORT_SYMBOL(of_platform_bus_probe);
166
167static int of_dev_node_match(struct device *dev, void *data)
168{
169 return to_of_device(dev)->dev.of_node == data;
170}
171
172struct of_device *of_find_device_by_node(struct device_node *np)
173{
174 struct device *dev;
175
176 dev = bus_find_device(&of_platform_bus_type,
177 NULL, np, of_dev_node_match);
178 if (dev)
179 return to_of_device(dev);
180 return NULL;
181}
182EXPORT_SYMBOL(of_find_device_by_node);
183
184static int of_dev_phandle_match(struct device *dev, void *data)
185{
186 phandle *ph = data;
187 return to_of_device(dev)->dev.of_node->phandle == *ph;
188}
189
190struct of_device *of_find_device_by_phandle(phandle ph)
191{
192 struct device *dev;
193
194 dev = bus_find_device(&of_platform_bus_type,
195 NULL, &ph, of_dev_phandle_match);
196 if (dev)
197 return to_of_device(dev);
198 return NULL;
199}
200EXPORT_SYMBOL(of_find_device_by_phandle);
diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c
index bf7e6c27e318..d33ba17601fa 100644
--- a/arch/microblaze/kernel/prom_parse.c
+++ b/arch/microblaze/kernel/prom_parse.c
@@ -6,219 +6,11 @@
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/ioport.h> 7#include <linux/ioport.h>
8#include <linux/etherdevice.h> 8#include <linux/etherdevice.h>
9#include <linux/of_address.h>
9#include <asm/prom.h> 10#include <asm/prom.h>
10#include <asm/pci-bridge.h> 11#include <asm/pci-bridge.h>
11 12
12#define PRu64 "%llx"
13
14/* Max address size we deal with */
15#define OF_MAX_ADDR_CELLS 4
16#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
17 (ns) > 0)
18
19static struct of_bus *of_match_bus(struct device_node *np);
20static int __of_address_to_resource(struct device_node *dev,
21 const u32 *addrp, u64 size, unsigned int flags,
22 struct resource *r);
23
24/* Debug utility */
25#ifdef DEBUG
26static void of_dump_addr(const char *s, const u32 *addr, int na)
27{
28 printk(KERN_INFO "%s", s);
29 while (na--)
30 printk(KERN_INFO " %08x", *(addr++));
31 printk(KERN_INFO "\n");
32}
33#else
34static void of_dump_addr(const char *s, const u32 *addr, int na) { }
35#endif
36
37/* Callbacks for bus specific translators */
38struct of_bus {
39 const char *name;
40 const char *addresses;
41 int (*match)(struct device_node *parent);
42 void (*count_cells)(struct device_node *child,
43 int *addrc, int *sizec);
44 u64 (*map)(u32 *addr, const u32 *range,
45 int na, int ns, int pna);
46 int (*translate)(u32 *addr, u64 offset, int na);
47 unsigned int (*get_flags)(const u32 *addr);
48};
49
50/*
51 * Default translator (generic bus)
52 */
53
54static void of_bus_default_count_cells(struct device_node *dev,
55 int *addrc, int *sizec)
56{
57 if (addrc)
58 *addrc = of_n_addr_cells(dev);
59 if (sizec)
60 *sizec = of_n_size_cells(dev);
61}
62
63static u64 of_bus_default_map(u32 *addr, const u32 *range,
64 int na, int ns, int pna)
65{
66 u64 cp, s, da;
67
68 cp = of_read_number(range, na);
69 s = of_read_number(range + na + pna, ns);
70 da = of_read_number(addr, na);
71
72 pr_debug("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n",
73 cp, s, da);
74
75 if (da < cp || da >= (cp + s))
76 return OF_BAD_ADDR;
77 return da - cp;
78}
79
80static int of_bus_default_translate(u32 *addr, u64 offset, int na)
81{
82 u64 a = of_read_number(addr, na);
83 memset(addr, 0, na * 4);
84 a += offset;
85 if (na > 1)
86 addr[na - 2] = a >> 32;
87 addr[na - 1] = a & 0xffffffffu;
88
89 return 0;
90}
91
92static unsigned int of_bus_default_get_flags(const u32 *addr)
93{
94 return IORESOURCE_MEM;
95}
96
97#ifdef CONFIG_PCI 13#ifdef CONFIG_PCI
98/*
99 * PCI bus specific translator
100 */
101
102static int of_bus_pci_match(struct device_node *np)
103{
104 /* "vci" is for the /chaos bridge on 1st-gen PCI powermacs */
105 return !strcmp(np->type, "pci") || !strcmp(np->type, "vci");
106}
107
108static void of_bus_pci_count_cells(struct device_node *np,
109 int *addrc, int *sizec)
110{
111 if (addrc)
112 *addrc = 3;
113 if (sizec)
114 *sizec = 2;
115}
116
117static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
118{
119 u64 cp, s, da;
120
121 /* Check address type match */
122 if ((addr[0] ^ range[0]) & 0x03000000)
123 return OF_BAD_ADDR;
124
125 /* Read address values, skipping high cell */
126 cp = of_read_number(range + 1, na - 1);
127 s = of_read_number(range + na + pna, ns);
128 da = of_read_number(addr + 1, na - 1);
129
130 pr_debug("OF: PCI map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da);
131
132 if (da < cp || da >= (cp + s))
133 return OF_BAD_ADDR;
134 return da - cp;
135}
136
137static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
138{
139 return of_bus_default_translate(addr + 1, offset, na - 1);
140}
141
142static unsigned int of_bus_pci_get_flags(const u32 *addr)
143{
144 unsigned int flags = 0;
145 u32 w = addr[0];
146
147 switch ((w >> 24) & 0x03) {
148 case 0x01:
149 flags |= IORESOURCE_IO;
150 break;
151 case 0x02: /* 32 bits */
152 case 0x03: /* 64 bits */
153 flags |= IORESOURCE_MEM;
154 break;
155 }
156 if (w & 0x40000000)
157 flags |= IORESOURCE_PREFETCH;
158 return flags;
159}
160
161const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
162 unsigned int *flags)
163{
164 const u32 *prop;
165 unsigned int psize;
166 struct device_node *parent;
167 struct of_bus *bus;
168 int onesize, i, na, ns;
169
170 /* Get parent & match bus type */
171 parent = of_get_parent(dev);
172 if (parent == NULL)
173 return NULL;
174 bus = of_match_bus(parent);
175 if (strcmp(bus->name, "pci")) {
176 of_node_put(parent);
177 return NULL;
178 }
179 bus->count_cells(dev, &na, &ns);
180 of_node_put(parent);
181 if (!OF_CHECK_COUNTS(na, ns))
182 return NULL;
183
184 /* Get "reg" or "assigned-addresses" property */
185 prop = of_get_property(dev, bus->addresses, &psize);
186 if (prop == NULL)
187 return NULL;
188 psize /= 4;
189
190 onesize = na + ns;
191 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
192 if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
193 if (size)
194 *size = of_read_number(prop + na, ns);
195 if (flags)
196 *flags = bus->get_flags(prop);
197 return prop;
198 }
199 return NULL;
200}
201EXPORT_SYMBOL(of_get_pci_address);
202
203int of_pci_address_to_resource(struct device_node *dev, int bar,
204 struct resource *r)
205{
206 const u32 *addrp;
207 u64 size;
208 unsigned int flags;
209
210 addrp = of_get_pci_address(dev, bar, &size, &flags);
211 if (addrp == NULL)
212 return -EINVAL;
213 return __of_address_to_resource(dev, addrp, size, flags, r);
214}
215EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
216
217static u8 of_irq_pci_swizzle(u8 slot, u8 pin)
218{
219 return (((pin - 1) + slot) % 4) + 1;
220}
221
222int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq) 14int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
223{ 15{
224 struct device_node *dn, *ppnode; 16 struct device_node *dn, *ppnode;
@@ -293,331 +85,6 @@ int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
293EXPORT_SYMBOL_GPL(of_irq_map_pci); 85EXPORT_SYMBOL_GPL(of_irq_map_pci);
294#endif /* CONFIG_PCI */ 86#endif /* CONFIG_PCI */
295 87
296/*
297 * ISA bus specific translator
298 */
299
300static int of_bus_isa_match(struct device_node *np)
301{
302 return !strcmp(np->name, "isa");
303}
304
305static void of_bus_isa_count_cells(struct device_node *child,
306 int *addrc, int *sizec)
307{
308 if (addrc)
309 *addrc = 2;
310 if (sizec)
311 *sizec = 1;
312}
313
314static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
315{
316 u64 cp, s, da;
317
318 /* Check address type match */
319 if ((addr[0] ^ range[0]) & 0x00000001)
320 return OF_BAD_ADDR;
321
322 /* Read address values, skipping high cell */
323 cp = of_read_number(range + 1, na - 1);
324 s = of_read_number(range + na + pna, ns);
325 da = of_read_number(addr + 1, na - 1);
326
327 pr_debug("OF: ISA map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da);
328
329 if (da < cp || da >= (cp + s))
330 return OF_BAD_ADDR;
331 return da - cp;
332}
333
334static int of_bus_isa_translate(u32 *addr, u64 offset, int na)
335{
336 return of_bus_default_translate(addr + 1, offset, na - 1);
337}
338
339static unsigned int of_bus_isa_get_flags(const u32 *addr)
340{
341 unsigned int flags = 0;
342 u32 w = addr[0];
343
344 if (w & 1)
345 flags |= IORESOURCE_IO;
346 else
347 flags |= IORESOURCE_MEM;
348 return flags;
349}
350
351/*
352 * Array of bus specific translators
353 */
354
355static struct of_bus of_busses[] = {
356#ifdef CONFIG_PCI
357 /* PCI */
358 {
359 .name = "pci",
360 .addresses = "assigned-addresses",
361 .match = of_bus_pci_match,
362 .count_cells = of_bus_pci_count_cells,
363 .map = of_bus_pci_map,
364 .translate = of_bus_pci_translate,
365 .get_flags = of_bus_pci_get_flags,
366 },
367#endif /* CONFIG_PCI */
368 /* ISA */
369 {
370 .name = "isa",
371 .addresses = "reg",
372 .match = of_bus_isa_match,
373 .count_cells = of_bus_isa_count_cells,
374 .map = of_bus_isa_map,
375 .translate = of_bus_isa_translate,
376 .get_flags = of_bus_isa_get_flags,
377 },
378 /* Default */
379 {
380 .name = "default",
381 .addresses = "reg",
382 .match = NULL,
383 .count_cells = of_bus_default_count_cells,
384 .map = of_bus_default_map,
385 .translate = of_bus_default_translate,
386 .get_flags = of_bus_default_get_flags,
387 },
388};
389
390static struct of_bus *of_match_bus(struct device_node *np)
391{
392 int i;
393
394 for (i = 0; i < ARRAY_SIZE(of_busses); i++)
395 if (!of_busses[i].match || of_busses[i].match(np))
396 return &of_busses[i];
397 BUG();
398 return NULL;
399}
400
401static int of_translate_one(struct device_node *parent, struct of_bus *bus,
402 struct of_bus *pbus, u32 *addr,
403 int na, int ns, int pna)
404{
405 const u32 *ranges;
406 unsigned int rlen;
407 int rone;
408 u64 offset = OF_BAD_ADDR;
409
410 /* Normally, an absence of a "ranges" property means we are
411 * crossing a non-translatable boundary, and thus the addresses
412 * below the current not cannot be converted to CPU physical ones.
413 * Unfortunately, while this is very clear in the spec, it's not
414 * what Apple understood, and they do have things like /uni-n or
415 * /ht nodes with no "ranges" property and a lot of perfectly
416 * useable mapped devices below them. Thus we treat the absence of
417 * "ranges" as equivalent to an empty "ranges" property which means
418 * a 1:1 translation at that level. It's up to the caller not to try
419 * to translate addresses that aren't supposed to be translated in
420 * the first place. --BenH.
421 */
422 ranges = of_get_property(parent, "ranges", (int *) &rlen);
423 if (ranges == NULL || rlen == 0) {
424 offset = of_read_number(addr, na);
425 memset(addr, 0, pna * 4);
426 pr_debug("OF: no ranges, 1:1 translation\n");
427 goto finish;
428 }
429
430 pr_debug("OF: walking ranges...\n");
431
432 /* Now walk through the ranges */
433 rlen /= 4;
434 rone = na + pna + ns;
435 for (; rlen >= rone; rlen -= rone, ranges += rone) {
436 offset = bus->map(addr, ranges, na, ns, pna);
437 if (offset != OF_BAD_ADDR)
438 break;
439 }
440 if (offset == OF_BAD_ADDR) {
441 pr_debug("OF: not found !\n");
442 return 1;
443 }
444 memcpy(addr, ranges + na, 4 * pna);
445
446 finish:
447 of_dump_addr("OF: parent translation for:", addr, pna);
448 pr_debug("OF: with offset: "PRu64"\n", offset);
449
450 /* Translate it into parent bus space */
451 return pbus->translate(addr, offset, pna);
452}
453
454/*
455 * Translate an address from the device-tree into a CPU physical address,
456 * this walks up the tree and applies the various bus mappings on the
457 * way.
458 *
459 * Note: We consider that crossing any level with #size-cells == 0 to mean
460 * that translation is impossible (that is we are not dealing with a value
461 * that can be mapped to a cpu physical address). This is not really specified
462 * that way, but this is traditionally the way IBM at least do things
463 */
464u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
465{
466 struct device_node *parent = NULL;
467 struct of_bus *bus, *pbus;
468 u32 addr[OF_MAX_ADDR_CELLS];
469 int na, ns, pna, pns;
470 u64 result = OF_BAD_ADDR;
471
472 pr_debug("OF: ** translation for device %s **\n", dev->full_name);
473
474 /* Increase refcount at current level */
475 of_node_get(dev);
476
477 /* Get parent & match bus type */
478 parent = of_get_parent(dev);
479 if (parent == NULL)
480 goto bail;
481 bus = of_match_bus(parent);
482
483 /* Cound address cells & copy address locally */
484 bus->count_cells(dev, &na, &ns);
485 if (!OF_CHECK_COUNTS(na, ns)) {
486 printk(KERN_ERR "prom_parse: Bad cell count for %s\n",
487 dev->full_name);
488 goto bail;
489 }
490 memcpy(addr, in_addr, na * 4);
491
492 pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n",
493 bus->name, na, ns, parent->full_name);
494 of_dump_addr("OF: translating address:", addr, na);
495
496 /* Translate */
497 for (;;) {
498 /* Switch to parent bus */
499 of_node_put(dev);
500 dev = parent;
501 parent = of_get_parent(dev);
502
503 /* If root, we have finished */
504 if (parent == NULL) {
505 pr_debug("OF: reached root node\n");
506 result = of_read_number(addr, na);
507 break;
508 }
509
510 /* Get new parent bus and counts */
511 pbus = of_match_bus(parent);
512 pbus->count_cells(dev, &pna, &pns);
513 if (!OF_CHECK_COUNTS(pna, pns)) {
514 printk(KERN_ERR "prom_parse: Bad cell count for %s\n",
515 dev->full_name);
516 break;
517 }
518
519 pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n",
520 pbus->name, pna, pns, parent->full_name);
521
522 /* Apply bus translation */
523 if (of_translate_one(dev, bus, pbus, addr, na, ns, pna))
524 break;
525
526 /* Complete the move up one level */
527 na = pna;
528 ns = pns;
529 bus = pbus;
530
531 of_dump_addr("OF: one level translation:", addr, na);
532 }
533 bail:
534 of_node_put(parent);
535 of_node_put(dev);
536
537 return result;
538}
539EXPORT_SYMBOL(of_translate_address);
540
541const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
542 unsigned int *flags)
543{
544 const u32 *prop;
545 unsigned int psize;
546 struct device_node *parent;
547 struct of_bus *bus;
548 int onesize, i, na, ns;
549
550 /* Get parent & match bus type */
551 parent = of_get_parent(dev);
552 if (parent == NULL)
553 return NULL;
554 bus = of_match_bus(parent);
555 bus->count_cells(dev, &na, &ns);
556 of_node_put(parent);
557 if (!OF_CHECK_COUNTS(na, ns))
558 return NULL;
559
560 /* Get "reg" or "assigned-addresses" property */
561 prop = of_get_property(dev, bus->addresses, (int *) &psize);
562 if (prop == NULL)
563 return NULL;
564 psize /= 4;
565
566 onesize = na + ns;
567 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
568 if (i == index) {
569 if (size)
570 *size = of_read_number(prop + na, ns);
571 if (flags)
572 *flags = bus->get_flags(prop);
573 return prop;
574 }
575 return NULL;
576}
577EXPORT_SYMBOL(of_get_address);
578
579static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
580 u64 size, unsigned int flags,
581 struct resource *r)
582{
583 u64 taddr;
584
585 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
586 return -EINVAL;
587 taddr = of_translate_address(dev, addrp);
588 if (taddr == OF_BAD_ADDR)
589 return -EINVAL;
590 memset(r, 0, sizeof(struct resource));
591 if (flags & IORESOURCE_IO) {
592 unsigned long port;
593 port = -1; /* pci_address_to_pio(taddr); */
594 if (port == (unsigned long)-1)
595 return -EINVAL;
596 r->start = port;
597 r->end = port + size - 1;
598 } else {
599 r->start = taddr;
600 r->end = taddr + size - 1;
601 }
602 r->flags = flags;
603 r->name = dev->name;
604 return 0;
605}
606
607int of_address_to_resource(struct device_node *dev, int index,
608 struct resource *r)
609{
610 const u32 *addrp;
611 u64 size;
612 unsigned int flags;
613
614 addrp = of_get_address(dev, index, &size, &flags);
615 if (addrp == NULL)
616 return -EINVAL;
617 return __of_address_to_resource(dev, addrp, size, flags, r);
618}
619EXPORT_SYMBOL_GPL(of_address_to_resource);
620
621void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 88void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
622 unsigned long *busno, unsigned long *phys, unsigned long *size) 89 unsigned long *busno, unsigned long *phys, unsigned long *size)
623{ 90{
@@ -644,308 +111,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
644 *size = of_read_number(dma_window, cells); 111 *size = of_read_number(dma_window, cells);
645} 112}
646 113
647/*
648 * Interrupt remapper
649 */
650
651static unsigned int of_irq_workarounds;
652static struct device_node *of_irq_dflt_pic;
653
654static struct device_node *of_irq_find_parent(struct device_node *child)
655{
656 struct device_node *p;
657 const phandle *parp;
658
659 if (!of_node_get(child))
660 return NULL;
661
662 do {
663 parp = of_get_property(child, "interrupt-parent", NULL);
664 if (parp == NULL)
665 p = of_get_parent(child);
666 else {
667 if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
668 p = of_node_get(of_irq_dflt_pic);
669 else
670 p = of_find_node_by_phandle(*parp);
671 }
672 of_node_put(child);
673 child = p;
674 } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
675
676 return p;
677}
678
679/* This doesn't need to be called if you don't have any special workaround
680 * flags to pass
681 */
682void of_irq_map_init(unsigned int flags)
683{
684 of_irq_workarounds = flags;
685
686 /* OldWorld, don't bother looking at other things */
687 if (flags & OF_IMAP_OLDWORLD_MAC)
688 return;
689
690 /* If we don't have phandles, let's try to locate a default interrupt
691 * controller (happens when booting with BootX). We do a first match
692 * here, hopefully, that only ever happens on machines with one
693 * controller.
694 */
695 if (flags & OF_IMAP_NO_PHANDLE) {
696 struct device_node *np;
697
698 for (np = NULL; (np = of_find_all_nodes(np)) != NULL;) {
699 if (of_get_property(np, "interrupt-controller", NULL)
700 == NULL)
701 continue;
702 /* Skip /chosen/interrupt-controller */
703 if (strcmp(np->name, "chosen") == 0)
704 continue;
705 /* It seems like at least one person on this planet
706 * wants to use BootX on a machine with an AppleKiwi
707 * controller which happens to pretend to be an
708 * interrupt controller too.
709 */
710 if (strcmp(np->name, "AppleKiwi") == 0)
711 continue;
712 /* I think we found one ! */
713 of_irq_dflt_pic = np;
714 break;
715 }
716 }
717
718}
719
720int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
721 const u32 *addr, struct of_irq *out_irq)
722{
723 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
724 const u32 *tmp, *imap, *imask;
725 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
726 int imaplen, match, i;
727
728 pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],"
729 "ointsize=%d\n",
730 parent->full_name, intspec[0], intspec[1], ointsize);
731
732 ipar = of_node_get(parent);
733
734 /* First get the #interrupt-cells property of the current cursor
735 * that tells us how to interpret the passed-in intspec. If there
736 * is none, we are nice and just walk up the tree
737 */
738 do {
739 tmp = of_get_property(ipar, "#interrupt-cells", NULL);
740 if (tmp != NULL) {
741 intsize = *tmp;
742 break;
743 }
744 tnode = ipar;
745 ipar = of_irq_find_parent(ipar);
746 of_node_put(tnode);
747 } while (ipar);
748 if (ipar == NULL) {
749 pr_debug(" -> no parent found !\n");
750 goto fail;
751 }
752
753 pr_debug("of_irq_map_raw: ipar=%s, size=%d\n",
754 ipar->full_name, intsize);
755
756 if (ointsize != intsize)
757 return -EINVAL;
758
759 /* Look for this #address-cells. We have to implement the old linux
760 * trick of looking for the parent here as some device-trees rely on it
761 */
762 old = of_node_get(ipar);
763 do {
764 tmp = of_get_property(old, "#address-cells", NULL);
765 tnode = of_get_parent(old);
766 of_node_put(old);
767 old = tnode;
768 } while (old && tmp == NULL);
769 of_node_put(old);
770 old = NULL;
771 addrsize = (tmp == NULL) ? 2 : *tmp;
772
773 pr_debug(" -> addrsize=%d\n", addrsize);
774
775 /* Now start the actual "proper" walk of the interrupt tree */
776 while (ipar != NULL) {
777 /* Now check if cursor is an interrupt-controller and if it is
778 * then we are done
779 */
780 if (of_get_property(ipar, "interrupt-controller", NULL) !=
781 NULL) {
782 pr_debug(" -> got it !\n");
783 memcpy(out_irq->specifier, intspec,
784 intsize * sizeof(u32));
785 out_irq->size = intsize;
786 out_irq->controller = ipar;
787 of_node_put(old);
788 return 0;
789 }
790
791 /* Now look for an interrupt-map */
792 imap = of_get_property(ipar, "interrupt-map", &imaplen);
793 /* No interrupt map, check for an interrupt parent */
794 if (imap == NULL) {
795 pr_debug(" -> no map, getting parent\n");
796 newpar = of_irq_find_parent(ipar);
797 goto skiplevel;
798 }
799 imaplen /= sizeof(u32);
800
801 /* Look for a mask */
802 imask = of_get_property(ipar, "interrupt-map-mask", NULL);
803
804 /* If we were passed no "reg" property and we attempt to parse
805 * an interrupt-map, then #address-cells must be 0.
806 * Fail if it's not.
807 */
808 if (addr == NULL && addrsize != 0) {
809 pr_debug(" -> no reg passed in when needed !\n");
810 goto fail;
811 }
812
813 /* Parse interrupt-map */
814 match = 0;
815 while (imaplen > (addrsize + intsize + 1) && !match) {
816 /* Compare specifiers */
817 match = 1;
818 for (i = 0; i < addrsize && match; ++i) {
819 u32 mask = imask ? imask[i] : 0xffffffffu;
820 match = ((addr[i] ^ imap[i]) & mask) == 0;
821 }
822 for (; i < (addrsize + intsize) && match; ++i) {
823 u32 mask = imask ? imask[i] : 0xffffffffu;
824 match =
825 ((intspec[i-addrsize] ^ imap[i])
826 & mask) == 0;
827 }
828 imap += addrsize + intsize;
829 imaplen -= addrsize + intsize;
830
831 pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen);
832
833 /* Get the interrupt parent */
834 if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
835 newpar = of_node_get(of_irq_dflt_pic);
836 else
837 newpar =
838 of_find_node_by_phandle((phandle)*imap);
839 imap++;
840 --imaplen;
841
842 /* Check if not found */
843 if (newpar == NULL) {
844 pr_debug(" -> imap parent not found !\n");
845 goto fail;
846 }
847
848 /* Get #interrupt-cells and #address-cells of new
849 * parent
850 */
851 tmp = of_get_property(newpar, "#interrupt-cells", NULL);
852 if (tmp == NULL) {
853 pr_debug(" -> parent lacks "
854 "#interrupt-cells!\n");
855 goto fail;
856 }
857 newintsize = *tmp;
858 tmp = of_get_property(newpar, "#address-cells", NULL);
859 newaddrsize = (tmp == NULL) ? 0 : *tmp;
860
861 pr_debug(" -> newintsize=%d, newaddrsize=%d\n",
862 newintsize, newaddrsize);
863
864 /* Check for malformed properties */
865 if (imaplen < (newaddrsize + newintsize))
866 goto fail;
867
868 imap += newaddrsize + newintsize;
869 imaplen -= newaddrsize + newintsize;
870
871 pr_debug(" -> imaplen=%d\n", imaplen);
872 }
873 if (!match)
874 goto fail;
875
876 of_node_put(old);
877 old = of_node_get(newpar);
878 addrsize = newaddrsize;
879 intsize = newintsize;
880 intspec = imap - intsize;
881 addr = intspec - addrsize;
882
883skiplevel:
884 /* Iterate again with new parent */
885 pr_debug(" -> new parent: %s\n",
886 newpar ? newpar->full_name : "<>");
887 of_node_put(ipar);
888 ipar = newpar;
889 newpar = NULL;
890 }
891fail:
892 of_node_put(ipar);
893 of_node_put(old);
894 of_node_put(newpar);
895
896 return -EINVAL;
897}
898EXPORT_SYMBOL_GPL(of_irq_map_raw);
899
900int of_irq_map_one(struct device_node *device,
901 int index, struct of_irq *out_irq)
902{
903 struct device_node *p;
904 const u32 *intspec, *tmp, *addr;
905 u32 intsize, intlen;
906 int res;
907
908 pr_debug("of_irq_map_one: dev=%s, index=%d\n",
909 device->full_name, index);
910
911 /* Get the interrupts property */
912 intspec = of_get_property(device, "interrupts", (int *) &intlen);
913 if (intspec == NULL)
914 return -EINVAL;
915 intlen /= sizeof(u32);
916
917 pr_debug(" intspec=%d intlen=%d\n", *intspec, intlen);
918
919 /* Get the reg property (if any) */
920 addr = of_get_property(device, "reg", NULL);
921
922 /* Look for the interrupt parent. */
923 p = of_irq_find_parent(device);
924 if (p == NULL)
925 return -EINVAL;
926
927 /* Get size of interrupt specifier */
928 tmp = of_get_property(p, "#interrupt-cells", NULL);
929 if (tmp == NULL) {
930 of_node_put(p);
931 return -EINVAL;
932 }
933 intsize = *tmp;
934
935 pr_debug(" intsize=%d intlen=%d\n", intsize, intlen);
936
937 /* Check index */
938 if ((index + 1) * intsize > intlen)
939 return -EINVAL;
940
941 /* Get new specifier and map it */
942 res = of_irq_map_raw(p, intspec + index * intsize, intsize,
943 addr, out_irq);
944 of_node_put(p);
945 return res;
946}
947EXPORT_SYMBOL_GPL(of_irq_map_one);
948
949/** 114/**
950 * Search the device tree for the best MAC address to use. 'mac-address' is 115 * Search the device tree for the best MAC address to use. 'mac-address' is
951 * checked first, because that is supposed to contain to "most recent" MAC 116 * checked first, because that is supposed to contain to "most recent" MAC
@@ -983,43 +148,3 @@ const void *of_get_mac_address(struct device_node *np)
983 return NULL; 148 return NULL;
984} 149}
985EXPORT_SYMBOL(of_get_mac_address); 150EXPORT_SYMBOL(of_get_mac_address);
986
987int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
988{
989 struct of_irq out_irq;
990 int irq;
991 int res;
992
993 res = of_irq_map_one(dev, index, &out_irq);
994
995 /* Get irq for the device */
996 if (res) {
997 pr_debug("IRQ not found... code = %d", res);
998 return NO_IRQ;
999 }
1000 /* Assuming single interrupt controller... */
1001 irq = out_irq.specifier[0];
1002
1003 pr_debug("IRQ found = %d", irq);
1004
1005 /* Only dereference the resource if both the
1006 * resource and the irq are valid. */
1007 if (r && irq != NO_IRQ) {
1008 r->start = r->end = irq;
1009 r->flags = IORESOURCE_IRQ;
1010 }
1011
1012 return irq;
1013}
1014EXPORT_SYMBOL_GPL(of_irq_to_resource);
1015
1016void __iomem *of_iomap(struct device_node *np, int index)
1017{
1018 struct resource res;
1019
1020 if (of_address_to_resource(np, index, &res))
1021 return NULL;
1022
1023 return ioremap(res.start, 1 + res.end - res.start);
1024}
1025EXPORT_SYMBOL(of_iomap);
diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c
index a1721a33042e..bd8ccab5ceff 100644
--- a/arch/microblaze/kernel/reset.c
+++ b/arch/microblaze/kernel/reset.c
@@ -24,8 +24,8 @@ static int of_reset_gpio_handle(void)
24 int ret; /* variable which stored handle reset gpio pin */ 24 int ret; /* variable which stored handle reset gpio pin */
25 struct device_node *root; /* root node */ 25 struct device_node *root; /* root node */
26 struct device_node *gpio; /* gpio node */ 26 struct device_node *gpio; /* gpio node */
27 struct of_gpio_chip *of_gc = NULL; 27 struct gpio_chip *gc;
28 enum of_gpio_flags flags ; 28 u32 flags;
29 const void *gpio_spec; 29 const void *gpio_spec;
30 30
31 /* find out root node */ 31 /* find out root node */
@@ -39,19 +39,19 @@ static int of_reset_gpio_handle(void)
39 goto err0; 39 goto err0;
40 } 40 }
41 41
42 of_gc = gpio->data; 42 gc = of_node_to_gpiochip(gpio);
43 if (!of_gc) { 43 if (!gc) {
44 pr_debug("%s: gpio controller %s isn't registered\n", 44 pr_debug("%s: gpio controller %s isn't registered\n",
45 root->full_name, gpio->full_name); 45 root->full_name, gpio->full_name);
46 ret = -ENODEV; 46 ret = -ENODEV;
47 goto err1; 47 goto err1;
48 } 48 }
49 49
50 ret = of_gc->xlate(of_gc, root, gpio_spec, &flags); 50 ret = gc->of_xlate(gc, root, gpio_spec, &flags);
51 if (ret < 0) 51 if (ret < 0)
52 goto err1; 52 goto err1;
53 53
54 ret += of_gc->gc.base; 54 ret += gc->base;
55err1: 55err1:
56 of_node_put(gpio); 56 of_node_put(gpio);
57err0: 57err0:
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 17c98dbcec88..f5f768842354 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -213,15 +213,9 @@ static struct notifier_block dflt_plat_bus_notifier = {
213 .priority = INT_MAX, 213 .priority = INT_MAX,
214}; 214};
215 215
216static struct notifier_block dflt_of_bus_notifier = {
217 .notifier_call = dflt_bus_notify,
218 .priority = INT_MAX,
219};
220
221static int __init setup_bus_notifier(void) 216static int __init setup_bus_notifier(void)
222{ 217{
223 bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); 218 bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier);
224 bus_register_notifier(&of_platform_bus_type, &dflt_of_bus_notifier);
225 219
226 return 0; 220 return 0;
227} 221}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e4545f85ee9f..e2bf40a2ce5a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -120,6 +120,8 @@ config ARCH_NO_VIRT_TO_BUS
120config PPC 120config PPC
121 bool 121 bool
122 default y 122 default y
123 select OF
124 select OF_FLATTREE
123 select HAVE_FTRACE_MCOUNT_RECORD 125 select HAVE_FTRACE_MCOUNT_RECORD
124 select HAVE_DYNAMIC_FTRACE 126 select HAVE_DYNAMIC_FTRACE
125 select HAVE_FUNCTION_TRACER 127 select HAVE_FUNCTION_TRACER
@@ -173,10 +175,6 @@ config ARCH_MAY_HAVE_PC_FDC
173config PPC_OF 175config PPC_OF
174 def_bool y 176 def_bool y
175 177
176config OF
177 def_bool y
178 select OF_FLATTREE
179
180config PPC_UDBG_16550 178config PPC_UDBG_16550
181 bool 179 bool
182 default n 180 default n
@@ -199,10 +197,6 @@ config SYS_SUPPORTS_APM_EMULATION
199 default y if PMAC_APM_EMU 197 default y if PMAC_APM_EMU
200 bool 198 bool
201 199
202config DTC
203 bool
204 default y
205
206config DEFAULT_UIMAGE 200config DEFAULT_UIMAGE
207 bool 201 bool
208 help 202 help
@@ -579,14 +573,6 @@ config SCHED_SMT
579 when dealing with POWER5 cpus at a cost of slightly increased 573 when dealing with POWER5 cpus at a cost of slightly increased
580 overhead in some places. If unsure say N here. 574 overhead in some places. If unsure say N here.
581 575
582config PROC_DEVICETREE
583 bool "Support for device tree in /proc"
584 depends on PROC_FS
585 help
586 This option adds a device-tree directory under /proc which contains
587 an image of the device tree that the kernel copies from Open
588 Firmware or other boot firmware. If unsure, say Y here.
589
590config CMDLINE_BOOL 576config CMDLINE_BOOL
591 bool "Default bootloader kernel arguments" 577 bool "Default bootloader kernel arguments"
592 578
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index ecba37a91749..67ab5fb7d153 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -300,34 +300,6 @@ extern unsigned int irq_alloc_virt(struct irq_host *host,
300 */ 300 */
301extern void irq_free_virt(unsigned int virq, unsigned int count); 301extern void irq_free_virt(unsigned int virq, unsigned int count);
302 302
303
304/* -- OF helpers -- */
305
306/**
307 * irq_create_of_mapping - Map a hardware interrupt into linux virq space
308 * @controller: Device node of the interrupt controller
309 * @inspec: Interrupt specifier from the device-tree
310 * @intsize: Size of the interrupt specifier from the device-tree
311 *
312 * This function is identical to irq_create_mapping except that it takes
313 * as input informations straight from the device-tree (typically the results
314 * of the of_irq_map_*() functions.
315 */
316extern unsigned int irq_create_of_mapping(struct device_node *controller,
317 const u32 *intspec, unsigned int intsize);
318
319/**
320 * irq_of_parse_and_map - Parse and Map an interrupt into linux virq space
321 * @device: Device node of the device whose interrupt is to be mapped
322 * @index: Index of the interrupt to map
323 *
324 * This function is a wrapper that chains of_irq_map_one() and
325 * irq_create_of_mapping() to make things easier to callers
326 */
327extern unsigned int irq_of_parse_and_map(struct device_node *dev, int index);
328
329/* -- End OF helpers -- */
330
331/** 303/**
332 * irq_early_init - Init irq remapping subsystem 304 * irq_early_init - Init irq remapping subsystem
333 */ 305 */
diff --git a/arch/powerpc/include/asm/macio.h b/arch/powerpc/include/asm/macio.h
index 675e159b5ef4..7ab82c825a03 100644
--- a/arch/powerpc/include/asm/macio.h
+++ b/arch/powerpc/include/asm/macio.h
@@ -38,7 +38,7 @@ struct macio_dev
38{ 38{
39 struct macio_bus *bus; /* macio bus this device is on */ 39 struct macio_bus *bus; /* macio bus this device is on */
40 struct macio_dev *media_bay; /* Device is part of a media bay */ 40 struct macio_dev *media_bay; /* Device is part of a media bay */
41 struct of_device ofdev; 41 struct platform_device ofdev;
42 struct device_dma_parameters dma_parms; /* ide needs that */ 42 struct device_dma_parameters dma_parms; /* ide needs that */
43 int n_resources; 43 int n_resources;
44 struct resource resource[MACIO_DEV_COUNT_RESOURCES]; 44 struct resource resource[MACIO_DEV_COUNT_RESOURCES];
diff --git a/arch/powerpc/include/asm/of_device.h b/arch/powerpc/include/asm/of_device.h
deleted file mode 100644
index 444e97e2982e..000000000000
--- a/arch/powerpc/include/asm/of_device.h
+++ /dev/null
@@ -1,27 +0,0 @@
1#ifndef _ASM_POWERPC_OF_DEVICE_H
2#define _ASM_POWERPC_OF_DEVICE_H
3#ifdef __KERNEL__
4
5#include <linux/device.h>
6#include <linux/of.h>
7
8/*
9 * The of_device is a kind of "base class" that is a superset of
10 * struct device for use by devices attached to an OF node and
11 * probed using OF properties.
12 */
13struct of_device
14{
15 struct device dev; /* Generic device interface */
16 struct pdev_archdata archdata;
17};
18
19extern struct of_device *of_device_alloc(struct device_node *np,
20 const char *bus_id,
21 struct device *parent);
22
23extern int of_device_uevent(struct device *dev,
24 struct kobj_uevent_env *env);
25
26#endif /* __KERNEL__ */
27#endif /* _ASM_POWERPC_OF_DEVICE_H */
diff --git a/arch/powerpc/include/asm/of_platform.h b/arch/powerpc/include/asm/of_platform.h
deleted file mode 100644
index d4aaa3489440..000000000000
--- a/arch/powerpc/include/asm/of_platform.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef _ASM_POWERPC_OF_PLATFORM_H
2#define _ASM_POWERPC_OF_PLATFORM_H
3/*
4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
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
14/* Platform devices and busses creation */
15extern struct of_device *of_platform_device_create(struct device_node *np,
16 const char *bus_id,
17 struct device *parent);
18/* pseudo "matches" value to not do deep probe */
19#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
20
21extern int of_platform_bus_probe(struct device_node *root,
22 const struct of_device_id *matches,
23 struct device *parent);
24
25extern struct of_device *of_find_device_by_phandle(phandle ph);
26
27extern void of_instantiate_rtc(void);
28
29#endif /* _ASM_POWERPC_OF_PLATFORM_H */
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 76e1f313a58e..51e9e6f90d12 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -303,13 +303,8 @@ extern void pcibios_free_controller(struct pci_controller *phb);
303extern void pcibios_setup_phb_resources(struct pci_controller *hose); 303extern void pcibios_setup_phb_resources(struct pci_controller *hose);
304 304
305#ifdef CONFIG_PCI 305#ifdef CONFIG_PCI
306extern unsigned long pci_address_to_pio(phys_addr_t address);
307extern int pcibios_vaddr_is_ioport(void __iomem *address); 306extern int pcibios_vaddr_is_ioport(void __iomem *address);
308#else 307#else
309static inline unsigned long pci_address_to_pio(phys_addr_t address)
310{
311 return (unsigned long)-1;
312}
313static inline int pcibios_vaddr_is_ioport(void __iomem *address) 308static inline int pcibios_vaddr_is_ioport(void __iomem *address)
314{ 309{
315 return 0; 310 return 0;
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index ddd408a93b5a..ae26f2efd089 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -17,9 +17,6 @@
17 * 2 of the License, or (at your option) any later version. 17 * 2 of the License, or (at your option) any later version.
18 */ 18 */
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/of_fdt.h>
21#include <linux/proc_fs.h>
22#include <linux/platform_device.h>
23#include <asm/irq.h> 20#include <asm/irq.h>
24#include <asm/atomic.h> 21#include <asm/atomic.h>
25 22
@@ -43,49 +40,14 @@ extern void pci_create_OF_bus_map(void);
43 * OF address retreival & translation 40 * OF address retreival & translation
44 */ 41 */
45 42
46/* Translate an OF address block into a CPU physical address
47 */
48extern u64 of_translate_address(struct device_node *np, const u32 *addr);
49
50/* Translate a DMA address from device space to CPU space */ 43/* Translate a DMA address from device space to CPU space */
51extern u64 of_translate_dma_address(struct device_node *dev, 44extern u64 of_translate_dma_address(struct device_node *dev,
52 const u32 *in_addr); 45 const u32 *in_addr);
53 46
54/* Extract an address from a device, returns the region size and
55 * the address space flags too. The PCI version uses a BAR number
56 * instead of an absolute index
57 */
58extern const u32 *of_get_address(struct device_node *dev, int index,
59 u64 *size, unsigned int *flags);
60#ifdef CONFIG_PCI 47#ifdef CONFIG_PCI
61extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, 48extern unsigned long pci_address_to_pio(phys_addr_t address);
62 u64 *size, unsigned int *flags); 49#define pci_address_to_pio pci_address_to_pio
63#else 50#endif /* CONFIG_PCI */
64static inline const u32 *of_get_pci_address(struct device_node *dev,
65 int bar_no, u64 *size, unsigned int *flags)
66{
67 return NULL;
68}
69#endif /* CONFIG_PCI */
70
71/* Get an address as a resource. Note that if your address is
72 * a PIO address, the conversion will fail if the physical address
73 * can't be internally converted to an IO token with
74 * pci_address_to_pio(), that is because it's either called to early
75 * or it can't be matched to any host bridge IO space
76 */
77extern int of_address_to_resource(struct device_node *dev, int index,
78 struct resource *r);
79#ifdef CONFIG_PCI
80extern int of_pci_address_to_resource(struct device_node *dev, int bar,
81 struct resource *r);
82#else
83static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
84 struct resource *r)
85{
86 return -ENOSYS;
87}
88#endif /* CONFIG_PCI */
89 51
90/* Parse the ibm,dma-window property of an OF node into the busno, phys and 52/* Parse the ibm,dma-window property of an OF node into the busno, phys and
91 * size parameters. 53 * size parameters.
@@ -104,69 +66,12 @@ struct device_node *of_find_next_cache_node(struct device_node *np);
104/* Get the MAC address */ 66/* Get the MAC address */
105extern const void *of_get_mac_address(struct device_node *np); 67extern const void *of_get_mac_address(struct device_node *np);
106 68
107/* 69#ifdef CONFIG_NUMA
108 * OF interrupt mapping 70extern int of_node_to_nid(struct device_node *device);
109 */ 71#else
110 72static inline int of_node_to_nid(struct device_node *device) { return 0; }
111/* This structure is returned when an interrupt is mapped. The controller 73#endif
112 * field needs to be put() after use 74#define of_node_to_nid of_node_to_nid
113 */
114
115#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
116
117struct of_irq {
118 struct device_node *controller; /* Interrupt controller node */
119 u32 size; /* Specifier size */
120 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
121};
122
123/**
124 * of_irq_map_init - Initialize the irq remapper
125 * @flags: flags defining workarounds to enable
126 *
127 * Some machines have bugs in the device-tree which require certain workarounds
128 * to be applied. Call this before any interrupt mapping attempts to enable
129 * those workarounds.
130 */
131#define OF_IMAP_OLDWORLD_MAC 0x00000001
132#define OF_IMAP_NO_PHANDLE 0x00000002
133
134extern void of_irq_map_init(unsigned int flags);
135
136/**
137 * of_irq_map_raw - Low level interrupt tree parsing
138 * @parent: the device interrupt parent
139 * @intspec: interrupt specifier ("interrupts" property of the device)
140 * @ointsize: size of the passed in interrupt specifier
141 * @addr: address specifier (start of "reg" property of the device)
142 * @out_irq: structure of_irq filled by this function
143 *
144 * Returns 0 on success and a negative number on error
145 *
146 * This function is a low-level interrupt tree walking function. It
147 * can be used to do a partial walk with synthetized reg and interrupts
148 * properties, for example when resolving PCI interrupts when no device
149 * node exist for the parent.
150 *
151 */
152
153extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
154 u32 ointsize, const u32 *addr,
155 struct of_irq *out_irq);
156
157
158/**
159 * of_irq_map_one - Resolve an interrupt for a device
160 * @device: the device whose interrupt is to be resolved
161 * @index: index of the interrupt to resolve
162 * @out_irq: structure of_irq filled by this function
163 *
164 * This function resolves an interrupt, walking the tree, for a given
165 * device-tree node. It's the high level pendant to of_irq_map_raw().
166 * It also implements the workarounds for OldWolrd Macs.
167 */
168extern int of_irq_map_one(struct device_node *device, int index,
169 struct of_irq *out_irq);
170 75
171/** 76/**
172 * of_irq_map_pci - Resolve the interrupt for a PCI device 77 * of_irq_map_pci - Resolve the interrupt for a PCI device
@@ -180,19 +85,19 @@ extern int of_irq_map_one(struct device_node *device, int index,
180 * resolving using the OF tree walking. 85 * resolving using the OF tree walking.
181 */ 86 */
182struct pci_dev; 87struct pci_dev;
88struct of_irq;
183extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); 89extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
184 90
185extern int of_irq_to_resource(struct device_node *dev, int index, 91extern void of_instantiate_rtc(void);
186 struct resource *r);
187 92
188/** 93/* These includes are put at the bottom because they may contain things
189 * of_iomap - Maps the memory mapped IO for a given device_node 94 * that are overridden by this file. Ideally they shouldn't be included
190 * @device: the device whose io range will be mapped 95 * by this file, but there are a bunch of .c files that currently depend
191 * @index: index of the io range 96 * on it. Eventually they will be cleaned up. */
192 * 97#include <linux/of_fdt.h>
193 * Returns a pointer to the mapped memory 98#include <linux/of_address.h>
194 */ 99#include <linux/of_irq.h>
195extern void __iomem *of_iomap(struct device_node *device, int index); 100#include <linux/platform_device.h>
196 101
197#endif /* __KERNEL__ */ 102#endif /* __KERNEL__ */
198#endif /* _POWERPC_PROM_H */ 103#endif /* _POWERPC_PROM_H */
diff --git a/arch/powerpc/include/asm/smu.h b/arch/powerpc/include/asm/smu.h
index 7ae2753da565..e3bdada8c542 100644
--- a/arch/powerpc/include/asm/smu.h
+++ b/arch/powerpc/include/asm/smu.h
@@ -457,8 +457,8 @@ extern void smu_poll(void);
457 */ 457 */
458extern int smu_init(void); 458extern int smu_init(void);
459extern int smu_present(void); 459extern int smu_present(void);
460struct of_device; 460struct platform_device;
461extern struct of_device *smu_get_ofdev(void); 461extern struct platform_device *smu_get_ofdev(void);
462 462
463 463
464/* 464/*
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 3033c1b30745..afe4aaa65c3b 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -41,8 +41,6 @@ static inline int cpu_to_node(int cpu)
41 cpu_all_mask : \ 41 cpu_all_mask : \
42 node_to_cpumask_map[node]) 42 node_to_cpumask_map[node])
43 43
44int of_node_to_nid(struct device_node *device);
45
46struct pci_bus; 44struct pci_bus;
47#ifdef CONFIG_PCI 45#ifdef CONFIG_PCI
48extern int pcibus_to_node(struct pci_bus *bus); 46extern int pcibus_to_node(struct pci_bus *bus);
@@ -97,11 +95,6 @@ extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid);
97 95
98#else 96#else
99 97
100static inline int of_node_to_nid(struct device_node *device)
101{
102 return 0;
103}
104
105static inline void dump_numa_cpu_topology(void) {} 98static inline void dump_numa_cpu_topology(void) {}
106 99
107static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid) 100static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid)
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 77d831a1cc32..1dda70129141 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o
41obj-$(CONFIG_PPC64) += vdso64/ 41obj-$(CONFIG_PPC64) += vdso64/
42obj-$(CONFIG_ALTIVEC) += vecemu.o 42obj-$(CONFIG_ALTIVEC) += vecemu.o
43obj-$(CONFIG_PPC_970_NAP) += idle_power4.o 43obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
44obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o 44obj-$(CONFIG_PPC_OF) += of_platform.o prom_parse.o
45obj-$(CONFIG_PPC_CLOCK) += clock.o 45obj-$(CONFIG_PPC_CLOCK) += clock.o
46procfs-y := proc_powerpc.o 46procfs-y := proc_powerpc.o
47obj-$(CONFIG_PROC_FS) += $(procfs-y) 47obj-$(CONFIG_PROC_FS) += $(procfs-y)
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 02f724f36753..4295e0b94b2d 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -82,17 +82,9 @@ static struct notifier_block ppc_swiotlb_plat_bus_notifier = {
82 .priority = 0, 82 .priority = 0,
83}; 83};
84 84
85static struct notifier_block ppc_swiotlb_of_bus_notifier = {
86 .notifier_call = ppc_swiotlb_bus_notify,
87 .priority = 0,
88};
89
90int __init swiotlb_setup_bus_notifier(void) 85int __init swiotlb_setup_bus_notifier(void)
91{ 86{
92 bus_register_notifier(&platform_bus_type, 87 bus_register_notifier(&platform_bus_type,
93 &ppc_swiotlb_plat_bus_notifier); 88 &ppc_swiotlb_plat_bus_notifier);
94 bus_register_notifier(&of_platform_bus_type,
95 &ppc_swiotlb_of_bus_notifier);
96
97 return 0; 89 return 0;
98} 90}
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 21266abfbda6..9b626cfffce1 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -140,19 +140,19 @@ static struct dma_map_ops ibmebus_dma_ops = {
140 140
141static int ibmebus_match_path(struct device *dev, void *data) 141static int ibmebus_match_path(struct device *dev, void *data)
142{ 142{
143 struct device_node *dn = to_of_device(dev)->dev.of_node; 143 struct device_node *dn = to_platform_device(dev)->dev.of_node;
144 return (dn->full_name && 144 return (dn->full_name &&
145 (strcasecmp((char *)data, dn->full_name) == 0)); 145 (strcasecmp((char *)data, dn->full_name) == 0));
146} 146}
147 147
148static int ibmebus_match_node(struct device *dev, void *data) 148static int ibmebus_match_node(struct device *dev, void *data)
149{ 149{
150 return to_of_device(dev)->dev.of_node == data; 150 return to_platform_device(dev)->dev.of_node == data;
151} 151}
152 152
153static int ibmebus_create_device(struct device_node *dn) 153static int ibmebus_create_device(struct device_node *dn)
154{ 154{
155 struct of_device *dev; 155 struct platform_device *dev;
156 int ret; 156 int ret;
157 157
158 dev = of_device_alloc(dn, NULL, &ibmebus_bus_device); 158 dev = of_device_alloc(dn, NULL, &ibmebus_bus_device);
@@ -298,7 +298,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
298 298
299 if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path, 299 if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
300 ibmebus_match_path))) { 300 ibmebus_match_path))) {
301 of_device_unregister(to_of_device(dev)); 301 of_device_unregister(to_platform_device(dev));
302 302
303 kfree(path); 303 kfree(path);
304 return count; 304 return count;
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 8f96d3198905..d3ce67cf03be 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -53,6 +53,8 @@
53#include <linux/bootmem.h> 53#include <linux/bootmem.h>
54#include <linux/pci.h> 54#include <linux/pci.h>
55#include <linux/debugfs.h> 55#include <linux/debugfs.h>
56#include <linux/of.h>
57#include <linux/of_irq.h>
56 58
57#include <asm/uaccess.h> 59#include <asm/uaccess.h>
58#include <asm/system.h> 60#include <asm/system.h>
@@ -820,18 +822,6 @@ unsigned int irq_create_of_mapping(struct device_node *controller,
820} 822}
821EXPORT_SYMBOL_GPL(irq_create_of_mapping); 823EXPORT_SYMBOL_GPL(irq_create_of_mapping);
822 824
823unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
824{
825 struct of_irq oirq;
826
827 if (of_irq_map_one(dev, index, &oirq))
828 return NO_IRQ;
829
830 return irq_create_of_mapping(oirq.controller, oirq.specifier,
831 oirq.size);
832}
833EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
834
835void irq_dispose_mapping(unsigned int virq) 825void irq_dispose_mapping(unsigned int virq)
836{ 826{
837 struct irq_host *host; 827 struct irq_host *host;
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 035ada5443ee..c1fd0f9658fd 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -4,6 +4,7 @@
4#include <linux/serial_core.h> 4#include <linux/serial_core.h>
5#include <linux/console.h> 5#include <linux/console.h>
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/of_address.h>
7#include <linux/of_device.h> 8#include <linux/of_device.h>
8#include <asm/io.h> 9#include <asm/io.h>
9#include <asm/mmu.h> 10#include <asm/mmu.h>
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
deleted file mode 100644
index df78e0236a02..000000000000
--- a/arch/powerpc/kernel/of_device.c
+++ /dev/null
@@ -1,133 +0,0 @@
1#include <linux/string.h>
2#include <linux/kernel.h>
3#include <linux/of.h>
4#include <linux/init.h>
5#include <linux/module.h>
6#include <linux/mod_devicetable.h>
7#include <linux/slab.h>
8#include <linux/of_device.h>
9
10#include <asm/errno.h>
11#include <asm/dcr.h>
12
13static void of_device_make_bus_id(struct of_device *dev)
14{
15 static atomic_t bus_no_reg_magic;
16 struct device_node *node = dev->dev.of_node;
17 const u32 *reg;
18 u64 addr;
19 int magic;
20
21 /*
22 * If it's a DCR based device, use 'd' for native DCRs
23 * and 'D' for MMIO DCRs.
24 */
25#ifdef CONFIG_PPC_DCR
26 reg = of_get_property(node, "dcr-reg", NULL);
27 if (reg) {
28#ifdef CONFIG_PPC_DCR_NATIVE
29 dev_set_name(&dev->dev, "d%x.%s", *reg, node->name);
30#else /* CONFIG_PPC_DCR_NATIVE */
31 addr = of_translate_dcr_address(node, *reg, NULL);
32 if (addr != OF_BAD_ADDR) {
33 dev_set_name(&dev->dev, "D%llx.%s",
34 (unsigned long long)addr, node->name);
35 return;
36 }
37#endif /* !CONFIG_PPC_DCR_NATIVE */
38 }
39#endif /* CONFIG_PPC_DCR */
40
41 /*
42 * For MMIO, get the physical address
43 */
44 reg = of_get_property(node, "reg", NULL);
45 if (reg) {
46 addr = of_translate_address(node, reg);
47 if (addr != OF_BAD_ADDR) {
48 dev_set_name(&dev->dev, "%llx.%s",
49 (unsigned long long)addr, node->name);
50 return;
51 }
52 }
53
54 /*
55 * No BusID, use the node name and add a globally incremented
56 * counter (and pray...)
57 */
58 magic = atomic_add_return(1, &bus_no_reg_magic);
59 dev_set_name(&dev->dev, "%s.%d", node->name, magic - 1);
60}
61
62struct of_device *of_device_alloc(struct device_node *np,
63 const char *bus_id,
64 struct device *parent)
65{
66 struct of_device *dev;
67
68 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
69 if (!dev)
70 return NULL;
71
72 dev->dev.of_node = of_node_get(np);
73 dev->dev.dma_mask = &dev->archdata.dma_mask;
74 dev->dev.parent = parent;
75 dev->dev.release = of_release_dev;
76
77 if (bus_id)
78 dev_set_name(&dev->dev, "%s", bus_id);
79 else
80 of_device_make_bus_id(dev);
81
82 return dev;
83}
84EXPORT_SYMBOL(of_device_alloc);
85
86int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
87{
88 struct of_device *ofdev;
89 const char *compat;
90 int seen = 0, cplen, sl;
91
92 if (!dev)
93 return -ENODEV;
94
95 ofdev = to_of_device(dev);
96
97 if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
98 return -ENOMEM;
99
100 if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
101 return -ENOMEM;
102
103 /* Since the compatible field can contain pretty much anything
104 * it's not really legal to split it out with commas. We split it
105 * up using a number of environment variables instead. */
106
107 compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
108 while (compat && *compat && cplen > 0) {
109 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
110 return -ENOMEM;
111
112 sl = strlen (compat) + 1;
113 compat += sl;
114 cplen -= sl;
115 seen++;
116 }
117
118 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen))
119 return -ENOMEM;
120
121 /* modalias is trickier, we add it in 2 steps */
122 if (add_uevent_var(env, "MODALIAS="))
123 return -ENOMEM;
124 sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1],
125 sizeof(env->buf) - env->buflen);
126 if (sl >= (sizeof(env->buf) - env->buflen))
127 return -ENOMEM;
128 env->buflen += sl;
129
130 return 0;
131}
132EXPORT_SYMBOL(of_device_uevent);
133EXPORT_SYMBOL(of_device_get_modalias);
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 487a98851ba6..b2c363ef38ad 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -28,207 +28,6 @@
28#include <asm/ppc-pci.h> 28#include <asm/ppc-pci.h>
29#include <asm/atomic.h> 29#include <asm/atomic.h>
30 30
31/*
32 * The list of OF IDs below is used for matching bus types in the
33 * system whose devices are to be exposed as of_platform_devices.
34 *
35 * This is the default list valid for most platforms. This file provides
36 * functions who can take an explicit list if necessary though
37 *
38 * The search is always performed recursively looking for children of
39 * the provided device_node and recursively if such a children matches
40 * a bus type in the list
41 */
42
43static const struct of_device_id of_default_bus_ids[] = {
44 { .type = "soc", },
45 { .compatible = "soc", },
46 { .type = "spider", },
47 { .type = "axon", },
48 { .type = "plb5", },
49 { .type = "plb4", },
50 { .type = "opb", },
51 { .type = "ebc", },
52 {},
53};
54
55struct bus_type of_platform_bus_type = {
56 .uevent = of_device_uevent,
57};
58EXPORT_SYMBOL(of_platform_bus_type);
59
60static int __init of_bus_driver_init(void)
61{
62 return of_bus_type_init(&of_platform_bus_type, "of_platform");
63}
64
65postcore_initcall(of_bus_driver_init);
66
67struct of_device* of_platform_device_create(struct device_node *np,
68 const char *bus_id,
69 struct device *parent)
70{
71 struct of_device *dev;
72
73 dev = of_device_alloc(np, bus_id, parent);
74 if (!dev)
75 return NULL;
76
77 dev->archdata.dma_mask = 0xffffffffUL;
78 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
79
80 dev->dev.bus = &of_platform_bus_type;
81
82 /* We do not fill the DMA ops for platform devices by default.
83 * This is currently the responsibility of the platform code
84 * to do such, possibly using a device notifier
85 */
86
87 if (of_device_register(dev) != 0) {
88 of_device_free(dev);
89 return NULL;
90 }
91
92 return dev;
93}
94EXPORT_SYMBOL(of_platform_device_create);
95
96
97
98/**
99 * of_platform_bus_create - Create an OF device for a bus node and all its
100 * children. Optionally recursively instanciate matching busses.
101 * @bus: device node of the bus to instanciate
102 * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to
103 * disallow recursive creation of child busses
104 */
105static int of_platform_bus_create(const struct device_node *bus,
106 const struct of_device_id *matches,
107 struct device *parent)
108{
109 struct device_node *child;
110 struct of_device *dev;
111 int rc = 0;
112
113 for_each_child_of_node(bus, child) {
114 pr_debug(" create child: %s\n", child->full_name);
115 dev = of_platform_device_create(child, NULL, parent);
116 if (dev == NULL)
117 rc = -ENOMEM;
118 else if (!of_match_node(matches, child))
119 continue;
120 if (rc == 0) {
121 pr_debug(" and sub busses\n");
122 rc = of_platform_bus_create(child, matches, &dev->dev);
123 } if (rc) {
124 of_node_put(child);
125 break;
126 }
127 }
128 return rc;
129}
130
131/**
132 * of_platform_bus_probe - Probe the device-tree for platform busses
133 * @root: parent of the first level to probe or NULL for the root of the tree
134 * @matches: match table, NULL to use the default
135 * @parent: parent to hook devices from, NULL for toplevel
136 *
137 * Note that children of the provided root are not instanciated as devices
138 * unless the specified root itself matches the bus list and is not NULL.
139 */
140
141int of_platform_bus_probe(struct device_node *root,
142 const struct of_device_id *matches,
143 struct device *parent)
144{
145 struct device_node *child;
146 struct of_device *dev;
147 int rc = 0;
148
149 if (matches == NULL)
150 matches = of_default_bus_ids;
151 if (matches == OF_NO_DEEP_PROBE)
152 return -EINVAL;
153 if (root == NULL)
154 root = of_find_node_by_path("/");
155 else
156 of_node_get(root);
157
158 pr_debug("of_platform_bus_probe()\n");
159 pr_debug(" starting at: %s\n", root->full_name);
160
161 /* Do a self check of bus type, if there's a match, create
162 * children
163 */
164 if (of_match_node(matches, root)) {
165 pr_debug(" root match, create all sub devices\n");
166 dev = of_platform_device_create(root, NULL, parent);
167 if (dev == NULL) {
168 rc = -ENOMEM;
169 goto bail;
170 }
171 pr_debug(" create all sub busses\n");
172 rc = of_platform_bus_create(root, matches, &dev->dev);
173 goto bail;
174 }
175 for_each_child_of_node(root, child) {
176 if (!of_match_node(matches, child))
177 continue;
178
179 pr_debug(" match: %s\n", child->full_name);
180 dev = of_platform_device_create(child, NULL, parent);
181 if (dev == NULL)
182 rc = -ENOMEM;
183 else
184 rc = of_platform_bus_create(child, matches, &dev->dev);
185 if (rc) {
186 of_node_put(child);
187 break;
188 }
189 }
190 bail:
191 of_node_put(root);
192 return rc;
193}
194EXPORT_SYMBOL(of_platform_bus_probe);
195
196static int of_dev_node_match(struct device *dev, void *data)
197{
198 return to_of_device(dev)->dev.of_node == data;
199}
200
201struct of_device *of_find_device_by_node(struct device_node *np)
202{
203 struct device *dev;
204
205 dev = bus_find_device(&of_platform_bus_type,
206 NULL, np, of_dev_node_match);
207 if (dev)
208 return to_of_device(dev);
209 return NULL;
210}
211EXPORT_SYMBOL(of_find_device_by_node);
212
213static int of_dev_phandle_match(struct device *dev, void *data)
214{
215 phandle *ph = data;
216 return to_of_device(dev)->dev.of_node->phandle == *ph;
217}
218
219struct of_device *of_find_device_by_phandle(phandle ph)
220{
221 struct device *dev;
222
223 dev = bus_find_device(&of_platform_bus_type,
224 NULL, &ph, of_dev_phandle_match);
225 if (dev)
226 return to_of_device(dev);
227 return NULL;
228}
229EXPORT_SYMBOL(of_find_device_by_phandle);
230
231
232#ifdef CONFIG_PPC_OF_PLATFORM_PCI 31#ifdef CONFIG_PPC_OF_PLATFORM_PCI
233 32
234/* The probing of PCI controllers from of_platform is currently 33/* The probing of PCI controllers from of_platform is currently
@@ -237,7 +36,7 @@ EXPORT_SYMBOL(of_find_device_by_phandle);
237 * lacking some bits needed here. 36 * lacking some bits needed here.
238 */ 37 */
239 38
240static int __devinit of_pci_phb_probe(struct of_device *dev, 39static int __devinit of_pci_phb_probe(struct platform_device *dev,
241 const struct of_device_id *match) 40 const struct of_device_id *match)
242{ 41{
243 struct pci_controller *phb; 42 struct pci_controller *phb;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 5b38f6ae2b29..9021c4ad4bbd 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -21,6 +21,7 @@
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/of_address.h>
24#include <linux/mm.h> 25#include <linux/mm.h>
25#include <linux/list.h> 26#include <linux/list.h>
26#include <linux/syscalls.h> 27#include <linux/syscalls.h>
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 8362620c9e6f..88334af038e5 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -6,232 +6,11 @@
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/ioport.h> 7#include <linux/ioport.h>
8#include <linux/etherdevice.h> 8#include <linux/etherdevice.h>
9#include <linux/of_address.h>
9#include <asm/prom.h> 10#include <asm/prom.h>
10#include <asm/pci-bridge.h> 11#include <asm/pci-bridge.h>
11 12
12#ifdef DEBUG
13#define DBG(fmt...) do { printk(fmt); } while(0)
14#else
15#define DBG(fmt...) do { } while(0)
16#endif
17
18#ifdef CONFIG_PPC64
19#define PRu64 "%lx"
20#else
21#define PRu64 "%llx"
22#endif
23
24/* Max address size we deal with */
25#define OF_MAX_ADDR_CELLS 4
26#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
27 (ns) > 0)
28
29static struct of_bus *of_match_bus(struct device_node *np);
30static int __of_address_to_resource(struct device_node *dev,
31 const u32 *addrp, u64 size, unsigned int flags,
32 struct resource *r);
33
34
35/* Debug utility */
36#ifdef DEBUG
37static void of_dump_addr(const char *s, const u32 *addr, int na)
38{
39 printk("%s", s);
40 while(na--)
41 printk(" %08x", *(addr++));
42 printk("\n");
43}
44#else
45static void of_dump_addr(const char *s, const u32 *addr, int na) { }
46#endif
47
48
49/* Callbacks for bus specific translators */
50struct of_bus {
51 const char *name;
52 const char *addresses;
53 int (*match)(struct device_node *parent);
54 void (*count_cells)(struct device_node *child,
55 int *addrc, int *sizec);
56 u64 (*map)(u32 *addr, const u32 *range,
57 int na, int ns, int pna);
58 int (*translate)(u32 *addr, u64 offset, int na);
59 unsigned int (*get_flags)(const u32 *addr);
60};
61
62
63/*
64 * Default translator (generic bus)
65 */
66
67static void of_bus_default_count_cells(struct device_node *dev,
68 int *addrc, int *sizec)
69{
70 if (addrc)
71 *addrc = of_n_addr_cells(dev);
72 if (sizec)
73 *sizec = of_n_size_cells(dev);
74}
75
76static u64 of_bus_default_map(u32 *addr, const u32 *range,
77 int na, int ns, int pna)
78{
79 u64 cp, s, da;
80
81 cp = of_read_number(range, na);
82 s = of_read_number(range + na + pna, ns);
83 da = of_read_number(addr, na);
84
85 DBG("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n",
86 cp, s, da);
87
88 if (da < cp || da >= (cp + s))
89 return OF_BAD_ADDR;
90 return da - cp;
91}
92
93static int of_bus_default_translate(u32 *addr, u64 offset, int na)
94{
95 u64 a = of_read_number(addr, na);
96 memset(addr, 0, na * 4);
97 a += offset;
98 if (na > 1)
99 addr[na - 2] = a >> 32;
100 addr[na - 1] = a & 0xffffffffu;
101
102 return 0;
103}
104
105static unsigned int of_bus_default_get_flags(const u32 *addr)
106{
107 return IORESOURCE_MEM;
108}
109
110
111#ifdef CONFIG_PCI 13#ifdef CONFIG_PCI
112/*
113 * PCI bus specific translator
114 */
115
116static int of_bus_pci_match(struct device_node *np)
117{
118 /* "vci" is for the /chaos bridge on 1st-gen PCI powermacs */
119 return !strcmp(np->type, "pci") || !strcmp(np->type, "vci");
120}
121
122static void of_bus_pci_count_cells(struct device_node *np,
123 int *addrc, int *sizec)
124{
125 if (addrc)
126 *addrc = 3;
127 if (sizec)
128 *sizec = 2;
129}
130
131static unsigned int of_bus_pci_get_flags(const u32 *addr)
132{
133 unsigned int flags = 0;
134 u32 w = addr[0];
135
136 switch((w >> 24) & 0x03) {
137 case 0x01:
138 flags |= IORESOURCE_IO;
139 break;
140 case 0x02: /* 32 bits */
141 case 0x03: /* 64 bits */
142 flags |= IORESOURCE_MEM;
143 break;
144 }
145 if (w & 0x40000000)
146 flags |= IORESOURCE_PREFETCH;
147 return flags;
148}
149
150static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
151{
152 u64 cp, s, da;
153 unsigned int af, rf;
154
155 af = of_bus_pci_get_flags(addr);
156 rf = of_bus_pci_get_flags(range);
157
158 /* Check address type match */
159 if ((af ^ rf) & (IORESOURCE_MEM | IORESOURCE_IO))
160 return OF_BAD_ADDR;
161
162 /* Read address values, skipping high cell */
163 cp = of_read_number(range + 1, na - 1);
164 s = of_read_number(range + na + pna, ns);
165 da = of_read_number(addr + 1, na - 1);
166
167 DBG("OF: PCI map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da);
168
169 if (da < cp || da >= (cp + s))
170 return OF_BAD_ADDR;
171 return da - cp;
172}
173
174static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
175{
176 return of_bus_default_translate(addr + 1, offset, na - 1);
177}
178
179const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
180 unsigned int *flags)
181{
182 const u32 *prop;
183 unsigned int psize;
184 struct device_node *parent;
185 struct of_bus *bus;
186 int onesize, i, na, ns;
187
188 /* Get parent & match bus type */
189 parent = of_get_parent(dev);
190 if (parent == NULL)
191 return NULL;
192 bus = of_match_bus(parent);
193 if (strcmp(bus->name, "pci")) {
194 of_node_put(parent);
195 return NULL;
196 }
197 bus->count_cells(dev, &na, &ns);
198 of_node_put(parent);
199 if (!OF_CHECK_COUNTS(na, ns))
200 return NULL;
201
202 /* Get "reg" or "assigned-addresses" property */
203 prop = of_get_property(dev, bus->addresses, &psize);
204 if (prop == NULL)
205 return NULL;
206 psize /= 4;
207
208 onesize = na + ns;
209 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
210 if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
211 if (size)
212 *size = of_read_number(prop + na, ns);
213 if (flags)
214 *flags = bus->get_flags(prop);
215 return prop;
216 }
217 return NULL;
218}
219EXPORT_SYMBOL(of_get_pci_address);
220
221int of_pci_address_to_resource(struct device_node *dev, int bar,
222 struct resource *r)
223{
224 const u32 *addrp;
225 u64 size;
226 unsigned int flags;
227
228 addrp = of_get_pci_address(dev, bar, &size, &flags);
229 if (addrp == NULL)
230 return -EINVAL;
231 return __of_address_to_resource(dev, addrp, size, flags, r);
232}
233EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
234
235int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq) 14int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
236{ 15{
237 struct device_node *dn, *ppnode; 16 struct device_node *dn, *ppnode;
@@ -313,345 +92,6 @@ int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
313EXPORT_SYMBOL_GPL(of_irq_map_pci); 92EXPORT_SYMBOL_GPL(of_irq_map_pci);
314#endif /* CONFIG_PCI */ 93#endif /* CONFIG_PCI */
315 94
316/*
317 * ISA bus specific translator
318 */
319
320static int of_bus_isa_match(struct device_node *np)
321{
322 return !strcmp(np->name, "isa");
323}
324
325static void of_bus_isa_count_cells(struct device_node *child,
326 int *addrc, int *sizec)
327{
328 if (addrc)
329 *addrc = 2;
330 if (sizec)
331 *sizec = 1;
332}
333
334static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
335{
336 u64 cp, s, da;
337
338 /* Check address type match */
339 if ((addr[0] ^ range[0]) & 0x00000001)
340 return OF_BAD_ADDR;
341
342 /* Read address values, skipping high cell */
343 cp = of_read_number(range + 1, na - 1);
344 s = of_read_number(range + na + pna, ns);
345 da = of_read_number(addr + 1, na - 1);
346
347 DBG("OF: ISA map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da);
348
349 if (da < cp || da >= (cp + s))
350 return OF_BAD_ADDR;
351 return da - cp;
352}
353
354static int of_bus_isa_translate(u32 *addr, u64 offset, int na)
355{
356 return of_bus_default_translate(addr + 1, offset, na - 1);
357}
358
359static unsigned int of_bus_isa_get_flags(const u32 *addr)
360{
361 unsigned int flags = 0;
362 u32 w = addr[0];
363
364 if (w & 1)
365 flags |= IORESOURCE_IO;
366 else
367 flags |= IORESOURCE_MEM;
368 return flags;
369}
370
371
372/*
373 * Array of bus specific translators
374 */
375
376static struct of_bus of_busses[] = {
377#ifdef CONFIG_PCI
378 /* PCI */
379 {
380 .name = "pci",
381 .addresses = "assigned-addresses",
382 .match = of_bus_pci_match,
383 .count_cells = of_bus_pci_count_cells,
384 .map = of_bus_pci_map,
385 .translate = of_bus_pci_translate,
386 .get_flags = of_bus_pci_get_flags,
387 },
388#endif /* CONFIG_PCI */
389 /* ISA */
390 {
391 .name = "isa",
392 .addresses = "reg",
393 .match = of_bus_isa_match,
394 .count_cells = of_bus_isa_count_cells,
395 .map = of_bus_isa_map,
396 .translate = of_bus_isa_translate,
397 .get_flags = of_bus_isa_get_flags,
398 },
399 /* Default */
400 {
401 .name = "default",
402 .addresses = "reg",
403 .match = NULL,
404 .count_cells = of_bus_default_count_cells,
405 .map = of_bus_default_map,
406 .translate = of_bus_default_translate,
407 .get_flags = of_bus_default_get_flags,
408 },
409};
410
411static struct of_bus *of_match_bus(struct device_node *np)
412{
413 int i;
414
415 for (i = 0; i < ARRAY_SIZE(of_busses); i ++)
416 if (!of_busses[i].match || of_busses[i].match(np))
417 return &of_busses[i];
418 BUG();
419 return NULL;
420}
421
422static int of_translate_one(struct device_node *parent, struct of_bus *bus,
423 struct of_bus *pbus, u32 *addr,
424 int na, int ns, int pna, const char *rprop)
425{
426 const u32 *ranges;
427 unsigned int rlen;
428 int rone;
429 u64 offset = OF_BAD_ADDR;
430
431 /* Normally, an absence of a "ranges" property means we are
432 * crossing a non-translatable boundary, and thus the addresses
433 * below the current not cannot be converted to CPU physical ones.
434 * Unfortunately, while this is very clear in the spec, it's not
435 * what Apple understood, and they do have things like /uni-n or
436 * /ht nodes with no "ranges" property and a lot of perfectly
437 * useable mapped devices below them. Thus we treat the absence of
438 * "ranges" as equivalent to an empty "ranges" property which means
439 * a 1:1 translation at that level. It's up to the caller not to try
440 * to translate addresses that aren't supposed to be translated in
441 * the first place. --BenH.
442 */
443 ranges = of_get_property(parent, rprop, &rlen);
444 if (ranges == NULL || rlen == 0) {
445 offset = of_read_number(addr, na);
446 memset(addr, 0, pna * 4);
447 DBG("OF: no ranges, 1:1 translation\n");
448 goto finish;
449 }
450
451 DBG("OF: walking ranges...\n");
452
453 /* Now walk through the ranges */
454 rlen /= 4;
455 rone = na + pna + ns;
456 for (; rlen >= rone; rlen -= rone, ranges += rone) {
457 offset = bus->map(addr, ranges, na, ns, pna);
458 if (offset != OF_BAD_ADDR)
459 break;
460 }
461 if (offset == OF_BAD_ADDR) {
462 DBG("OF: not found !\n");
463 return 1;
464 }
465 memcpy(addr, ranges + na, 4 * pna);
466
467 finish:
468 of_dump_addr("OF: parent translation for:", addr, pna);
469 DBG("OF: with offset: "PRu64"\n", offset);
470
471 /* Translate it into parent bus space */
472 return pbus->translate(addr, offset, pna);
473}
474
475
476/*
477 * Translate an address from the device-tree into a CPU physical address,
478 * this walks up the tree and applies the various bus mappings on the
479 * way.
480 *
481 * Note: We consider that crossing any level with #size-cells == 0 to mean
482 * that translation is impossible (that is we are not dealing with a value
483 * that can be mapped to a cpu physical address). This is not really specified
484 * that way, but this is traditionally the way IBM at least do things
485 */
486u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
487 const char *rprop)
488{
489 struct device_node *parent = NULL;
490 struct of_bus *bus, *pbus;
491 u32 addr[OF_MAX_ADDR_CELLS];
492 int na, ns, pna, pns;
493 u64 result = OF_BAD_ADDR;
494
495 DBG("OF: ** translation for device %s **\n", dev->full_name);
496
497 /* Increase refcount at current level */
498 of_node_get(dev);
499
500 /* Get parent & match bus type */
501 parent = of_get_parent(dev);
502 if (parent == NULL)
503 goto bail;
504 bus = of_match_bus(parent);
505
506 /* Cound address cells & copy address locally */
507 bus->count_cells(dev, &na, &ns);
508 if (!OF_CHECK_COUNTS(na, ns)) {
509 printk(KERN_ERR "prom_parse: Bad cell count for %s\n",
510 dev->full_name);
511 goto bail;
512 }
513 memcpy(addr, in_addr, na * 4);
514
515 DBG("OF: bus is %s (na=%d, ns=%d) on %s\n",
516 bus->name, na, ns, parent->full_name);
517 of_dump_addr("OF: translating address:", addr, na);
518
519 /* Translate */
520 for (;;) {
521 /* Switch to parent bus */
522 of_node_put(dev);
523 dev = parent;
524 parent = of_get_parent(dev);
525
526 /* If root, we have finished */
527 if (parent == NULL) {
528 DBG("OF: reached root node\n");
529 result = of_read_number(addr, na);
530 break;
531 }
532
533 /* Get new parent bus and counts */
534 pbus = of_match_bus(parent);
535 pbus->count_cells(dev, &pna, &pns);
536 if (!OF_CHECK_COUNTS(pna, pns)) {
537 printk(KERN_ERR "prom_parse: Bad cell count for %s\n",
538 dev->full_name);
539 break;
540 }
541
542 DBG("OF: parent bus is %s (na=%d, ns=%d) on %s\n",
543 pbus->name, pna, pns, parent->full_name);
544
545 /* Apply bus translation */
546 if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop))
547 break;
548
549 /* Complete the move up one level */
550 na = pna;
551 ns = pns;
552 bus = pbus;
553
554 of_dump_addr("OF: one level translation:", addr, na);
555 }
556 bail:
557 of_node_put(parent);
558 of_node_put(dev);
559
560 return result;
561}
562
563u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
564{
565 return __of_translate_address(dev, in_addr, "ranges");
566}
567EXPORT_SYMBOL(of_translate_address);
568
569u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr)
570{
571 return __of_translate_address(dev, in_addr, "dma-ranges");
572}
573EXPORT_SYMBOL(of_translate_dma_address);
574
575const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
576 unsigned int *flags)
577{
578 const u32 *prop;
579 unsigned int psize;
580 struct device_node *parent;
581 struct of_bus *bus;
582 int onesize, i, na, ns;
583
584 /* Get parent & match bus type */
585 parent = of_get_parent(dev);
586 if (parent == NULL)
587 return NULL;
588 bus = of_match_bus(parent);
589 bus->count_cells(dev, &na, &ns);
590 of_node_put(parent);
591 if (!OF_CHECK_COUNTS(na, ns))
592 return NULL;
593
594 /* Get "reg" or "assigned-addresses" property */
595 prop = of_get_property(dev, bus->addresses, &psize);
596 if (prop == NULL)
597 return NULL;
598 psize /= 4;
599
600 onesize = na + ns;
601 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
602 if (i == index) {
603 if (size)
604 *size = of_read_number(prop + na, ns);
605 if (flags)
606 *flags = bus->get_flags(prop);
607 return prop;
608 }
609 return NULL;
610}
611EXPORT_SYMBOL(of_get_address);
612
613static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
614 u64 size, unsigned int flags,
615 struct resource *r)
616{
617 u64 taddr;
618
619 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
620 return -EINVAL;
621 taddr = of_translate_address(dev, addrp);
622 if (taddr == OF_BAD_ADDR)
623 return -EINVAL;
624 memset(r, 0, sizeof(struct resource));
625 if (flags & IORESOURCE_IO) {
626 unsigned long port;
627 port = pci_address_to_pio(taddr);
628 if (port == (unsigned long)-1)
629 return -EINVAL;
630 r->start = port;
631 r->end = port + size - 1;
632 } else {
633 r->start = taddr;
634 r->end = taddr + size - 1;
635 }
636 r->flags = flags;
637 r->name = dev->name;
638 return 0;
639}
640
641int of_address_to_resource(struct device_node *dev, int index,
642 struct resource *r)
643{
644 const u32 *addrp;
645 u64 size;
646 unsigned int flags;
647
648 addrp = of_get_address(dev, index, &size, &flags);
649 if (addrp == NULL)
650 return -EINVAL;
651 return __of_address_to_resource(dev, addrp, size, flags, r);
652}
653EXPORT_SYMBOL_GPL(of_address_to_resource);
654
655void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 95void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
656 unsigned long *busno, unsigned long *phys, unsigned long *size) 96 unsigned long *busno, unsigned long *phys, unsigned long *size)
657{ 97{
@@ -678,342 +118,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
678 *size = of_read_number(dma_window, cells); 118 *size = of_read_number(dma_window, cells);
679} 119}
680 120
681/*
682 * Interrupt remapper
683 */
684
685static unsigned int of_irq_workarounds;
686static struct device_node *of_irq_dflt_pic;
687
688static struct device_node *of_irq_find_parent(struct device_node *child)
689{
690 struct device_node *p;
691 const phandle *parp;
692
693 if (!of_node_get(child))
694 return NULL;
695
696 do {
697 parp = of_get_property(child, "interrupt-parent", NULL);
698 if (parp == NULL)
699 p = of_get_parent(child);
700 else {
701 if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
702 p = of_node_get(of_irq_dflt_pic);
703 else
704 p = of_find_node_by_phandle(*parp);
705 }
706 of_node_put(child);
707 child = p;
708 } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
709
710 return p;
711}
712
713/* This doesn't need to be called if you don't have any special workaround
714 * flags to pass
715 */
716void of_irq_map_init(unsigned int flags)
717{
718 of_irq_workarounds = flags;
719
720 /* OldWorld, don't bother looking at other things */
721 if (flags & OF_IMAP_OLDWORLD_MAC)
722 return;
723
724 /* If we don't have phandles, let's try to locate a default interrupt
725 * controller (happens when booting with BootX). We do a first match
726 * here, hopefully, that only ever happens on machines with one
727 * controller.
728 */
729 if (flags & OF_IMAP_NO_PHANDLE) {
730 struct device_node *np;
731
732 for_each_node_with_property(np, "interrupt-controller") {
733 /* Skip /chosen/interrupt-controller */
734 if (strcmp(np->name, "chosen") == 0)
735 continue;
736 /* It seems like at least one person on this planet wants
737 * to use BootX on a machine with an AppleKiwi controller
738 * which happens to pretend to be an interrupt
739 * controller too.
740 */
741 if (strcmp(np->name, "AppleKiwi") == 0)
742 continue;
743 /* I think we found one ! */
744 of_irq_dflt_pic = np;
745 break;
746 }
747 }
748
749}
750
751int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
752 const u32 *addr, struct of_irq *out_irq)
753{
754 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
755 const u32 *tmp, *imap, *imask;
756 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
757 int imaplen, match, i;
758
759 DBG("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n",
760 parent->full_name, intspec[0], intspec[1], ointsize);
761
762 ipar = of_node_get(parent);
763
764 /* First get the #interrupt-cells property of the current cursor
765 * that tells us how to interpret the passed-in intspec. If there
766 * is none, we are nice and just walk up the tree
767 */
768 do {
769 tmp = of_get_property(ipar, "#interrupt-cells", NULL);
770 if (tmp != NULL) {
771 intsize = *tmp;
772 break;
773 }
774 tnode = ipar;
775 ipar = of_irq_find_parent(ipar);
776 of_node_put(tnode);
777 } while (ipar);
778 if (ipar == NULL) {
779 DBG(" -> no parent found !\n");
780 goto fail;
781 }
782
783 DBG("of_irq_map_raw: ipar=%s, size=%d\n", ipar->full_name, intsize);
784
785 if (ointsize != intsize)
786 return -EINVAL;
787
788 /* Look for this #address-cells. We have to implement the old linux
789 * trick of looking for the parent here as some device-trees rely on it
790 */
791 old = of_node_get(ipar);
792 do {
793 tmp = of_get_property(old, "#address-cells", NULL);
794 tnode = of_get_parent(old);
795 of_node_put(old);
796 old = tnode;
797 } while(old && tmp == NULL);
798 of_node_put(old);
799 old = NULL;
800 addrsize = (tmp == NULL) ? 2 : *tmp;
801
802 DBG(" -> addrsize=%d\n", addrsize);
803
804 /* Now start the actual "proper" walk of the interrupt tree */
805 while (ipar != NULL) {
806 /* Now check if cursor is an interrupt-controller and if it is
807 * then we are done
808 */
809 if (of_get_property(ipar, "interrupt-controller", NULL) !=
810 NULL) {
811 DBG(" -> got it !\n");
812 memcpy(out_irq->specifier, intspec,
813 intsize * sizeof(u32));
814 out_irq->size = intsize;
815 out_irq->controller = ipar;
816 of_node_put(old);
817 return 0;
818 }
819
820 /* Now look for an interrupt-map */
821 imap = of_get_property(ipar, "interrupt-map", &imaplen);
822 /* No interrupt map, check for an interrupt parent */
823 if (imap == NULL) {
824 DBG(" -> no map, getting parent\n");
825 newpar = of_irq_find_parent(ipar);
826 goto skiplevel;
827 }
828 imaplen /= sizeof(u32);
829
830 /* Look for a mask */
831 imask = of_get_property(ipar, "interrupt-map-mask", NULL);
832
833 /* If we were passed no "reg" property and we attempt to parse
834 * an interrupt-map, then #address-cells must be 0.
835 * Fail if it's not.
836 */
837 if (addr == NULL && addrsize != 0) {
838 DBG(" -> no reg passed in when needed !\n");
839 goto fail;
840 }
841
842 /* Parse interrupt-map */
843 match = 0;
844 while (imaplen > (addrsize + intsize + 1) && !match) {
845 /* Compare specifiers */
846 match = 1;
847 for (i = 0; i < addrsize && match; ++i) {
848 u32 mask = imask ? imask[i] : 0xffffffffu;
849 match = ((addr[i] ^ imap[i]) & mask) == 0;
850 }
851 for (; i < (addrsize + intsize) && match; ++i) {
852 u32 mask = imask ? imask[i] : 0xffffffffu;
853 match =
854 ((intspec[i-addrsize] ^ imap[i]) & mask) == 0;
855 }
856 imap += addrsize + intsize;
857 imaplen -= addrsize + intsize;
858
859 DBG(" -> match=%d (imaplen=%d)\n", match, imaplen);
860
861 /* Get the interrupt parent */
862 if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
863 newpar = of_node_get(of_irq_dflt_pic);
864 else
865 newpar = of_find_node_by_phandle((phandle)*imap);
866 imap++;
867 --imaplen;
868
869 /* Check if not found */
870 if (newpar == NULL) {
871 DBG(" -> imap parent not found !\n");
872 goto fail;
873 }
874
875 /* Get #interrupt-cells and #address-cells of new
876 * parent
877 */
878 tmp = of_get_property(newpar, "#interrupt-cells", NULL);
879 if (tmp == NULL) {
880 DBG(" -> parent lacks #interrupt-cells !\n");
881 goto fail;
882 }
883 newintsize = *tmp;
884 tmp = of_get_property(newpar, "#address-cells", NULL);
885 newaddrsize = (tmp == NULL) ? 0 : *tmp;
886
887 DBG(" -> newintsize=%d, newaddrsize=%d\n",
888 newintsize, newaddrsize);
889
890 /* Check for malformed properties */
891 if (imaplen < (newaddrsize + newintsize))
892 goto fail;
893
894 imap += newaddrsize + newintsize;
895 imaplen -= newaddrsize + newintsize;
896
897 DBG(" -> imaplen=%d\n", imaplen);
898 }
899 if (!match)
900 goto fail;
901
902 of_node_put(old);
903 old = of_node_get(newpar);
904 addrsize = newaddrsize;
905 intsize = newintsize;
906 intspec = imap - intsize;
907 addr = intspec - addrsize;
908
909 skiplevel:
910 /* Iterate again with new parent */
911 DBG(" -> new parent: %s\n", newpar ? newpar->full_name : "<>");
912 of_node_put(ipar);
913 ipar = newpar;
914 newpar = NULL;
915 }
916 fail:
917 of_node_put(ipar);
918 of_node_put(old);
919 of_node_put(newpar);
920
921 return -EINVAL;
922}
923EXPORT_SYMBOL_GPL(of_irq_map_raw);
924
925#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
926static int of_irq_map_oldworld(struct device_node *device, int index,
927 struct of_irq *out_irq)
928{
929 const u32 *ints = NULL;
930 int intlen;
931
932 /*
933 * Old machines just have a list of interrupt numbers
934 * and no interrupt-controller nodes. We also have dodgy
935 * cases where the APPL,interrupts property is completely
936 * missing behind pci-pci bridges and we have to get it
937 * from the parent (the bridge itself, as apple just wired
938 * everything together on these)
939 */
940 while (device) {
941 ints = of_get_property(device, "AAPL,interrupts", &intlen);
942 if (ints != NULL)
943 break;
944 device = device->parent;
945 if (device && strcmp(device->type, "pci") != 0)
946 break;
947 }
948 if (ints == NULL)
949 return -EINVAL;
950 intlen /= sizeof(u32);
951
952 if (index >= intlen)
953 return -EINVAL;
954
955 out_irq->controller = NULL;
956 out_irq->specifier[0] = ints[index];
957 out_irq->size = 1;
958
959 return 0;
960}
961#else /* defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) */
962static int of_irq_map_oldworld(struct device_node *device, int index,
963 struct of_irq *out_irq)
964{
965 return -EINVAL;
966}
967#endif /* !(defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)) */
968
969int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq)
970{
971 struct device_node *p;
972 const u32 *intspec, *tmp, *addr;
973 u32 intsize, intlen;
974 int res = -EINVAL;
975
976 DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index);
977
978 /* OldWorld mac stuff is "special", handle out of line */
979 if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
980 return of_irq_map_oldworld(device, index, out_irq);
981
982 /* Get the interrupts property */
983 intspec = of_get_property(device, "interrupts", &intlen);
984 if (intspec == NULL)
985 return -EINVAL;
986 intlen /= sizeof(u32);
987
988 /* Get the reg property (if any) */
989 addr = of_get_property(device, "reg", NULL);
990
991 /* Look for the interrupt parent. */
992 p = of_irq_find_parent(device);
993 if (p == NULL)
994 return -EINVAL;
995
996 /* Get size of interrupt specifier */
997 tmp = of_get_property(p, "#interrupt-cells", NULL);
998 if (tmp == NULL)
999 goto out;
1000 intsize = *tmp;
1001
1002 DBG(" intsize=%d intlen=%d\n", intsize, intlen);
1003
1004 /* Check index */
1005 if ((index + 1) * intsize > intlen)
1006 goto out;
1007
1008 /* Get new specifier and map it */
1009 res = of_irq_map_raw(p, intspec + index * intsize, intsize,
1010 addr, out_irq);
1011out:
1012 of_node_put(p);
1013 return res;
1014}
1015EXPORT_SYMBOL_GPL(of_irq_map_one);
1016
1017/** 121/**
1018 * Search the device tree for the best MAC address to use. 'mac-address' is 122 * Search the device tree for the best MAC address to use. 'mac-address' is
1019 * checked first, because that is supposed to contain to "most recent" MAC 123 * checked first, because that is supposed to contain to "most recent" MAC
@@ -1051,29 +155,3 @@ const void *of_get_mac_address(struct device_node *np)
1051 return NULL; 155 return NULL;
1052} 156}
1053EXPORT_SYMBOL(of_get_mac_address); 157EXPORT_SYMBOL(of_get_mac_address);
1054
1055int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
1056{
1057 int irq = irq_of_parse_and_map(dev, index);
1058
1059 /* Only dereference the resource if both the
1060 * resource and the irq are valid. */
1061 if (r && irq != NO_IRQ) {
1062 r->start = r->end = irq;
1063 r->flags = IORESOURCE_IRQ;
1064 }
1065
1066 return irq;
1067}
1068EXPORT_SYMBOL_GPL(of_irq_to_resource);
1069
1070void __iomem *of_iomap(struct device_node *np, int index)
1071{
1072 struct resource res;
1073
1074 if (of_address_to_resource(np, index, &res))
1075 return NULL;
1076
1077 return ioremap(res.start, 1 + res.end - res.start);
1078}
1079EXPORT_SYMBOL(of_iomap);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 70decd8068ca..15ade0d7bbb2 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -714,16 +714,9 @@ static struct notifier_block ppc_dflt_plat_bus_notifier = {
714 .priority = INT_MAX, 714 .priority = INT_MAX,
715}; 715};
716 716
717static struct notifier_block ppc_dflt_of_bus_notifier = {
718 .notifier_call = ppc_dflt_bus_notify,
719 .priority = INT_MAX,
720};
721
722static int __init setup_bus_notifier(void) 717static int __init setup_bus_notifier(void)
723{ 718{
724 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier); 719 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier);
725 bus_register_notifier(&of_platform_bus_type, &ppc_dflt_of_bus_notifier);
726
727 return 0; 720 return 0;
728} 721}
729 722
diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c
index e1c5cd6650b1..5b243bd3eb3b 100644
--- a/arch/powerpc/platforms/512x/clock.c
+++ b/arch/powerpc/platforms/512x/clock.c
@@ -678,7 +678,7 @@ static void psc_clks_init(void)
678{ 678{
679 struct device_node *np; 679 struct device_node *np;
680 const u32 *cell_index; 680 const u32 *cell_index;
681 struct of_device *ofdev; 681 struct platform_device *ofdev;
682 682
683 for_each_compatible_node(np, NULL, "fsl,mpc5121-psc") { 683 for_each_compatible_node(np, NULL, "fsl,mpc5121-psc") {
684 cell_index = of_get_property(np, "cell-index", NULL); 684 cell_index = of_get_property(np, "cell-index", NULL);
diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c
index 6d584f4e3c9a..de55bc0584b5 100644
--- a/arch/powerpc/platforms/52xx/lite5200.c
+++ b/arch/powerpc/platforms/52xx/lite5200.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/of_address.h>
21#include <linux/root_dev.h> 22#include <linux/root_dev.h>
22#include <linux/initrd.h> 23#include <linux/initrd.h>
23#include <asm/time.h> 24#include <asm/time.h>
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
index ca5305a5bd61..0dad9a935eb5 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
@@ -147,26 +147,25 @@ mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
147 return 0; 147 return 0;
148} 148}
149 149
150static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, 150static int __devinit mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev,
151 const struct of_device_id *match) 151 const struct of_device_id *match)
152{ 152{
153 struct mpc52xx_gpiochip *chip; 153 struct mpc52xx_gpiochip *chip;
154 struct mpc52xx_gpio_wkup __iomem *regs; 154 struct mpc52xx_gpio_wkup __iomem *regs;
155 struct of_gpio_chip *ofchip; 155 struct gpio_chip *gc;
156 int ret; 156 int ret;
157 157
158 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 158 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
159 if (!chip) 159 if (!chip)
160 return -ENOMEM; 160 return -ENOMEM;
161 161
162 ofchip = &chip->mmchip.of_gc; 162 gc = &chip->mmchip.gc;
163 163
164 ofchip->gpio_cells = 2; 164 gc->ngpio = 8;
165 ofchip->gc.ngpio = 8; 165 gc->direction_input = mpc52xx_wkup_gpio_dir_in;
166 ofchip->gc.direction_input = mpc52xx_wkup_gpio_dir_in; 166 gc->direction_output = mpc52xx_wkup_gpio_dir_out;
167 ofchip->gc.direction_output = mpc52xx_wkup_gpio_dir_out; 167 gc->get = mpc52xx_wkup_gpio_get;
168 ofchip->gc.get = mpc52xx_wkup_gpio_get; 168 gc->set = mpc52xx_wkup_gpio_set;
169 ofchip->gc.set = mpc52xx_wkup_gpio_set;
170 169
171 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); 170 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
172 if (ret) 171 if (ret)
@@ -180,7 +179,7 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev,
180 return 0; 179 return 0;
181} 180}
182 181
183static int mpc52xx_gpiochip_remove(struct of_device *ofdev) 182static int mpc52xx_gpiochip_remove(struct platform_device *ofdev)
184{ 183{
185 return -EBUSY; 184 return -EBUSY;
186} 185}
@@ -311,11 +310,11 @@ mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
311 return 0; 310 return 0;
312} 311}
313 312
314static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, 313static int __devinit mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev,
315 const struct of_device_id *match) 314 const struct of_device_id *match)
316{ 315{
317 struct mpc52xx_gpiochip *chip; 316 struct mpc52xx_gpiochip *chip;
318 struct of_gpio_chip *ofchip; 317 struct gpio_chip *gc;
319 struct mpc52xx_gpio __iomem *regs; 318 struct mpc52xx_gpio __iomem *regs;
320 int ret; 319 int ret;
321 320
@@ -323,14 +322,13 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev,
323 if (!chip) 322 if (!chip)
324 return -ENOMEM; 323 return -ENOMEM;
325 324
326 ofchip = &chip->mmchip.of_gc; 325 gc = &chip->mmchip.gc;
327 326
328 ofchip->gpio_cells = 2; 327 gc->ngpio = 32;
329 ofchip->gc.ngpio = 32; 328 gc->direction_input = mpc52xx_simple_gpio_dir_in;
330 ofchip->gc.direction_input = mpc52xx_simple_gpio_dir_in; 329 gc->direction_output = mpc52xx_simple_gpio_dir_out;
331 ofchip->gc.direction_output = mpc52xx_simple_gpio_dir_out; 330 gc->get = mpc52xx_simple_gpio_get;
332 ofchip->gc.get = mpc52xx_simple_gpio_get; 331 gc->set = mpc52xx_simple_gpio_set;
333 ofchip->gc.set = mpc52xx_simple_gpio_set;
334 332
335 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); 333 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
336 if (ret) 334 if (ret)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
index 46c93578cbf0..fea833e18ad5 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
@@ -78,7 +78,7 @@ MODULE_LICENSE("GPL");
78 * @dev: pointer to device structure 78 * @dev: pointer to device structure
79 * @regs: virtual address of GPT registers 79 * @regs: virtual address of GPT registers
80 * @lock: spinlock to coordinate between different functions. 80 * @lock: spinlock to coordinate between different functions.
81 * @of_gc: of_gpio_chip instance structure; used when GPIO is enabled 81 * @gc: gpio_chip instance structure; used when GPIO is enabled
82 * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported 82 * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported
83 * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates 83 * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates
84 * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates 84 * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates
@@ -94,7 +94,7 @@ struct mpc52xx_gpt_priv {
94 u8 wdt_mode; 94 u8 wdt_mode;
95 95
96#if defined(CONFIG_GPIOLIB) 96#if defined(CONFIG_GPIOLIB)
97 struct of_gpio_chip of_gc; 97 struct gpio_chip gc;
98#endif 98#endif
99}; 99};
100 100
@@ -280,7 +280,7 @@ mpc52xx_gpt_irq_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node)
280#if defined(CONFIG_GPIOLIB) 280#if defined(CONFIG_GPIOLIB)
281static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) 281static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc)
282{ 282{
283 return container_of(to_of_gpio_chip(gc), struct mpc52xx_gpt_priv,of_gc); 283 return container_of(gc, struct mpc52xx_gpt_priv, gc);
284} 284}
285 285
286static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) 286static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio)
@@ -336,28 +336,25 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node)
336 if (!of_find_property(node, "gpio-controller", NULL)) 336 if (!of_find_property(node, "gpio-controller", NULL))
337 return; 337 return;
338 338
339 gpt->of_gc.gc.label = kstrdup(node->full_name, GFP_KERNEL); 339 gpt->gc.label = kstrdup(node->full_name, GFP_KERNEL);
340 if (!gpt->of_gc.gc.label) { 340 if (!gpt->gc.label) {
341 dev_err(gpt->dev, "out of memory\n"); 341 dev_err(gpt->dev, "out of memory\n");
342 return; 342 return;
343 } 343 }
344 344
345 gpt->of_gc.gpio_cells = 2; 345 gpt->gc.ngpio = 1;
346 gpt->of_gc.gc.ngpio = 1; 346 gpt->gc.direction_input = mpc52xx_gpt_gpio_dir_in;
347 gpt->of_gc.gc.direction_input = mpc52xx_gpt_gpio_dir_in; 347 gpt->gc.direction_output = mpc52xx_gpt_gpio_dir_out;
348 gpt->of_gc.gc.direction_output = mpc52xx_gpt_gpio_dir_out; 348 gpt->gc.get = mpc52xx_gpt_gpio_get;
349 gpt->of_gc.gc.get = mpc52xx_gpt_gpio_get; 349 gpt->gc.set = mpc52xx_gpt_gpio_set;
350 gpt->of_gc.gc.set = mpc52xx_gpt_gpio_set; 350 gpt->gc.base = -1;
351 gpt->of_gc.gc.base = -1; 351 gpt->gc.of_node = node;
352 gpt->of_gc.xlate = of_gpio_simple_xlate;
353 node->data = &gpt->of_gc;
354 of_node_get(node);
355 352
356 /* Setup external pin in GPIO mode */ 353 /* Setup external pin in GPIO mode */
357 clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, 354 clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK,
358 MPC52xx_GPT_MODE_MS_GPIO); 355 MPC52xx_GPT_MODE_MS_GPIO);
359 356
360 rc = gpiochip_add(&gpt->of_gc.gc); 357 rc = gpiochip_add(&gpt->gc);
361 if (rc) 358 if (rc)
362 dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc); 359 dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc);
363 360
@@ -723,7 +720,7 @@ static inline int mpc52xx_gpt_wdt_setup(struct mpc52xx_gpt_priv *gpt,
723/* --------------------------------------------------------------------- 720/* ---------------------------------------------------------------------
724 * of_platform bus binding code 721 * of_platform bus binding code
725 */ 722 */
726static int __devinit mpc52xx_gpt_probe(struct of_device *ofdev, 723static int __devinit mpc52xx_gpt_probe(struct platform_device *ofdev,
727 const struct of_device_id *match) 724 const struct of_device_id *match)
728{ 725{
729 struct mpc52xx_gpt_priv *gpt; 726 struct mpc52xx_gpt_priv *gpt;
@@ -769,7 +766,7 @@ static int __devinit mpc52xx_gpt_probe(struct of_device *ofdev,
769 return 0; 766 return 0;
770} 767}
771 768
772static int mpc52xx_gpt_remove(struct of_device *ofdev) 769static int mpc52xx_gpt_remove(struct platform_device *ofdev)
773{ 770{
774 return -EBUSY; 771 return -EBUSY;
775} 772}
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
index e86aec644501..f4ac213c89c0 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
@@ -436,8 +436,8 @@ void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req)
436} 436}
437EXPORT_SYMBOL(mpc52xx_lpbfifo_abort); 437EXPORT_SYMBOL(mpc52xx_lpbfifo_abort);
438 438
439static int __devinit 439static int __devinit mpc52xx_lpbfifo_probe(struct platform_device *op,
440mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match) 440 const struct of_device_id *match)
441{ 441{
442 struct resource res; 442 struct resource res;
443 int rc = -ENOMEM; 443 int rc = -ENOMEM;
@@ -507,7 +507,7 @@ mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match)
507} 507}
508 508
509 509
510static int __devexit mpc52xx_lpbfifo_remove(struct of_device *op) 510static int __devexit mpc52xx_lpbfifo_remove(struct platform_device *op)
511{ 511{
512 if (lpbfifo.dev != &op->dev) 512 if (lpbfifo.dev != &op->dev)
513 return 0; 513 return 0;
diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c
index 9f2e52b36f91..1565e0446dc8 100644
--- a/arch/powerpc/platforms/82xx/ep8248e.c
+++ b/arch/powerpc/platforms/82xx/ep8248e.c
@@ -111,7 +111,7 @@ static struct mdiobb_ctrl ep8248e_mdio_ctrl = {
111 .ops = &ep8248e_mdio_ops, 111 .ops = &ep8248e_mdio_ops,
112}; 112};
113 113
114static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, 114static int __devinit ep8248e_mdio_probe(struct platform_device *ofdev,
115 const struct of_device_id *match) 115 const struct of_device_id *match)
116{ 116{
117 struct mii_bus *bus; 117 struct mii_bus *bus;
@@ -154,7 +154,7 @@ err_free_bus:
154 return ret; 154 return ret;
155} 155}
156 156
157static int ep8248e_mdio_remove(struct of_device *ofdev) 157static int ep8248e_mdio_remove(struct platform_device *ofdev)
158{ 158{
159 BUG(); 159 BUG();
160 return 0; 160 return 0;
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index d119a7c1c17a..70798ac911ef 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -35,9 +35,8 @@
35 35
36struct mcu { 36struct mcu {
37 struct mutex lock; 37 struct mutex lock;
38 struct device_node *np;
39 struct i2c_client *client; 38 struct i2c_client *client;
40 struct of_gpio_chip of_gc; 39 struct gpio_chip gc;
41 u8 reg_ctrl; 40 u8 reg_ctrl;
42}; 41};
43 42
@@ -56,8 +55,7 @@ static void mcu_power_off(void)
56 55
57static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 56static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
58{ 57{
59 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc); 58 struct mcu *mcu = container_of(gc, struct mcu, gc);
60 struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
61 u8 bit = 1 << (4 + gpio); 59 u8 bit = 1 << (4 + gpio);
62 60
63 mutex_lock(&mcu->lock); 61 mutex_lock(&mcu->lock);
@@ -79,9 +77,7 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
79static int mcu_gpiochip_add(struct mcu *mcu) 77static int mcu_gpiochip_add(struct mcu *mcu)
80{ 78{
81 struct device_node *np; 79 struct device_node *np;
82 struct of_gpio_chip *of_gc = &mcu->of_gc; 80 struct gpio_chip *gc = &mcu->gc;
83 struct gpio_chip *gc = &of_gc->gc;
84 int ret;
85 81
86 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx"); 82 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
87 if (!np) 83 if (!np)
@@ -94,32 +90,14 @@ static int mcu_gpiochip_add(struct mcu *mcu)
94 gc->base = -1; 90 gc->base = -1;
95 gc->set = mcu_gpio_set; 91 gc->set = mcu_gpio_set;
96 gc->direction_output = mcu_gpio_dir_out; 92 gc->direction_output = mcu_gpio_dir_out;
97 of_gc->gpio_cells = 2; 93 gc->of_node = np;
98 of_gc->xlate = of_gpio_simple_xlate;
99 94
100 np->data = of_gc; 95 return gpiochip_add(gc);
101 mcu->np = np;
102
103 /*
104 * We don't want to lose the node, its ->data and ->full_name...
105 * So, if succeeded, we don't put the node here.
106 */
107 ret = gpiochip_add(gc);
108 if (ret)
109 of_node_put(np);
110 return ret;
111} 96}
112 97
113static int mcu_gpiochip_remove(struct mcu *mcu) 98static int mcu_gpiochip_remove(struct mcu *mcu)
114{ 99{
115 int ret; 100 return gpiochip_remove(&mcu->gc);
116
117 ret = gpiochip_remove(&mcu->of_gc.gc);
118 if (ret)
119 return ret;
120 of_node_put(mcu->np);
121
122 return 0;
123} 101}
124 102
125static int __devinit mcu_probe(struct i2c_client *client, 103static int __devinit mcu_probe(struct i2c_client *client,
@@ -182,10 +160,16 @@ static const struct i2c_device_id mcu_ids[] = {
182}; 160};
183MODULE_DEVICE_TABLE(i2c, mcu_ids); 161MODULE_DEVICE_TABLE(i2c, mcu_ids);
184 162
163static struct of_device_id mcu_of_match_table[] __devinitdata = {
164 { .compatible = "fsl,mcu-mpc8349emitx", },
165 { },
166};
167
185static struct i2c_driver mcu_driver = { 168static struct i2c_driver mcu_driver = {
186 .driver = { 169 .driver = {
187 .name = "mcu-mpc8349emitx", 170 .name = "mcu-mpc8349emitx",
188 .owner = THIS_MODULE, 171 .owner = THIS_MODULE,
172 .of_match_table = mcu_of_match_table,
189 }, 173 },
190 .probe = mcu_probe, 174 .probe = mcu_probe,
191 .remove = __devexit_p(mcu_remove), 175 .remove = __devexit_p(mcu_remove),
diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c
index ebe6c3537209..75ae77f1af6a 100644
--- a/arch/powerpc/platforms/83xx/suspend.c
+++ b/arch/powerpc/platforms/83xx/suspend.c
@@ -99,7 +99,7 @@ struct pmc_type {
99 int has_deep_sleep; 99 int has_deep_sleep;
100}; 100};
101 101
102static struct of_device *pmc_dev; 102static struct platform_device *pmc_dev;
103static int has_deep_sleep, deep_sleeping; 103static int has_deep_sleep, deep_sleeping;
104static int pmc_irq; 104static int pmc_irq;
105static struct mpc83xx_pmc __iomem *pmc_regs; 105static struct mpc83xx_pmc __iomem *pmc_regs;
@@ -318,7 +318,7 @@ static struct platform_suspend_ops mpc83xx_suspend_ops = {
318 .end = mpc83xx_suspend_end, 318 .end = mpc83xx_suspend_end,
319}; 319};
320 320
321static int pmc_probe(struct of_device *ofdev, 321static int pmc_probe(struct platform_device *ofdev,
322 const struct of_device_id *match) 322 const struct of_device_id *match)
323{ 323{
324 struct device_node *np = ofdev->dev.of_node; 324 struct device_node *np = ofdev->dev.of_node;
@@ -396,7 +396,7 @@ out:
396 return ret; 396 return ret;
397} 397}
398 398
399static int pmc_remove(struct of_device *ofdev) 399static int pmc_remove(struct platform_device *ofdev)
400{ 400{
401 return -EPERM; 401 return -EPERM;
402}; 402};
diff --git a/arch/powerpc/platforms/86xx/gef_gpio.c b/arch/powerpc/platforms/86xx/gef_gpio.c
index b8cb08dbd89c..4ff7b1e7bbad 100644
--- a/arch/powerpc/platforms/86xx/gef_gpio.c
+++ b/arch/powerpc/platforms/86xx/gef_gpio.c
@@ -118,12 +118,12 @@ static int __init gef_gpio_init(void)
118 } 118 }
119 119
120 /* Setup pointers to chip functions */ 120 /* Setup pointers to chip functions */
121 gef_gpio_chip->of_gc.gpio_cells = 2; 121 gef_gpio_chip->gc.of_gpio_n_cells = 2;
122 gef_gpio_chip->of_gc.gc.ngpio = 19; 122 gef_gpio_chip->gc.ngpio = 19;
123 gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; 123 gef_gpio_chip->gc.direction_input = gef_gpio_dir_in;
124 gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; 124 gef_gpio_chip->gc.direction_output = gef_gpio_dir_out;
125 gef_gpio_chip->of_gc.gc.get = gef_gpio_get; 125 gef_gpio_chip->gc.get = gef_gpio_get;
126 gef_gpio_chip->of_gc.gc.set = gef_gpio_set; 126 gef_gpio_chip->gc.set = gef_gpio_set;
127 127
128 /* This function adds a memory mapped GPIO chip */ 128 /* This function adds a memory mapped GPIO chip */
129 retval = of_mm_gpiochip_add(np, gef_gpio_chip); 129 retval = of_mm_gpiochip_add(np, gef_gpio_chip);
@@ -146,12 +146,12 @@ static int __init gef_gpio_init(void)
146 } 146 }
147 147
148 /* Setup pointers to chip functions */ 148 /* Setup pointers to chip functions */
149 gef_gpio_chip->of_gc.gpio_cells = 2; 149 gef_gpio_chip->gc.of_gpio_n_cells = 2;
150 gef_gpio_chip->of_gc.gc.ngpio = 6; 150 gef_gpio_chip->gc.ngpio = 6;
151 gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; 151 gef_gpio_chip->gc.direction_input = gef_gpio_dir_in;
152 gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; 152 gef_gpio_chip->gc.direction_output = gef_gpio_dir_out;
153 gef_gpio_chip->of_gc.gc.get = gef_gpio_get; 153 gef_gpio_chip->gc.get = gef_gpio_get;
154 gef_gpio_chip->of_gc.gc.set = gef_gpio_set; 154 gef_gpio_chip->gc.set = gef_gpio_set;
155 155
156 /* This function adds a memory mapped GPIO chip */ 156 /* This function adds a memory mapped GPIO chip */
157 retval = of_mm_gpiochip_add(np, gef_gpio_chip); 157 retval = of_mm_gpiochip_add(np, gef_gpio_chip);
diff --git a/arch/powerpc/platforms/amigaone/setup.c b/arch/powerpc/platforms/amigaone/setup.c
index fb4eb0df054c..03aabc0e16ac 100644
--- a/arch/powerpc/platforms/amigaone/setup.c
+++ b/arch/powerpc/platforms/amigaone/setup.c
@@ -13,12 +13,13 @@
13 */ 13 */
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
16#include <linux/seq_file.h> 18#include <linux/seq_file.h>
17#include <generated/utsrelease.h> 19#include <generated/utsrelease.h>
18 20
19#include <asm/machdep.h> 21#include <asm/machdep.h>
20#include <asm/cputable.h> 22#include <asm/cputable.h>
21#include <asm/prom.h>
22#include <asm/pci-bridge.h> 23#include <asm/pci-bridge.h>
23#include <asm/i8259.h> 24#include <asm/i8259.h>
24#include <asm/time.h> 25#include <asm/time.h>
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 6257e5378615..97085530aa63 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -328,7 +328,7 @@ static struct irq_host_ops msic_host_ops = {
328 .map = msic_host_map, 328 .map = msic_host_map,
329}; 329};
330 330
331static int axon_msi_shutdown(struct of_device *device) 331static int axon_msi_shutdown(struct platform_device *device)
332{ 332{
333 struct axon_msic *msic = dev_get_drvdata(&device->dev); 333 struct axon_msic *msic = dev_get_drvdata(&device->dev);
334 u32 tmp; 334 u32 tmp;
@@ -342,7 +342,7 @@ static int axon_msi_shutdown(struct of_device *device)
342 return 0; 342 return 0;
343} 343}
344 344
345static int axon_msi_probe(struct of_device *device, 345static int axon_msi_probe(struct platform_device *device,
346 const struct of_device_id *device_id) 346 const struct of_device_id *device_id)
347{ 347{
348 struct device_node *dn = device->dev.of_node; 348 struct device_node *dn = device->dev.of_node;
diff --git a/arch/powerpc/platforms/cell/beat_iommu.c b/arch/powerpc/platforms/cell/beat_iommu.c
index 39d361c5c6d2..beec405eb6f8 100644
--- a/arch/powerpc/platforms/cell/beat_iommu.c
+++ b/arch/powerpc/platforms/cell/beat_iommu.c
@@ -108,7 +108,7 @@ static int __init celleb_init_iommu(void)
108 celleb_init_direct_mapping(); 108 celleb_init_direct_mapping();
109 set_pci_dma_ops(&dma_direct_ops); 109 set_pci_dma_ops(&dma_direct_ops);
110 ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup; 110 ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup;
111 bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier); 111 bus_register_notifier(&platform_bus_type, &celleb_of_bus_notifier);
112 112
113 return 0; 113 return 0;
114} 114}
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 3712900471ba..58b13ce3847e 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -1204,7 +1204,7 @@ static int __init cell_iommu_init(void)
1204 /* Register callbacks on OF platform device addition/removal 1204 /* Register callbacks on OF platform device addition/removal
1205 * to handle linking them to the right DMA operations 1205 * to handle linking them to the right DMA operations
1206 */ 1206 */
1207 bus_register_notifier(&of_platform_bus_type, &cell_of_bus_notifier); 1207 bus_register_notifier(&platform_bus_type, &cell_of_bus_notifier);
1208 1208
1209 return 0; 1209 return 0;
1210} 1210}
diff --git a/arch/powerpc/platforms/cell/qpace_setup.c b/arch/powerpc/platforms/cell/qpace_setup.c
index c5ce02e84c8e..1b5749042756 100644
--- a/arch/powerpc/platforms/cell/qpace_setup.c
+++ b/arch/powerpc/platforms/cell/qpace_setup.c
@@ -61,12 +61,24 @@ static void qpace_progress(char *s, unsigned short hex)
61 printk("*** %04x : %s\n", hex, s ? s : ""); 61 printk("*** %04x : %s\n", hex, s ? s : "");
62} 62}
63 63
64static const struct of_device_id qpace_bus_ids[] __initdata = {
65 { .type = "soc", },
66 { .compatible = "soc", },
67 { .type = "spider", },
68 { .type = "axon", },
69 { .type = "plb5", },
70 { .type = "plb4", },
71 { .type = "opb", },
72 { .type = "ebc", },
73 {},
74};
75
64static int __init qpace_publish_devices(void) 76static int __init qpace_publish_devices(void)
65{ 77{
66 int node; 78 int node;
67 79
68 /* Publish OF platform devices for southbridge IOs */ 80 /* Publish OF platform devices for southbridge IOs */
69 of_platform_bus_probe(NULL, NULL, NULL); 81 of_platform_bus_probe(NULL, qpace_bus_ids, NULL);
70 82
71 /* There is no device for the MIC memory controller, thus we create 83 /* There is no device for the MIC memory controller, thus we create
72 * a platform device for it to attach the EDAC driver to. 84 * a platform device for it to attach the EDAC driver to.
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 50385db586bd..691995761b3d 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -141,6 +141,18 @@ static int __devinit cell_setup_phb(struct pci_controller *phb)
141 return 0; 141 return 0;
142} 142}
143 143
144static const struct of_device_id cell_bus_ids[] __initdata = {
145 { .type = "soc", },
146 { .compatible = "soc", },
147 { .type = "spider", },
148 { .type = "axon", },
149 { .type = "plb5", },
150 { .type = "plb4", },
151 { .type = "opb", },
152 { .type = "ebc", },
153 {},
154};
155
144static int __init cell_publish_devices(void) 156static int __init cell_publish_devices(void)
145{ 157{
146 struct device_node *root = of_find_node_by_path("/"); 158 struct device_node *root = of_find_node_by_path("/");
@@ -148,7 +160,7 @@ static int __init cell_publish_devices(void)
148 int node; 160 int node;
149 161
150 /* Publish OF platform devices for southbridge IOs */ 162 /* Publish OF platform devices for southbridge IOs */
151 of_platform_bus_probe(NULL, NULL, NULL); 163 of_platform_bus_probe(NULL, cell_bus_ids, NULL);
152 164
153 /* On spider based blades, we need to manually create the OF 165 /* On spider based blades, we need to manually create the OF
154 * platform devices for the PCI host bridges 166 * platform devices for the PCI host bridges
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index d2c1d497846e..33e5fc7334fc 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/completion.h> 31#include <linux/completion.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/proc_fs.h>
33#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
34#include <linux/bcd.h> 35#include <linux/bcd.h>
35#include <linux/rtc.h> 36#include <linux/rtc.h>
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
index 627ee089e75d..a5d907b5a4c2 100644
--- a/arch/powerpc/platforms/pasemi/gpio_mdio.c
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -216,7 +216,7 @@ static int gpio_mdio_reset(struct mii_bus *bus)
216} 216}
217 217
218 218
219static int __devinit gpio_mdio_probe(struct of_device *ofdev, 219static int __devinit gpio_mdio_probe(struct platform_device *ofdev,
220 const struct of_device_id *match) 220 const struct of_device_id *match)
221{ 221{
222 struct device *dev = &ofdev->dev; 222 struct device *dev = &ofdev->dev;
@@ -275,7 +275,7 @@ out:
275} 275}
276 276
277 277
278static int gpio_mdio_remove(struct of_device *dev) 278static int gpio_mdio_remove(struct platform_device *dev)
279{ 279{
280 struct mii_bus *bus = dev_get_drvdata(&dev->dev); 280 struct mii_bus *bus = dev_get_drvdata(&dev->dev);
281 281
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 79bd3e89dbaf..39df6ab1735a 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -21,6 +21,8 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/of.h>
25#include <linux/of_address.h>
24#include <linux/spinlock.h> 26#include <linux/spinlock.h>
25#include <linux/adb.h> 27#include <linux/adb.h>
26#include <linux/pmu.h> 28#include <linux/pmu.h>
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 630a533d0e59..890d5f72b198 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -46,6 +46,10 @@ struct pmac_irq_hw {
46 unsigned int level; 46 unsigned int level;
47}; 47};
48 48
49/* Workaround flags for 32bit powermac machines */
50unsigned int of_irq_workarounds;
51struct device_node *of_irq_dflt_pic;
52
49/* Default addresses */ 53/* Default addresses */
50static volatile struct pmac_irq_hw __iomem *pmac_irq_hw[4]; 54static volatile struct pmac_irq_hw __iomem *pmac_irq_hw[4];
51 55
@@ -428,6 +432,42 @@ static void __init pmac_pic_probe_oldstyle(void)
428 setup_irq(irq_create_mapping(NULL, 20), &xmon_action); 432 setup_irq(irq_create_mapping(NULL, 20), &xmon_action);
429#endif 433#endif
430} 434}
435
436int of_irq_map_oldworld(struct device_node *device, int index,
437 struct of_irq *out_irq)
438{
439 const u32 *ints = NULL;
440 int intlen;
441
442 /*
443 * Old machines just have a list of interrupt numbers
444 * and no interrupt-controller nodes. We also have dodgy
445 * cases where the APPL,interrupts property is completely
446 * missing behind pci-pci bridges and we have to get it
447 * from the parent (the bridge itself, as apple just wired
448 * everything together on these)
449 */
450 while (device) {
451 ints = of_get_property(device, "AAPL,interrupts", &intlen);
452 if (ints != NULL)
453 break;
454 device = device->parent;
455 if (device && strcmp(device->type, "pci") != 0)
456 break;
457 }
458 if (ints == NULL)
459 return -EINVAL;
460 intlen /= sizeof(u32);
461
462 if (index >= intlen)
463 return -EINVAL;
464
465 out_irq->controller = NULL;
466 out_irq->specifier[0] = ints[index];
467 out_irq->size = 1;
468
469 return 0;
470}
431#endif /* CONFIG_PPC32 */ 471#endif /* CONFIG_PPC32 */
432 472
433static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc) 473static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
@@ -559,19 +599,39 @@ static int __init pmac_pic_probe_mpic(void)
559 599
560void __init pmac_pic_init(void) 600void __init pmac_pic_init(void)
561{ 601{
562 unsigned int flags = 0;
563
564 /* We configure the OF parsing based on our oldworld vs. newworld 602 /* We configure the OF parsing based on our oldworld vs. newworld
565 * platform type and wether we were booted by BootX. 603 * platform type and wether we were booted by BootX.
566 */ 604 */
567#ifdef CONFIG_PPC32 605#ifdef CONFIG_PPC32
568 if (!pmac_newworld) 606 if (!pmac_newworld)
569 flags |= OF_IMAP_OLDWORLD_MAC; 607 of_irq_workarounds |= OF_IMAP_OLDWORLD_MAC;
570 if (of_get_property(of_chosen, "linux,bootx", NULL) != NULL) 608 if (of_get_property(of_chosen, "linux,bootx", NULL) != NULL)
571 flags |= OF_IMAP_NO_PHANDLE; 609 of_irq_workarounds |= OF_IMAP_NO_PHANDLE;
572#endif /* CONFIG_PPC_32 */
573 610
574 of_irq_map_init(flags); 611 /* If we don't have phandles on a newworld, then try to locate a
612 * default interrupt controller (happens when booting with BootX).
613 * We do a first match here, hopefully, that only ever happens on
614 * machines with one controller.
615 */
616 if (pmac_newworld && (of_irq_workarounds & OF_IMAP_NO_PHANDLE)) {
617 struct device_node *np;
618
619 for_each_node_with_property(np, "interrupt-controller") {
620 /* Skip /chosen/interrupt-controller */
621 if (strcmp(np->name, "chosen") == 0)
622 continue;
623 /* It seems like at least one person wants
624 * to use BootX on a machine with an AppleKiwi
625 * controller which happens to pretend to be an
626 * interrupt controller too. */
627 if (strcmp(np->name, "AppleKiwi") == 0)
628 continue;
629 /* I think we found one ! */
630 of_irq_dflt_pic = np;
631 break;
632 }
633 }
634#endif /* CONFIG_PPC32 */
575 635
576 /* We first try to detect Apple's new Core99 chipset, since mac-io 636 /* We first try to detect Apple's new Core99 chipset, since mac-io
577 * is quite different on those machines and contains an IBM MPIC2. 637 * is quite different on those machines and contains an IBM MPIC2.
diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
index 402d2212162f..2659a60bd7b8 100644
--- a/arch/powerpc/sysdev/axonram.c
+++ b/arch/powerpc/sysdev/axonram.c
@@ -60,7 +60,7 @@
60static int azfs_major, azfs_minor; 60static int azfs_major, azfs_minor;
61 61
62struct axon_ram_bank { 62struct axon_ram_bank {
63 struct of_device *device; 63 struct platform_device *device;
64 struct gendisk *disk; 64 struct gendisk *disk;
65 unsigned int irq_id; 65 unsigned int irq_id;
66 unsigned long ph_addr; 66 unsigned long ph_addr;
@@ -72,7 +72,7 @@ struct axon_ram_bank {
72static ssize_t 72static ssize_t
73axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf) 73axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf)
74{ 74{
75 struct of_device *device = to_of_device(dev); 75 struct platform_device *device = to_platform_device(dev);
76 struct axon_ram_bank *bank = device->dev.platform_data; 76 struct axon_ram_bank *bank = device->dev.platform_data;
77 77
78 BUG_ON(!bank); 78 BUG_ON(!bank);
@@ -90,7 +90,7 @@ static DEVICE_ATTR(ecc, S_IRUGO, axon_ram_sysfs_ecc, NULL);
90static irqreturn_t 90static irqreturn_t
91axon_ram_irq_handler(int irq, void *dev) 91axon_ram_irq_handler(int irq, void *dev)
92{ 92{
93 struct of_device *device = dev; 93 struct platform_device *device = dev;
94 struct axon_ram_bank *bank = device->dev.platform_data; 94 struct axon_ram_bank *bank = device->dev.platform_data;
95 95
96 BUG_ON(!bank); 96 BUG_ON(!bank);
@@ -174,8 +174,8 @@ static const struct block_device_operations axon_ram_devops = {
174 * axon_ram_probe - probe() method for platform driver 174 * axon_ram_probe - probe() method for platform driver
175 * @device, @device_id: see of_platform_driver method 175 * @device, @device_id: see of_platform_driver method
176 */ 176 */
177static int 177static int axon_ram_probe(struct platform_device *device,
178axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) 178 const struct of_device_id *device_id)
179{ 179{
180 static int axon_ram_bank_id = -1; 180 static int axon_ram_bank_id = -1;
181 struct axon_ram_bank *bank; 181 struct axon_ram_bank *bank;
@@ -304,7 +304,7 @@ failed:
304 * @device: see of_platform_driver method 304 * @device: see of_platform_driver method
305 */ 305 */
306static int 306static int
307axon_ram_remove(struct of_device *device) 307axon_ram_remove(struct platform_device *device)
308{ 308{
309 struct axon_ram_bank *bank = device->dev.platform_data; 309 struct axon_ram_bank *bank = device->dev.platform_data;
310 310
diff --git a/arch/powerpc/sysdev/bestcomm/bestcomm.c b/arch/powerpc/sysdev/bestcomm/bestcomm.c
index a7c5c470af14..650256115064 100644
--- a/arch/powerpc/sysdev/bestcomm/bestcomm.c
+++ b/arch/powerpc/sysdev/bestcomm/bestcomm.c
@@ -365,8 +365,8 @@ bcom_engine_cleanup(void)
365/* OF platform driver */ 365/* OF platform driver */
366/* ======================================================================== */ 366/* ======================================================================== */
367 367
368static int __devinit 368static int __devinit mpc52xx_bcom_probe(struct platform_device *op,
369mpc52xx_bcom_probe(struct of_device *op, const struct of_device_id *match) 369 const struct of_device_id *match)
370{ 370{
371 struct device_node *ofn_sram; 371 struct device_node *ofn_sram;
372 struct resource res_bcom; 372 struct resource res_bcom;
@@ -461,8 +461,7 @@ error_ofput:
461} 461}
462 462
463 463
464static int 464static int mpc52xx_bcom_remove(struct platform_device *op)
465mpc52xx_bcom_remove(struct of_device *op)
466{ 465{
467 /* Clean up the engine */ 466 /* Clean up the engine */
468 bcom_engine_cleanup(); 467 bcom_engine_cleanup();
diff --git a/arch/powerpc/sysdev/bestcomm/sram.c b/arch/powerpc/sysdev/bestcomm/sram.c
index 5d74ef7a651f..1225012a681a 100644
--- a/arch/powerpc/sysdev/bestcomm/sram.c
+++ b/arch/powerpc/sysdev/bestcomm/sram.c
@@ -11,6 +11,7 @@
11 * kind, whether express or implied. 11 * kind, whether express or implied.
12 */ 12 */
13 13
14#include <linux/err.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c
index 8d103ca6d6ab..00852124ff4a 100644
--- a/arch/powerpc/sysdev/cpm1.c
+++ b/arch/powerpc/sysdev/cpm1.c
@@ -621,7 +621,6 @@ int cpm1_gpiochip_add16(struct device_node *np)
621{ 621{
622 struct cpm1_gpio16_chip *cpm1_gc; 622 struct cpm1_gpio16_chip *cpm1_gc;
623 struct of_mm_gpio_chip *mm_gc; 623 struct of_mm_gpio_chip *mm_gc;
624 struct of_gpio_chip *of_gc;
625 struct gpio_chip *gc; 624 struct gpio_chip *gc;
626 625
627 cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); 626 cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL);
@@ -631,11 +630,9 @@ int cpm1_gpiochip_add16(struct device_node *np)
631 spin_lock_init(&cpm1_gc->lock); 630 spin_lock_init(&cpm1_gc->lock);
632 631
633 mm_gc = &cpm1_gc->mm_gc; 632 mm_gc = &cpm1_gc->mm_gc;
634 of_gc = &mm_gc->of_gc; 633 gc = &mm_gc->gc;
635 gc = &of_gc->gc;
636 634
637 mm_gc->save_regs = cpm1_gpio16_save_regs; 635 mm_gc->save_regs = cpm1_gpio16_save_regs;
638 of_gc->gpio_cells = 2;
639 gc->ngpio = 16; 636 gc->ngpio = 16;
640 gc->direction_input = cpm1_gpio16_dir_in; 637 gc->direction_input = cpm1_gpio16_dir_in;
641 gc->direction_output = cpm1_gpio16_dir_out; 638 gc->direction_output = cpm1_gpio16_dir_out;
@@ -745,7 +742,6 @@ int cpm1_gpiochip_add32(struct device_node *np)
745{ 742{
746 struct cpm1_gpio32_chip *cpm1_gc; 743 struct cpm1_gpio32_chip *cpm1_gc;
747 struct of_mm_gpio_chip *mm_gc; 744 struct of_mm_gpio_chip *mm_gc;
748 struct of_gpio_chip *of_gc;
749 struct gpio_chip *gc; 745 struct gpio_chip *gc;
750 746
751 cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); 747 cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL);
@@ -755,11 +751,9 @@ int cpm1_gpiochip_add32(struct device_node *np)
755 spin_lock_init(&cpm1_gc->lock); 751 spin_lock_init(&cpm1_gc->lock);
756 752
757 mm_gc = &cpm1_gc->mm_gc; 753 mm_gc = &cpm1_gc->mm_gc;
758 of_gc = &mm_gc->of_gc; 754 gc = &mm_gc->gc;
759 gc = &of_gc->gc;
760 755
761 mm_gc->save_regs = cpm1_gpio32_save_regs; 756 mm_gc->save_regs = cpm1_gpio32_save_regs;
762 of_gc->gpio_cells = 2;
763 gc->ngpio = 32; 757 gc->ngpio = 32;
764 gc->direction_input = cpm1_gpio32_dir_in; 758 gc->direction_input = cpm1_gpio32_dir_in;
765 gc->direction_output = cpm1_gpio32_dir_out; 759 gc->direction_output = cpm1_gpio32_dir_out;
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index 88b9812c854f..2b69aa0315b3 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -325,7 +325,6 @@ int cpm2_gpiochip_add32(struct device_node *np)
325{ 325{
326 struct cpm2_gpio32_chip *cpm2_gc; 326 struct cpm2_gpio32_chip *cpm2_gc;
327 struct of_mm_gpio_chip *mm_gc; 327 struct of_mm_gpio_chip *mm_gc;
328 struct of_gpio_chip *of_gc;
329 struct gpio_chip *gc; 328 struct gpio_chip *gc;
330 329
331 cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL); 330 cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL);
@@ -335,11 +334,9 @@ int cpm2_gpiochip_add32(struct device_node *np)
335 spin_lock_init(&cpm2_gc->lock); 334 spin_lock_init(&cpm2_gc->lock);
336 335
337 mm_gc = &cpm2_gc->mm_gc; 336 mm_gc = &cpm2_gc->mm_gc;
338 of_gc = &mm_gc->of_gc; 337 gc = &mm_gc->gc;
339 gc = &of_gc->gc;
340 338
341 mm_gc->save_regs = cpm2_gpio32_save_regs; 339 mm_gc->save_regs = cpm2_gpio32_save_regs;
342 of_gc->gpio_cells = 2;
343 gc->ngpio = 32; 340 gc->ngpio = 32;
344 gc->direction_input = cpm2_gpio32_dir_in; 341 gc->direction_input = cpm2_gpio32_dir_in;
345 gc->direction_output = cpm2_gpio32_dir_out; 342 gc->direction_output = cpm2_gpio32_dir_out;
diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c
index eca4545dd52e..7dd2885321ad 100644
--- a/arch/powerpc/sysdev/fsl_gtm.c
+++ b/arch/powerpc/sysdev/fsl_gtm.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/list.h> 19#include <linux/list.h>
19#include <linux/io.h> 20#include <linux/io.h>
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 962c2d8dd8d9..87991d3abbab 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -250,7 +250,7 @@ unlock:
250 raw_spin_unlock(&desc->lock); 250 raw_spin_unlock(&desc->lock);
251} 251}
252 252
253static int fsl_of_msi_remove(struct of_device *ofdev) 253static int fsl_of_msi_remove(struct platform_device *ofdev)
254{ 254{
255 struct fsl_msi *msi = ofdev->dev.platform_data; 255 struct fsl_msi *msi = ofdev->dev.platform_data;
256 int virq, i; 256 int virq, i;
@@ -274,7 +274,7 @@ static int fsl_of_msi_remove(struct of_device *ofdev)
274 return 0; 274 return 0;
275} 275}
276 276
277static int __devinit fsl_of_msi_probe(struct of_device *dev, 277static int __devinit fsl_of_msi_probe(struct platform_device *dev,
278 const struct of_device_id *match) 278 const struct of_device_id *match)
279{ 279{
280 struct fsl_msi *msi; 280 struct fsl_msi *msi;
diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c
index 9082eb921ad9..44de8559c975 100644
--- a/arch/powerpc/sysdev/fsl_pmc.c
+++ b/arch/powerpc/sysdev/fsl_pmc.c
@@ -58,7 +58,8 @@ static struct platform_suspend_ops pmc_suspend_ops = {
58 .enter = pmc_suspend_enter, 58 .enter = pmc_suspend_enter,
59}; 59};
60 60
61static int pmc_probe(struct of_device *ofdev, const struct of_device_id *id) 61static int pmc_probe(struct platform_device *ofdev,
62 const struct of_device_id *id)
62{ 63{
63 pmc_regs = of_iomap(ofdev->dev.of_node, 0); 64 pmc_regs = of_iomap(ofdev->dev.of_node, 0);
64 if (!pmc_regs) 65 if (!pmc_regs)
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 30e1626b2e85..8bd86530ee25 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1338,7 +1338,7 @@ static inline void fsl_rio_info(struct device *dev, u32 ccsr)
1338 * master port with system-specific info, and registers the 1338 * master port with system-specific info, and registers the
1339 * master port with the RapidIO subsystem. 1339 * master port with the RapidIO subsystem.
1340 */ 1340 */
1341int fsl_rio_setup(struct of_device *dev) 1341int fsl_rio_setup(struct platform_device *dev)
1342{ 1342{
1343 struct rio_ops *ops; 1343 struct rio_ops *ops;
1344 struct rio_mport *port; 1344 struct rio_mport *port;
@@ -1536,7 +1536,7 @@ err_ops:
1536 1536
1537/* The probe function for RapidIO peer-to-peer network. 1537/* The probe function for RapidIO peer-to-peer network.
1538 */ 1538 */
1539static int __devinit fsl_of_rio_rpn_probe(struct of_device *dev, 1539static int __devinit fsl_of_rio_rpn_probe(struct platform_device *dev,
1540 const struct of_device_id *match) 1540 const struct of_device_id *match)
1541{ 1541{
1542 int rc; 1542 int rc;
diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
index 83f519655fac..2b69084d0f0c 100644
--- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
@@ -257,7 +257,6 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
257{ 257{
258 struct mpc8xxx_gpio_chip *mpc8xxx_gc; 258 struct mpc8xxx_gpio_chip *mpc8xxx_gc;
259 struct of_mm_gpio_chip *mm_gc; 259 struct of_mm_gpio_chip *mm_gc;
260 struct of_gpio_chip *of_gc;
261 struct gpio_chip *gc; 260 struct gpio_chip *gc;
262 unsigned hwirq; 261 unsigned hwirq;
263 int ret; 262 int ret;
@@ -271,11 +270,9 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
271 spin_lock_init(&mpc8xxx_gc->lock); 270 spin_lock_init(&mpc8xxx_gc->lock);
272 271
273 mm_gc = &mpc8xxx_gc->mm_gc; 272 mm_gc = &mpc8xxx_gc->mm_gc;
274 of_gc = &mm_gc->of_gc; 273 gc = &mm_gc->gc;
275 gc = &of_gc->gc;
276 274
277 mm_gc->save_regs = mpc8xxx_gpio_save_regs; 275 mm_gc->save_regs = mpc8xxx_gpio_save_regs;
278 of_gc->gpio_cells = 2;
279 gc->ngpio = MPC8XXX_GPIO_PINS; 276 gc->ngpio = MPC8XXX_GPIO_PINS;
280 gc->direction_input = mpc8xxx_gpio_dir_in; 277 gc->direction_input = mpc8xxx_gpio_dir_in;
281 gc->direction_output = mpc8xxx_gpio_dir_out; 278 gc->direction_output = mpc8xxx_gpio_dir_out;
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 31acd3b1718b..1398bc454999 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -20,12 +20,7 @@
20 20
21#include <asm/prom.h> 21#include <asm/prom.h>
22 22
23/* 23/* These functions provide the necessary setup for the mv64x60 drivers. */
24 * These functions provide the necessary setup for the mv64x60 drivers.
25 * These drivers are unusual in that they work on both the MIPS and PowerPC
26 * architectures. Because of that, the drivers do not support the normal
27 * PowerPC of_platform_bus_type. They support platform_bus_type instead.
28 */
29 24
30static struct of_device_id __initdata of_mv64x60_devices[] = { 25static struct of_device_id __initdata of_mv64x60_devices[] = {
31 { .compatible = "marvell,mv64306-devctrl", }, 26 { .compatible = "marvell,mv64306-devctrl", },
diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c
index d07137a07d75..24a0bb955b18 100644
--- a/arch/powerpc/sysdev/pmi.c
+++ b/arch/powerpc/sysdev/pmi.c
@@ -43,7 +43,7 @@ struct pmi_data {
43 struct mutex msg_mutex; 43 struct mutex msg_mutex;
44 pmi_message_t msg; 44 pmi_message_t msg;
45 struct completion *completion; 45 struct completion *completion;
46 struct of_device *dev; 46 struct platform_device *dev;
47 int irq; 47 int irq;
48 u8 __iomem *pmi_reg; 48 u8 __iomem *pmi_reg;
49 struct work_struct work; 49 struct work_struct work;
@@ -121,7 +121,7 @@ static void pmi_notify_handlers(struct work_struct *work)
121 spin_unlock(&data->handler_spinlock); 121 spin_unlock(&data->handler_spinlock);
122} 122}
123 123
124static int pmi_of_probe(struct of_device *dev, 124static int pmi_of_probe(struct platform_device *dev,
125 const struct of_device_id *match) 125 const struct of_device_id *match)
126{ 126{
127 struct device_node *np = dev->dev.of_node; 127 struct device_node *np = dev->dev.of_node;
@@ -185,7 +185,7 @@ out:
185 return rc; 185 return rc;
186} 186}
187 187
188static int pmi_of_remove(struct of_device *dev) 188static int pmi_of_remove(struct platform_device *dev)
189{ 189{
190 struct pmi_handler *handler, *tmp; 190 struct pmi_handler *handler, *tmp;
191 191
diff --git a/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c
index 3812fc366bec..fc65ad1b3293 100644
--- a/arch/powerpc/sysdev/ppc4xx_gpio.c
+++ b/arch/powerpc/sysdev/ppc4xx_gpio.c
@@ -181,7 +181,6 @@ static int __init ppc4xx_add_gpiochips(void)
181 int ret; 181 int ret;
182 struct ppc4xx_gpio_chip *ppc4xx_gc; 182 struct ppc4xx_gpio_chip *ppc4xx_gc;
183 struct of_mm_gpio_chip *mm_gc; 183 struct of_mm_gpio_chip *mm_gc;
184 struct of_gpio_chip *of_gc;
185 struct gpio_chip *gc; 184 struct gpio_chip *gc;
186 185
187 ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL); 186 ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL);
@@ -193,10 +192,8 @@ static int __init ppc4xx_add_gpiochips(void)
193 spin_lock_init(&ppc4xx_gc->lock); 192 spin_lock_init(&ppc4xx_gc->lock);
194 193
195 mm_gc = &ppc4xx_gc->mm_gc; 194 mm_gc = &ppc4xx_gc->mm_gc;
196 of_gc = &mm_gc->of_gc; 195 gc = &mm_gc->gc;
197 gc = &of_gc->gc;
198 196
199 of_gc->gpio_cells = 2;
200 gc->ngpio = 32; 197 gc->ngpio = 32;
201 gc->direction_input = ppc4xx_gpio_dir_in; 198 gc->direction_input = ppc4xx_gpio_dir_in;
202 gc->direction_output = ppc4xx_gpio_dir_out; 199 gc->direction_output = ppc4xx_gpio_dir_out;
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
index dc8f8d618074..36bf845df127 100644
--- a/arch/powerpc/sysdev/qe_lib/gpio.c
+++ b/arch/powerpc/sysdev/qe_lib/gpio.c
@@ -138,8 +138,8 @@ struct qe_pin {
138struct qe_pin *qe_pin_request(struct device_node *np, int index) 138struct qe_pin *qe_pin_request(struct device_node *np, int index)
139{ 139{
140 struct qe_pin *qe_pin; 140 struct qe_pin *qe_pin;
141 struct device_node *gc; 141 struct device_node *gpio_np;
142 struct of_gpio_chip *of_gc = NULL; 142 struct gpio_chip *gc;
143 struct of_mm_gpio_chip *mm_gc; 143 struct of_mm_gpio_chip *mm_gc;
144 struct qe_gpio_chip *qe_gc; 144 struct qe_gpio_chip *qe_gc;
145 int err; 145 int err;
@@ -155,40 +155,40 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
155 } 155 }
156 156
157 err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, 157 err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,
158 &gc, &gpio_spec); 158 &gpio_np, &gpio_spec);
159 if (err) { 159 if (err) {
160 pr_debug("%s: can't parse gpios property\n", __func__); 160 pr_debug("%s: can't parse gpios property\n", __func__);
161 goto err0; 161 goto err0;
162 } 162 }
163 163
164 if (!of_device_is_compatible(gc, "fsl,mpc8323-qe-pario-bank")) { 164 if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) {
165 pr_debug("%s: tried to get a non-qe pin\n", __func__); 165 pr_debug("%s: tried to get a non-qe pin\n", __func__);
166 err = -EINVAL; 166 err = -EINVAL;
167 goto err1; 167 goto err1;
168 } 168 }
169 169
170 of_gc = gc->data; 170 gc = of_node_to_gpiochip(gpio_np);
171 if (!of_gc) { 171 if (!gc) {
172 pr_debug("%s: gpio controller %s isn't registered\n", 172 pr_debug("%s: gpio controller %s isn't registered\n",
173 np->full_name, gc->full_name); 173 np->full_name, gpio_np->full_name);
174 err = -ENODEV; 174 err = -ENODEV;
175 goto err1; 175 goto err1;
176 } 176 }
177 177
178 gpio_cells = of_get_property(gc, "#gpio-cells", &size); 178 gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size);
179 if (!gpio_cells || size != sizeof(*gpio_cells) || 179 if (!gpio_cells || size != sizeof(*gpio_cells) ||
180 *gpio_cells != of_gc->gpio_cells) { 180 *gpio_cells != gc->of_gpio_n_cells) {
181 pr_debug("%s: wrong #gpio-cells for %s\n", 181 pr_debug("%s: wrong #gpio-cells for %s\n",
182 np->full_name, gc->full_name); 182 np->full_name, gpio_np->full_name);
183 err = -EINVAL; 183 err = -EINVAL;
184 goto err1; 184 goto err1;
185 } 185 }
186 186
187 err = of_gc->xlate(of_gc, np, gpio_spec, NULL); 187 err = gc->of_xlate(gc, np, gpio_spec, NULL);
188 if (err < 0) 188 if (err < 0)
189 goto err1; 189 goto err1;
190 190
191 mm_gc = to_of_mm_gpio_chip(&of_gc->gc); 191 mm_gc = to_of_mm_gpio_chip(gc);
192 qe_gc = to_qe_gpio_chip(mm_gc); 192 qe_gc = to_qe_gpio_chip(mm_gc);
193 193
194 spin_lock_irqsave(&qe_gc->lock, flags); 194 spin_lock_irqsave(&qe_gc->lock, flags);
@@ -206,7 +206,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
206 if (!err) 206 if (!err)
207 return qe_pin; 207 return qe_pin;
208err1: 208err1:
209 of_node_put(gc); 209 of_node_put(gpio_np);
210err0: 210err0:
211 kfree(qe_pin); 211 kfree(qe_pin);
212 pr_debug("%s failed with status %d\n", __func__, err); 212 pr_debug("%s failed with status %d\n", __func__, err);
@@ -307,7 +307,6 @@ static int __init qe_add_gpiochips(void)
307 int ret; 307 int ret;
308 struct qe_gpio_chip *qe_gc; 308 struct qe_gpio_chip *qe_gc;
309 struct of_mm_gpio_chip *mm_gc; 309 struct of_mm_gpio_chip *mm_gc;
310 struct of_gpio_chip *of_gc;
311 struct gpio_chip *gc; 310 struct gpio_chip *gc;
312 311
313 qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL); 312 qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
@@ -319,11 +318,9 @@ static int __init qe_add_gpiochips(void)
319 spin_lock_init(&qe_gc->lock); 318 spin_lock_init(&qe_gc->lock);
320 319
321 mm_gc = &qe_gc->mm_gc; 320 mm_gc = &qe_gc->mm_gc;
322 of_gc = &mm_gc->of_gc; 321 gc = &mm_gc->gc;
323 gc = &of_gc->gc;
324 322
325 mm_gc->save_regs = qe_gpio_save_regs; 323 mm_gc->save_regs = qe_gpio_save_regs;
326 of_gc->gpio_cells = 2;
327 gc->ngpio = QE_PIO_PINS; 324 gc->ngpio = QE_PIO_PINS;
328 gc->direction_input = qe_gpio_dir_in; 325 gc->direction_input = qe_gpio_dir_in;
329 gc->direction_output = qe_gpio_dir_out; 326 gc->direction_output = qe_gpio_dir_out;
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 093e0ae1a941..3da8014931c9 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -651,14 +651,15 @@ unsigned int qe_get_num_of_snums(void)
651EXPORT_SYMBOL(qe_get_num_of_snums); 651EXPORT_SYMBOL(qe_get_num_of_snums);
652 652
653#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC_85xx) 653#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC_85xx)
654static int qe_resume(struct of_device *ofdev) 654static int qe_resume(struct platform_device *ofdev)
655{ 655{
656 if (!qe_alive_during_sleep()) 656 if (!qe_alive_during_sleep())
657 qe_reset(); 657 qe_reset();
658 return 0; 658 return 0;
659} 659}
660 660
661static int qe_probe(struct of_device *ofdev, const struct of_device_id *id) 661static int qe_probe(struct platform_device *ofdev,
662 const struct of_device_id *id)
662{ 663{
663 return 0; 664 return 0;
664} 665}
diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c
index d5fb173e588c..b6defda5ccc9 100644
--- a/arch/powerpc/sysdev/simple_gpio.c
+++ b/arch/powerpc/sysdev/simple_gpio.c
@@ -91,7 +91,6 @@ static int __init u8_simple_gpiochip_add(struct device_node *np)
91 int ret; 91 int ret;
92 struct u8_gpio_chip *u8_gc; 92 struct u8_gpio_chip *u8_gc;
93 struct of_mm_gpio_chip *mm_gc; 93 struct of_mm_gpio_chip *mm_gc;
94 struct of_gpio_chip *of_gc;
95 struct gpio_chip *gc; 94 struct gpio_chip *gc;
96 95
97 u8_gc = kzalloc(sizeof(*u8_gc), GFP_KERNEL); 96 u8_gc = kzalloc(sizeof(*u8_gc), GFP_KERNEL);
@@ -101,11 +100,9 @@ static int __init u8_simple_gpiochip_add(struct device_node *np)
101 spin_lock_init(&u8_gc->lock); 100 spin_lock_init(&u8_gc->lock);
102 101
103 mm_gc = &u8_gc->mm_gc; 102 mm_gc = &u8_gc->mm_gc;
104 of_gc = &mm_gc->of_gc; 103 gc = &mm_gc->gc;
105 gc = &of_gc->gc;
106 104
107 mm_gc->save_regs = u8_gpio_save_regs; 105 mm_gc->save_regs = u8_gpio_save_regs;
108 of_gc->gpio_cells = 2;
109 gc->ngpio = 8; 106 gc->ngpio = 8;
110 gc->direction_input = u8_gpio_dir_in; 107 gc->direction_input = u8_gpio_dir_in;
111 gc->direction_output = u8_gpio_dir_out; 108 gc->direction_output = u8_gpio_dir_out;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c0015db247ba..ba068c833e5d 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -18,6 +18,7 @@ config 64BIT
18config SPARC 18config SPARC
19 bool 19 bool
20 default y 20 default y
21 select OF
21 select HAVE_IDE 22 select HAVE_IDE
22 select HAVE_OPROFILE 23 select HAVE_OPROFILE
23 select HAVE_ARCH_KGDB if !SMP || SPARC64 24 select HAVE_ARCH_KGDB if !SMP || SPARC64
@@ -148,9 +149,6 @@ config GENERIC_GPIO
148config ARCH_NO_VIRT_TO_BUS 149config ARCH_NO_VIRT_TO_BUS
149 def_bool y 150 def_bool y
150 151
151config OF
152 def_bool y
153
154config ARCH_SUPPORTS_DEBUG_PAGEALLOC 152config ARCH_SUPPORTS_DEBUG_PAGEALLOC
155 def_bool y if SPARC64 153 def_bool y if SPARC64
156 154
diff --git a/arch/sparc/include/asm/device.h b/arch/sparc/include/asm/device.h
index d4c452147412..daa6a8a5e9cd 100644
--- a/arch/sparc/include/asm/device.h
+++ b/arch/sparc/include/asm/device.h
@@ -6,18 +6,25 @@
6#ifndef _ASM_SPARC_DEVICE_H 6#ifndef _ASM_SPARC_DEVICE_H
7#define _ASM_SPARC_DEVICE_H 7#define _ASM_SPARC_DEVICE_H
8 8
9#include <asm/openprom.h>
10
9struct device_node; 11struct device_node;
10struct of_device; 12struct platform_device;
11 13
12struct dev_archdata { 14struct dev_archdata {
13 void *iommu; 15 void *iommu;
14 void *stc; 16 void *stc;
15 void *host_controller; 17 void *host_controller;
16 struct of_device *op; 18 struct platform_device *op;
17 int numa_node; 19 int numa_node;
18}; 20};
19 21
22extern void of_propagate_archdata(struct platform_device *bus);
23
20struct pdev_archdata { 24struct pdev_archdata {
25 struct resource resource[PROMREG_MAX];
26 unsigned int irqs[PROMINTR_MAX];
27 int num_irqs;
21}; 28};
22 29
23#endif /* _ASM_SPARC_DEVICE_H */ 30#endif /* _ASM_SPARC_DEVICE_H */
diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
index 8fac3ab22f36..6597ce874d78 100644
--- a/arch/sparc/include/asm/floppy_64.h
+++ b/arch/sparc/include/asm/floppy_64.h
@@ -43,7 +43,7 @@ struct sun_flpy_controller {
43/* You'll only ever find one controller on an Ultra anyways. */ 43/* You'll only ever find one controller on an Ultra anyways. */
44static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1; 44static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1;
45unsigned long fdc_status; 45unsigned long fdc_status;
46static struct of_device *floppy_op = NULL; 46static struct platform_device *floppy_op = NULL;
47 47
48struct sun_floppy_ops { 48struct sun_floppy_ops {
49 unsigned char (*fd_inb) (unsigned long port); 49 unsigned char (*fd_inb) (unsigned long port);
@@ -548,7 +548,7 @@ static unsigned long __init sun_floppy_init(void)
548{ 548{
549 static int initialized = 0; 549 static int initialized = 0;
550 struct device_node *dp; 550 struct device_node *dp;
551 struct of_device *op; 551 struct platform_device *op;
552 const char *prop; 552 const char *prop;
553 char state[128]; 553 char state[128];
554 554
@@ -567,7 +567,7 @@ static unsigned long __init sun_floppy_init(void)
567 } 567 }
568 if (op) { 568 if (op) {
569 floppy_op = op; 569 floppy_op = op;
570 FLOPPY_IRQ = op->irqs[0]; 570 FLOPPY_IRQ = op->archdata.irqs[0];
571 } else { 571 } else {
572 struct device_node *ebus_dp; 572 struct device_node *ebus_dp;
573 void __iomem *auxio_reg; 573 void __iomem *auxio_reg;
@@ -593,7 +593,7 @@ static unsigned long __init sun_floppy_init(void)
593 if (state_prop && !strncmp(state_prop, "disabled", 8)) 593 if (state_prop && !strncmp(state_prop, "disabled", 8))
594 return 0; 594 return 0;
595 595
596 FLOPPY_IRQ = op->irqs[0]; 596 FLOPPY_IRQ = op->archdata.irqs[0];
597 597
598 /* Make sure the high density bit is set, some systems 598 /* Make sure the high density bit is set, some systems
599 * (most notably Ultra5/Ultra10) come up with it clear. 599 * (most notably Ultra5/Ultra10) come up with it clear.
@@ -661,7 +661,7 @@ static unsigned long __init sun_floppy_init(void)
661 config = 0; 661 config = 0;
662 for (dp = ebus_dp->child; dp; dp = dp->sibling) { 662 for (dp = ebus_dp->child; dp; dp = dp->sibling) {
663 if (!strcmp(dp->name, "ecpp")) { 663 if (!strcmp(dp->name, "ecpp")) {
664 struct of_device *ecpp_op; 664 struct platform_device *ecpp_op;
665 665
666 ecpp_op = of_find_device_by_node(dp); 666 ecpp_op = of_find_device_by_node(dp);
667 if (ecpp_op) 667 if (ecpp_op)
diff --git a/arch/sparc/include/asm/of_device.h b/arch/sparc/include/asm/of_device.h
deleted file mode 100644
index f320246a0586..000000000000
--- a/arch/sparc/include/asm/of_device.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef _ASM_SPARC_OF_DEVICE_H
2#define _ASM_SPARC_OF_DEVICE_H
3#ifdef __KERNEL__
4
5#include <linux/device.h>
6#include <linux/of.h>
7#include <linux/mod_devicetable.h>
8#include <asm/openprom.h>
9
10/*
11 * The of_device is a kind of "base class" that is a superset of
12 * struct device for use by devices attached to an OF node and
13 * probed using OF properties.
14 */
15struct of_device
16{
17 struct device dev;
18 struct resource resource[PROMREG_MAX];
19 unsigned int irqs[PROMINTR_MAX];
20 int num_irqs;
21
22 void *sysdata;
23
24 int slot;
25 int portid;
26 int clock_freq;
27};
28
29extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
30extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size);
31
32extern void of_propagate_archdata(struct of_device *bus);
33
34/* This is just here during the transition */
35#include <linux/of_platform.h>
36
37#endif /* __KERNEL__ */
38#endif /* _ASM_SPARC_OF_DEVICE_H */
diff --git a/arch/sparc/include/asm/of_platform.h b/arch/sparc/include/asm/of_platform.h
deleted file mode 100644
index 90da99059f83..000000000000
--- a/arch/sparc/include/asm/of_platform.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef ___ASM_SPARC_OF_PLATFORM_H
2#define ___ASM_SPARC_OF_PLATFORM_H
3/*
4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 * Modified for Sparc by merging parts of asm/of_device.h
7 * by Stephen Rothwell
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 */
15
16#define of_bus_type of_platform_bus_type /* for compatibility */
17
18#endif
diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h
index c333b8d0949b..4f7afa01b2ae 100644
--- a/arch/sparc/include/asm/parport.h
+++ b/arch/sparc/include/asm/parport.h
@@ -103,7 +103,7 @@ static inline unsigned int get_dma_residue(unsigned int dmanr)
103 return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info); 103 return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
104} 104}
105 105
106static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id *match) 106static int __devinit ecpp_probe(struct platform_device *op, const struct of_device_id *match)
107{ 107{
108 unsigned long base = op->resource[0].start; 108 unsigned long base = op->resource[0].start;
109 unsigned long config = op->resource[1].start; 109 unsigned long config = op->resource[1].start;
@@ -116,7 +116,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id
116 parent = op->dev.of_node->parent; 116 parent = op->dev.of_node->parent;
117 if (!strcmp(parent->name, "dma")) { 117 if (!strcmp(parent->name, "dma")) {
118 p = parport_pc_probe_port(base, base + 0x400, 118 p = parport_pc_probe_port(base, base + 0x400,
119 op->irqs[0], PARPORT_DMA_NOFIFO, 119 op->archdata.irqs[0], PARPORT_DMA_NOFIFO,
120 op->dev.parent->parent, 0); 120 op->dev.parent->parent, 0);
121 if (!p) 121 if (!p)
122 return -ENOMEM; 122 return -ENOMEM;
@@ -166,7 +166,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id
166 0, PTR_LPT_REG_DIR); 166 0, PTR_LPT_REG_DIR);
167 167
168 p = parport_pc_probe_port(base, base + 0x400, 168 p = parport_pc_probe_port(base, base + 0x400,
169 op->irqs[0], 169 op->archdata.irqs[0],
170 slot, 170 slot,
171 op->dev.parent, 171 op->dev.parent,
172 0); 172 0);
@@ -192,7 +192,7 @@ out_err:
192 return err; 192 return err;
193} 193}
194 194
195static int __devexit ecpp_remove(struct of_device *op) 195static int __devexit ecpp_remove(struct platform_device *op)
196{ 196{
197 struct parport *p = dev_get_drvdata(&op->dev); 197 struct parport *p = dev_get_drvdata(&op->dev);
198 int slot = p->dma; 198 int slot = p->dma;
@@ -243,9 +243,7 @@ static struct of_platform_driver ecpp_driver = {
243 243
244static int parport_pc_find_nonpci_ports(int autoirq, int autodma) 244static int parport_pc_find_nonpci_ports(int autoirq, int autodma)
245{ 245{
246 of_register_driver(&ecpp_driver, &of_bus_type); 246 return of_register_platform_driver(&ecpp_driver);
247
248 return 0;
249} 247}
250 248
251#endif /* !(_ASM_SPARC64_PARPORT_H */ 249#endif /* !(_ASM_SPARC64_PARPORT_H */
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index f845828ca4c6..291f12575edd 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -43,20 +43,22 @@ extern int of_getintprop_default(struct device_node *np,
43extern int of_find_in_proplist(const char *list, const char *match, int len); 43extern int of_find_in_proplist(const char *list, const char *match, int len);
44#ifdef CONFIG_NUMA 44#ifdef CONFIG_NUMA
45extern int of_node_to_nid(struct device_node *dp); 45extern int of_node_to_nid(struct device_node *dp);
46#else 46#define of_node_to_nid of_node_to_nid
47#define of_node_to_nid(dp) (-1)
48#endif 47#endif
49 48
50extern void prom_build_devicetree(void); 49extern void prom_build_devicetree(void);
51extern void of_populate_present_mask(void); 50extern void of_populate_present_mask(void);
52extern void of_fill_in_cpu_data(void); 51extern void of_fill_in_cpu_data(void);
53 52
53struct resource;
54extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
55extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size);
56
54/* These routines are here to provide compatibility with how powerpc 57/* These routines are here to provide compatibility with how powerpc
55 * handles IRQ mapping for OF device nodes. We precompute and permanently 58 * handles IRQ mapping for OF device nodes. We precompute and permanently
56 * register them in the of_device objects, whereas powerpc computes them 59 * register them in the platform_device objects, whereas powerpc computes them
57 * on request. 60 * on request.
58 */ 61 */
59extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
60static inline void irq_dispose_mapping(unsigned int virq) 62static inline void irq_dispose_mapping(unsigned int virq)
61{ 63{
62} 64}
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index b27476caa133..2c0046ecc715 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -68,7 +68,7 @@ static void apc_swift_idle(void)
68#endif 68#endif
69} 69}
70 70
71static inline void apc_free(struct of_device *op) 71static inline void apc_free(struct platform_device *op)
72{ 72{
73 of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0])); 73 of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0]));
74} 74}
@@ -136,7 +136,7 @@ static const struct file_operations apc_fops = {
136 136
137static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; 137static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };
138 138
139static int __devinit apc_probe(struct of_device *op, 139static int __devinit apc_probe(struct platform_device *op,
140 const struct of_device_id *match) 140 const struct of_device_id *match)
141{ 141{
142 int err; 142 int err;
@@ -184,7 +184,7 @@ static struct of_platform_driver apc_driver = {
184 184
185static int __init apc_init(void) 185static int __init apc_init(void)
186{ 186{
187 return of_register_driver(&apc_driver, &of_bus_type); 187 return of_register_platform_driver(&apc_driver);
188} 188}
189 189
190/* This driver is not critical to the boot process 190/* This driver is not critical to the boot process
diff --git a/arch/sparc/kernel/auxio_64.c b/arch/sparc/kernel/auxio_64.c
index ddc84128b3c2..3efd3c5af6a9 100644
--- a/arch/sparc/kernel/auxio_64.c
+++ b/arch/sparc/kernel/auxio_64.c
@@ -102,7 +102,8 @@ static struct of_device_id __initdata auxio_match[] = {
102 102
103MODULE_DEVICE_TABLE(of, auxio_match); 103MODULE_DEVICE_TABLE(of, auxio_match);
104 104
105static int __devinit auxio_probe(struct of_device *dev, const struct of_device_id *match) 105static int __devinit auxio_probe(struct platform_device *dev,
106 const struct of_device_id *match)
106{ 107{
107 struct device_node *dp = dev->dev.of_node; 108 struct device_node *dp = dev->dev.of_node;
108 unsigned long size; 109 unsigned long size;
@@ -142,7 +143,7 @@ static struct of_platform_driver auxio_driver = {
142 143
143static int __init auxio_init(void) 144static int __init auxio_init(void)
144{ 145{
145 return of_register_driver(&auxio_driver, &of_platform_bus_type); 146 return of_register_platform_driver(&auxio_driver);
146} 147}
147 148
148/* Must be after subsys_initcall() so that busses are probed. Must 149/* Must be after subsys_initcall() so that busses are probed. Must
diff --git a/arch/sparc/kernel/central.c b/arch/sparc/kernel/central.c
index 434335f65823..cfa2624c5332 100644
--- a/arch/sparc/kernel/central.c
+++ b/arch/sparc/kernel/central.c
@@ -59,7 +59,7 @@ static int __devinit clock_board_calc_nslots(struct clock_board *p)
59 } 59 }
60} 60}
61 61
62static int __devinit clock_board_probe(struct of_device *op, 62static int __devinit clock_board_probe(struct platform_device *op,
63 const struct of_device_id *match) 63 const struct of_device_id *match)
64{ 64{
65 struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL); 65 struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL);
@@ -157,7 +157,7 @@ static struct of_platform_driver clock_board_driver = {
157 }, 157 },
158}; 158};
159 159
160static int __devinit fhc_probe(struct of_device *op, 160static int __devinit fhc_probe(struct platform_device *op,
161 const struct of_device_id *match) 161 const struct of_device_id *match)
162{ 162{
163 struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL); 163 struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL);
@@ -265,8 +265,8 @@ static struct of_platform_driver fhc_driver = {
265 265
266static int __init sunfire_init(void) 266static int __init sunfire_init(void)
267{ 267{
268 (void) of_register_driver(&fhc_driver, &of_platform_bus_type); 268 (void) of_register_platform_driver(&fhc_driver);
269 (void) of_register_driver(&clock_board_driver, &of_platform_bus_type); 269 (void) of_register_platform_driver(&clock_board_driver);
270 return 0; 270 return 0;
271} 271}
272 272
diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c
index 870cb65b3f21..08c466ebb32b 100644
--- a/arch/sparc/kernel/chmc.c
+++ b/arch/sparc/kernel/chmc.c
@@ -392,7 +392,7 @@ static void __devinit jbusmc_construct_dimm_groups(struct jbusmc *p,
392 } 392 }
393} 393}
394 394
395static int __devinit jbusmc_probe(struct of_device *op, 395static int __devinit jbusmc_probe(struct platform_device *op,
396 const struct of_device_id *match) 396 const struct of_device_id *match)
397{ 397{
398 const struct linux_prom64_registers *mem_regs; 398 const struct linux_prom64_registers *mem_regs;
@@ -690,7 +690,7 @@ static void chmc_fetch_decode_regs(struct chmc *p)
690 chmc_read_mcreg(p, CHMCTRL_DECODE4)); 690 chmc_read_mcreg(p, CHMCTRL_DECODE4));
691} 691}
692 692
693static int __devinit chmc_probe(struct of_device *op, 693static int __devinit chmc_probe(struct platform_device *op,
694 const struct of_device_id *match) 694 const struct of_device_id *match)
695{ 695{
696 struct device_node *dp = op->dev.of_node; 696 struct device_node *dp = op->dev.of_node;
@@ -765,7 +765,7 @@ out_free:
765 goto out; 765 goto out;
766} 766}
767 767
768static int __devinit us3mc_probe(struct of_device *op, 768static int __devinit us3mc_probe(struct platform_device *op,
769 const struct of_device_id *match) 769 const struct of_device_id *match)
770{ 770{
771 if (mc_type == MC_TYPE_SAFARI) 771 if (mc_type == MC_TYPE_SAFARI)
@@ -775,21 +775,21 @@ static int __devinit us3mc_probe(struct of_device *op,
775 return -ENODEV; 775 return -ENODEV;
776} 776}
777 777
778static void __devexit chmc_destroy(struct of_device *op, struct chmc *p) 778static void __devexit chmc_destroy(struct platform_device *op, struct chmc *p)
779{ 779{
780 list_del(&p->list); 780 list_del(&p->list);
781 of_iounmap(&op->resource[0], p->regs, 0x48); 781 of_iounmap(&op->resource[0], p->regs, 0x48);
782 kfree(p); 782 kfree(p);
783} 783}
784 784
785static void __devexit jbusmc_destroy(struct of_device *op, struct jbusmc *p) 785static void __devexit jbusmc_destroy(struct platform_device *op, struct jbusmc *p)
786{ 786{
787 mc_list_del(&p->list); 787 mc_list_del(&p->list);
788 of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE); 788 of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE);
789 kfree(p); 789 kfree(p);
790} 790}
791 791
792static int __devexit us3mc_remove(struct of_device *op) 792static int __devexit us3mc_remove(struct platform_device *op)
793{ 793{
794 void *p = dev_get_drvdata(&op->dev); 794 void *p = dev_get_drvdata(&op->dev);
795 795
@@ -848,7 +848,7 @@ static int __init us3mc_init(void)
848 ret = register_dimm_printer(us3mc_dimm_printer); 848 ret = register_dimm_printer(us3mc_dimm_printer);
849 849
850 if (!ret) { 850 if (!ret) {
851 ret = of_register_driver(&us3mc_driver, &of_bus_type); 851 ret = of_register_platform_driver(&us3mc_driver);
852 if (ret) 852 if (ret)
853 unregister_dimm_printer(us3mc_dimm_printer); 853 unregister_dimm_printer(us3mc_dimm_printer);
854 } 854 }
@@ -859,7 +859,7 @@ static void __exit us3mc_cleanup(void)
859{ 859{
860 if (us3mc_platform()) { 860 if (us3mc_platform()) {
861 unregister_dimm_printer(us3mc_dimm_printer); 861 unregister_dimm_printer(us3mc_dimm_printer);
862 of_unregister_driver(&us3mc_driver); 862 of_unregister_platform_driver(&us3mc_driver);
863 } 863 }
864} 864}
865 865
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 703e4aa9bc38..41f7e4e0f72a 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(sbus_set_sbus64);
253static void *sbus_alloc_coherent(struct device *dev, size_t len, 253static void *sbus_alloc_coherent(struct device *dev, size_t len,
254 dma_addr_t *dma_addrp, gfp_t gfp) 254 dma_addr_t *dma_addrp, gfp_t gfp)
255{ 255{
256 struct of_device *op = to_of_device(dev); 256 struct platform_device *op = to_platform_device(dev);
257 unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; 257 unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK;
258 unsigned long va; 258 unsigned long va;
259 struct resource *res; 259 struct resource *res;
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 47e63f1e719c..2d055a1e9cc2 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -241,10 +241,10 @@ static int __init use_1to1_mapping(struct device_node *pp)
241 241
242static int of_resource_verbose; 242static int of_resource_verbose;
243 243
244static void __init build_device_resources(struct of_device *op, 244static void __init build_device_resources(struct platform_device *op,
245 struct device *parent) 245 struct device *parent)
246{ 246{
247 struct of_device *p_op; 247 struct platform_device *p_op;
248 struct of_bus *bus; 248 struct of_bus *bus;
249 int na, ns; 249 int na, ns;
250 int index, num_reg; 250 int index, num_reg;
@@ -253,7 +253,7 @@ static void __init build_device_resources(struct of_device *op,
253 if (!parent) 253 if (!parent)
254 return; 254 return;
255 255
256 p_op = to_of_device(parent); 256 p_op = to_platform_device(parent);
257 bus = of_match_bus(p_op->dev.of_node); 257 bus = of_match_bus(p_op->dev.of_node);
258 bus->count_cells(op->dev.of_node, &na, &ns); 258 bus->count_cells(op->dev.of_node, &na, &ns);
259 259
@@ -267,6 +267,8 @@ static void __init build_device_resources(struct of_device *op,
267 /* Conver to num-entries. */ 267 /* Conver to num-entries. */
268 num_reg /= na + ns; 268 num_reg /= na + ns;
269 269
270 op->resource = op->archdata.resource;
271 op->num_resources = num_reg;
270 for (index = 0; index < num_reg; index++) { 272 for (index = 0; index < num_reg; index++) {
271 struct resource *r = &op->resource[index]; 273 struct resource *r = &op->resource[index];
272 u32 addr[OF_MAX_ADDR_CELLS]; 274 u32 addr[OF_MAX_ADDR_CELLS];
@@ -333,10 +335,10 @@ static void __init build_device_resources(struct of_device *op,
333 } 335 }
334} 336}
335 337
336static struct of_device * __init scan_one_device(struct device_node *dp, 338static struct platform_device * __init scan_one_device(struct device_node *dp,
337 struct device *parent) 339 struct device *parent)
338{ 340{
339 struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); 341 struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
340 const struct linux_prom_irqs *intr; 342 const struct linux_prom_irqs *intr;
341 struct dev_archdata *sd; 343 struct dev_archdata *sd;
342 int len, i; 344 int len, i;
@@ -349,27 +351,21 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
349 351
350 op->dev.of_node = dp; 352 op->dev.of_node = dp;
351 353
352 op->clock_freq = of_getintprop_default(dp, "clock-frequency",
353 (25*1000*1000));
354 op->portid = of_getintprop_default(dp, "upa-portid", -1);
355 if (op->portid == -1)
356 op->portid = of_getintprop_default(dp, "portid", -1);
357
358 intr = of_get_property(dp, "intr", &len); 354 intr = of_get_property(dp, "intr", &len);
359 if (intr) { 355 if (intr) {
360 op->num_irqs = len / sizeof(struct linux_prom_irqs); 356 op->archdata.num_irqs = len / sizeof(struct linux_prom_irqs);
361 for (i = 0; i < op->num_irqs; i++) 357 for (i = 0; i < op->archdata.num_irqs; i++)
362 op->irqs[i] = intr[i].pri; 358 op->archdata.irqs[i] = intr[i].pri;
363 } else { 359 } else {
364 const unsigned int *irq = 360 const unsigned int *irq =
365 of_get_property(dp, "interrupts", &len); 361 of_get_property(dp, "interrupts", &len);
366 362
367 if (irq) { 363 if (irq) {
368 op->num_irqs = len / sizeof(unsigned int); 364 op->archdata.num_irqs = len / sizeof(unsigned int);
369 for (i = 0; i < op->num_irqs; i++) 365 for (i = 0; i < op->archdata.num_irqs; i++)
370 op->irqs[i] = irq[i]; 366 op->archdata.irqs[i] = irq[i];
371 } else { 367 } else {
372 op->num_irqs = 0; 368 op->archdata.num_irqs = 0;
373 } 369 }
374 } 370 }
375 if (sparc_cpu_model == sun4d) { 371 if (sparc_cpu_model == sun4d) {
@@ -411,8 +407,8 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
411 goto build_resources; 407 goto build_resources;
412 } 408 }
413 409
414 for (i = 0; i < op->num_irqs; i++) { 410 for (i = 0; i < op->archdata.num_irqs; i++) {
415 int this_irq = op->irqs[i]; 411 int this_irq = op->archdata.irqs[i];
416 int sbusl = pil_to_sbus[this_irq]; 412 int sbusl = pil_to_sbus[this_irq];
417 413
418 if (sbusl) 414 if (sbusl)
@@ -420,7 +416,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
420 (sbusl << 2) + 416 (sbusl << 2) +
421 slot); 417 slot);
422 418
423 op->irqs[i] = this_irq; 419 op->archdata.irqs[i] = this_irq;
424 } 420 }
425 } 421 }
426 422
@@ -428,7 +424,7 @@ build_resources:
428 build_device_resources(op, parent); 424 build_device_resources(op, parent);
429 425
430 op->dev.parent = parent; 426 op->dev.parent = parent;
431 op->dev.bus = &of_platform_bus_type; 427 op->dev.bus = &platform_bus_type;
432 if (!parent) 428 if (!parent)
433 dev_set_name(&op->dev, "root"); 429 dev_set_name(&op->dev, "root");
434 else 430 else
@@ -447,7 +443,7 @@ build_resources:
447static void __init scan_tree(struct device_node *dp, struct device *parent) 443static void __init scan_tree(struct device_node *dp, struct device *parent)
448{ 444{
449 while (dp) { 445 while (dp) {
450 struct of_device *op = scan_one_device(dp, parent); 446 struct platform_device *op = scan_one_device(dp, parent);
451 447
452 if (op) 448 if (op)
453 scan_tree(dp->child, &op->dev); 449 scan_tree(dp->child, &op->dev);
@@ -456,30 +452,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent)
456 } 452 }
457} 453}
458 454
459static void __init scan_of_devices(void) 455static int __init scan_of_devices(void)
460{ 456{
461 struct device_node *root = of_find_node_by_path("/"); 457 struct device_node *root = of_find_node_by_path("/");
462 struct of_device *parent; 458 struct platform_device *parent;
463 459
464 parent = scan_one_device(root, NULL); 460 parent = scan_one_device(root, NULL);
465 if (!parent) 461 if (!parent)
466 return; 462 return 0;
467 463
468 scan_tree(root->child, &parent->dev); 464 scan_tree(root->child, &parent->dev);
465 return 0;
469} 466}
470 467postcore_initcall(scan_of_devices);
471static int __init of_bus_driver_init(void)
472{
473 int err;
474
475 err = of_bus_type_init(&of_platform_bus_type, "of");
476 if (!err)
477 scan_of_devices();
478
479 return err;
480}
481
482postcore_initcall(of_bus_driver_init);
483 468
484static int __init of_debug(char *str) 469static int __init of_debug(char *str)
485{ 470{
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 1dae8079f728..63cd4e5d47c2 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -310,10 +310,10 @@ static int __init use_1to1_mapping(struct device_node *pp)
310 310
311static int of_resource_verbose; 311static int of_resource_verbose;
312 312
313static void __init build_device_resources(struct of_device *op, 313static void __init build_device_resources(struct platform_device *op,
314 struct device *parent) 314 struct device *parent)
315{ 315{
316 struct of_device *p_op; 316 struct platform_device *p_op;
317 struct of_bus *bus; 317 struct of_bus *bus;
318 int na, ns; 318 int na, ns;
319 int index, num_reg; 319 int index, num_reg;
@@ -322,7 +322,7 @@ static void __init build_device_resources(struct of_device *op,
322 if (!parent) 322 if (!parent)
323 return; 323 return;
324 324
325 p_op = to_of_device(parent); 325 p_op = to_platform_device(parent);
326 bus = of_match_bus(p_op->dev.of_node); 326 bus = of_match_bus(p_op->dev.of_node);
327 bus->count_cells(op->dev.of_node, &na, &ns); 327 bus->count_cells(op->dev.of_node, &na, &ns);
328 328
@@ -344,6 +344,8 @@ static void __init build_device_resources(struct of_device *op,
344 num_reg = PROMREG_MAX; 344 num_reg = PROMREG_MAX;
345 } 345 }
346 346
347 op->resource = op->archdata.resource;
348 op->num_resources = num_reg;
347 for (index = 0; index < num_reg; index++) { 349 for (index = 0; index < num_reg; index++) {
348 struct resource *r = &op->resource[index]; 350 struct resource *r = &op->resource[index];
349 u32 addr[OF_MAX_ADDR_CELLS]; 351 u32 addr[OF_MAX_ADDR_CELLS];
@@ -526,7 +528,7 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp,
526 528
527static int of_irq_verbose; 529static int of_irq_verbose;
528 530
529static unsigned int __init build_one_device_irq(struct of_device *op, 531static unsigned int __init build_one_device_irq(struct platform_device *op,
530 struct device *parent, 532 struct device *parent,
531 unsigned int irq) 533 unsigned int irq)
532{ 534{
@@ -628,10 +630,10 @@ out:
628 return irq; 630 return irq;
629} 631}
630 632
631static struct of_device * __init scan_one_device(struct device_node *dp, 633static struct platform_device * __init scan_one_device(struct device_node *dp,
632 struct device *parent) 634 struct device *parent)
633{ 635{
634 struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); 636 struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
635 const unsigned int *irq; 637 const unsigned int *irq;
636 struct dev_archdata *sd; 638 struct dev_archdata *sd;
637 int len, i; 639 int len, i;
@@ -644,34 +646,28 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
644 646
645 op->dev.of_node = dp; 647 op->dev.of_node = dp;
646 648
647 op->clock_freq = of_getintprop_default(dp, "clock-frequency",
648 (25*1000*1000));
649 op->portid = of_getintprop_default(dp, "upa-portid", -1);
650 if (op->portid == -1)
651 op->portid = of_getintprop_default(dp, "portid", -1);
652
653 irq = of_get_property(dp, "interrupts", &len); 649 irq = of_get_property(dp, "interrupts", &len);
654 if (irq) { 650 if (irq) {
655 op->num_irqs = len / 4; 651 op->archdata.num_irqs = len / 4;
656 652
657 /* Prevent overrunning the op->irqs[] array. */ 653 /* Prevent overrunning the op->irqs[] array. */
658 if (op->num_irqs > PROMINTR_MAX) { 654 if (op->archdata.num_irqs > PROMINTR_MAX) {
659 printk(KERN_WARNING "%s: Too many irqs (%d), " 655 printk(KERN_WARNING "%s: Too many irqs (%d), "
660 "limiting to %d.\n", 656 "limiting to %d.\n",
661 dp->full_name, op->num_irqs, PROMINTR_MAX); 657 dp->full_name, op->archdata.num_irqs, PROMINTR_MAX);
662 op->num_irqs = PROMINTR_MAX; 658 op->archdata.num_irqs = PROMINTR_MAX;
663 } 659 }
664 memcpy(op->irqs, irq, op->num_irqs * 4); 660 memcpy(op->archdata.irqs, irq, op->archdata.num_irqs * 4);
665 } else { 661 } else {
666 op->num_irqs = 0; 662 op->archdata.num_irqs = 0;
667 } 663 }
668 664
669 build_device_resources(op, parent); 665 build_device_resources(op, parent);
670 for (i = 0; i < op->num_irqs; i++) 666 for (i = 0; i < op->archdata.num_irqs; i++)
671 op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]); 667 op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]);
672 668
673 op->dev.parent = parent; 669 op->dev.parent = parent;
674 op->dev.bus = &of_platform_bus_type; 670 op->dev.bus = &platform_bus_type;
675 if (!parent) 671 if (!parent)
676 dev_set_name(&op->dev, "root"); 672 dev_set_name(&op->dev, "root");
677 else 673 else
@@ -690,7 +686,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
690static void __init scan_tree(struct device_node *dp, struct device *parent) 686static void __init scan_tree(struct device_node *dp, struct device *parent)
691{ 687{
692 while (dp) { 688 while (dp) {
693 struct of_device *op = scan_one_device(dp, parent); 689 struct platform_device *op = scan_one_device(dp, parent);
694 690
695 if (op) 691 if (op)
696 scan_tree(dp->child, &op->dev); 692 scan_tree(dp->child, &op->dev);
@@ -699,30 +695,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent)
699 } 695 }
700} 696}
701 697
702static void __init scan_of_devices(void) 698static int __init scan_of_devices(void)
703{ 699{
704 struct device_node *root = of_find_node_by_path("/"); 700 struct device_node *root = of_find_node_by_path("/");
705 struct of_device *parent; 701 struct platform_device *parent;
706 702
707 parent = scan_one_device(root, NULL); 703 parent = scan_one_device(root, NULL);
708 if (!parent) 704 if (!parent)
709 return; 705 return 0;
710 706
711 scan_tree(root->child, &parent->dev); 707 scan_tree(root->child, &parent->dev);
708 return 0;
712} 709}
713 710postcore_initcall(scan_of_devices);
714static int __init of_bus_driver_init(void)
715{
716 int err;
717
718 err = of_bus_type_init(&of_platform_bus_type, "of");
719 if (!err)
720 scan_of_devices();
721
722 return err;
723}
724
725postcore_initcall(of_bus_driver_init);
726 711
727static int __init of_debug(char *str) 712static int __init of_debug(char *str)
728{ 713{
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c
index 10c6c36a6e75..49ddff56cb04 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -11,48 +11,28 @@
11 11
12#include "of_device_common.h" 12#include "of_device_common.h"
13 13
14static int node_match(struct device *dev, void *data)
15{
16 struct of_device *op = to_of_device(dev);
17 struct device_node *dp = data;
18
19 return (op->dev.of_node == dp);
20}
21
22struct of_device *of_find_device_by_node(struct device_node *dp)
23{
24 struct device *dev = bus_find_device(&of_platform_bus_type, NULL,
25 dp, node_match);
26
27 if (dev)
28 return to_of_device(dev);
29
30 return NULL;
31}
32EXPORT_SYMBOL(of_find_device_by_node);
33
34unsigned int irq_of_parse_and_map(struct device_node *node, int index) 14unsigned int irq_of_parse_and_map(struct device_node *node, int index)
35{ 15{
36 struct of_device *op = of_find_device_by_node(node); 16 struct platform_device *op = of_find_device_by_node(node);
37 17
38 if (!op || index >= op->num_irqs) 18 if (!op || index >= op->archdata.num_irqs)
39 return 0; 19 return 0;
40 20
41 return op->irqs[index]; 21 return op->archdata.irqs[index];
42} 22}
43EXPORT_SYMBOL(irq_of_parse_and_map); 23EXPORT_SYMBOL(irq_of_parse_and_map);
44 24
45/* Take the archdata values for IOMMU, STC, and HOSTDATA found in 25/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
46 * BUS and propagate to all child of_device objects. 26 * BUS and propagate to all child platform_device objects.
47 */ 27 */
48void of_propagate_archdata(struct of_device *bus) 28void of_propagate_archdata(struct platform_device *bus)
49{ 29{
50 struct dev_archdata *bus_sd = &bus->dev.archdata; 30 struct dev_archdata *bus_sd = &bus->dev.archdata;
51 struct device_node *bus_dp = bus->dev.of_node; 31 struct device_node *bus_dp = bus->dev.of_node;
52 struct device_node *dp; 32 struct device_node *dp;
53 33
54 for (dp = bus_dp->child; dp; dp = dp->sibling) { 34 for (dp = bus_dp->child; dp; dp = dp->sibling) {
55 struct of_device *op = of_find_device_by_node(dp); 35 struct platform_device *op = of_find_device_by_node(dp);
56 36
57 op->dev.archdata.iommu = bus_sd->iommu; 37 op->dev.archdata.iommu = bus_sd->iommu;
58 op->dev.archdata.stc = bus_sd->stc; 38 op->dev.archdata.stc = bus_sd->stc;
@@ -64,9 +44,6 @@ void of_propagate_archdata(struct of_device *bus)
64 } 44 }
65} 45}
66 46
67struct bus_type of_platform_bus_type;
68EXPORT_SYMBOL(of_platform_bus_type);
69
70static void get_cells(struct device_node *dp, int *addrc, int *sizec) 47static void get_cells(struct device_node *dp, int *addrc, int *sizec)
71{ 48{
72 if (addrc) 49 if (addrc)
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 8a8363adb8bd..4137579d9adc 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -198,7 +198,7 @@ static unsigned long pci_parse_of_flags(u32 addr0)
198 * into physical address resources, we only have to figure out the register 198 * into physical address resources, we only have to figure out the register
199 * mapping. 199 * mapping.
200 */ 200 */
201static void pci_parse_of_addrs(struct of_device *op, 201static void pci_parse_of_addrs(struct platform_device *op,
202 struct device_node *node, 202 struct device_node *node,
203 struct pci_dev *dev) 203 struct pci_dev *dev)
204{ 204{
@@ -248,7 +248,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
248{ 248{
249 struct dev_archdata *sd; 249 struct dev_archdata *sd;
250 struct pci_slot *slot; 250 struct pci_slot *slot;
251 struct of_device *op; 251 struct platform_device *op;
252 struct pci_dev *dev; 252 struct pci_dev *dev;
253 const char *type; 253 const char *type;
254 u32 class; 254 u32 class;
@@ -340,7 +340,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
340 dev->hdr_type = PCI_HEADER_TYPE_NORMAL; 340 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
341 dev->rom_base_reg = PCI_ROM_ADDRESS; 341 dev->rom_base_reg = PCI_ROM_ADDRESS;
342 342
343 dev->irq = sd->op->irqs[0]; 343 dev->irq = sd->op->archdata.irqs[0];
344 if (dev->irq == 0xffffffff) 344 if (dev->irq == 0xffffffff)
345 dev->irq = PCI_IRQ_NONE; 345 dev->irq = PCI_IRQ_NONE;
346 } 346 }
diff --git a/arch/sparc/kernel/pci_fire.c b/arch/sparc/kernel/pci_fire.c
index 51cfa09e392a..efb896d68754 100644
--- a/arch/sparc/kernel/pci_fire.c
+++ b/arch/sparc/kernel/pci_fire.c
@@ -410,7 +410,7 @@ static void pci_fire_hw_init(struct pci_pbm_info *pbm)
410} 410}
411 411
412static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm, 412static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm,
413 struct of_device *op, u32 portid) 413 struct platform_device *op, u32 portid)
414{ 414{
415 const struct linux_prom64_registers *regs; 415 const struct linux_prom64_registers *regs;
416 struct device_node *dp = op->dev.of_node; 416 struct device_node *dp = op->dev.of_node;
@@ -455,7 +455,7 @@ static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm,
455 return 0; 455 return 0;
456} 456}
457 457
458static int __devinit fire_probe(struct of_device *op, 458static int __devinit fire_probe(struct platform_device *op,
459 const struct of_device_id *match) 459 const struct of_device_id *match)
460{ 460{
461 struct device_node *dp = op->dev.of_node; 461 struct device_node *dp = op->dev.of_node;
@@ -518,7 +518,7 @@ static struct of_platform_driver fire_driver = {
518 518
519static int __init fire_init(void) 519static int __init fire_init(void)
520{ 520{
521 return of_register_driver(&fire_driver, &of_bus_type); 521 return of_register_platform_driver(&fire_driver);
522} 522}
523 523
524subsys_initcall(fire_init); 524subsys_initcall(fire_init);
diff --git a/arch/sparc/kernel/pci_impl.h b/arch/sparc/kernel/pci_impl.h
index 03186824327e..e20ed5f06e9c 100644
--- a/arch/sparc/kernel/pci_impl.h
+++ b/arch/sparc/kernel/pci_impl.h
@@ -91,7 +91,7 @@ struct pci_pbm_info {
91 char *name; 91 char *name;
92 92
93 /* OBP specific information. */ 93 /* OBP specific information. */
94 struct of_device *op; 94 struct platform_device *op;
95 u64 ino_bitmap; 95 u64 ino_bitmap;
96 96
97 /* PBM I/O and Memory space resources. */ 97 /* PBM I/O and Memory space resources. */
diff --git a/arch/sparc/kernel/pci_psycho.c b/arch/sparc/kernel/pci_psycho.c
index 558a70512824..22eab7cf3b11 100644
--- a/arch/sparc/kernel/pci_psycho.c
+++ b/arch/sparc/kernel/pci_psycho.c
@@ -285,7 +285,7 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id)
285#define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */ 285#define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */
286static void psycho_register_error_handlers(struct pci_pbm_info *pbm) 286static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
287{ 287{
288 struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); 288 struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node);
289 unsigned long base = pbm->controller_regs; 289 unsigned long base = pbm->controller_regs;
290 u64 tmp; 290 u64 tmp;
291 int err; 291 int err;
@@ -302,23 +302,23 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
302 * 5: POWER MANAGEMENT 302 * 5: POWER MANAGEMENT
303 */ 303 */
304 304
305 if (op->num_irqs < 6) 305 if (op->archdata.num_irqs < 6)
306 return; 306 return;
307 307
308 /* We really mean to ignore the return result here. Two 308 /* We really mean to ignore the return result here. Two
309 * PCI controller share the same interrupt numbers and 309 * PCI controller share the same interrupt numbers and
310 * drive the same front-end hardware. 310 * drive the same front-end hardware.
311 */ 311 */
312 err = request_irq(op->irqs[1], psycho_ue_intr, IRQF_SHARED, 312 err = request_irq(op->archdata.irqs[1], psycho_ue_intr, IRQF_SHARED,
313 "PSYCHO_UE", pbm); 313 "PSYCHO_UE", pbm);
314 err = request_irq(op->irqs[2], psycho_ce_intr, IRQF_SHARED, 314 err = request_irq(op->archdata.irqs[2], psycho_ce_intr, IRQF_SHARED,
315 "PSYCHO_CE", pbm); 315 "PSYCHO_CE", pbm);
316 316
317 /* This one, however, ought not to fail. We can just warn 317 /* This one, however, ought not to fail. We can just warn
318 * about it since the system can still operate properly even 318 * about it since the system can still operate properly even
319 * if this fails. 319 * if this fails.
320 */ 320 */
321 err = request_irq(op->irqs[0], psycho_pcierr_intr, IRQF_SHARED, 321 err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, IRQF_SHARED,
322 "PSYCHO_PCIERR", pbm); 322 "PSYCHO_PCIERR", pbm);
323 if (err) 323 if (err)
324 printk(KERN_WARNING "%s: Could not register PCIERR, " 324 printk(KERN_WARNING "%s: Could not register PCIERR, "
@@ -483,7 +483,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
483#define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL 483#define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL
484 484
485static void __devinit psycho_pbm_init(struct pci_pbm_info *pbm, 485static void __devinit psycho_pbm_init(struct pci_pbm_info *pbm,
486 struct of_device *op, int is_pbm_a) 486 struct platform_device *op, int is_pbm_a)
487{ 487{
488 psycho_pbm_init_common(pbm, op, "PSYCHO", PBM_CHIP_TYPE_PSYCHO); 488 psycho_pbm_init_common(pbm, op, "PSYCHO", PBM_CHIP_TYPE_PSYCHO);
489 psycho_pbm_strbuf_init(pbm, is_pbm_a); 489 psycho_pbm_strbuf_init(pbm, is_pbm_a);
@@ -503,7 +503,7 @@ static struct pci_pbm_info * __devinit psycho_find_sibling(u32 upa_portid)
503 503
504#define PSYCHO_CONFIGSPACE 0x001000000UL 504#define PSYCHO_CONFIGSPACE 0x001000000UL
505 505
506static int __devinit psycho_probe(struct of_device *op, 506static int __devinit psycho_probe(struct platform_device *op,
507 const struct of_device_id *match) 507 const struct of_device_id *match)
508{ 508{
509 const struct linux_prom64_registers *pr_regs; 509 const struct linux_prom64_registers *pr_regs;
@@ -612,7 +612,7 @@ static struct of_platform_driver psycho_driver = {
612 612
613static int __init psycho_init(void) 613static int __init psycho_init(void)
614{ 614{
615 return of_register_driver(&psycho_driver, &of_bus_type); 615 return of_register_platform_driver(&psycho_driver);
616} 616}
617 617
618subsys_initcall(psycho_init); 618subsys_initcall(psycho_init);
diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c
index 6dad8e3b7506..5c3f5ec4cabc 100644
--- a/arch/sparc/kernel/pci_sabre.c
+++ b/arch/sparc/kernel/pci_sabre.c
@@ -311,7 +311,7 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
311static void sabre_register_error_handlers(struct pci_pbm_info *pbm) 311static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
312{ 312{
313 struct device_node *dp = pbm->op->dev.of_node; 313 struct device_node *dp = pbm->op->dev.of_node;
314 struct of_device *op; 314 struct platform_device *op;
315 unsigned long base = pbm->controller_regs; 315 unsigned long base = pbm->controller_regs;
316 u64 tmp; 316 u64 tmp;
317 int err; 317 int err;
@@ -329,7 +329,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
329 * 2: CE ERR 329 * 2: CE ERR
330 * 3: POWER FAIL 330 * 3: POWER FAIL
331 */ 331 */
332 if (op->num_irqs < 4) 332 if (op->archdata.num_irqs < 4)
333 return; 333 return;
334 334
335 /* We clear the error bits in the appropriate AFSR before 335 /* We clear the error bits in the appropriate AFSR before
@@ -341,7 +341,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
341 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE), 341 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE),
342 base + SABRE_UE_AFSR); 342 base + SABRE_UE_AFSR);
343 343
344 err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm); 344 err = request_irq(op->archdata.irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm);
345 if (err) 345 if (err)
346 printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n", 346 printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n",
347 pbm->name, err); 347 pbm->name, err);
@@ -351,11 +351,11 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
351 base + SABRE_CE_AFSR); 351 base + SABRE_CE_AFSR);
352 352
353 353
354 err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm); 354 err = request_irq(op->archdata.irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm);
355 if (err) 355 if (err)
356 printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n", 356 printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n",
357 pbm->name, err); 357 pbm->name, err);
358 err = request_irq(op->irqs[0], psycho_pcierr_intr, 0, 358 err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, 0,
359 "SABRE_PCIERR", pbm); 359 "SABRE_PCIERR", pbm);
360 if (err) 360 if (err)
361 printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n", 361 printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n",
@@ -443,7 +443,7 @@ static void __devinit sabre_scan_bus(struct pci_pbm_info *pbm,
443} 443}
444 444
445static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm, 445static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm,
446 struct of_device *op) 446 struct platform_device *op)
447{ 447{
448 psycho_pbm_init_common(pbm, op, "SABRE", PBM_CHIP_TYPE_SABRE); 448 psycho_pbm_init_common(pbm, op, "SABRE", PBM_CHIP_TYPE_SABRE);
449 pbm->pci_afsr = pbm->controller_regs + SABRE_PIOAFSR; 449 pbm->pci_afsr = pbm->controller_regs + SABRE_PIOAFSR;
@@ -452,7 +452,7 @@ static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm,
452 sabre_scan_bus(pbm, &op->dev); 452 sabre_scan_bus(pbm, &op->dev);
453} 453}
454 454
455static int __devinit sabre_probe(struct of_device *op, 455static int __devinit sabre_probe(struct platform_device *op,
456 const struct of_device_id *match) 456 const struct of_device_id *match)
457{ 457{
458 const struct linux_prom64_registers *pr_regs; 458 const struct linux_prom64_registers *pr_regs;
@@ -606,7 +606,7 @@ static struct of_platform_driver sabre_driver = {
606 606
607static int __init sabre_init(void) 607static int __init sabre_init(void)
608{ 608{
609 return of_register_driver(&sabre_driver, &of_bus_type); 609 return of_register_platform_driver(&sabre_driver);
610} 610}
611 611
612subsys_initcall(sabre_init); 612subsys_initcall(sabre_init);
diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c
index 97a1ae2e1c02..445a47a2fb3d 100644
--- a/arch/sparc/kernel/pci_schizo.c
+++ b/arch/sparc/kernel/pci_schizo.c
@@ -844,7 +844,7 @@ static int pbm_routes_this_ino(struct pci_pbm_info *pbm, u32 ino)
844 */ 844 */
845static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) 845static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
846{ 846{
847 struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); 847 struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node);
848 u64 tmp, err_mask, err_no_mask; 848 u64 tmp, err_mask, err_no_mask;
849 int err; 849 int err;
850 850
@@ -857,14 +857,14 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
857 */ 857 */
858 858
859 if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { 859 if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) {
860 err = request_irq(op->irqs[1], schizo_ue_intr, 0, 860 err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0,
861 "TOMATILLO_UE", pbm); 861 "TOMATILLO_UE", pbm);
862 if (err) 862 if (err)
863 printk(KERN_WARNING "%s: Could not register UE, " 863 printk(KERN_WARNING "%s: Could not register UE, "
864 "err=%d\n", pbm->name, err); 864 "err=%d\n", pbm->name, err);
865 } 865 }
866 if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { 866 if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) {
867 err = request_irq(op->irqs[2], schizo_ce_intr, 0, 867 err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0,
868 "TOMATILLO_CE", pbm); 868 "TOMATILLO_CE", pbm);
869 if (err) 869 if (err)
870 printk(KERN_WARNING "%s: Could not register CE, " 870 printk(KERN_WARNING "%s: Could not register CE, "
@@ -872,10 +872,10 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
872 } 872 }
873 err = 0; 873 err = 0;
874 if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { 874 if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) {
875 err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, 875 err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
876 "TOMATILLO_PCIERR", pbm); 876 "TOMATILLO_PCIERR", pbm);
877 } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { 877 } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) {
878 err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, 878 err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
879 "TOMATILLO_PCIERR", pbm); 879 "TOMATILLO_PCIERR", pbm);
880 } 880 }
881 if (err) 881 if (err)
@@ -883,7 +883,7 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
883 "err=%d\n", pbm->name, err); 883 "err=%d\n", pbm->name, err);
884 884
885 if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { 885 if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) {
886 err = request_irq(op->irqs[3], schizo_safarierr_intr, 0, 886 err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0,
887 "TOMATILLO_SERR", pbm); 887 "TOMATILLO_SERR", pbm);
888 if (err) 888 if (err)
889 printk(KERN_WARNING "%s: Could not register SERR, " 889 printk(KERN_WARNING "%s: Could not register SERR, "
@@ -939,7 +939,7 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
939 939
940static void schizo_register_error_handlers(struct pci_pbm_info *pbm) 940static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
941{ 941{
942 struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); 942 struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node);
943 u64 tmp, err_mask, err_no_mask; 943 u64 tmp, err_mask, err_no_mask;
944 int err; 944 int err;
945 945
@@ -952,14 +952,14 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
952 */ 952 */
953 953
954 if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { 954 if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) {
955 err = request_irq(op->irqs[1], schizo_ue_intr, 0, 955 err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0,
956 "SCHIZO_UE", pbm); 956 "SCHIZO_UE", pbm);
957 if (err) 957 if (err)
958 printk(KERN_WARNING "%s: Could not register UE, " 958 printk(KERN_WARNING "%s: Could not register UE, "
959 "err=%d\n", pbm->name, err); 959 "err=%d\n", pbm->name, err);
960 } 960 }
961 if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { 961 if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) {
962 err = request_irq(op->irqs[2], schizo_ce_intr, 0, 962 err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0,
963 "SCHIZO_CE", pbm); 963 "SCHIZO_CE", pbm);
964 if (err) 964 if (err)
965 printk(KERN_WARNING "%s: Could not register CE, " 965 printk(KERN_WARNING "%s: Could not register CE, "
@@ -967,10 +967,10 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
967 } 967 }
968 err = 0; 968 err = 0;
969 if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { 969 if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) {
970 err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, 970 err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
971 "SCHIZO_PCIERR", pbm); 971 "SCHIZO_PCIERR", pbm);
972 } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { 972 } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) {
973 err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, 973 err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0,
974 "SCHIZO_PCIERR", pbm); 974 "SCHIZO_PCIERR", pbm);
975 } 975 }
976 if (err) 976 if (err)
@@ -978,7 +978,7 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
978 "err=%d\n", pbm->name, err); 978 "err=%d\n", pbm->name, err);
979 979
980 if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { 980 if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) {
981 err = request_irq(op->irqs[3], schizo_safarierr_intr, 0, 981 err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0,
982 "SCHIZO_SERR", pbm); 982 "SCHIZO_SERR", pbm);
983 if (err) 983 if (err)
984 printk(KERN_WARNING "%s: Could not register SERR, " 984 printk(KERN_WARNING "%s: Could not register SERR, "
@@ -1307,7 +1307,7 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1307} 1307}
1308 1308
1309static int __devinit schizo_pbm_init(struct pci_pbm_info *pbm, 1309static int __devinit schizo_pbm_init(struct pci_pbm_info *pbm,
1310 struct of_device *op, u32 portid, 1310 struct platform_device *op, u32 portid,
1311 int chip_type) 1311 int chip_type)
1312{ 1312{
1313 const struct linux_prom64_registers *regs; 1313 const struct linux_prom64_registers *regs;
@@ -1413,7 +1413,7 @@ static struct pci_pbm_info * __devinit schizo_find_sibling(u32 portid,
1413 return NULL; 1413 return NULL;
1414} 1414}
1415 1415
1416static int __devinit __schizo_init(struct of_device *op, unsigned long chip_type) 1416static int __devinit __schizo_init(struct platform_device *op, unsigned long chip_type)
1417{ 1417{
1418 struct device_node *dp = op->dev.of_node; 1418 struct device_node *dp = op->dev.of_node;
1419 struct pci_pbm_info *pbm; 1419 struct pci_pbm_info *pbm;
@@ -1460,7 +1460,7 @@ out_err:
1460 return err; 1460 return err;
1461} 1461}
1462 1462
1463static int __devinit schizo_probe(struct of_device *op, 1463static int __devinit schizo_probe(struct platform_device *op,
1464 const struct of_device_id *match) 1464 const struct of_device_id *match)
1465{ 1465{
1466 return __schizo_init(op, (unsigned long) match->data); 1466 return __schizo_init(op, (unsigned long) match->data);
@@ -1501,7 +1501,7 @@ static struct of_platform_driver schizo_driver = {
1501 1501
1502static int __init schizo_init(void) 1502static int __init schizo_init(void)
1503{ 1503{
1504 return of_register_driver(&schizo_driver, &of_bus_type); 1504 return of_register_platform_driver(&schizo_driver);
1505} 1505}
1506 1506
1507subsys_initcall(schizo_init); 1507subsys_initcall(schizo_init);
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index a24af6f7e17f..743344aa6d8a 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -879,7 +879,7 @@ static void pci_sun4v_msi_init(struct pci_pbm_info *pbm)
879#endif /* !(CONFIG_PCI_MSI) */ 879#endif /* !(CONFIG_PCI_MSI) */
880 880
881static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm, 881static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm,
882 struct of_device *op, u32 devhandle) 882 struct platform_device *op, u32 devhandle)
883{ 883{
884 struct device_node *dp = op->dev.of_node; 884 struct device_node *dp = op->dev.of_node;
885 int err; 885 int err;
@@ -918,7 +918,7 @@ static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm,
918 return 0; 918 return 0;
919} 919}
920 920
921static int __devinit pci_sun4v_probe(struct of_device *op, 921static int __devinit pci_sun4v_probe(struct platform_device *op,
922 const struct of_device_id *match) 922 const struct of_device_id *match)
923{ 923{
924 const struct linux_prom64_registers *regs; 924 const struct linux_prom64_registers *regs;
@@ -1019,7 +1019,7 @@ static struct of_platform_driver pci_sun4v_driver = {
1019 1019
1020static int __init pci_sun4v_init(void) 1020static int __init pci_sun4v_init(void)
1021{ 1021{
1022 return of_register_driver(&pci_sun4v_driver, &of_bus_type); 1022 return of_register_platform_driver(&pci_sun4v_driver);
1023} 1023}
1024 1024
1025subsys_initcall(pci_sun4v_init); 1025subsys_initcall(pci_sun4v_init);
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c
index 9589d8b9b0c1..94536a85f161 100644
--- a/arch/sparc/kernel/pmc.c
+++ b/arch/sparc/kernel/pmc.c
@@ -51,7 +51,7 @@ static void pmc_swift_idle(void)
51#endif 51#endif
52} 52}
53 53
54static int __devinit pmc_probe(struct of_device *op, 54static int __devinit pmc_probe(struct platform_device *op,
55 const struct of_device_id *match) 55 const struct of_device_id *match)
56{ 56{
57 regs = of_ioremap(&op->resource[0], 0, 57 regs = of_ioremap(&op->resource[0], 0,
@@ -89,7 +89,7 @@ static struct of_platform_driver pmc_driver = {
89 89
90static int __init pmc_init(void) 90static int __init pmc_init(void)
91{ 91{
92 return of_register_driver(&pmc_driver, &of_bus_type); 92 return of_register_platform_driver(&pmc_driver);
93} 93}
94 94
95/* This driver is not critical to the boot process 95/* This driver is not critical to the boot process
diff --git a/arch/sparc/kernel/power.c b/arch/sparc/kernel/power.c
index 168d4cb63f5b..2c59f4d387dd 100644
--- a/arch/sparc/kernel/power.c
+++ b/arch/sparc/kernel/power.c
@@ -33,10 +33,10 @@ static int __devinit has_button_interrupt(unsigned int irq, struct device_node *
33 return 1; 33 return 1;
34} 34}
35 35
36static int __devinit power_probe(struct of_device *op, const struct of_device_id *match) 36static int __devinit power_probe(struct platform_device *op, const struct of_device_id *match)
37{ 37{
38 struct resource *res = &op->resource[0]; 38 struct resource *res = &op->resource[0];
39 unsigned int irq= op->irqs[0]; 39 unsigned int irq = op->archdata.irqs[0];
40 40
41 power_reg = of_ioremap(res, 0, 0x4, "power"); 41 power_reg = of_ioremap(res, 0, 0x4, "power");
42 42
@@ -70,7 +70,7 @@ static struct of_platform_driver power_driver = {
70 70
71static int __init power_init(void) 71static int __init power_init(void)
72{ 72{
73 return of_register_driver(&power_driver, &of_platform_bus_type); 73 return of_register_platform_driver(&power_driver);
74} 74}
75 75
76device_initcall(power_init); 76device_initcall(power_init);
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index a8591ef2636d..eeb04a782ec8 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -9,14 +9,6 @@ extern void irq_trans_init(struct device_node *dp);
9 9
10extern unsigned int prom_unique_id; 10extern unsigned int prom_unique_id;
11 11
12static inline int is_root_node(const struct device_node *dp)
13{
14 if (!dp)
15 return 0;
16
17 return (dp->parent == NULL);
18}
19
20extern char *build_path_component(struct device_node *dp); 12extern char *build_path_component(struct device_node *dp);
21extern void of_console_init(void); 13extern void of_console_init(void);
22 14
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index 466a32763ea8..86597d9867fd 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -21,7 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/memblock.h> 23#include <linux/memblock.h>
24#include <linux/of_device.h> 24#include <linux/of.h>
25 25
26#include <asm/prom.h> 26#include <asm/prom.h>
27#include <asm/oplib.h> 27#include <asm/oplib.h>
@@ -81,7 +81,7 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
81 return; 81 return;
82 82
83 regs = rprop->value; 83 regs = rprop->value;
84 if (!is_root_node(dp->parent)) { 84 if (!of_node_is_root(dp->parent)) {
85 sprintf(tmp_buf, "%s@%x,%x", 85 sprintf(tmp_buf, "%s@%x,%x",
86 dp->name, 86 dp->name,
87 (unsigned int) (regs->phys_addr >> 32UL), 87 (unsigned int) (regs->phys_addr >> 32UL),
@@ -121,7 +121,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
121 return; 121 return;
122 122
123 regs = prop->value; 123 regs = prop->value;
124 if (!is_root_node(dp->parent)) { 124 if (!of_node_is_root(dp->parent)) {
125 sprintf(tmp_buf, "%s@%x,%x", 125 sprintf(tmp_buf, "%s@%x,%x",
126 dp->name, 126 dp->name,
127 (unsigned int) (regs->phys_addr >> 32UL), 127 (unsigned int) (regs->phys_addr >> 32UL),
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 57ac9e28be0c..1f830da2ddf2 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -244,7 +244,7 @@ char * __init build_full_name(struct device_node *dp)
244 244
245 n = prom_early_alloc(len); 245 n = prom_early_alloc(len);
246 strcpy(n, dp->parent->full_name); 246 strcpy(n, dp->parent->full_name);
247 if (!is_root_node(dp->parent)) { 247 if (!of_node_is_root(dp->parent)) {
248 strcpy(n + plen, "/"); 248 strcpy(n + plen, "/");
249 plen++; 249 plen++;
250 } 250 }
diff --git a/arch/sparc/kernel/prom_irqtrans.c b/arch/sparc/kernel/prom_irqtrans.c
index 5702ad4710cb..ce651147fabc 100644
--- a/arch/sparc/kernel/prom_irqtrans.c
+++ b/arch/sparc/kernel/prom_irqtrans.c
@@ -719,7 +719,7 @@ static unsigned int central_build_irq(struct device_node *dp,
719 void *_data) 719 void *_data)
720{ 720{
721 struct device_node *central_dp = _data; 721 struct device_node *central_dp = _data;
722 struct of_device *central_op = of_find_device_by_node(central_dp); 722 struct platform_device *central_op = of_find_device_by_node(central_dp);
723 struct resource *res; 723 struct resource *res;
724 unsigned long imap, iclr; 724 unsigned long imap, iclr;
725 u32 tmp; 725 u32 tmp;
diff --git a/arch/sparc/kernel/psycho_common.c b/arch/sparc/kernel/psycho_common.c
index 3f34ac853931..fe2af66bb198 100644
--- a/arch/sparc/kernel/psycho_common.c
+++ b/arch/sparc/kernel/psycho_common.c
@@ -447,7 +447,7 @@ int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize,
447 447
448} 448}
449 449
450void psycho_pbm_init_common(struct pci_pbm_info *pbm, struct of_device *op, 450void psycho_pbm_init_common(struct pci_pbm_info *pbm, struct platform_device *op,
451 const char *chip_name, int chip_type) 451 const char *chip_name, int chip_type)
452{ 452{
453 struct device_node *dp = op->dev.of_node; 453 struct device_node *dp = op->dev.of_node;
diff --git a/arch/sparc/kernel/psycho_common.h b/arch/sparc/kernel/psycho_common.h
index 092c278ef28d..590b4ed8ab5e 100644
--- a/arch/sparc/kernel/psycho_common.h
+++ b/arch/sparc/kernel/psycho_common.h
@@ -42,7 +42,7 @@ extern int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize,
42 unsigned long write_complete_offset); 42 unsigned long write_complete_offset);
43 43
44extern void psycho_pbm_init_common(struct pci_pbm_info *pbm, 44extern void psycho_pbm_init_common(struct pci_pbm_info *pbm,
45 struct of_device *op, 45 struct platform_device *op,
46 const char *chip_name, int chip_type); 46 const char *chip_name, int chip_type);
47 47
48#endif /* _PSYCHO_COMMON_H */ 48#endif /* _PSYCHO_COMMON_H */
diff --git a/arch/sparc/kernel/sbus.c b/arch/sparc/kernel/sbus.c
index cfeaf04b9cdf..2ca32d13abcf 100644
--- a/arch/sparc/kernel/sbus.c
+++ b/arch/sparc/kernel/sbus.c
@@ -57,7 +57,7 @@
57void sbus_set_sbus64(struct device *dev, int bursts) 57void sbus_set_sbus64(struct device *dev, int bursts)
58{ 58{
59 struct iommu *iommu = dev->archdata.iommu; 59 struct iommu *iommu = dev->archdata.iommu;
60 struct of_device *op = to_of_device(dev); 60 struct platform_device *op = to_platform_device(dev);
61 const struct linux_prom_registers *regs; 61 const struct linux_prom_registers *regs;
62 unsigned long cfg_reg; 62 unsigned long cfg_reg;
63 int slot; 63 int slot;
@@ -204,7 +204,7 @@ static unsigned long sysio_imap_to_iclr(unsigned long imap)
204 return imap + diff; 204 return imap + diff;
205} 205}
206 206
207static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino) 207static unsigned int sbus_build_irq(struct platform_device *op, unsigned int ino)
208{ 208{
209 struct iommu *iommu = op->dev.archdata.iommu; 209 struct iommu *iommu = op->dev.archdata.iommu;
210 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 210 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
@@ -267,7 +267,7 @@ static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino)
267#define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 267#define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */
268static irqreturn_t sysio_ue_handler(int irq, void *dev_id) 268static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
269{ 269{
270 struct of_device *op = dev_id; 270 struct platform_device *op = dev_id;
271 struct iommu *iommu = op->dev.archdata.iommu; 271 struct iommu *iommu = op->dev.archdata.iommu;
272 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 272 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
273 unsigned long afsr_reg, afar_reg; 273 unsigned long afsr_reg, afar_reg;
@@ -341,7 +341,7 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
341#define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 341#define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */
342static irqreturn_t sysio_ce_handler(int irq, void *dev_id) 342static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
343{ 343{
344 struct of_device *op = dev_id; 344 struct platform_device *op = dev_id;
345 struct iommu *iommu = op->dev.archdata.iommu; 345 struct iommu *iommu = op->dev.archdata.iommu;
346 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 346 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
347 unsigned long afsr_reg, afar_reg; 347 unsigned long afsr_reg, afar_reg;
@@ -420,7 +420,7 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
420#define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */ 420#define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */
421static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) 421static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
422{ 422{
423 struct of_device *op = dev_id; 423 struct platform_device *op = dev_id;
424 struct iommu *iommu = op->dev.archdata.iommu; 424 struct iommu *iommu = op->dev.archdata.iommu;
425 unsigned long afsr_reg, afar_reg, reg_base; 425 unsigned long afsr_reg, afar_reg, reg_base;
426 unsigned long afsr, afar, error_bits; 426 unsigned long afsr, afar, error_bits;
@@ -488,7 +488,7 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
488#define SYSIO_CE_INO 0x35 488#define SYSIO_CE_INO 0x35
489#define SYSIO_SBUSERR_INO 0x36 489#define SYSIO_SBUSERR_INO 0x36
490 490
491static void __init sysio_register_error_handlers(struct of_device *op) 491static void __init sysio_register_error_handlers(struct platform_device *op)
492{ 492{
493 struct iommu *iommu = op->dev.archdata.iommu; 493 struct iommu *iommu = op->dev.archdata.iommu;
494 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 494 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
@@ -534,7 +534,7 @@ static void __init sysio_register_error_handlers(struct of_device *op)
534} 534}
535 535
536/* Boot time initialization. */ 536/* Boot time initialization. */
537static void __init sbus_iommu_init(struct of_device *op) 537static void __init sbus_iommu_init(struct platform_device *op)
538{ 538{
539 const struct linux_prom64_registers *pr; 539 const struct linux_prom64_registers *pr;
540 struct device_node *dp = op->dev.of_node; 540 struct device_node *dp = op->dev.of_node;
@@ -663,7 +663,7 @@ static int __init sbus_init(void)
663 struct device_node *dp; 663 struct device_node *dp;
664 664
665 for_each_node_by_name(dp, "sbus") { 665 for_each_node_by_name(dp, "sbus") {
666 struct of_device *op = of_find_device_by_node(dp); 666 struct platform_device *op = of_find_device_by_node(dp);
667 667
668 sbus_iommu_init(op); 668 sbus_iommu_init(op);
669 of_propagate_archdata(op); 669 of_propagate_archdata(op);
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c
index e404b063be2c..9c743b1886ff 100644
--- a/arch/sparc/kernel/time_32.c
+++ b/arch/sparc/kernel/time_32.c
@@ -142,7 +142,7 @@ static struct platform_device m48t59_rtc = {
142 }, 142 },
143}; 143};
144 144
145static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match) 145static int __devinit clock_probe(struct platform_device *op, const struct of_device_id *match)
146{ 146{
147 struct device_node *dp = op->dev.of_node; 147 struct device_node *dp = op->dev.of_node;
148 const char *model = of_get_property(dp, "model", NULL); 148 const char *model = of_get_property(dp, "model", NULL);
@@ -189,7 +189,7 @@ static struct of_platform_driver clock_driver = {
189/* Probe for the mostek real time clock chip. */ 189/* Probe for the mostek real time clock chip. */
190static int __init clock_init(void) 190static int __init clock_init(void)
191{ 191{
192 return of_register_driver(&clock_driver, &of_platform_bus_type); 192 return of_register_platform_driver(&clock_driver);
193} 193}
194/* Must be after subsys_initcall() so that busses are probed. Must 194/* Must be after subsys_initcall() so that busses are probed. Must
195 * be before device_initcall() because things like the RTC driver 195 * be before device_initcall() because things like the RTC driver
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 21e9fcae0668..3bc9c9979b92 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -419,7 +419,7 @@ static struct platform_device rtc_cmos_device = {
419 .num_resources = 1, 419 .num_resources = 1,
420}; 420};
421 421
422static int __devinit rtc_probe(struct of_device *op, const struct of_device_id *match) 422static int __devinit rtc_probe(struct platform_device *op, const struct of_device_id *match)
423{ 423{
424 struct resource *r; 424 struct resource *r;
425 425
@@ -477,7 +477,7 @@ static struct platform_device rtc_bq4802_device = {
477 .num_resources = 1, 477 .num_resources = 1,
478}; 478};
479 479
480static int __devinit bq4802_probe(struct of_device *op, const struct of_device_id *match) 480static int __devinit bq4802_probe(struct platform_device *op, const struct of_device_id *match)
481{ 481{
482 482
483 printk(KERN_INFO "%s: BQ4802 regs at 0x%llx\n", 483 printk(KERN_INFO "%s: BQ4802 regs at 0x%llx\n",
@@ -534,7 +534,7 @@ static struct platform_device m48t59_rtc = {
534 }, 534 },
535}; 535};
536 536
537static int __devinit mostek_probe(struct of_device *op, const struct of_device_id *match) 537static int __devinit mostek_probe(struct platform_device *op, const struct of_device_id *match)
538{ 538{
539 struct device_node *dp = op->dev.of_node; 539 struct device_node *dp = op->dev.of_node;
540 540
@@ -586,9 +586,9 @@ static int __init clock_init(void)
586 if (tlb_type == hypervisor) 586 if (tlb_type == hypervisor)
587 return platform_device_register(&rtc_sun4v_device); 587 return platform_device_register(&rtc_sun4v_device);
588 588
589 (void) of_register_driver(&rtc_driver, &of_platform_bus_type); 589 (void) of_register_platform_driver(&rtc_driver);
590 (void) of_register_driver(&mostek_driver, &of_platform_bus_type); 590 (void) of_register_platform_driver(&mostek_driver);
591 (void) of_register_driver(&bq4802_driver, &of_platform_bus_type); 591 (void) of_register_platform_driver(&bq4802_driver);
592 592
593 return 0; 593 return 0;
594} 594}
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index 005e758a4db7..fc58c3e917df 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -35,7 +35,7 @@
35#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) 35#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
36#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) 36#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)
37 37
38static void __init iounit_iommu_init(struct of_device *op) 38static void __init iounit_iommu_init(struct platform_device *op)
39{ 39{
40 struct iounit_struct *iounit; 40 struct iounit_struct *iounit;
41 iopte_t *xpt, *xptend; 41 iopte_t *xpt, *xptend;
@@ -74,7 +74,7 @@ static int __init iounit_init(void)
74 struct device_node *dp; 74 struct device_node *dp;
75 75
76 for_each_node_by_name(dp, "sbi") { 76 for_each_node_by_name(dp, "sbi") {
77 struct of_device *op = of_find_device_by_node(dp); 77 struct platform_device *op = of_find_device_by_node(dp);
78 78
79 iounit_iommu_init(op); 79 iounit_iommu_init(op);
80 of_propagate_archdata(op); 80 of_propagate_archdata(op);
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 0e8ae298b3c3..07fc6a65d9b6 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -56,7 +56,7 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */
56#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) 56#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
57#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ) 57#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)
58 58
59static void __init sbus_iommu_init(struct of_device *op) 59static void __init sbus_iommu_init(struct platform_device *op)
60{ 60{
61 struct iommu_struct *iommu; 61 struct iommu_struct *iommu;
62 unsigned int impl, vers; 62 unsigned int impl, vers;
@@ -132,7 +132,7 @@ static int __init iommu_init(void)
132 struct device_node *dp; 132 struct device_node *dp;
133 133
134 for_each_node_by_name(dp, "iommu") { 134 for_each_node_by_name(dp, "iommu") {
135 struct of_device *op = of_find_device_by_node(dp); 135 struct platform_device *op = of_find_device_by_node(dp);
136 136
137 sbus_iommu_init(op); 137 sbus_iommu_init(op);
138 of_propagate_archdata(op); 138 of_propagate_archdata(op);