diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 18:57:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 18:57:35 -0400 |
commit | 03c0c29aff7e56b722eb6c47eace222b140d0377 (patch) | |
tree | 47267a19b523159cf36a050ef3c35f4dbdb33016 /arch/powerpc | |
parent | c60c6a96b7bb0f1f8bb635fdfcf5b592aaf062b4 (diff) | |
parent | 7fb8f881c54beb05dd4d2c947dada1c636581d87 (diff) |
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (63 commits)
of/platform: Register of_platform_drivers with an "of:" prefix
of/address: Clean up function declarations
of/spi: call of_register_spi_devices() from spi core code
of: Provide default of_node_to_nid() implementation.
of/device: Make of_device_make_bus_id() usable by other code.
of/irq: Fix endian issues in parsing interrupt specifiers
of: Fix phandle endian issues
of/flattree: fix of_flat_dt_is_compatible() to match the full compatible string
of: remove of_default_bus_ids
of: make of_find_device_by_node generic
microblaze: remove references to of_device and to_of_device
sparc: remove references to of_device and to_of_device
powerpc: remove references to of_device and to_of_device
of/device: Replace of_device with platform_device in includes and core code
of/device: Protect against binding of_platform_drivers to non-OF devices
of: remove asm/of_device.h
of: remove asm/of_platform.h
of/platform: remove all of_bus_type and of_platform_bus_type references
of: Merge of_platform_bus_type with platform_bus_type
drivercore/of: Add OF style matching to platform bus
...
Fix up trivial conflicts in arch/microblaze/kernel/Makefile due to just
some obj-y removals by the devicetree branch, while the microblaze
updates added a new file.
Diffstat (limited to 'arch/powerpc')
54 files changed, 248 insertions, 1687 deletions
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 | |||
120 | config PPC | 120 | config 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 | |||
173 | config PPC_OF | 175 | config PPC_OF |
174 | def_bool y | 176 | def_bool y |
175 | 177 | ||
176 | config OF | ||
177 | def_bool y | ||
178 | select OF_FLATTREE | ||
179 | |||
180 | config PPC_UDBG_16550 | 178 | config 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 | ||
202 | config DTC | ||
203 | bool | ||
204 | default y | ||
205 | |||
206 | config DEFAULT_UIMAGE | 200 | config 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 | ||
582 | config 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 | |||
590 | config CMDLINE_BOOL | 576 | config 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 | */ |
301 | extern void irq_free_virt(unsigned int virq, unsigned int count); | 301 | extern 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 | */ | ||
316 | extern 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 | */ | ||
327 | extern 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 | */ | ||
13 | struct of_device | ||
14 | { | ||
15 | struct device dev; /* Generic device interface */ | ||
16 | struct pdev_archdata archdata; | ||
17 | }; | ||
18 | |||
19 | extern struct of_device *of_device_alloc(struct device_node *np, | ||
20 | const char *bus_id, | ||
21 | struct device *parent); | ||
22 | |||
23 | extern 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 */ | ||
15 | extern 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 | |||
21 | extern int of_platform_bus_probe(struct device_node *root, | ||
22 | const struct of_device_id *matches, | ||
23 | struct device *parent); | ||
24 | |||
25 | extern struct of_device *of_find_device_by_phandle(phandle ph); | ||
26 | |||
27 | extern 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); | |||
303 | extern void pcibios_setup_phb_resources(struct pci_controller *hose); | 303 | extern void pcibios_setup_phb_resources(struct pci_controller *hose); |
304 | 304 | ||
305 | #ifdef CONFIG_PCI | 305 | #ifdef CONFIG_PCI |
306 | extern unsigned long pci_address_to_pio(phys_addr_t address); | ||
307 | extern int pcibios_vaddr_is_ioport(void __iomem *address); | 306 | extern int pcibios_vaddr_is_ioport(void __iomem *address); |
308 | #else | 307 | #else |
309 | static inline unsigned long pci_address_to_pio(phys_addr_t address) | ||
310 | { | ||
311 | return (unsigned long)-1; | ||
312 | } | ||
313 | static inline int pcibios_vaddr_is_ioport(void __iomem *address) | 308 | static 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 | */ | ||
48 | extern 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 */ |
51 | extern u64 of_translate_dma_address(struct device_node *dev, | 44 | extern 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 | */ | ||
58 | extern 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 |
61 | extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, | 48 | extern 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 */ |
64 | static 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 | */ | ||
77 | extern int of_address_to_resource(struct device_node *dev, int index, | ||
78 | struct resource *r); | ||
79 | #ifdef CONFIG_PCI | ||
80 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
81 | struct resource *r); | ||
82 | #else | ||
83 | static 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 */ |
105 | extern const void *of_get_mac_address(struct device_node *np); | 67 | extern const void *of_get_mac_address(struct device_node *np); |
106 | 68 | ||
107 | /* | 69 | #ifdef CONFIG_NUMA |
108 | * OF interrupt mapping | 70 | extern int of_node_to_nid(struct device_node *device); |
109 | */ | 71 | #else |
110 | 72 | static 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 | |||
117 | struct 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 | |||
134 | extern 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 | |||
153 | extern 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 | */ | ||
168 | extern 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 | */ |
182 | struct pci_dev; | 87 | struct pci_dev; |
88 | struct of_irq; | ||
183 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 89 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
184 | 90 | ||
185 | extern int of_irq_to_resource(struct device_node *dev, int index, | 91 | extern 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> |
195 | extern 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 | */ |
458 | extern int smu_init(void); | 458 | extern int smu_init(void); |
459 | extern int smu_present(void); | 459 | extern int smu_present(void); |
460 | struct of_device; | 460 | struct platform_device; |
461 | extern struct of_device *smu_get_ofdev(void); | 461 | extern 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 | ||
44 | int of_node_to_nid(struct device_node *device); | ||
45 | |||
46 | struct pci_bus; | 44 | struct pci_bus; |
47 | #ifdef CONFIG_PCI | 45 | #ifdef CONFIG_PCI |
48 | extern int pcibus_to_node(struct pci_bus *bus); | 46 | extern 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 | ||
100 | static inline int of_node_to_nid(struct device_node *device) | ||
101 | { | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static inline void dump_numa_cpu_topology(void) {} | 98 | static inline void dump_numa_cpu_topology(void) {} |
106 | 99 | ||
107 | static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid) | 100 | static 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 | |||
41 | obj-$(CONFIG_PPC64) += vdso64/ | 41 | obj-$(CONFIG_PPC64) += vdso64/ |
42 | obj-$(CONFIG_ALTIVEC) += vecemu.o | 42 | obj-$(CONFIG_ALTIVEC) += vecemu.o |
43 | obj-$(CONFIG_PPC_970_NAP) += idle_power4.o | 43 | obj-$(CONFIG_PPC_970_NAP) += idle_power4.o |
44 | obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o | 44 | obj-$(CONFIG_PPC_OF) += of_platform.o prom_parse.o |
45 | obj-$(CONFIG_PPC_CLOCK) += clock.o | 45 | obj-$(CONFIG_PPC_CLOCK) += clock.o |
46 | procfs-y := proc_powerpc.o | 46 | procfs-y := proc_powerpc.o |
47 | obj-$(CONFIG_PROC_FS) += $(procfs-y) | 47 | obj-$(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 | ||
85 | static struct notifier_block ppc_swiotlb_of_bus_notifier = { | ||
86 | .notifier_call = ppc_swiotlb_bus_notify, | ||
87 | .priority = 0, | ||
88 | }; | ||
89 | |||
90 | int __init swiotlb_setup_bus_notifier(void) | 85 | int __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 | ||
141 | static int ibmebus_match_path(struct device *dev, void *data) | 141 | static 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 | ||
148 | static int ibmebus_match_node(struct device *dev, void *data) | 148 | static 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 | ||
153 | static int ibmebus_create_device(struct device_node *dn) | 153 | static 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 | } |
821 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | 823 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); |
822 | 824 | ||
823 | unsigned 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 | } | ||
833 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | ||
834 | |||
835 | void irq_dispose_mapping(unsigned int virq) | 825 | void 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 | |||
13 | static 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 | |||
62 | struct 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 | } | ||
84 | EXPORT_SYMBOL(of_device_alloc); | ||
85 | |||
86 | int 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 | } | ||
132 | EXPORT_SYMBOL(of_device_uevent); | ||
133 | EXPORT_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 | |||
43 | static 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 | |||
55 | struct bus_type of_platform_bus_type = { | ||
56 | .uevent = of_device_uevent, | ||
57 | }; | ||
58 | EXPORT_SYMBOL(of_platform_bus_type); | ||
59 | |||
60 | static int __init of_bus_driver_init(void) | ||
61 | { | ||
62 | return of_bus_type_init(&of_platform_bus_type, "of_platform"); | ||
63 | } | ||
64 | |||
65 | postcore_initcall(of_bus_driver_init); | ||
66 | |||
67 | struct 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 | } | ||
94 | EXPORT_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 | */ | ||
105 | static 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 | |||
141 | int 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 | } | ||
194 | EXPORT_SYMBOL(of_platform_bus_probe); | ||
195 | |||
196 | static int of_dev_node_match(struct device *dev, void *data) | ||
197 | { | ||
198 | return to_of_device(dev)->dev.of_node == data; | ||
199 | } | ||
200 | |||
201 | struct 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 | } | ||
211 | EXPORT_SYMBOL(of_find_device_by_node); | ||
212 | |||
213 | static 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 | |||
219 | struct 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 | } | ||
229 | EXPORT_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 | ||
240 | static int __devinit of_pci_phb_probe(struct of_device *dev, | 39 | static 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 | |||
29 | static struct of_bus *of_match_bus(struct device_node *np); | ||
30 | static 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 | ||
37 | static 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 | ||
45 | static void of_dump_addr(const char *s, const u32 *addr, int na) { } | ||
46 | #endif | ||
47 | |||
48 | |||
49 | /* Callbacks for bus specific translators */ | ||
50 | struct 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 | |||
67 | static 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 | |||
76 | static 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 | |||
93 | static 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 | |||
105 | static 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 | |||
116 | static 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 | |||
122 | static 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 | |||
131 | static 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 | |||
150 | static 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 | |||
174 | static 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 | |||
179 | const 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 | } | ||
219 | EXPORT_SYMBOL(of_get_pci_address); | ||
220 | |||
221 | int 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 | } | ||
233 | EXPORT_SYMBOL_GPL(of_pci_address_to_resource); | ||
234 | |||
235 | int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq) | 14 | int 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) | |||
313 | EXPORT_SYMBOL_GPL(of_irq_map_pci); | 92 | EXPORT_SYMBOL_GPL(of_irq_map_pci); |
314 | #endif /* CONFIG_PCI */ | 93 | #endif /* CONFIG_PCI */ |
315 | 94 | ||
316 | /* | ||
317 | * ISA bus specific translator | ||
318 | */ | ||
319 | |||
320 | static int of_bus_isa_match(struct device_node *np) | ||
321 | { | ||
322 | return !strcmp(np->name, "isa"); | ||
323 | } | ||
324 | |||
325 | static 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 | |||
334 | static 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 | |||
354 | static 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 | |||
359 | static 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 | |||
376 | static 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 | |||
411 | static 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 | |||
422 | static 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 | */ | ||
486 | u64 __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 | |||
563 | u64 of_translate_address(struct device_node *dev, const u32 *in_addr) | ||
564 | { | ||
565 | return __of_translate_address(dev, in_addr, "ranges"); | ||
566 | } | ||
567 | EXPORT_SYMBOL(of_translate_address); | ||
568 | |||
569 | u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr) | ||
570 | { | ||
571 | return __of_translate_address(dev, in_addr, "dma-ranges"); | ||
572 | } | ||
573 | EXPORT_SYMBOL(of_translate_dma_address); | ||
574 | |||
575 | const 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 | } | ||
611 | EXPORT_SYMBOL(of_get_address); | ||
612 | |||
613 | static 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 | |||
641 | int 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 | } | ||
653 | EXPORT_SYMBOL_GPL(of_address_to_resource); | ||
654 | |||
655 | void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | 95 | void 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 | |||
685 | static unsigned int of_irq_workarounds; | ||
686 | static struct device_node *of_irq_dflt_pic; | ||
687 | |||
688 | static 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 | */ | ||
716 | void 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 | |||
751 | int 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 | } | ||
923 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
924 | |||
925 | #if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) | ||
926 | static 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) */ | ||
962 | static 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 | |||
969 | int 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); | ||
1011 | out: | ||
1012 | of_node_put(p); | ||
1013 | return res; | ||
1014 | } | ||
1015 | EXPORT_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 | } |
1053 | EXPORT_SYMBOL(of_get_mac_address); | 157 | EXPORT_SYMBOL(of_get_mac_address); |
1054 | |||
1055 | int 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 | } | ||
1068 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
1069 | |||
1070 | void __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 | } | ||
1079 | EXPORT_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 | ||
717 | static struct notifier_block ppc_dflt_of_bus_notifier = { | ||
718 | .notifier_call = ppc_dflt_bus_notify, | ||
719 | .priority = INT_MAX, | ||
720 | }; | ||
721 | |||
722 | static int __init setup_bus_notifier(void) | 717 | static 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 | ||
150 | static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, | 150 | static 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 | ||
183 | static int mpc52xx_gpiochip_remove(struct of_device *ofdev) | 182 | static 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 | ||
314 | static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, | 313 | static 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) |
281 | static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) | 281 | static 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 | ||
286 | static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) | 286 | static 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 | */ |
726 | static int __devinit mpc52xx_gpt_probe(struct of_device *ofdev, | 723 | static 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 | ||
772 | static int mpc52xx_gpt_remove(struct of_device *ofdev) | 769 | static 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 | } |
437 | EXPORT_SYMBOL(mpc52xx_lpbfifo_abort); | 437 | EXPORT_SYMBOL(mpc52xx_lpbfifo_abort); |
438 | 438 | ||
439 | static int __devinit | 439 | static int __devinit mpc52xx_lpbfifo_probe(struct platform_device *op, |
440 | mpc52xx_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 | ||
510 | static int __devexit mpc52xx_lpbfifo_remove(struct of_device *op) | 510 | static 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 | ||
114 | static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, | 114 | static 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 | ||
157 | static int ep8248e_mdio_remove(struct of_device *ofdev) | 157 | static 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 | ||
36 | struct mcu { | 36 | struct 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 | ||
57 | static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | 56 | static 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) | |||
79 | static int mcu_gpiochip_add(struct mcu *mcu) | 77 | static 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 | ||
113 | static int mcu_gpiochip_remove(struct mcu *mcu) | 98 | static 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 | ||
125 | static int __devinit mcu_probe(struct i2c_client *client, | 103 | static int __devinit mcu_probe(struct i2c_client *client, |
@@ -182,10 +160,16 @@ static const struct i2c_device_id mcu_ids[] = { | |||
182 | }; | 160 | }; |
183 | MODULE_DEVICE_TABLE(i2c, mcu_ids); | 161 | MODULE_DEVICE_TABLE(i2c, mcu_ids); |
184 | 162 | ||
163 | static struct of_device_id mcu_of_match_table[] __devinitdata = { | ||
164 | { .compatible = "fsl,mcu-mpc8349emitx", }, | ||
165 | { }, | ||
166 | }; | ||
167 | |||
185 | static struct i2c_driver mcu_driver = { | 168 | static 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 | ||
102 | static struct of_device *pmc_dev; | 102 | static struct platform_device *pmc_dev; |
103 | static int has_deep_sleep, deep_sleeping; | 103 | static int has_deep_sleep, deep_sleeping; |
104 | static int pmc_irq; | 104 | static int pmc_irq; |
105 | static struct mpc83xx_pmc __iomem *pmc_regs; | 105 | static 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 | ||
321 | static int pmc_probe(struct of_device *ofdev, | 321 | static 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 | ||
399 | static int pmc_remove(struct of_device *ofdev) | 399 | static 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 | ||
331 | static int axon_msi_shutdown(struct of_device *device) | 331 | static 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 | ||
345 | static int axon_msi_probe(struct of_device *device, | 345 | static 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 | ||
64 | static 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 | |||
64 | static int __init qpace_publish_devices(void) | 76 | static 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 | ||
144 | static 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 | |||
144 | static int __init cell_publish_devices(void) | 156 | static 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 | ||
219 | static int __devinit gpio_mdio_probe(struct of_device *ofdev, | 219 | static 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 | ||
278 | static int gpio_mdio_remove(struct of_device *dev) | 278 | static 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 */ | ||
50 | unsigned int of_irq_workarounds; | ||
51 | struct device_node *of_irq_dflt_pic; | ||
52 | |||
49 | /* Default addresses */ | 53 | /* Default addresses */ |
50 | static volatile struct pmac_irq_hw __iomem *pmac_irq_hw[4]; | 54 | static 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 | |||
436 | int 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 | ||
433 | static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc) | 473 | static 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 | ||
560 | void __init pmac_pic_init(void) | 600 | void __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 @@ | |||
60 | static int azfs_major, azfs_minor; | 60 | static int azfs_major, azfs_minor; |
61 | 61 | ||
62 | struct axon_ram_bank { | 62 | struct 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 { | |||
72 | static ssize_t | 72 | static ssize_t |
73 | axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf) | 73 | axon_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); | |||
90 | static irqreturn_t | 90 | static irqreturn_t |
91 | axon_ram_irq_handler(int irq, void *dev) | 91 | axon_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 | */ |
177 | static int | 177 | static int axon_ram_probe(struct platform_device *device, |
178 | axon_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 | */ |
306 | static int | 306 | static int |
307 | axon_ram_remove(struct of_device *device) | 307 | axon_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 | ||
368 | static int __devinit | 368 | static int __devinit mpc52xx_bcom_probe(struct platform_device *op, |
369 | mpc52xx_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 | ||
464 | static int | 464 | static int mpc52xx_bcom_remove(struct platform_device *op) |
465 | mpc52xx_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 | ||
253 | static int fsl_of_msi_remove(struct of_device *ofdev) | 253 | static 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 | ||
277 | static int __devinit fsl_of_msi_probe(struct of_device *dev, | 277 | static 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 | ||
61 | static int pmc_probe(struct of_device *ofdev, const struct of_device_id *id) | 61 | static 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 | */ |
1341 | int fsl_rio_setup(struct of_device *dev) | 1341 | int 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 | */ |
1539 | static int __devinit fsl_of_rio_rpn_probe(struct of_device *dev, | 1539 | static 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 | ||
30 | static struct of_device_id __initdata of_mv64x60_devices[] = { | 25 | static 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 | ||
124 | static int pmi_of_probe(struct of_device *dev, | 124 | static 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 | ||
188 | static int pmi_of_remove(struct of_device *dev) | 188 | static 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 { | |||
138 | struct qe_pin *qe_pin_request(struct device_node *np, int index) | 138 | struct 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; |
208 | err1: | 208 | err1: |
209 | of_node_put(gc); | 209 | of_node_put(gpio_np); |
210 | err0: | 210 | err0: |
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) | |||
651 | EXPORT_SYMBOL(qe_get_num_of_snums); | 651 | EXPORT_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) |
654 | static int qe_resume(struct of_device *ofdev) | 654 | static 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 | ||
661 | static int qe_probe(struct of_device *ofdev, const struct of_device_id *id) | 661 | static 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; |