diff options
190 files changed, 2492 insertions, 3864 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index be3855250db6..9bd64b4b2b0c 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -18,6 +18,8 @@ config MICROBLAZE | |||
18 | select HAVE_DMA_ATTRS | 18 | select HAVE_DMA_ATTRS |
19 | select HAVE_DMA_API_DEBUG | 19 | select HAVE_DMA_API_DEBUG |
20 | select TRACING_SUPPORT | 20 | select TRACING_SUPPORT |
21 | select OF | ||
22 | select OF_FLATTREE | ||
21 | 23 | ||
22 | config SWAP | 24 | config SWAP |
23 | def_bool n | 25 | def_bool n |
@@ -76,9 +78,6 @@ config LOCKDEP_SUPPORT | |||
76 | config HAVE_LATENCYTOP_SUPPORT | 78 | config HAVE_LATENCYTOP_SUPPORT |
77 | def_bool y | 79 | def_bool y |
78 | 80 | ||
79 | config DTC | ||
80 | def_bool y | ||
81 | |||
82 | source "init/Kconfig" | 81 | source "init/Kconfig" |
83 | 82 | ||
84 | source "kernel/Kconfig.freezer" | 83 | source "kernel/Kconfig.freezer" |
@@ -125,18 +124,6 @@ config CMDLINE_FORCE | |||
125 | Set this to have arguments from the default kernel command string | 124 | Set this to have arguments from the default kernel command string |
126 | override those passed by the boot loader. | 125 | override those passed by the boot loader. |
127 | 126 | ||
128 | config OF | ||
129 | def_bool y | ||
130 | select OF_FLATTREE | ||
131 | |||
132 | config PROC_DEVICETREE | ||
133 | bool "Support for device tree in /proc" | ||
134 | depends on PROC_FS | ||
135 | help | ||
136 | This option adds a device-tree directory under /proc which contains | ||
137 | an image of the device tree that the kernel copies from Open | ||
138 | Firmware or other boot firmware. If unsure, say Y here. | ||
139 | |||
140 | endmenu | 127 | endmenu |
141 | 128 | ||
142 | menu "Advanced setup" | 129 | menu "Advanced setup" |
diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h index 31a35c33df63..ec5583d6111c 100644 --- a/arch/microblaze/include/asm/irq.h +++ b/arch/microblaze/include/asm/irq.h | |||
@@ -27,17 +27,6 @@ extern unsigned int nr_irq; | |||
27 | struct pt_regs; | 27 | struct pt_regs; |
28 | extern void do_IRQ(struct pt_regs *regs); | 28 | extern void do_IRQ(struct pt_regs *regs); |
29 | 29 | ||
30 | /** | ||
31 | * irq_of_parse_and_map - Parse and Map an interrupt into linux virq space | ||
32 | * @device: Device node of the device whose interrupt is to be mapped | ||
33 | * @index: Index of the interrupt to map | ||
34 | * | ||
35 | * This function is a wrapper that chains of_irq_map_one() and | ||
36 | * irq_create_of_mapping() to make things easier to callers | ||
37 | */ | ||
38 | struct device_node; | ||
39 | extern unsigned int irq_of_parse_and_map(struct device_node *dev, int index); | ||
40 | |||
41 | /** FIXME - not implement | 30 | /** FIXME - not implement |
42 | * irq_dispose_mapping - Unmap an interrupt | 31 | * irq_dispose_mapping - Unmap an interrupt |
43 | * @virq: linux virq number of the interrupt to unmap | 32 | * @virq: linux virq number of the interrupt to unmap |
@@ -62,17 +51,4 @@ struct irq_host; | |||
62 | extern unsigned int irq_create_mapping(struct irq_host *host, | 51 | extern unsigned int irq_create_mapping(struct irq_host *host, |
63 | irq_hw_number_t hwirq); | 52 | irq_hw_number_t hwirq); |
64 | 53 | ||
65 | /** | ||
66 | * irq_create_of_mapping - Map a hardware interrupt into linux virq space | ||
67 | * @controller: Device node of the interrupt controller | ||
68 | * @inspec: Interrupt specifier from the device-tree | ||
69 | * @intsize: Size of the interrupt specifier from the device-tree | ||
70 | * | ||
71 | * This function is identical to irq_create_mapping except that it takes | ||
72 | * as input informations straight from the device-tree (typically the results | ||
73 | * of the of_irq_map_*() functions. | ||
74 | */ | ||
75 | extern unsigned int irq_create_of_mapping(struct device_node *controller, | ||
76 | u32 *intspec, unsigned int intsize); | ||
77 | |||
78 | #endif /* _ASM_MICROBLAZE_IRQ_H */ | 54 | #endif /* _ASM_MICROBLAZE_IRQ_H */ |
diff --git a/arch/microblaze/include/asm/of_device.h b/arch/microblaze/include/asm/of_device.h deleted file mode 100644 index 73cb98040982..000000000000 --- a/arch/microblaze/include/asm/of_device.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu> | ||
3 | * | ||
4 | * based on PowerPC of_device.h | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #ifndef _ASM_MICROBLAZE_OF_DEVICE_H | ||
12 | #define _ASM_MICROBLAZE_OF_DEVICE_H | ||
13 | #ifdef __KERNEL__ | ||
14 | |||
15 | #include <linux/device.h> | ||
16 | #include <linux/of.h> | ||
17 | |||
18 | /* | ||
19 | * The of_device is a kind of "base class" that is a superset of | ||
20 | * struct device for use by devices attached to an OF node and | ||
21 | * probed using OF properties. | ||
22 | */ | ||
23 | struct of_device { | ||
24 | struct device dev; /* Generic device interface */ | ||
25 | struct pdev_archdata archdata; | ||
26 | }; | ||
27 | |||
28 | extern ssize_t of_device_get_modalias(struct of_device *ofdev, | ||
29 | char *str, ssize_t len); | ||
30 | |||
31 | extern struct of_device *of_device_alloc(struct device_node *np, | ||
32 | const char *bus_id, | ||
33 | struct device *parent); | ||
34 | |||
35 | extern int of_device_uevent(struct device *dev, | ||
36 | struct kobj_uevent_env *env); | ||
37 | |||
38 | extern void of_device_make_bus_id(struct of_device *dev); | ||
39 | |||
40 | /* This is just here during the transition */ | ||
41 | #include <linux/of_device.h> | ||
42 | |||
43 | #endif /* __KERNEL__ */ | ||
44 | #endif /* _ASM_MICROBLAZE_OF_DEVICE_H */ | ||
diff --git a/arch/microblaze/include/asm/of_platform.h b/arch/microblaze/include/asm/of_platform.h deleted file mode 100644 index 37491276c6ca..000000000000 --- a/arch/microblaze/include/asm/of_platform.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
3 | * <benh@kernel.crashing.org> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #ifndef _ASM_MICROBLAZE_OF_PLATFORM_H | ||
12 | #define _ASM_MICROBLAZE_OF_PLATFORM_H | ||
13 | |||
14 | /* This is just here during the transition */ | ||
15 | #include <linux/of_platform.h> | ||
16 | |||
17 | /* | ||
18 | * The list of OF IDs below is used for matching bus types in the | ||
19 | * system whose devices are to be exposed as of_platform_devices. | ||
20 | * | ||
21 | * This is the default list valid for most platforms. This file provides | ||
22 | * functions who can take an explicit list if necessary though | ||
23 | * | ||
24 | * The search is always performed recursively looking for children of | ||
25 | * the provided device_node and recursively if such a children matches | ||
26 | * a bus type in the list | ||
27 | */ | ||
28 | |||
29 | static const struct of_device_id of_default_bus_ids[] = { | ||
30 | { .type = "soc", }, | ||
31 | { .compatible = "soc", }, | ||
32 | { .type = "plb5", }, | ||
33 | { .type = "plb4", }, | ||
34 | { .type = "opb", }, | ||
35 | { .type = "simple", }, | ||
36 | {}, | ||
37 | }; | ||
38 | |||
39 | /* Platform devices and busses creation */ | ||
40 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
41 | const char *bus_id, | ||
42 | struct device *parent); | ||
43 | /* pseudo "matches" value to not do deep probe */ | ||
44 | #define OF_NO_DEEP_PROBE ((struct of_device_id *)-1) | ||
45 | |||
46 | extern int of_platform_bus_probe(struct device_node *root, | ||
47 | const struct of_device_id *matches, | ||
48 | struct device *parent); | ||
49 | |||
50 | extern struct of_device *of_find_device_by_phandle(phandle ph); | ||
51 | |||
52 | extern void of_instantiate_rtc(void); | ||
53 | |||
54 | #endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */ | ||
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h index c12c6dfafd9f..4f268faa0126 100644 --- a/arch/microblaze/include/asm/page.h +++ b/arch/microblaze/include/asm/page.h | |||
@@ -47,13 +47,6 @@ | |||
47 | #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) | 47 | #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) |
48 | #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) | 48 | #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) |
49 | 49 | ||
50 | /* align addr on a size boundary - adjust address up/down if needed */ | ||
51 | #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1))) | ||
52 | #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1))) | ||
53 | |||
54 | /* align addr on a size boundary - adjust address up if needed */ | ||
55 | #define _ALIGN(addr, size) _ALIGN_UP(addr, size) | ||
56 | |||
57 | #ifndef CONFIG_MMU | 50 | #ifndef CONFIG_MMU |
58 | /* | 51 | /* |
59 | * PAGE_OFFSET -- the first address of the first page of memory. When not | 52 | * PAGE_OFFSET -- the first address of the first page of memory. When not |
diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h index 0c77cda9f5d8..0c68764ab547 100644 --- a/arch/microblaze/include/asm/pci-bridge.h +++ b/arch/microblaze/include/asm/pci-bridge.h | |||
@@ -172,13 +172,8 @@ static inline int pci_has_flag(int flag) | |||
172 | 172 | ||
173 | extern struct list_head hose_list; | 173 | extern struct list_head hose_list; |
174 | 174 | ||
175 | extern unsigned long pci_address_to_pio(phys_addr_t address); | ||
176 | extern int pcibios_vaddr_is_ioport(void __iomem *address); | 175 | extern int pcibios_vaddr_is_ioport(void __iomem *address); |
177 | #else | 176 | #else |
178 | static inline unsigned long pci_address_to_pio(phys_addr_t address) | ||
179 | { | ||
180 | return (unsigned long)-1; | ||
181 | } | ||
182 | static inline int pcibios_vaddr_is_ioport(void __iomem *address) | 177 | static inline int pcibios_vaddr_is_ioport(void __iomem *address) |
183 | { | 178 | { |
184 | return 0; | 179 | return 0; |
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index e7d67a329bd7..101fa098f62a 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -20,9 +20,6 @@ | |||
20 | #ifndef __ASSEMBLY__ | 20 | #ifndef __ASSEMBLY__ |
21 | 21 | ||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/of_fdt.h> | ||
24 | #include <linux/proc_fs.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
27 | #include <asm/atomic.h> | 24 | #include <asm/atomic.h> |
28 | 25 | ||
@@ -50,29 +47,10 @@ extern void pci_create_OF_bus_map(void); | |||
50 | * OF address retreival & translation | 47 | * OF address retreival & translation |
51 | */ | 48 | */ |
52 | 49 | ||
53 | /* Translate an OF address block into a CPU physical address | 50 | #ifdef CONFIG_PCI |
54 | */ | 51 | extern unsigned long pci_address_to_pio(phys_addr_t address); |
55 | extern u64 of_translate_address(struct device_node *np, const u32 *addr); | 52 | #define pci_address_to_pio pci_address_to_pio |
56 | 53 | #endif /* CONFIG_PCI */ | |
57 | /* Extract an address from a device, returns the region size and | ||
58 | * the address space flags too. The PCI version uses a BAR number | ||
59 | * instead of an absolute index | ||
60 | */ | ||
61 | extern const u32 *of_get_address(struct device_node *dev, int index, | ||
62 | u64 *size, unsigned int *flags); | ||
63 | extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, | ||
64 | u64 *size, unsigned int *flags); | ||
65 | |||
66 | /* Get an address as a resource. Note that if your address is | ||
67 | * a PIO address, the conversion will fail if the physical address | ||
68 | * can't be internally converted to an IO token with | ||
69 | * pci_address_to_pio(), that is because it's either called to early | ||
70 | * or it can't be matched to any host bridge IO space | ||
71 | */ | ||
72 | extern int of_address_to_resource(struct device_node *dev, int index, | ||
73 | struct resource *r); | ||
74 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
75 | struct resource *r); | ||
76 | 54 | ||
77 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and | 55 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and |
78 | * size parameters. | 56 | * size parameters. |
@@ -88,69 +66,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | |||
88 | /* Get the MAC address */ | 66 | /* Get the MAC address */ |
89 | extern const void *of_get_mac_address(struct device_node *np); | 67 | extern const void *of_get_mac_address(struct device_node *np); |
90 | 68 | ||
91 | /* | ||
92 | * OF interrupt mapping | ||
93 | */ | ||
94 | |||
95 | /* This structure is returned when an interrupt is mapped. The controller | ||
96 | * field needs to be put() after use | ||
97 | */ | ||
98 | |||
99 | #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */ | ||
100 | |||
101 | struct of_irq { | ||
102 | struct device_node *controller; /* Interrupt controller node */ | ||
103 | u32 size; /* Specifier size */ | ||
104 | u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ | ||
105 | }; | ||
106 | |||
107 | /** | ||
108 | * of_irq_map_init - Initialize the irq remapper | ||
109 | * @flags: flags defining workarounds to enable | ||
110 | * | ||
111 | * Some machines have bugs in the device-tree which require certain workarounds | ||
112 | * to be applied. Call this before any interrupt mapping attempts to enable | ||
113 | * those workarounds. | ||
114 | */ | ||
115 | #define OF_IMAP_OLDWORLD_MAC 0x00000001 | ||
116 | #define OF_IMAP_NO_PHANDLE 0x00000002 | ||
117 | |||
118 | extern void of_irq_map_init(unsigned int flags); | ||
119 | |||
120 | /** | ||
121 | * of_irq_map_raw - Low level interrupt tree parsing | ||
122 | * @parent: the device interrupt parent | ||
123 | * @intspec: interrupt specifier ("interrupts" property of the device) | ||
124 | * @ointsize: size of the passed in interrupt specifier | ||
125 | * @addr: address specifier (start of "reg" property of the device) | ||
126 | * @out_irq: structure of_irq filled by this function | ||
127 | * | ||
128 | * Returns 0 on success and a negative number on error | ||
129 | * | ||
130 | * This function is a low-level interrupt tree walking function. It | ||
131 | * can be used to do a partial walk with synthetized reg and interrupts | ||
132 | * properties, for example when resolving PCI interrupts when no device | ||
133 | * node exist for the parent. | ||
134 | * | ||
135 | */ | ||
136 | |||
137 | extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | ||
138 | u32 ointsize, const u32 *addr, | ||
139 | struct of_irq *out_irq); | ||
140 | |||
141 | /** | ||
142 | * of_irq_map_one - Resolve an interrupt for a device | ||
143 | * @device: the device whose interrupt is to be resolved | ||
144 | * @index: index of the interrupt to resolve | ||
145 | * @out_irq: structure of_irq filled by this function | ||
146 | * | ||
147 | * This function resolves an interrupt, walking the tree, for a given | ||
148 | * device-tree node. It's the high level pendant to of_irq_map_raw(). | ||
149 | * It also implements the workarounds for OldWolrd Macs. | ||
150 | */ | ||
151 | extern int of_irq_map_one(struct device_node *device, int index, | ||
152 | struct of_irq *out_irq); | ||
153 | |||
154 | /** | 69 | /** |
155 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 70 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
156 | * @pdev: the device whose interrupt is to be resolved | 71 | * @pdev: the device whose interrupt is to be resolved |
@@ -163,20 +78,18 @@ extern int of_irq_map_one(struct device_node *device, int index, | |||
163 | * resolving using the OF tree walking. | 78 | * resolving using the OF tree walking. |
164 | */ | 79 | */ |
165 | struct pci_dev; | 80 | struct pci_dev; |
81 | struct of_irq; | ||
166 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 82 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
167 | 83 | ||
168 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
169 | struct resource *r); | ||
170 | |||
171 | /** | ||
172 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
173 | * @device: the device whose io range will be mapped | ||
174 | * @index: index of the io range | ||
175 | * | ||
176 | * Returns a pointer to the mapped memory | ||
177 | */ | ||
178 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
179 | |||
180 | #endif /* __ASSEMBLY__ */ | 84 | #endif /* __ASSEMBLY__ */ |
181 | #endif /* __KERNEL__ */ | 85 | #endif /* __KERNEL__ */ |
86 | |||
87 | /* These includes are put at the bottom because they may contain things | ||
88 | * that are overridden by this file. Ideally they shouldn't be included | ||
89 | * by this file, but there are a bunch of .c files that currently depend | ||
90 | * on it. Eventually they will be cleaned up. */ | ||
91 | #include <linux/of_fdt.h> | ||
92 | #include <linux/of_irq.h> | ||
93 | #include <linux/platform_device.h> | ||
94 | |||
182 | #endif /* _ASM_MICROBLAZE_PROM_H */ | 95 | #endif /* _ASM_MICROBLAZE_PROM_H */ |
diff --git a/arch/microblaze/include/asm/topology.h b/arch/microblaze/include/asm/topology.h index 96bcea5a9920..5428f333a02c 100644 --- a/arch/microblaze/include/asm/topology.h +++ b/arch/microblaze/include/asm/topology.h | |||
@@ -1,11 +1 @@ | |||
1 | #include <asm-generic/topology.h> | #include <asm-generic/topology.h> | |
2 | |||
3 | #ifndef _ASM_MICROBLAZE_TOPOLOGY_H | ||
4 | #define _ASM_MICROBLAZE_TOPOLOGY_H | ||
5 | |||
6 | struct device_node; | ||
7 | static inline int of_node_to_nid(struct device_node *device) | ||
8 | { | ||
9 | return 0; | ||
10 | } | ||
11 | #endif /* _ASM_MICROBLAZE_TOPOLOGY_H */ | ||
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile index 5eecc9f1fbd9..f0cb5c26c81c 100644 --- a/arch/microblaze/kernel/Makefile +++ b/arch/microblaze/kernel/Makefile | |||
@@ -15,8 +15,8 @@ endif | |||
15 | extra-y := head.o vmlinux.lds | 15 | extra-y := head.o vmlinux.lds |
16 | 16 | ||
17 | obj-y += dma.o exceptions.o \ | 17 | obj-y += dma.o exceptions.o \ |
18 | hw_exception_handler.o init_task.o intc.o irq.o of_device.o \ | 18 | hw_exception_handler.o init_task.o intc.o irq.o \ |
19 | of_platform.o process.o prom.o prom_parse.o ptrace.o \ | 19 | process.o prom.o prom_parse.o ptrace.o \ |
20 | reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o | 20 | reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o |
21 | 21 | ||
22 | obj-y += cpu/ | 22 | obj-y += cpu/ |
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c index 598f1fd61c89..a9345fb4906a 100644 --- a/arch/microblaze/kernel/irq.c +++ b/arch/microblaze/kernel/irq.c | |||
@@ -17,20 +17,10 @@ | |||
17 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
18 | #include <linux/kernel_stat.h> | 18 | #include <linux/kernel_stat.h> |
19 | #include <linux/irq.h> | 19 | #include <linux/irq.h> |
20 | #include <linux/of_irq.h> | ||
20 | 21 | ||
21 | #include <asm/prom.h> | 22 | #include <asm/prom.h> |
22 | 23 | ||
23 | unsigned int irq_of_parse_and_map(struct device_node *dev, int index) | ||
24 | { | ||
25 | struct of_irq oirq; | ||
26 | |||
27 | if (of_irq_map_one(dev, index, &oirq)) | ||
28 | return NO_IRQ; | ||
29 | |||
30 | return oirq.specifier[0]; | ||
31 | } | ||
32 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | ||
33 | |||
34 | static u32 concurrent_irq; | 24 | static u32 concurrent_irq; |
35 | 25 | ||
36 | void __irq_entry do_IRQ(struct pt_regs *regs) | 26 | void __irq_entry do_IRQ(struct pt_regs *regs) |
@@ -106,7 +96,7 @@ unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq) | |||
106 | EXPORT_SYMBOL_GPL(irq_create_mapping); | 96 | EXPORT_SYMBOL_GPL(irq_create_mapping); |
107 | 97 | ||
108 | unsigned int irq_create_of_mapping(struct device_node *controller, | 98 | unsigned int irq_create_of_mapping(struct device_node *controller, |
109 | u32 *intspec, unsigned int intsize) | 99 | const u32 *intspec, unsigned int intsize) |
110 | { | 100 | { |
111 | return intspec[0]; | 101 | return intspec[0]; |
112 | } | 102 | } |
diff --git a/arch/microblaze/kernel/of_device.c b/arch/microblaze/kernel/of_device.c deleted file mode 100644 index b372787886ed..000000000000 --- a/arch/microblaze/kernel/of_device.c +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | #include <linux/string.h> | ||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/of.h> | ||
4 | #include <linux/init.h> | ||
5 | #include <linux/module.h> | ||
6 | #include <linux/mod_devicetable.h> | ||
7 | #include <linux/slab.h> | ||
8 | #include <linux/of_device.h> | ||
9 | |||
10 | #include <linux/errno.h> | ||
11 | |||
12 | void of_device_make_bus_id(struct of_device *dev) | ||
13 | { | ||
14 | static atomic_t bus_no_reg_magic; | ||
15 | struct device_node *node = dev->dev.of_node; | ||
16 | const u32 *reg; | ||
17 | u64 addr; | ||
18 | int magic; | ||
19 | |||
20 | /* | ||
21 | * For MMIO, get the physical address | ||
22 | */ | ||
23 | reg = of_get_property(node, "reg", NULL); | ||
24 | if (reg) { | ||
25 | addr = of_translate_address(node, reg); | ||
26 | if (addr != OF_BAD_ADDR) { | ||
27 | dev_set_name(&dev->dev, "%llx.%s", | ||
28 | (unsigned long long)addr, node->name); | ||
29 | return; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | /* | ||
34 | * No BusID, use the node name and add a globally incremented | ||
35 | * counter (and pray...) | ||
36 | */ | ||
37 | magic = atomic_add_return(1, &bus_no_reg_magic); | ||
38 | dev_set_name(&dev->dev, "%s.%d", node->name, magic - 1); | ||
39 | } | ||
40 | EXPORT_SYMBOL(of_device_make_bus_id); | ||
41 | |||
42 | struct of_device *of_device_alloc(struct device_node *np, | ||
43 | const char *bus_id, | ||
44 | struct device *parent) | ||
45 | { | ||
46 | struct of_device *dev; | ||
47 | |||
48 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
49 | if (!dev) | ||
50 | return NULL; | ||
51 | |||
52 | dev->dev.of_node = of_node_get(np); | ||
53 | dev->dev.dma_mask = &dev->archdata.dma_mask; | ||
54 | dev->dev.parent = parent; | ||
55 | dev->dev.release = of_release_dev; | ||
56 | |||
57 | if (bus_id) | ||
58 | dev_set_name(&dev->dev, bus_id); | ||
59 | else | ||
60 | of_device_make_bus_id(dev); | ||
61 | |||
62 | return dev; | ||
63 | } | ||
64 | EXPORT_SYMBOL(of_device_alloc); | ||
65 | |||
66 | int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
67 | { | ||
68 | struct of_device *ofdev; | ||
69 | const char *compat; | ||
70 | int seen = 0, cplen, sl; | ||
71 | |||
72 | if (!dev) | ||
73 | return -ENODEV; | ||
74 | |||
75 | ofdev = to_of_device(dev); | ||
76 | |||
77 | if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name)) | ||
78 | return -ENOMEM; | ||
79 | |||
80 | if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type)) | ||
81 | return -ENOMEM; | ||
82 | |||
83 | /* Since the compatible field can contain pretty much anything | ||
84 | * it's not really legal to split it out with commas. We split it | ||
85 | * up using a number of environment variables instead. */ | ||
86 | |||
87 | compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen); | ||
88 | while (compat && *compat && cplen > 0) { | ||
89 | if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat)) | ||
90 | return -ENOMEM; | ||
91 | |||
92 | sl = strlen(compat) + 1; | ||
93 | compat += sl; | ||
94 | cplen -= sl; | ||
95 | seen++; | ||
96 | } | ||
97 | |||
98 | if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen)) | ||
99 | return -ENOMEM; | ||
100 | |||
101 | /* modalias is trickier, we add it in 2 steps */ | ||
102 | if (add_uevent_var(env, "MODALIAS=")) | ||
103 | return -ENOMEM; | ||
104 | sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1], | ||
105 | sizeof(env->buf) - env->buflen); | ||
106 | if (sl >= (sizeof(env->buf) - env->buflen)) | ||
107 | return -ENOMEM; | ||
108 | env->buflen += sl; | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | EXPORT_SYMBOL(of_device_uevent); | ||
diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c deleted file mode 100644 index ccf6f4257f4b..000000000000 --- a/arch/microblaze/kernel/of_platform.c +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
3 | * <benh@kernel.crashing.org> | ||
4 | * and Arnd Bergmann, IBM Corp. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #undef DEBUG | ||
14 | |||
15 | #include <linux/string.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/mod_devicetable.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/of.h> | ||
22 | #include <linux/of_device.h> | ||
23 | #include <linux/of_platform.h> | ||
24 | |||
25 | #include <linux/errno.h> | ||
26 | #include <linux/topology.h> | ||
27 | #include <asm/atomic.h> | ||
28 | |||
29 | struct bus_type of_platform_bus_type = { | ||
30 | .uevent = of_device_uevent, | ||
31 | }; | ||
32 | EXPORT_SYMBOL(of_platform_bus_type); | ||
33 | |||
34 | static int __init of_bus_driver_init(void) | ||
35 | { | ||
36 | return of_bus_type_init(&of_platform_bus_type, "of_platform"); | ||
37 | } | ||
38 | postcore_initcall(of_bus_driver_init); | ||
39 | |||
40 | struct of_device *of_platform_device_create(struct device_node *np, | ||
41 | const char *bus_id, | ||
42 | struct device *parent) | ||
43 | { | ||
44 | struct of_device *dev; | ||
45 | |||
46 | dev = of_device_alloc(np, bus_id, parent); | ||
47 | if (!dev) | ||
48 | return NULL; | ||
49 | |||
50 | dev->archdata.dma_mask = 0xffffffffUL; | ||
51 | dev->dev.bus = &of_platform_bus_type; | ||
52 | |||
53 | /* We do not fill the DMA ops for platform devices by default. | ||
54 | * This is currently the responsibility of the platform code | ||
55 | * to do such, possibly using a device notifier | ||
56 | */ | ||
57 | |||
58 | if (of_device_register(dev) != 0) { | ||
59 | of_device_free(dev); | ||
60 | return NULL; | ||
61 | } | ||
62 | |||
63 | return dev; | ||
64 | } | ||
65 | EXPORT_SYMBOL(of_platform_device_create); | ||
66 | |||
67 | /** | ||
68 | * of_platform_bus_create - Create an OF device for a bus node and all its | ||
69 | * children. Optionally recursively instanciate matching busses. | ||
70 | * @bus: device node of the bus to instanciate | ||
71 | * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to | ||
72 | * disallow recursive creation of child busses | ||
73 | */ | ||
74 | static int of_platform_bus_create(const struct device_node *bus, | ||
75 | const struct of_device_id *matches, | ||
76 | struct device *parent) | ||
77 | { | ||
78 | struct device_node *child; | ||
79 | struct of_device *dev; | ||
80 | int rc = 0; | ||
81 | |||
82 | for_each_child_of_node(bus, child) { | ||
83 | pr_debug(" create child: %s\n", child->full_name); | ||
84 | dev = of_platform_device_create(child, NULL, parent); | ||
85 | if (dev == NULL) | ||
86 | rc = -ENOMEM; | ||
87 | else if (!of_match_node(matches, child)) | ||
88 | continue; | ||
89 | if (rc == 0) { | ||
90 | pr_debug(" and sub busses\n"); | ||
91 | rc = of_platform_bus_create(child, matches, &dev->dev); | ||
92 | } | ||
93 | if (rc) { | ||
94 | of_node_put(child); | ||
95 | break; | ||
96 | } | ||
97 | } | ||
98 | return rc; | ||
99 | } | ||
100 | |||
101 | |||
102 | /** | ||
103 | * of_platform_bus_probe - Probe the device-tree for platform busses | ||
104 | * @root: parent of the first level to probe or NULL for the root of the tree | ||
105 | * @matches: match table, NULL to use the default | ||
106 | * @parent: parent to hook devices from, NULL for toplevel | ||
107 | * | ||
108 | * Note that children of the provided root are not instanciated as devices | ||
109 | * unless the specified root itself matches the bus list and is not NULL. | ||
110 | */ | ||
111 | |||
112 | int of_platform_bus_probe(struct device_node *root, | ||
113 | const struct of_device_id *matches, | ||
114 | struct device *parent) | ||
115 | { | ||
116 | struct device_node *child; | ||
117 | struct of_device *dev; | ||
118 | int rc = 0; | ||
119 | |||
120 | if (matches == NULL) | ||
121 | matches = of_default_bus_ids; | ||
122 | if (matches == OF_NO_DEEP_PROBE) | ||
123 | return -EINVAL; | ||
124 | if (root == NULL) | ||
125 | root = of_find_node_by_path("/"); | ||
126 | else | ||
127 | of_node_get(root); | ||
128 | |||
129 | pr_debug("of_platform_bus_probe()\n"); | ||
130 | pr_debug(" starting at: %s\n", root->full_name); | ||
131 | |||
132 | /* Do a self check of bus type, if there's a match, create | ||
133 | * children | ||
134 | */ | ||
135 | if (of_match_node(matches, root)) { | ||
136 | pr_debug(" root match, create all sub devices\n"); | ||
137 | dev = of_platform_device_create(root, NULL, parent); | ||
138 | if (dev == NULL) { | ||
139 | rc = -ENOMEM; | ||
140 | goto bail; | ||
141 | } | ||
142 | pr_debug(" create all sub busses\n"); | ||
143 | rc = of_platform_bus_create(root, matches, &dev->dev); | ||
144 | goto bail; | ||
145 | } | ||
146 | for_each_child_of_node(root, child) { | ||
147 | if (!of_match_node(matches, child)) | ||
148 | continue; | ||
149 | |||
150 | pr_debug(" match: %s\n", child->full_name); | ||
151 | dev = of_platform_device_create(child, NULL, parent); | ||
152 | if (dev == NULL) | ||
153 | rc = -ENOMEM; | ||
154 | else | ||
155 | rc = of_platform_bus_create(child, matches, &dev->dev); | ||
156 | if (rc) { | ||
157 | of_node_put(child); | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | bail: | ||
162 | of_node_put(root); | ||
163 | return rc; | ||
164 | } | ||
165 | EXPORT_SYMBOL(of_platform_bus_probe); | ||
166 | |||
167 | static int of_dev_node_match(struct device *dev, void *data) | ||
168 | { | ||
169 | return to_of_device(dev)->dev.of_node == data; | ||
170 | } | ||
171 | |||
172 | struct of_device *of_find_device_by_node(struct device_node *np) | ||
173 | { | ||
174 | struct device *dev; | ||
175 | |||
176 | dev = bus_find_device(&of_platform_bus_type, | ||
177 | NULL, np, of_dev_node_match); | ||
178 | if (dev) | ||
179 | return to_of_device(dev); | ||
180 | return NULL; | ||
181 | } | ||
182 | EXPORT_SYMBOL(of_find_device_by_node); | ||
183 | |||
184 | static int of_dev_phandle_match(struct device *dev, void *data) | ||
185 | { | ||
186 | phandle *ph = data; | ||
187 | return to_of_device(dev)->dev.of_node->phandle == *ph; | ||
188 | } | ||
189 | |||
190 | struct of_device *of_find_device_by_phandle(phandle ph) | ||
191 | { | ||
192 | struct device *dev; | ||
193 | |||
194 | dev = bus_find_device(&of_platform_bus_type, | ||
195 | NULL, &ph, of_dev_phandle_match); | ||
196 | if (dev) | ||
197 | return to_of_device(dev); | ||
198 | return NULL; | ||
199 | } | ||
200 | EXPORT_SYMBOL(of_find_device_by_phandle); | ||
diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c index bf7e6c27e318..d33ba17601fa 100644 --- a/arch/microblaze/kernel/prom_parse.c +++ b/arch/microblaze/kernel/prom_parse.c | |||
@@ -6,219 +6,11 @@ | |||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/ioport.h> | 7 | #include <linux/ioport.h> |
8 | #include <linux/etherdevice.h> | 8 | #include <linux/etherdevice.h> |
9 | #include <linux/of_address.h> | ||
9 | #include <asm/prom.h> | 10 | #include <asm/prom.h> |
10 | #include <asm/pci-bridge.h> | 11 | #include <asm/pci-bridge.h> |
11 | 12 | ||
12 | #define PRu64 "%llx" | ||
13 | |||
14 | /* Max address size we deal with */ | ||
15 | #define OF_MAX_ADDR_CELLS 4 | ||
16 | #define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ | ||
17 | (ns) > 0) | ||
18 | |||
19 | static struct of_bus *of_match_bus(struct device_node *np); | ||
20 | static int __of_address_to_resource(struct device_node *dev, | ||
21 | const u32 *addrp, u64 size, unsigned int flags, | ||
22 | struct resource *r); | ||
23 | |||
24 | /* Debug utility */ | ||
25 | #ifdef DEBUG | ||
26 | static void of_dump_addr(const char *s, const u32 *addr, int na) | ||
27 | { | ||
28 | printk(KERN_INFO "%s", s); | ||
29 | while (na--) | ||
30 | printk(KERN_INFO " %08x", *(addr++)); | ||
31 | printk(KERN_INFO "\n"); | ||
32 | } | ||
33 | #else | ||
34 | static void of_dump_addr(const char *s, const u32 *addr, int na) { } | ||
35 | #endif | ||
36 | |||
37 | /* Callbacks for bus specific translators */ | ||
38 | struct of_bus { | ||
39 | const char *name; | ||
40 | const char *addresses; | ||
41 | int (*match)(struct device_node *parent); | ||
42 | void (*count_cells)(struct device_node *child, | ||
43 | int *addrc, int *sizec); | ||
44 | u64 (*map)(u32 *addr, const u32 *range, | ||
45 | int na, int ns, int pna); | ||
46 | int (*translate)(u32 *addr, u64 offset, int na); | ||
47 | unsigned int (*get_flags)(const u32 *addr); | ||
48 | }; | ||
49 | |||
50 | /* | ||
51 | * Default translator (generic bus) | ||
52 | */ | ||
53 | |||
54 | static void of_bus_default_count_cells(struct device_node *dev, | ||
55 | int *addrc, int *sizec) | ||
56 | { | ||
57 | if (addrc) | ||
58 | *addrc = of_n_addr_cells(dev); | ||
59 | if (sizec) | ||
60 | *sizec = of_n_size_cells(dev); | ||
61 | } | ||
62 | |||
63 | static u64 of_bus_default_map(u32 *addr, const u32 *range, | ||
64 | int na, int ns, int pna) | ||
65 | { | ||
66 | u64 cp, s, da; | ||
67 | |||
68 | cp = of_read_number(range, na); | ||
69 | s = of_read_number(range + na + pna, ns); | ||
70 | da = of_read_number(addr, na); | ||
71 | |||
72 | pr_debug("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n", | ||
73 | cp, s, da); | ||
74 | |||
75 | if (da < cp || da >= (cp + s)) | ||
76 | return OF_BAD_ADDR; | ||
77 | return da - cp; | ||
78 | } | ||
79 | |||
80 | static int of_bus_default_translate(u32 *addr, u64 offset, int na) | ||
81 | { | ||
82 | u64 a = of_read_number(addr, na); | ||
83 | memset(addr, 0, na * 4); | ||
84 | a += offset; | ||
85 | if (na > 1) | ||
86 | addr[na - 2] = a >> 32; | ||
87 | addr[na - 1] = a & 0xffffffffu; | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static unsigned int of_bus_default_get_flags(const u32 *addr) | ||
93 | { | ||
94 | return IORESOURCE_MEM; | ||
95 | } | ||
96 | |||
97 | #ifdef CONFIG_PCI | 13 | #ifdef CONFIG_PCI |
98 | /* | ||
99 | * PCI bus specific translator | ||
100 | */ | ||
101 | |||
102 | static int of_bus_pci_match(struct device_node *np) | ||
103 | { | ||
104 | /* "vci" is for the /chaos bridge on 1st-gen PCI powermacs */ | ||
105 | return !strcmp(np->type, "pci") || !strcmp(np->type, "vci"); | ||
106 | } | ||
107 | |||
108 | static void of_bus_pci_count_cells(struct device_node *np, | ||
109 | int *addrc, int *sizec) | ||
110 | { | ||
111 | if (addrc) | ||
112 | *addrc = 3; | ||
113 | if (sizec) | ||
114 | *sizec = 2; | ||
115 | } | ||
116 | |||
117 | static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) | ||
118 | { | ||
119 | u64 cp, s, da; | ||
120 | |||
121 | /* Check address type match */ | ||
122 | if ((addr[0] ^ range[0]) & 0x03000000) | ||
123 | return OF_BAD_ADDR; | ||
124 | |||
125 | /* Read address values, skipping high cell */ | ||
126 | cp = of_read_number(range + 1, na - 1); | ||
127 | s = of_read_number(range + na + pna, ns); | ||
128 | da = of_read_number(addr + 1, na - 1); | ||
129 | |||
130 | pr_debug("OF: PCI map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); | ||
131 | |||
132 | if (da < cp || da >= (cp + s)) | ||
133 | return OF_BAD_ADDR; | ||
134 | return da - cp; | ||
135 | } | ||
136 | |||
137 | static int of_bus_pci_translate(u32 *addr, u64 offset, int na) | ||
138 | { | ||
139 | return of_bus_default_translate(addr + 1, offset, na - 1); | ||
140 | } | ||
141 | |||
142 | static unsigned int of_bus_pci_get_flags(const u32 *addr) | ||
143 | { | ||
144 | unsigned int flags = 0; | ||
145 | u32 w = addr[0]; | ||
146 | |||
147 | switch ((w >> 24) & 0x03) { | ||
148 | case 0x01: | ||
149 | flags |= IORESOURCE_IO; | ||
150 | break; | ||
151 | case 0x02: /* 32 bits */ | ||
152 | case 0x03: /* 64 bits */ | ||
153 | flags |= IORESOURCE_MEM; | ||
154 | break; | ||
155 | } | ||
156 | if (w & 0x40000000) | ||
157 | flags |= IORESOURCE_PREFETCH; | ||
158 | return flags; | ||
159 | } | ||
160 | |||
161 | const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | ||
162 | unsigned int *flags) | ||
163 | { | ||
164 | const u32 *prop; | ||
165 | unsigned int psize; | ||
166 | struct device_node *parent; | ||
167 | struct of_bus *bus; | ||
168 | int onesize, i, na, ns; | ||
169 | |||
170 | /* Get parent & match bus type */ | ||
171 | parent = of_get_parent(dev); | ||
172 | if (parent == NULL) | ||
173 | return NULL; | ||
174 | bus = of_match_bus(parent); | ||
175 | if (strcmp(bus->name, "pci")) { | ||
176 | of_node_put(parent); | ||
177 | return NULL; | ||
178 | } | ||
179 | bus->count_cells(dev, &na, &ns); | ||
180 | of_node_put(parent); | ||
181 | if (!OF_CHECK_COUNTS(na, ns)) | ||
182 | return NULL; | ||
183 | |||
184 | /* Get "reg" or "assigned-addresses" property */ | ||
185 | prop = of_get_property(dev, bus->addresses, &psize); | ||
186 | if (prop == NULL) | ||
187 | return NULL; | ||
188 | psize /= 4; | ||
189 | |||
190 | onesize = na + ns; | ||
191 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | ||
192 | if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { | ||
193 | if (size) | ||
194 | *size = of_read_number(prop + na, ns); | ||
195 | if (flags) | ||
196 | *flags = bus->get_flags(prop); | ||
197 | return prop; | ||
198 | } | ||
199 | return NULL; | ||
200 | } | ||
201 | EXPORT_SYMBOL(of_get_pci_address); | ||
202 | |||
203 | int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
204 | struct resource *r) | ||
205 | { | ||
206 | const u32 *addrp; | ||
207 | u64 size; | ||
208 | unsigned int flags; | ||
209 | |||
210 | addrp = of_get_pci_address(dev, bar, &size, &flags); | ||
211 | if (addrp == NULL) | ||
212 | return -EINVAL; | ||
213 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
214 | } | ||
215 | EXPORT_SYMBOL_GPL(of_pci_address_to_resource); | ||
216 | |||
217 | static u8 of_irq_pci_swizzle(u8 slot, u8 pin) | ||
218 | { | ||
219 | return (((pin - 1) + slot) % 4) + 1; | ||
220 | } | ||
221 | |||
222 | 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) |
223 | { | 15 | { |
224 | struct device_node *dn, *ppnode; | 16 | struct device_node *dn, *ppnode; |
@@ -293,331 +85,6 @@ int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq) | |||
293 | EXPORT_SYMBOL_GPL(of_irq_map_pci); | 85 | EXPORT_SYMBOL_GPL(of_irq_map_pci); |
294 | #endif /* CONFIG_PCI */ | 86 | #endif /* CONFIG_PCI */ |
295 | 87 | ||
296 | /* | ||
297 | * ISA bus specific translator | ||
298 | */ | ||
299 | |||
300 | static int of_bus_isa_match(struct device_node *np) | ||
301 | { | ||
302 | return !strcmp(np->name, "isa"); | ||
303 | } | ||
304 | |||
305 | static void of_bus_isa_count_cells(struct device_node *child, | ||
306 | int *addrc, int *sizec) | ||
307 | { | ||
308 | if (addrc) | ||
309 | *addrc = 2; | ||
310 | if (sizec) | ||
311 | *sizec = 1; | ||
312 | } | ||
313 | |||
314 | static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna) | ||
315 | { | ||
316 | u64 cp, s, da; | ||
317 | |||
318 | /* Check address type match */ | ||
319 | if ((addr[0] ^ range[0]) & 0x00000001) | ||
320 | return OF_BAD_ADDR; | ||
321 | |||
322 | /* Read address values, skipping high cell */ | ||
323 | cp = of_read_number(range + 1, na - 1); | ||
324 | s = of_read_number(range + na + pna, ns); | ||
325 | da = of_read_number(addr + 1, na - 1); | ||
326 | |||
327 | pr_debug("OF: ISA map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); | ||
328 | |||
329 | if (da < cp || da >= (cp + s)) | ||
330 | return OF_BAD_ADDR; | ||
331 | return da - cp; | ||
332 | } | ||
333 | |||
334 | static int of_bus_isa_translate(u32 *addr, u64 offset, int na) | ||
335 | { | ||
336 | return of_bus_default_translate(addr + 1, offset, na - 1); | ||
337 | } | ||
338 | |||
339 | static unsigned int of_bus_isa_get_flags(const u32 *addr) | ||
340 | { | ||
341 | unsigned int flags = 0; | ||
342 | u32 w = addr[0]; | ||
343 | |||
344 | if (w & 1) | ||
345 | flags |= IORESOURCE_IO; | ||
346 | else | ||
347 | flags |= IORESOURCE_MEM; | ||
348 | return flags; | ||
349 | } | ||
350 | |||
351 | /* | ||
352 | * Array of bus specific translators | ||
353 | */ | ||
354 | |||
355 | static struct of_bus of_busses[] = { | ||
356 | #ifdef CONFIG_PCI | ||
357 | /* PCI */ | ||
358 | { | ||
359 | .name = "pci", | ||
360 | .addresses = "assigned-addresses", | ||
361 | .match = of_bus_pci_match, | ||
362 | .count_cells = of_bus_pci_count_cells, | ||
363 | .map = of_bus_pci_map, | ||
364 | .translate = of_bus_pci_translate, | ||
365 | .get_flags = of_bus_pci_get_flags, | ||
366 | }, | ||
367 | #endif /* CONFIG_PCI */ | ||
368 | /* ISA */ | ||
369 | { | ||
370 | .name = "isa", | ||
371 | .addresses = "reg", | ||
372 | .match = of_bus_isa_match, | ||
373 | .count_cells = of_bus_isa_count_cells, | ||
374 | .map = of_bus_isa_map, | ||
375 | .translate = of_bus_isa_translate, | ||
376 | .get_flags = of_bus_isa_get_flags, | ||
377 | }, | ||
378 | /* Default */ | ||
379 | { | ||
380 | .name = "default", | ||
381 | .addresses = "reg", | ||
382 | .match = NULL, | ||
383 | .count_cells = of_bus_default_count_cells, | ||
384 | .map = of_bus_default_map, | ||
385 | .translate = of_bus_default_translate, | ||
386 | .get_flags = of_bus_default_get_flags, | ||
387 | }, | ||
388 | }; | ||
389 | |||
390 | static struct of_bus *of_match_bus(struct device_node *np) | ||
391 | { | ||
392 | int i; | ||
393 | |||
394 | for (i = 0; i < ARRAY_SIZE(of_busses); i++) | ||
395 | if (!of_busses[i].match || of_busses[i].match(np)) | ||
396 | return &of_busses[i]; | ||
397 | BUG(); | ||
398 | return NULL; | ||
399 | } | ||
400 | |||
401 | static int of_translate_one(struct device_node *parent, struct of_bus *bus, | ||
402 | struct of_bus *pbus, u32 *addr, | ||
403 | int na, int ns, int pna) | ||
404 | { | ||
405 | const u32 *ranges; | ||
406 | unsigned int rlen; | ||
407 | int rone; | ||
408 | u64 offset = OF_BAD_ADDR; | ||
409 | |||
410 | /* Normally, an absence of a "ranges" property means we are | ||
411 | * crossing a non-translatable boundary, and thus the addresses | ||
412 | * below the current not cannot be converted to CPU physical ones. | ||
413 | * Unfortunately, while this is very clear in the spec, it's not | ||
414 | * what Apple understood, and they do have things like /uni-n or | ||
415 | * /ht nodes with no "ranges" property and a lot of perfectly | ||
416 | * useable mapped devices below them. Thus we treat the absence of | ||
417 | * "ranges" as equivalent to an empty "ranges" property which means | ||
418 | * a 1:1 translation at that level. It's up to the caller not to try | ||
419 | * to translate addresses that aren't supposed to be translated in | ||
420 | * the first place. --BenH. | ||
421 | */ | ||
422 | ranges = of_get_property(parent, "ranges", (int *) &rlen); | ||
423 | if (ranges == NULL || rlen == 0) { | ||
424 | offset = of_read_number(addr, na); | ||
425 | memset(addr, 0, pna * 4); | ||
426 | pr_debug("OF: no ranges, 1:1 translation\n"); | ||
427 | goto finish; | ||
428 | } | ||
429 | |||
430 | pr_debug("OF: walking ranges...\n"); | ||
431 | |||
432 | /* Now walk through the ranges */ | ||
433 | rlen /= 4; | ||
434 | rone = na + pna + ns; | ||
435 | for (; rlen >= rone; rlen -= rone, ranges += rone) { | ||
436 | offset = bus->map(addr, ranges, na, ns, pna); | ||
437 | if (offset != OF_BAD_ADDR) | ||
438 | break; | ||
439 | } | ||
440 | if (offset == OF_BAD_ADDR) { | ||
441 | pr_debug("OF: not found !\n"); | ||
442 | return 1; | ||
443 | } | ||
444 | memcpy(addr, ranges + na, 4 * pna); | ||
445 | |||
446 | finish: | ||
447 | of_dump_addr("OF: parent translation for:", addr, pna); | ||
448 | pr_debug("OF: with offset: "PRu64"\n", offset); | ||
449 | |||
450 | /* Translate it into parent bus space */ | ||
451 | return pbus->translate(addr, offset, pna); | ||
452 | } | ||
453 | |||
454 | /* | ||
455 | * Translate an address from the device-tree into a CPU physical address, | ||
456 | * this walks up the tree and applies the various bus mappings on the | ||
457 | * way. | ||
458 | * | ||
459 | * Note: We consider that crossing any level with #size-cells == 0 to mean | ||
460 | * that translation is impossible (that is we are not dealing with a value | ||
461 | * that can be mapped to a cpu physical address). This is not really specified | ||
462 | * that way, but this is traditionally the way IBM at least do things | ||
463 | */ | ||
464 | u64 of_translate_address(struct device_node *dev, const u32 *in_addr) | ||
465 | { | ||
466 | struct device_node *parent = NULL; | ||
467 | struct of_bus *bus, *pbus; | ||
468 | u32 addr[OF_MAX_ADDR_CELLS]; | ||
469 | int na, ns, pna, pns; | ||
470 | u64 result = OF_BAD_ADDR; | ||
471 | |||
472 | pr_debug("OF: ** translation for device %s **\n", dev->full_name); | ||
473 | |||
474 | /* Increase refcount at current level */ | ||
475 | of_node_get(dev); | ||
476 | |||
477 | /* Get parent & match bus type */ | ||
478 | parent = of_get_parent(dev); | ||
479 | if (parent == NULL) | ||
480 | goto bail; | ||
481 | bus = of_match_bus(parent); | ||
482 | |||
483 | /* Cound address cells & copy address locally */ | ||
484 | bus->count_cells(dev, &na, &ns); | ||
485 | if (!OF_CHECK_COUNTS(na, ns)) { | ||
486 | printk(KERN_ERR "prom_parse: Bad cell count for %s\n", | ||
487 | dev->full_name); | ||
488 | goto bail; | ||
489 | } | ||
490 | memcpy(addr, in_addr, na * 4); | ||
491 | |||
492 | pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n", | ||
493 | bus->name, na, ns, parent->full_name); | ||
494 | of_dump_addr("OF: translating address:", addr, na); | ||
495 | |||
496 | /* Translate */ | ||
497 | for (;;) { | ||
498 | /* Switch to parent bus */ | ||
499 | of_node_put(dev); | ||
500 | dev = parent; | ||
501 | parent = of_get_parent(dev); | ||
502 | |||
503 | /* If root, we have finished */ | ||
504 | if (parent == NULL) { | ||
505 | pr_debug("OF: reached root node\n"); | ||
506 | result = of_read_number(addr, na); | ||
507 | break; | ||
508 | } | ||
509 | |||
510 | /* Get new parent bus and counts */ | ||
511 | pbus = of_match_bus(parent); | ||
512 | pbus->count_cells(dev, &pna, &pns); | ||
513 | if (!OF_CHECK_COUNTS(pna, pns)) { | ||
514 | printk(KERN_ERR "prom_parse: Bad cell count for %s\n", | ||
515 | dev->full_name); | ||
516 | break; | ||
517 | } | ||
518 | |||
519 | pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n", | ||
520 | pbus->name, pna, pns, parent->full_name); | ||
521 | |||
522 | /* Apply bus translation */ | ||
523 | if (of_translate_one(dev, bus, pbus, addr, na, ns, pna)) | ||
524 | break; | ||
525 | |||
526 | /* Complete the move up one level */ | ||
527 | na = pna; | ||
528 | ns = pns; | ||
529 | bus = pbus; | ||
530 | |||
531 | of_dump_addr("OF: one level translation:", addr, na); | ||
532 | } | ||
533 | bail: | ||
534 | of_node_put(parent); | ||
535 | of_node_put(dev); | ||
536 | |||
537 | return result; | ||
538 | } | ||
539 | EXPORT_SYMBOL(of_translate_address); | ||
540 | |||
541 | const u32 *of_get_address(struct device_node *dev, int index, u64 *size, | ||
542 | unsigned int *flags) | ||
543 | { | ||
544 | const u32 *prop; | ||
545 | unsigned int psize; | ||
546 | struct device_node *parent; | ||
547 | struct of_bus *bus; | ||
548 | int onesize, i, na, ns; | ||
549 | |||
550 | /* Get parent & match bus type */ | ||
551 | parent = of_get_parent(dev); | ||
552 | if (parent == NULL) | ||
553 | return NULL; | ||
554 | bus = of_match_bus(parent); | ||
555 | bus->count_cells(dev, &na, &ns); | ||
556 | of_node_put(parent); | ||
557 | if (!OF_CHECK_COUNTS(na, ns)) | ||
558 | return NULL; | ||
559 | |||
560 | /* Get "reg" or "assigned-addresses" property */ | ||
561 | prop = of_get_property(dev, bus->addresses, (int *) &psize); | ||
562 | if (prop == NULL) | ||
563 | return NULL; | ||
564 | psize /= 4; | ||
565 | |||
566 | onesize = na + ns; | ||
567 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | ||
568 | if (i == index) { | ||
569 | if (size) | ||
570 | *size = of_read_number(prop + na, ns); | ||
571 | if (flags) | ||
572 | *flags = bus->get_flags(prop); | ||
573 | return prop; | ||
574 | } | ||
575 | return NULL; | ||
576 | } | ||
577 | EXPORT_SYMBOL(of_get_address); | ||
578 | |||
579 | static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | ||
580 | u64 size, unsigned int flags, | ||
581 | struct resource *r) | ||
582 | { | ||
583 | u64 taddr; | ||
584 | |||
585 | if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) | ||
586 | return -EINVAL; | ||
587 | taddr = of_translate_address(dev, addrp); | ||
588 | if (taddr == OF_BAD_ADDR) | ||
589 | return -EINVAL; | ||
590 | memset(r, 0, sizeof(struct resource)); | ||
591 | if (flags & IORESOURCE_IO) { | ||
592 | unsigned long port; | ||
593 | port = -1; /* pci_address_to_pio(taddr); */ | ||
594 | if (port == (unsigned long)-1) | ||
595 | return -EINVAL; | ||
596 | r->start = port; | ||
597 | r->end = port + size - 1; | ||
598 | } else { | ||
599 | r->start = taddr; | ||
600 | r->end = taddr + size - 1; | ||
601 | } | ||
602 | r->flags = flags; | ||
603 | r->name = dev->name; | ||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | int of_address_to_resource(struct device_node *dev, int index, | ||
608 | struct resource *r) | ||
609 | { | ||
610 | const u32 *addrp; | ||
611 | u64 size; | ||
612 | unsigned int flags; | ||
613 | |||
614 | addrp = of_get_address(dev, index, &size, &flags); | ||
615 | if (addrp == NULL) | ||
616 | return -EINVAL; | ||
617 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
618 | } | ||
619 | EXPORT_SYMBOL_GPL(of_address_to_resource); | ||
620 | |||
621 | void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | 88 | void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, |
622 | unsigned long *busno, unsigned long *phys, unsigned long *size) | 89 | unsigned long *busno, unsigned long *phys, unsigned long *size) |
623 | { | 90 | { |
@@ -644,308 +111,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | |||
644 | *size = of_read_number(dma_window, cells); | 111 | *size = of_read_number(dma_window, cells); |
645 | } | 112 | } |
646 | 113 | ||
647 | /* | ||
648 | * Interrupt remapper | ||
649 | */ | ||
650 | |||
651 | static unsigned int of_irq_workarounds; | ||
652 | static struct device_node *of_irq_dflt_pic; | ||
653 | |||
654 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
655 | { | ||
656 | struct device_node *p; | ||
657 | const phandle *parp; | ||
658 | |||
659 | if (!of_node_get(child)) | ||
660 | return NULL; | ||
661 | |||
662 | do { | ||
663 | parp = of_get_property(child, "interrupt-parent", NULL); | ||
664 | if (parp == NULL) | ||
665 | p = of_get_parent(child); | ||
666 | else { | ||
667 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
668 | p = of_node_get(of_irq_dflt_pic); | ||
669 | else | ||
670 | p = of_find_node_by_phandle(*parp); | ||
671 | } | ||
672 | of_node_put(child); | ||
673 | child = p; | ||
674 | } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); | ||
675 | |||
676 | return p; | ||
677 | } | ||
678 | |||
679 | /* This doesn't need to be called if you don't have any special workaround | ||
680 | * flags to pass | ||
681 | */ | ||
682 | void of_irq_map_init(unsigned int flags) | ||
683 | { | ||
684 | of_irq_workarounds = flags; | ||
685 | |||
686 | /* OldWorld, don't bother looking at other things */ | ||
687 | if (flags & OF_IMAP_OLDWORLD_MAC) | ||
688 | return; | ||
689 | |||
690 | /* If we don't have phandles, let's try to locate a default interrupt | ||
691 | * controller (happens when booting with BootX). We do a first match | ||
692 | * here, hopefully, that only ever happens on machines with one | ||
693 | * controller. | ||
694 | */ | ||
695 | if (flags & OF_IMAP_NO_PHANDLE) { | ||
696 | struct device_node *np; | ||
697 | |||
698 | for (np = NULL; (np = of_find_all_nodes(np)) != NULL;) { | ||
699 | if (of_get_property(np, "interrupt-controller", NULL) | ||
700 | == NULL) | ||
701 | continue; | ||
702 | /* Skip /chosen/interrupt-controller */ | ||
703 | if (strcmp(np->name, "chosen") == 0) | ||
704 | continue; | ||
705 | /* It seems like at least one person on this planet | ||
706 | * wants to use BootX on a machine with an AppleKiwi | ||
707 | * controller which happens to pretend to be an | ||
708 | * interrupt controller too. | ||
709 | */ | ||
710 | if (strcmp(np->name, "AppleKiwi") == 0) | ||
711 | continue; | ||
712 | /* I think we found one ! */ | ||
713 | of_irq_dflt_pic = np; | ||
714 | break; | ||
715 | } | ||
716 | } | ||
717 | |||
718 | } | ||
719 | |||
720 | int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize, | ||
721 | const u32 *addr, struct of_irq *out_irq) | ||
722 | { | ||
723 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
724 | const u32 *tmp, *imap, *imask; | ||
725 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
726 | int imaplen, match, i; | ||
727 | |||
728 | pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...]," | ||
729 | "ointsize=%d\n", | ||
730 | parent->full_name, intspec[0], intspec[1], ointsize); | ||
731 | |||
732 | ipar = of_node_get(parent); | ||
733 | |||
734 | /* First get the #interrupt-cells property of the current cursor | ||
735 | * that tells us how to interpret the passed-in intspec. If there | ||
736 | * is none, we are nice and just walk up the tree | ||
737 | */ | ||
738 | do { | ||
739 | tmp = of_get_property(ipar, "#interrupt-cells", NULL); | ||
740 | if (tmp != NULL) { | ||
741 | intsize = *tmp; | ||
742 | break; | ||
743 | } | ||
744 | tnode = ipar; | ||
745 | ipar = of_irq_find_parent(ipar); | ||
746 | of_node_put(tnode); | ||
747 | } while (ipar); | ||
748 | if (ipar == NULL) { | ||
749 | pr_debug(" -> no parent found !\n"); | ||
750 | goto fail; | ||
751 | } | ||
752 | |||
753 | pr_debug("of_irq_map_raw: ipar=%s, size=%d\n", | ||
754 | ipar->full_name, intsize); | ||
755 | |||
756 | if (ointsize != intsize) | ||
757 | return -EINVAL; | ||
758 | |||
759 | /* Look for this #address-cells. We have to implement the old linux | ||
760 | * trick of looking for the parent here as some device-trees rely on it | ||
761 | */ | ||
762 | old = of_node_get(ipar); | ||
763 | do { | ||
764 | tmp = of_get_property(old, "#address-cells", NULL); | ||
765 | tnode = of_get_parent(old); | ||
766 | of_node_put(old); | ||
767 | old = tnode; | ||
768 | } while (old && tmp == NULL); | ||
769 | of_node_put(old); | ||
770 | old = NULL; | ||
771 | addrsize = (tmp == NULL) ? 2 : *tmp; | ||
772 | |||
773 | pr_debug(" -> addrsize=%d\n", addrsize); | ||
774 | |||
775 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
776 | while (ipar != NULL) { | ||
777 | /* Now check if cursor is an interrupt-controller and if it is | ||
778 | * then we are done | ||
779 | */ | ||
780 | if (of_get_property(ipar, "interrupt-controller", NULL) != | ||
781 | NULL) { | ||
782 | pr_debug(" -> got it !\n"); | ||
783 | memcpy(out_irq->specifier, intspec, | ||
784 | intsize * sizeof(u32)); | ||
785 | out_irq->size = intsize; | ||
786 | out_irq->controller = ipar; | ||
787 | of_node_put(old); | ||
788 | return 0; | ||
789 | } | ||
790 | |||
791 | /* Now look for an interrupt-map */ | ||
792 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | ||
793 | /* No interrupt map, check for an interrupt parent */ | ||
794 | if (imap == NULL) { | ||
795 | pr_debug(" -> no map, getting parent\n"); | ||
796 | newpar = of_irq_find_parent(ipar); | ||
797 | goto skiplevel; | ||
798 | } | ||
799 | imaplen /= sizeof(u32); | ||
800 | |||
801 | /* Look for a mask */ | ||
802 | imask = of_get_property(ipar, "interrupt-map-mask", NULL); | ||
803 | |||
804 | /* If we were passed no "reg" property and we attempt to parse | ||
805 | * an interrupt-map, then #address-cells must be 0. | ||
806 | * Fail if it's not. | ||
807 | */ | ||
808 | if (addr == NULL && addrsize != 0) { | ||
809 | pr_debug(" -> no reg passed in when needed !\n"); | ||
810 | goto fail; | ||
811 | } | ||
812 | |||
813 | /* Parse interrupt-map */ | ||
814 | match = 0; | ||
815 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
816 | /* Compare specifiers */ | ||
817 | match = 1; | ||
818 | for (i = 0; i < addrsize && match; ++i) { | ||
819 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
820 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
821 | } | ||
822 | for (; i < (addrsize + intsize) && match; ++i) { | ||
823 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
824 | match = | ||
825 | ((intspec[i-addrsize] ^ imap[i]) | ||
826 | & mask) == 0; | ||
827 | } | ||
828 | imap += addrsize + intsize; | ||
829 | imaplen -= addrsize + intsize; | ||
830 | |||
831 | pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
832 | |||
833 | /* Get the interrupt parent */ | ||
834 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
835 | newpar = of_node_get(of_irq_dflt_pic); | ||
836 | else | ||
837 | newpar = | ||
838 | of_find_node_by_phandle((phandle)*imap); | ||
839 | imap++; | ||
840 | --imaplen; | ||
841 | |||
842 | /* Check if not found */ | ||
843 | if (newpar == NULL) { | ||
844 | pr_debug(" -> imap parent not found !\n"); | ||
845 | goto fail; | ||
846 | } | ||
847 | |||
848 | /* Get #interrupt-cells and #address-cells of new | ||
849 | * parent | ||
850 | */ | ||
851 | tmp = of_get_property(newpar, "#interrupt-cells", NULL); | ||
852 | if (tmp == NULL) { | ||
853 | pr_debug(" -> parent lacks " | ||
854 | "#interrupt-cells!\n"); | ||
855 | goto fail; | ||
856 | } | ||
857 | newintsize = *tmp; | ||
858 | tmp = of_get_property(newpar, "#address-cells", NULL); | ||
859 | newaddrsize = (tmp == NULL) ? 0 : *tmp; | ||
860 | |||
861 | pr_debug(" -> newintsize=%d, newaddrsize=%d\n", | ||
862 | newintsize, newaddrsize); | ||
863 | |||
864 | /* Check for malformed properties */ | ||
865 | if (imaplen < (newaddrsize + newintsize)) | ||
866 | goto fail; | ||
867 | |||
868 | imap += newaddrsize + newintsize; | ||
869 | imaplen -= newaddrsize + newintsize; | ||
870 | |||
871 | pr_debug(" -> imaplen=%d\n", imaplen); | ||
872 | } | ||
873 | if (!match) | ||
874 | goto fail; | ||
875 | |||
876 | of_node_put(old); | ||
877 | old = of_node_get(newpar); | ||
878 | addrsize = newaddrsize; | ||
879 | intsize = newintsize; | ||
880 | intspec = imap - intsize; | ||
881 | addr = intspec - addrsize; | ||
882 | |||
883 | skiplevel: | ||
884 | /* Iterate again with new parent */ | ||
885 | pr_debug(" -> new parent: %s\n", | ||
886 | newpar ? newpar->full_name : "<>"); | ||
887 | of_node_put(ipar); | ||
888 | ipar = newpar; | ||
889 | newpar = NULL; | ||
890 | } | ||
891 | fail: | ||
892 | of_node_put(ipar); | ||
893 | of_node_put(old); | ||
894 | of_node_put(newpar); | ||
895 | |||
896 | return -EINVAL; | ||
897 | } | ||
898 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
899 | |||
900 | int of_irq_map_one(struct device_node *device, | ||
901 | int index, struct of_irq *out_irq) | ||
902 | { | ||
903 | struct device_node *p; | ||
904 | const u32 *intspec, *tmp, *addr; | ||
905 | u32 intsize, intlen; | ||
906 | int res; | ||
907 | |||
908 | pr_debug("of_irq_map_one: dev=%s, index=%d\n", | ||
909 | device->full_name, index); | ||
910 | |||
911 | /* Get the interrupts property */ | ||
912 | intspec = of_get_property(device, "interrupts", (int *) &intlen); | ||
913 | if (intspec == NULL) | ||
914 | return -EINVAL; | ||
915 | intlen /= sizeof(u32); | ||
916 | |||
917 | pr_debug(" intspec=%d intlen=%d\n", *intspec, intlen); | ||
918 | |||
919 | /* Get the reg property (if any) */ | ||
920 | addr = of_get_property(device, "reg", NULL); | ||
921 | |||
922 | /* Look for the interrupt parent. */ | ||
923 | p = of_irq_find_parent(device); | ||
924 | if (p == NULL) | ||
925 | return -EINVAL; | ||
926 | |||
927 | /* Get size of interrupt specifier */ | ||
928 | tmp = of_get_property(p, "#interrupt-cells", NULL); | ||
929 | if (tmp == NULL) { | ||
930 | of_node_put(p); | ||
931 | return -EINVAL; | ||
932 | } | ||
933 | intsize = *tmp; | ||
934 | |||
935 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | ||
936 | |||
937 | /* Check index */ | ||
938 | if ((index + 1) * intsize > intlen) | ||
939 | return -EINVAL; | ||
940 | |||
941 | /* Get new specifier and map it */ | ||
942 | res = of_irq_map_raw(p, intspec + index * intsize, intsize, | ||
943 | addr, out_irq); | ||
944 | of_node_put(p); | ||
945 | return res; | ||
946 | } | ||
947 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
948 | |||
949 | /** | 114 | /** |
950 | * Search the device tree for the best MAC address to use. 'mac-address' is | 115 | * Search the device tree for the best MAC address to use. 'mac-address' is |
951 | * checked first, because that is supposed to contain to "most recent" MAC | 116 | * checked first, because that is supposed to contain to "most recent" MAC |
@@ -983,43 +148,3 @@ const void *of_get_mac_address(struct device_node *np) | |||
983 | return NULL; | 148 | return NULL; |
984 | } | 149 | } |
985 | EXPORT_SYMBOL(of_get_mac_address); | 150 | EXPORT_SYMBOL(of_get_mac_address); |
986 | |||
987 | int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | ||
988 | { | ||
989 | struct of_irq out_irq; | ||
990 | int irq; | ||
991 | int res; | ||
992 | |||
993 | res = of_irq_map_one(dev, index, &out_irq); | ||
994 | |||
995 | /* Get irq for the device */ | ||
996 | if (res) { | ||
997 | pr_debug("IRQ not found... code = %d", res); | ||
998 | return NO_IRQ; | ||
999 | } | ||
1000 | /* Assuming single interrupt controller... */ | ||
1001 | irq = out_irq.specifier[0]; | ||
1002 | |||
1003 | pr_debug("IRQ found = %d", irq); | ||
1004 | |||
1005 | /* Only dereference the resource if both the | ||
1006 | * resource and the irq are valid. */ | ||
1007 | if (r && irq != NO_IRQ) { | ||
1008 | r->start = r->end = irq; | ||
1009 | r->flags = IORESOURCE_IRQ; | ||
1010 | } | ||
1011 | |||
1012 | return irq; | ||
1013 | } | ||
1014 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
1015 | |||
1016 | void __iomem *of_iomap(struct device_node *np, int index) | ||
1017 | { | ||
1018 | struct resource res; | ||
1019 | |||
1020 | if (of_address_to_resource(np, index, &res)) | ||
1021 | return NULL; | ||
1022 | |||
1023 | return ioremap(res.start, 1 + res.end - res.start); | ||
1024 | } | ||
1025 | EXPORT_SYMBOL(of_iomap); | ||
diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index a1721a33042e..bd8ccab5ceff 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c | |||
@@ -24,8 +24,8 @@ static int of_reset_gpio_handle(void) | |||
24 | int ret; /* variable which stored handle reset gpio pin */ | 24 | int ret; /* variable which stored handle reset gpio pin */ |
25 | struct device_node *root; /* root node */ | 25 | struct device_node *root; /* root node */ |
26 | struct device_node *gpio; /* gpio node */ | 26 | struct device_node *gpio; /* gpio node */ |
27 | struct of_gpio_chip *of_gc = NULL; | 27 | struct gpio_chip *gc; |
28 | enum of_gpio_flags flags ; | 28 | u32 flags; |
29 | const void *gpio_spec; | 29 | const void *gpio_spec; |
30 | 30 | ||
31 | /* find out root node */ | 31 | /* find out root node */ |
@@ -39,19 +39,19 @@ static int of_reset_gpio_handle(void) | |||
39 | goto err0; | 39 | goto err0; |
40 | } | 40 | } |
41 | 41 | ||
42 | of_gc = gpio->data; | 42 | gc = of_node_to_gpiochip(gpio); |
43 | if (!of_gc) { | 43 | if (!gc) { |
44 | pr_debug("%s: gpio controller %s isn't registered\n", | 44 | pr_debug("%s: gpio controller %s isn't registered\n", |
45 | root->full_name, gpio->full_name); | 45 | root->full_name, gpio->full_name); |
46 | ret = -ENODEV; | 46 | ret = -ENODEV; |
47 | goto err1; | 47 | goto err1; |
48 | } | 48 | } |
49 | 49 | ||
50 | ret = of_gc->xlate(of_gc, root, gpio_spec, &flags); | 50 | ret = gc->of_xlate(gc, root, gpio_spec, &flags); |
51 | if (ret < 0) | 51 | if (ret < 0) |
52 | goto err1; | 52 | goto err1; |
53 | 53 | ||
54 | ret += of_gc->gc.base; | 54 | ret += gc->base; |
55 | err1: | 55 | err1: |
56 | of_node_put(gpio); | 56 | of_node_put(gpio); |
57 | err0: | 57 | err0: |
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 17c98dbcec88..f5f768842354 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c | |||
@@ -213,15 +213,9 @@ static struct notifier_block dflt_plat_bus_notifier = { | |||
213 | .priority = INT_MAX, | 213 | .priority = INT_MAX, |
214 | }; | 214 | }; |
215 | 215 | ||
216 | static struct notifier_block dflt_of_bus_notifier = { | ||
217 | .notifier_call = dflt_bus_notify, | ||
218 | .priority = INT_MAX, | ||
219 | }; | ||
220 | |||
221 | static int __init setup_bus_notifier(void) | 216 | static int __init setup_bus_notifier(void) |
222 | { | 217 | { |
223 | bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); | 218 | bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); |
224 | bus_register_notifier(&of_platform_bus_type, &dflt_of_bus_notifier); | ||
225 | 219 | ||
226 | return 0; | 220 | return 0; |
227 | } | 221 | } |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index e4545f85ee9f..e2bf40a2ce5a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -120,6 +120,8 @@ config ARCH_NO_VIRT_TO_BUS | |||
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; |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index c0015db247ba..ba068c833e5d 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -18,6 +18,7 @@ config 64BIT | |||
18 | config SPARC | 18 | config SPARC |
19 | bool | 19 | bool |
20 | default y | 20 | default y |
21 | select OF | ||
21 | select HAVE_IDE | 22 | select HAVE_IDE |
22 | select HAVE_OPROFILE | 23 | select HAVE_OPROFILE |
23 | select HAVE_ARCH_KGDB if !SMP || SPARC64 | 24 | select HAVE_ARCH_KGDB if !SMP || SPARC64 |
@@ -148,9 +149,6 @@ config GENERIC_GPIO | |||
148 | config ARCH_NO_VIRT_TO_BUS | 149 | config ARCH_NO_VIRT_TO_BUS |
149 | def_bool y | 150 | def_bool y |
150 | 151 | ||
151 | config OF | ||
152 | def_bool y | ||
153 | |||
154 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC | 152 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC |
155 | def_bool y if SPARC64 | 153 | def_bool y if SPARC64 |
156 | 154 | ||
diff --git a/arch/sparc/include/asm/device.h b/arch/sparc/include/asm/device.h index d4c452147412..daa6a8a5e9cd 100644 --- a/arch/sparc/include/asm/device.h +++ b/arch/sparc/include/asm/device.h | |||
@@ -6,18 +6,25 @@ | |||
6 | #ifndef _ASM_SPARC_DEVICE_H | 6 | #ifndef _ASM_SPARC_DEVICE_H |
7 | #define _ASM_SPARC_DEVICE_H | 7 | #define _ASM_SPARC_DEVICE_H |
8 | 8 | ||
9 | #include <asm/openprom.h> | ||
10 | |||
9 | struct device_node; | 11 | struct device_node; |
10 | struct of_device; | 12 | struct platform_device; |
11 | 13 | ||
12 | struct dev_archdata { | 14 | struct dev_archdata { |
13 | void *iommu; | 15 | void *iommu; |
14 | void *stc; | 16 | void *stc; |
15 | void *host_controller; | 17 | void *host_controller; |
16 | struct of_device *op; | 18 | struct platform_device *op; |
17 | int numa_node; | 19 | int numa_node; |
18 | }; | 20 | }; |
19 | 21 | ||
22 | extern void of_propagate_archdata(struct platform_device *bus); | ||
23 | |||
20 | struct pdev_archdata { | 24 | struct pdev_archdata { |
25 | struct resource resource[PROMREG_MAX]; | ||
26 | unsigned int irqs[PROMINTR_MAX]; | ||
27 | int num_irqs; | ||
21 | }; | 28 | }; |
22 | 29 | ||
23 | #endif /* _ASM_SPARC_DEVICE_H */ | 30 | #endif /* _ASM_SPARC_DEVICE_H */ |
diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h index 8fac3ab22f36..6597ce874d78 100644 --- a/arch/sparc/include/asm/floppy_64.h +++ b/arch/sparc/include/asm/floppy_64.h | |||
@@ -43,7 +43,7 @@ struct sun_flpy_controller { | |||
43 | /* You'll only ever find one controller on an Ultra anyways. */ | 43 | /* You'll only ever find one controller on an Ultra anyways. */ |
44 | static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1; | 44 | static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1; |
45 | unsigned long fdc_status; | 45 | unsigned long fdc_status; |
46 | static struct of_device *floppy_op = NULL; | 46 | static struct platform_device *floppy_op = NULL; |
47 | 47 | ||
48 | struct sun_floppy_ops { | 48 | struct sun_floppy_ops { |
49 | unsigned char (*fd_inb) (unsigned long port); | 49 | unsigned char (*fd_inb) (unsigned long port); |
@@ -548,7 +548,7 @@ static unsigned long __init sun_floppy_init(void) | |||
548 | { | 548 | { |
549 | static int initialized = 0; | 549 | static int initialized = 0; |
550 | struct device_node *dp; | 550 | struct device_node *dp; |
551 | struct of_device *op; | 551 | struct platform_device *op; |
552 | const char *prop; | 552 | const char *prop; |
553 | char state[128]; | 553 | char state[128]; |
554 | 554 | ||
@@ -567,7 +567,7 @@ static unsigned long __init sun_floppy_init(void) | |||
567 | } | 567 | } |
568 | if (op) { | 568 | if (op) { |
569 | floppy_op = op; | 569 | floppy_op = op; |
570 | FLOPPY_IRQ = op->irqs[0]; | 570 | FLOPPY_IRQ = op->archdata.irqs[0]; |
571 | } else { | 571 | } else { |
572 | struct device_node *ebus_dp; | 572 | struct device_node *ebus_dp; |
573 | void __iomem *auxio_reg; | 573 | void __iomem *auxio_reg; |
@@ -593,7 +593,7 @@ static unsigned long __init sun_floppy_init(void) | |||
593 | if (state_prop && !strncmp(state_prop, "disabled", 8)) | 593 | if (state_prop && !strncmp(state_prop, "disabled", 8)) |
594 | return 0; | 594 | return 0; |
595 | 595 | ||
596 | FLOPPY_IRQ = op->irqs[0]; | 596 | FLOPPY_IRQ = op->archdata.irqs[0]; |
597 | 597 | ||
598 | /* Make sure the high density bit is set, some systems | 598 | /* Make sure the high density bit is set, some systems |
599 | * (most notably Ultra5/Ultra10) come up with it clear. | 599 | * (most notably Ultra5/Ultra10) come up with it clear. |
@@ -661,7 +661,7 @@ static unsigned long __init sun_floppy_init(void) | |||
661 | config = 0; | 661 | config = 0; |
662 | for (dp = ebus_dp->child; dp; dp = dp->sibling) { | 662 | for (dp = ebus_dp->child; dp; dp = dp->sibling) { |
663 | if (!strcmp(dp->name, "ecpp")) { | 663 | if (!strcmp(dp->name, "ecpp")) { |
664 | struct of_device *ecpp_op; | 664 | struct platform_device *ecpp_op; |
665 | 665 | ||
666 | ecpp_op = of_find_device_by_node(dp); | 666 | ecpp_op = of_find_device_by_node(dp); |
667 | if (ecpp_op) | 667 | if (ecpp_op) |
diff --git a/arch/sparc/include/asm/of_device.h b/arch/sparc/include/asm/of_device.h deleted file mode 100644 index f320246a0586..000000000000 --- a/arch/sparc/include/asm/of_device.h +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #ifndef _ASM_SPARC_OF_DEVICE_H | ||
2 | #define _ASM_SPARC_OF_DEVICE_H | ||
3 | #ifdef __KERNEL__ | ||
4 | |||
5 | #include <linux/device.h> | ||
6 | #include <linux/of.h> | ||
7 | #include <linux/mod_devicetable.h> | ||
8 | #include <asm/openprom.h> | ||
9 | |||
10 | /* | ||
11 | * The of_device is a kind of "base class" that is a superset of | ||
12 | * struct device for use by devices attached to an OF node and | ||
13 | * probed using OF properties. | ||
14 | */ | ||
15 | struct of_device | ||
16 | { | ||
17 | struct device dev; | ||
18 | struct resource resource[PROMREG_MAX]; | ||
19 | unsigned int irqs[PROMINTR_MAX]; | ||
20 | int num_irqs; | ||
21 | |||
22 | void *sysdata; | ||
23 | |||
24 | int slot; | ||
25 | int portid; | ||
26 | int clock_freq; | ||
27 | }; | ||
28 | |||
29 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); | ||
30 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); | ||
31 | |||
32 | extern void of_propagate_archdata(struct of_device *bus); | ||
33 | |||
34 | /* This is just here during the transition */ | ||
35 | #include <linux/of_platform.h> | ||
36 | |||
37 | #endif /* __KERNEL__ */ | ||
38 | #endif /* _ASM_SPARC_OF_DEVICE_H */ | ||
diff --git a/arch/sparc/include/asm/of_platform.h b/arch/sparc/include/asm/of_platform.h deleted file mode 100644 index 90da99059f83..000000000000 --- a/arch/sparc/include/asm/of_platform.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | #ifndef ___ASM_SPARC_OF_PLATFORM_H | ||
2 | #define ___ASM_SPARC_OF_PLATFORM_H | ||
3 | /* | ||
4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * Modified for Sparc by merging parts of asm/of_device.h | ||
7 | * by Stephen Rothwell | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #define of_bus_type of_platform_bus_type /* for compatibility */ | ||
17 | |||
18 | #endif | ||
diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h index c333b8d0949b..4f7afa01b2ae 100644 --- a/arch/sparc/include/asm/parport.h +++ b/arch/sparc/include/asm/parport.h | |||
@@ -103,7 +103,7 @@ static inline unsigned int get_dma_residue(unsigned int dmanr) | |||
103 | return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info); | 103 | return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info); |
104 | } | 104 | } |
105 | 105 | ||
106 | static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id *match) | 106 | static int __devinit ecpp_probe(struct platform_device *op, const struct of_device_id *match) |
107 | { | 107 | { |
108 | unsigned long base = op->resource[0].start; | 108 | unsigned long base = op->resource[0].start; |
109 | unsigned long config = op->resource[1].start; | 109 | unsigned long config = op->resource[1].start; |
@@ -116,7 +116,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id | |||
116 | parent = op->dev.of_node->parent; | 116 | parent = op->dev.of_node->parent; |
117 | if (!strcmp(parent->name, "dma")) { | 117 | if (!strcmp(parent->name, "dma")) { |
118 | p = parport_pc_probe_port(base, base + 0x400, | 118 | p = parport_pc_probe_port(base, base + 0x400, |
119 | op->irqs[0], PARPORT_DMA_NOFIFO, | 119 | op->archdata.irqs[0], PARPORT_DMA_NOFIFO, |
120 | op->dev.parent->parent, 0); | 120 | op->dev.parent->parent, 0); |
121 | if (!p) | 121 | if (!p) |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
@@ -166,7 +166,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id | |||
166 | 0, PTR_LPT_REG_DIR); | 166 | 0, PTR_LPT_REG_DIR); |
167 | 167 | ||
168 | p = parport_pc_probe_port(base, base + 0x400, | 168 | p = parport_pc_probe_port(base, base + 0x400, |
169 | op->irqs[0], | 169 | op->archdata.irqs[0], |
170 | slot, | 170 | slot, |
171 | op->dev.parent, | 171 | op->dev.parent, |
172 | 0); | 172 | 0); |
@@ -192,7 +192,7 @@ out_err: | |||
192 | return err; | 192 | return err; |
193 | } | 193 | } |
194 | 194 | ||
195 | static int __devexit ecpp_remove(struct of_device *op) | 195 | static int __devexit ecpp_remove(struct platform_device *op) |
196 | { | 196 | { |
197 | struct parport *p = dev_get_drvdata(&op->dev); | 197 | struct parport *p = dev_get_drvdata(&op->dev); |
198 | int slot = p->dma; | 198 | int slot = p->dma; |
@@ -243,9 +243,7 @@ static struct of_platform_driver ecpp_driver = { | |||
243 | 243 | ||
244 | static int parport_pc_find_nonpci_ports(int autoirq, int autodma) | 244 | static int parport_pc_find_nonpci_ports(int autoirq, int autodma) |
245 | { | 245 | { |
246 | of_register_driver(&ecpp_driver, &of_bus_type); | 246 | return of_register_platform_driver(&ecpp_driver); |
247 | |||
248 | return 0; | ||
249 | } | 247 | } |
250 | 248 | ||
251 | #endif /* !(_ASM_SPARC64_PARPORT_H */ | 249 | #endif /* !(_ASM_SPARC64_PARPORT_H */ |
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h index f845828ca4c6..291f12575edd 100644 --- a/arch/sparc/include/asm/prom.h +++ b/arch/sparc/include/asm/prom.h | |||
@@ -43,20 +43,22 @@ extern int of_getintprop_default(struct device_node *np, | |||
43 | extern int of_find_in_proplist(const char *list, const char *match, int len); | 43 | extern int of_find_in_proplist(const char *list, const char *match, int len); |
44 | #ifdef CONFIG_NUMA | 44 | #ifdef CONFIG_NUMA |
45 | extern int of_node_to_nid(struct device_node *dp); | 45 | extern int of_node_to_nid(struct device_node *dp); |
46 | #else | 46 | #define of_node_to_nid of_node_to_nid |
47 | #define of_node_to_nid(dp) (-1) | ||
48 | #endif | 47 | #endif |
49 | 48 | ||
50 | extern void prom_build_devicetree(void); | 49 | extern void prom_build_devicetree(void); |
51 | extern void of_populate_present_mask(void); | 50 | extern void of_populate_present_mask(void); |
52 | extern void of_fill_in_cpu_data(void); | 51 | extern void of_fill_in_cpu_data(void); |
53 | 52 | ||
53 | struct resource; | ||
54 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); | ||
55 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); | ||
56 | |||
54 | /* These routines are here to provide compatibility with how powerpc | 57 | /* These routines are here to provide compatibility with how powerpc |
55 | * handles IRQ mapping for OF device nodes. We precompute and permanently | 58 | * handles IRQ mapping for OF device nodes. We precompute and permanently |
56 | * register them in the of_device objects, whereas powerpc computes them | 59 | * register them in the platform_device objects, whereas powerpc computes them |
57 | * on request. | 60 | * on request. |
58 | */ | 61 | */ |
59 | extern unsigned int irq_of_parse_and_map(struct device_node *node, int index); | ||
60 | static inline void irq_dispose_mapping(unsigned int virq) | 62 | static inline void irq_dispose_mapping(unsigned int virq) |
61 | { | 63 | { |
62 | } | 64 | } |
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c index b27476caa133..2c0046ecc715 100644 --- a/arch/sparc/kernel/apc.c +++ b/arch/sparc/kernel/apc.c | |||
@@ -68,7 +68,7 @@ static void apc_swift_idle(void) | |||
68 | #endif | 68 | #endif |
69 | } | 69 | } |
70 | 70 | ||
71 | static inline void apc_free(struct of_device *op) | 71 | static inline void apc_free(struct platform_device *op) |
72 | { | 72 | { |
73 | of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0])); | 73 | of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0])); |
74 | } | 74 | } |
@@ -136,7 +136,7 @@ static const struct file_operations apc_fops = { | |||
136 | 136 | ||
137 | static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; | 137 | static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; |
138 | 138 | ||
139 | static int __devinit apc_probe(struct of_device *op, | 139 | static int __devinit apc_probe(struct platform_device *op, |
140 | const struct of_device_id *match) | 140 | const struct of_device_id *match) |
141 | { | 141 | { |
142 | int err; | 142 | int err; |
@@ -184,7 +184,7 @@ static struct of_platform_driver apc_driver = { | |||
184 | 184 | ||
185 | static int __init apc_init(void) | 185 | static int __init apc_init(void) |
186 | { | 186 | { |
187 | return of_register_driver(&apc_driver, &of_bus_type); | 187 | return of_register_platform_driver(&apc_driver); |
188 | } | 188 | } |
189 | 189 | ||
190 | /* This driver is not critical to the boot process | 190 | /* This driver is not critical to the boot process |
diff --git a/arch/sparc/kernel/auxio_64.c b/arch/sparc/kernel/auxio_64.c index ddc84128b3c2..3efd3c5af6a9 100644 --- a/arch/sparc/kernel/auxio_64.c +++ b/arch/sparc/kernel/auxio_64.c | |||
@@ -102,7 +102,8 @@ static struct of_device_id __initdata auxio_match[] = { | |||
102 | 102 | ||
103 | MODULE_DEVICE_TABLE(of, auxio_match); | 103 | MODULE_DEVICE_TABLE(of, auxio_match); |
104 | 104 | ||
105 | static int __devinit auxio_probe(struct of_device *dev, const struct of_device_id *match) | 105 | static int __devinit auxio_probe(struct platform_device *dev, |
106 | const struct of_device_id *match) | ||
106 | { | 107 | { |
107 | struct device_node *dp = dev->dev.of_node; | 108 | struct device_node *dp = dev->dev.of_node; |
108 | unsigned long size; | 109 | unsigned long size; |
@@ -142,7 +143,7 @@ static struct of_platform_driver auxio_driver = { | |||
142 | 143 | ||
143 | static int __init auxio_init(void) | 144 | static int __init auxio_init(void) |
144 | { | 145 | { |
145 | return of_register_driver(&auxio_driver, &of_platform_bus_type); | 146 | return of_register_platform_driver(&auxio_driver); |
146 | } | 147 | } |
147 | 148 | ||
148 | /* Must be after subsys_initcall() so that busses are probed. Must | 149 | /* Must be after subsys_initcall() so that busses are probed. Must |
diff --git a/arch/sparc/kernel/central.c b/arch/sparc/kernel/central.c index 434335f65823..cfa2624c5332 100644 --- a/arch/sparc/kernel/central.c +++ b/arch/sparc/kernel/central.c | |||
@@ -59,7 +59,7 @@ static int __devinit clock_board_calc_nslots(struct clock_board *p) | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | static int __devinit clock_board_probe(struct of_device *op, | 62 | static int __devinit clock_board_probe(struct platform_device *op, |
63 | const struct of_device_id *match) | 63 | const struct of_device_id *match) |
64 | { | 64 | { |
65 | struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL); | 65 | struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL); |
@@ -157,7 +157,7 @@ static struct of_platform_driver clock_board_driver = { | |||
157 | }, | 157 | }, |
158 | }; | 158 | }; |
159 | 159 | ||
160 | static int __devinit fhc_probe(struct of_device *op, | 160 | static int __devinit fhc_probe(struct platform_device *op, |
161 | const struct of_device_id *match) | 161 | const struct of_device_id *match) |
162 | { | 162 | { |
163 | struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL); | 163 | struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL); |
@@ -265,8 +265,8 @@ static struct of_platform_driver fhc_driver = { | |||
265 | 265 | ||
266 | static int __init sunfire_init(void) | 266 | static int __init sunfire_init(void) |
267 | { | 267 | { |
268 | (void) of_register_driver(&fhc_driver, &of_platform_bus_type); | 268 | (void) of_register_platform_driver(&fhc_driver); |
269 | (void) of_register_driver(&clock_board_driver, &of_platform_bus_type); | 269 | (void) of_register_platform_driver(&clock_board_driver); |
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
272 | 272 | ||
diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c index 870cb65b3f21..08c466ebb32b 100644 --- a/arch/sparc/kernel/chmc.c +++ b/arch/sparc/kernel/chmc.c | |||
@@ -392,7 +392,7 @@ static void __devinit jbusmc_construct_dimm_groups(struct jbusmc *p, | |||
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | static int __devinit jbusmc_probe(struct of_device *op, | 395 | static int __devinit jbusmc_probe(struct platform_device *op, |
396 | const struct of_device_id *match) | 396 | const struct of_device_id *match) |
397 | { | 397 | { |
398 | const struct linux_prom64_registers *mem_regs; | 398 | const struct linux_prom64_registers *mem_regs; |
@@ -690,7 +690,7 @@ static void chmc_fetch_decode_regs(struct chmc *p) | |||
690 | chmc_read_mcreg(p, CHMCTRL_DECODE4)); | 690 | chmc_read_mcreg(p, CHMCTRL_DECODE4)); |
691 | } | 691 | } |
692 | 692 | ||
693 | static int __devinit chmc_probe(struct of_device *op, | 693 | static int __devinit chmc_probe(struct platform_device *op, |
694 | const struct of_device_id *match) | 694 | const struct of_device_id *match) |
695 | { | 695 | { |
696 | struct device_node *dp = op->dev.of_node; | 696 | struct device_node *dp = op->dev.of_node; |
@@ -765,7 +765,7 @@ out_free: | |||
765 | goto out; | 765 | goto out; |
766 | } | 766 | } |
767 | 767 | ||
768 | static int __devinit us3mc_probe(struct of_device *op, | 768 | static int __devinit us3mc_probe(struct platform_device *op, |
769 | const struct of_device_id *match) | 769 | const struct of_device_id *match) |
770 | { | 770 | { |
771 | if (mc_type == MC_TYPE_SAFARI) | 771 | if (mc_type == MC_TYPE_SAFARI) |
@@ -775,21 +775,21 @@ static int __devinit us3mc_probe(struct of_device *op, | |||
775 | return -ENODEV; | 775 | return -ENODEV; |
776 | } | 776 | } |
777 | 777 | ||
778 | static void __devexit chmc_destroy(struct of_device *op, struct chmc *p) | 778 | static void __devexit chmc_destroy(struct platform_device *op, struct chmc *p) |
779 | { | 779 | { |
780 | list_del(&p->list); | 780 | list_del(&p->list); |
781 | of_iounmap(&op->resource[0], p->regs, 0x48); | 781 | of_iounmap(&op->resource[0], p->regs, 0x48); |
782 | kfree(p); | 782 | kfree(p); |
783 | } | 783 | } |
784 | 784 | ||
785 | static void __devexit jbusmc_destroy(struct of_device *op, struct jbusmc *p) | 785 | static void __devexit jbusmc_destroy(struct platform_device *op, struct jbusmc *p) |
786 | { | 786 | { |
787 | mc_list_del(&p->list); | 787 | mc_list_del(&p->list); |
788 | of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE); | 788 | of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE); |
789 | kfree(p); | 789 | kfree(p); |
790 | } | 790 | } |
791 | 791 | ||
792 | static int __devexit us3mc_remove(struct of_device *op) | 792 | static int __devexit us3mc_remove(struct platform_device *op) |
793 | { | 793 | { |
794 | void *p = dev_get_drvdata(&op->dev); | 794 | void *p = dev_get_drvdata(&op->dev); |
795 | 795 | ||
@@ -848,7 +848,7 @@ static int __init us3mc_init(void) | |||
848 | ret = register_dimm_printer(us3mc_dimm_printer); | 848 | ret = register_dimm_printer(us3mc_dimm_printer); |
849 | 849 | ||
850 | if (!ret) { | 850 | if (!ret) { |
851 | ret = of_register_driver(&us3mc_driver, &of_bus_type); | 851 | ret = of_register_platform_driver(&us3mc_driver); |
852 | if (ret) | 852 | if (ret) |
853 | unregister_dimm_printer(us3mc_dimm_printer); | 853 | unregister_dimm_printer(us3mc_dimm_printer); |
854 | } | 854 | } |
@@ -859,7 +859,7 @@ static void __exit us3mc_cleanup(void) | |||
859 | { | 859 | { |
860 | if (us3mc_platform()) { | 860 | if (us3mc_platform()) { |
861 | unregister_dimm_printer(us3mc_dimm_printer); | 861 | unregister_dimm_printer(us3mc_dimm_printer); |
862 | of_unregister_driver(&us3mc_driver); | 862 | of_unregister_platform_driver(&us3mc_driver); |
863 | } | 863 | } |
864 | } | 864 | } |
865 | 865 | ||
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 703e4aa9bc38..41f7e4e0f72a 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(sbus_set_sbus64); | |||
253 | static void *sbus_alloc_coherent(struct device *dev, size_t len, | 253 | static void *sbus_alloc_coherent(struct device *dev, size_t len, |
254 | dma_addr_t *dma_addrp, gfp_t gfp) | 254 | dma_addr_t *dma_addrp, gfp_t gfp) |
255 | { | 255 | { |
256 | struct of_device *op = to_of_device(dev); | 256 | struct platform_device *op = to_platform_device(dev); |
257 | unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; | 257 | unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; |
258 | unsigned long va; | 258 | unsigned long va; |
259 | struct resource *res; | 259 | struct resource *res; |
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 47e63f1e719c..2d055a1e9cc2 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c | |||
@@ -241,10 +241,10 @@ static int __init use_1to1_mapping(struct device_node *pp) | |||
241 | 241 | ||
242 | static int of_resource_verbose; | 242 | static int of_resource_verbose; |
243 | 243 | ||
244 | static void __init build_device_resources(struct of_device *op, | 244 | static void __init build_device_resources(struct platform_device *op, |
245 | struct device *parent) | 245 | struct device *parent) |
246 | { | 246 | { |
247 | struct of_device *p_op; | 247 | struct platform_device *p_op; |
248 | struct of_bus *bus; | 248 | struct of_bus *bus; |
249 | int na, ns; | 249 | int na, ns; |
250 | int index, num_reg; | 250 | int index, num_reg; |
@@ -253,7 +253,7 @@ static void __init build_device_resources(struct of_device *op, | |||
253 | if (!parent) | 253 | if (!parent) |
254 | return; | 254 | return; |
255 | 255 | ||
256 | p_op = to_of_device(parent); | 256 | p_op = to_platform_device(parent); |
257 | bus = of_match_bus(p_op->dev.of_node); | 257 | bus = of_match_bus(p_op->dev.of_node); |
258 | bus->count_cells(op->dev.of_node, &na, &ns); | 258 | bus->count_cells(op->dev.of_node, &na, &ns); |
259 | 259 | ||
@@ -267,6 +267,8 @@ static void __init build_device_resources(struct of_device *op, | |||
267 | /* Conver to num-entries. */ | 267 | /* Conver to num-entries. */ |
268 | num_reg /= na + ns; | 268 | num_reg /= na + ns; |
269 | 269 | ||
270 | op->resource = op->archdata.resource; | ||
271 | op->num_resources = num_reg; | ||
270 | for (index = 0; index < num_reg; index++) { | 272 | for (index = 0; index < num_reg; index++) { |
271 | struct resource *r = &op->resource[index]; | 273 | struct resource *r = &op->resource[index]; |
272 | u32 addr[OF_MAX_ADDR_CELLS]; | 274 | u32 addr[OF_MAX_ADDR_CELLS]; |
@@ -333,10 +335,10 @@ static void __init build_device_resources(struct of_device *op, | |||
333 | } | 335 | } |
334 | } | 336 | } |
335 | 337 | ||
336 | static struct of_device * __init scan_one_device(struct device_node *dp, | 338 | static struct platform_device * __init scan_one_device(struct device_node *dp, |
337 | struct device *parent) | 339 | struct device *parent) |
338 | { | 340 | { |
339 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); | 341 | struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL); |
340 | const struct linux_prom_irqs *intr; | 342 | const struct linux_prom_irqs *intr; |
341 | struct dev_archdata *sd; | 343 | struct dev_archdata *sd; |
342 | int len, i; | 344 | int len, i; |
@@ -349,27 +351,21 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
349 | 351 | ||
350 | op->dev.of_node = dp; | 352 | op->dev.of_node = dp; |
351 | 353 | ||
352 | op->clock_freq = of_getintprop_default(dp, "clock-frequency", | ||
353 | (25*1000*1000)); | ||
354 | op->portid = of_getintprop_default(dp, "upa-portid", -1); | ||
355 | if (op->portid == -1) | ||
356 | op->portid = of_getintprop_default(dp, "portid", -1); | ||
357 | |||
358 | intr = of_get_property(dp, "intr", &len); | 354 | intr = of_get_property(dp, "intr", &len); |
359 | if (intr) { | 355 | if (intr) { |
360 | op->num_irqs = len / sizeof(struct linux_prom_irqs); | 356 | op->archdata.num_irqs = len / sizeof(struct linux_prom_irqs); |
361 | for (i = 0; i < op->num_irqs; i++) | 357 | for (i = 0; i < op->archdata.num_irqs; i++) |
362 | op->irqs[i] = intr[i].pri; | 358 | op->archdata.irqs[i] = intr[i].pri; |
363 | } else { | 359 | } else { |
364 | const unsigned int *irq = | 360 | const unsigned int *irq = |
365 | of_get_property(dp, "interrupts", &len); | 361 | of_get_property(dp, "interrupts", &len); |
366 | 362 | ||
367 | if (irq) { | 363 | if (irq) { |
368 | op->num_irqs = len / sizeof(unsigned int); | 364 | op->archdata.num_irqs = len / sizeof(unsigned int); |
369 | for (i = 0; i < op->num_irqs; i++) | 365 | for (i = 0; i < op->archdata.num_irqs; i++) |
370 | op->irqs[i] = irq[i]; | 366 | op->archdata.irqs[i] = irq[i]; |
371 | } else { | 367 | } else { |
372 | op->num_irqs = 0; | 368 | op->archdata.num_irqs = 0; |
373 | } | 369 | } |
374 | } | 370 | } |
375 | if (sparc_cpu_model == sun4d) { | 371 | if (sparc_cpu_model == sun4d) { |
@@ -411,8 +407,8 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
411 | goto build_resources; | 407 | goto build_resources; |
412 | } | 408 | } |
413 | 409 | ||
414 | for (i = 0; i < op->num_irqs; i++) { | 410 | for (i = 0; i < op->archdata.num_irqs; i++) { |
415 | int this_irq = op->irqs[i]; | 411 | int this_irq = op->archdata.irqs[i]; |
416 | int sbusl = pil_to_sbus[this_irq]; | 412 | int sbusl = pil_to_sbus[this_irq]; |
417 | 413 | ||
418 | if (sbusl) | 414 | if (sbusl) |
@@ -420,7 +416,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
420 | (sbusl << 2) + | 416 | (sbusl << 2) + |
421 | slot); | 417 | slot); |
422 | 418 | ||
423 | op->irqs[i] = this_irq; | 419 | op->archdata.irqs[i] = this_irq; |
424 | } | 420 | } |
425 | } | 421 | } |
426 | 422 | ||
@@ -428,7 +424,7 @@ build_resources: | |||
428 | build_device_resources(op, parent); | 424 | build_device_resources(op, parent); |
429 | 425 | ||
430 | op->dev.parent = parent; | 426 | op->dev.parent = parent; |
431 | op->dev.bus = &of_platform_bus_type; | 427 | op->dev.bus = &platform_bus_type; |
432 | if (!parent) | 428 | if (!parent) |
433 | dev_set_name(&op->dev, "root"); | 429 | dev_set_name(&op->dev, "root"); |
434 | else | 430 | else |
@@ -447,7 +443,7 @@ build_resources: | |||
447 | static void __init scan_tree(struct device_node *dp, struct device *parent) | 443 | static void __init scan_tree(struct device_node *dp, struct device *parent) |
448 | { | 444 | { |
449 | while (dp) { | 445 | while (dp) { |
450 | struct of_device *op = scan_one_device(dp, parent); | 446 | struct platform_device *op = scan_one_device(dp, parent); |
451 | 447 | ||
452 | if (op) | 448 | if (op) |
453 | scan_tree(dp->child, &op->dev); | 449 | scan_tree(dp->child, &op->dev); |
@@ -456,30 +452,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent) | |||
456 | } | 452 | } |
457 | } | 453 | } |
458 | 454 | ||
459 | static void __init scan_of_devices(void) | 455 | static int __init scan_of_devices(void) |
460 | { | 456 | { |
461 | struct device_node *root = of_find_node_by_path("/"); | 457 | struct device_node *root = of_find_node_by_path("/"); |
462 | struct of_device *parent; | 458 | struct platform_device *parent; |
463 | 459 | ||
464 | parent = scan_one_device(root, NULL); | 460 | parent = scan_one_device(root, NULL); |
465 | if (!parent) | 461 | if (!parent) |
466 | return; | 462 | return 0; |
467 | 463 | ||
468 | scan_tree(root->child, &parent->dev); | 464 | scan_tree(root->child, &parent->dev); |
465 | return 0; | ||
469 | } | 466 | } |
470 | 467 | postcore_initcall(scan_of_devices); | |
471 | static int __init of_bus_driver_init(void) | ||
472 | { | ||
473 | int err; | ||
474 | |||
475 | err = of_bus_type_init(&of_platform_bus_type, "of"); | ||
476 | if (!err) | ||
477 | scan_of_devices(); | ||
478 | |||
479 | return err; | ||
480 | } | ||
481 | |||
482 | postcore_initcall(of_bus_driver_init); | ||
483 | 468 | ||
484 | static int __init of_debug(char *str) | 469 | static int __init of_debug(char *str) |
485 | { | 470 | { |
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 1dae8079f728..63cd4e5d47c2 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
@@ -310,10 +310,10 @@ static int __init use_1to1_mapping(struct device_node *pp) | |||
310 | 310 | ||
311 | static int of_resource_verbose; | 311 | static int of_resource_verbose; |
312 | 312 | ||
313 | static void __init build_device_resources(struct of_device *op, | 313 | static void __init build_device_resources(struct platform_device *op, |
314 | struct device *parent) | 314 | struct device *parent) |
315 | { | 315 | { |
316 | struct of_device *p_op; | 316 | struct platform_device *p_op; |
317 | struct of_bus *bus; | 317 | struct of_bus *bus; |
318 | int na, ns; | 318 | int na, ns; |
319 | int index, num_reg; | 319 | int index, num_reg; |
@@ -322,7 +322,7 @@ static void __init build_device_resources(struct of_device *op, | |||
322 | if (!parent) | 322 | if (!parent) |
323 | return; | 323 | return; |
324 | 324 | ||
325 | p_op = to_of_device(parent); | 325 | p_op = to_platform_device(parent); |
326 | bus = of_match_bus(p_op->dev.of_node); | 326 | bus = of_match_bus(p_op->dev.of_node); |
327 | bus->count_cells(op->dev.of_node, &na, &ns); | 327 | bus->count_cells(op->dev.of_node, &na, &ns); |
328 | 328 | ||
@@ -344,6 +344,8 @@ static void __init build_device_resources(struct of_device *op, | |||
344 | num_reg = PROMREG_MAX; | 344 | num_reg = PROMREG_MAX; |
345 | } | 345 | } |
346 | 346 | ||
347 | op->resource = op->archdata.resource; | ||
348 | op->num_resources = num_reg; | ||
347 | for (index = 0; index < num_reg; index++) { | 349 | for (index = 0; index < num_reg; index++) { |
348 | struct resource *r = &op->resource[index]; | 350 | struct resource *r = &op->resource[index]; |
349 | u32 addr[OF_MAX_ADDR_CELLS]; | 351 | u32 addr[OF_MAX_ADDR_CELLS]; |
@@ -526,7 +528,7 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp, | |||
526 | 528 | ||
527 | static int of_irq_verbose; | 529 | static int of_irq_verbose; |
528 | 530 | ||
529 | static unsigned int __init build_one_device_irq(struct of_device *op, | 531 | static unsigned int __init build_one_device_irq(struct platform_device *op, |
530 | struct device *parent, | 532 | struct device *parent, |
531 | unsigned int irq) | 533 | unsigned int irq) |
532 | { | 534 | { |
@@ -628,10 +630,10 @@ out: | |||
628 | return irq; | 630 | return irq; |
629 | } | 631 | } |
630 | 632 | ||
631 | static struct of_device * __init scan_one_device(struct device_node *dp, | 633 | static struct platform_device * __init scan_one_device(struct device_node *dp, |
632 | struct device *parent) | 634 | struct device *parent) |
633 | { | 635 | { |
634 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); | 636 | struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL); |
635 | const unsigned int *irq; | 637 | const unsigned int *irq; |
636 | struct dev_archdata *sd; | 638 | struct dev_archdata *sd; |
637 | int len, i; | 639 | int len, i; |
@@ -644,34 +646,28 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
644 | 646 | ||
645 | op->dev.of_node = dp; | 647 | op->dev.of_node = dp; |
646 | 648 | ||
647 | op->clock_freq = of_getintprop_default(dp, "clock-frequency", | ||
648 | (25*1000*1000)); | ||
649 | op->portid = of_getintprop_default(dp, "upa-portid", -1); | ||
650 | if (op->portid == -1) | ||
651 | op->portid = of_getintprop_default(dp, "portid", -1); | ||
652 | |||
653 | irq = of_get_property(dp, "interrupts", &len); | 649 | irq = of_get_property(dp, "interrupts", &len); |
654 | if (irq) { | 650 | if (irq) { |
655 | op->num_irqs = len / 4; | 651 | op->archdata.num_irqs = len / 4; |
656 | 652 | ||
657 | /* Prevent overrunning the op->irqs[] array. */ | 653 | /* Prevent overrunning the op->irqs[] array. */ |
658 | if (op->num_irqs > PROMINTR_MAX) { | 654 | if (op->archdata.num_irqs > PROMINTR_MAX) { |
659 | printk(KERN_WARNING "%s: Too many irqs (%d), " | 655 | printk(KERN_WARNING "%s: Too many irqs (%d), " |
660 | "limiting to %d.\n", | 656 | "limiting to %d.\n", |
661 | dp->full_name, op->num_irqs, PROMINTR_MAX); | 657 | dp->full_name, op->archdata.num_irqs, PROMINTR_MAX); |
662 | op->num_irqs = PROMINTR_MAX; | 658 | op->archdata.num_irqs = PROMINTR_MAX; |
663 | } | 659 | } |
664 | memcpy(op->irqs, irq, op->num_irqs * 4); | 660 | memcpy(op->archdata.irqs, irq, op->archdata.num_irqs * 4); |
665 | } else { | 661 | } else { |
666 | op->num_irqs = 0; | 662 | op->archdata.num_irqs = 0; |
667 | } | 663 | } |
668 | 664 | ||
669 | build_device_resources(op, parent); | 665 | build_device_resources(op, parent); |
670 | for (i = 0; i < op->num_irqs; i++) | 666 | for (i = 0; i < op->archdata.num_irqs; i++) |
671 | op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]); | 667 | op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]); |
672 | 668 | ||
673 | op->dev.parent = parent; | 669 | op->dev.parent = parent; |
674 | op->dev.bus = &of_platform_bus_type; | 670 | op->dev.bus = &platform_bus_type; |
675 | if (!parent) | 671 | if (!parent) |
676 | dev_set_name(&op->dev, "root"); | 672 | dev_set_name(&op->dev, "root"); |
677 | else | 673 | else |
@@ -690,7 +686,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
690 | static void __init scan_tree(struct device_node *dp, struct device *parent) | 686 | static void __init scan_tree(struct device_node *dp, struct device *parent) |
691 | { | 687 | { |
692 | while (dp) { | 688 | while (dp) { |
693 | struct of_device *op = scan_one_device(dp, parent); | 689 | struct platform_device *op = scan_one_device(dp, parent); |
694 | 690 | ||
695 | if (op) | 691 | if (op) |
696 | scan_tree(dp->child, &op->dev); | 692 | scan_tree(dp->child, &op->dev); |
@@ -699,30 +695,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent) | |||
699 | } | 695 | } |
700 | } | 696 | } |
701 | 697 | ||
702 | static void __init scan_of_devices(void) | 698 | static int __init scan_of_devices(void) |
703 | { | 699 | { |
704 | struct device_node *root = of_find_node_by_path("/"); | 700 | struct device_node *root = of_find_node_by_path("/"); |
705 | struct of_device *parent; | 701 | struct platform_device *parent; |
706 | 702 | ||
707 | parent = scan_one_device(root, NULL); | 703 | parent = scan_one_device(root, NULL); |
708 | if (!parent) | 704 | if (!parent) |
709 | return; | 705 | return 0; |
710 | 706 | ||
711 | scan_tree(root->child, &parent->dev); | 707 | scan_tree(root->child, &parent->dev); |
708 | return 0; | ||
712 | } | 709 | } |
713 | 710 | postcore_initcall(scan_of_devices); | |
714 | static int __init of_bus_driver_init(void) | ||
715 | { | ||
716 | int err; | ||
717 | |||
718 | err = of_bus_type_init(&of_platform_bus_type, "of"); | ||
719 | if (!err) | ||
720 | scan_of_devices(); | ||
721 | |||
722 | return err; | ||
723 | } | ||
724 | |||
725 | postcore_initcall(of_bus_driver_init); | ||
726 | 711 | ||
727 | static int __init of_debug(char *str) | 712 | static int __init of_debug(char *str) |
728 | { | 713 | { |
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c index 10c6c36a6e75..49ddff56cb04 100644 --- a/arch/sparc/kernel/of_device_common.c +++ b/arch/sparc/kernel/of_device_common.c | |||
@@ -11,48 +11,28 @@ | |||
11 | 11 | ||
12 | #include "of_device_common.h" | 12 | #include "of_device_common.h" |
13 | 13 | ||
14 | static int node_match(struct device *dev, void *data) | ||
15 | { | ||
16 | struct of_device *op = to_of_device(dev); | ||
17 | struct device_node *dp = data; | ||
18 | |||
19 | return (op->dev.of_node == dp); | ||
20 | } | ||
21 | |||
22 | struct of_device *of_find_device_by_node(struct device_node *dp) | ||
23 | { | ||
24 | struct device *dev = bus_find_device(&of_platform_bus_type, NULL, | ||
25 | dp, node_match); | ||
26 | |||
27 | if (dev) | ||
28 | return to_of_device(dev); | ||
29 | |||
30 | return NULL; | ||
31 | } | ||
32 | EXPORT_SYMBOL(of_find_device_by_node); | ||
33 | |||
34 | unsigned int irq_of_parse_and_map(struct device_node *node, int index) | 14 | unsigned int irq_of_parse_and_map(struct device_node *node, int index) |
35 | { | 15 | { |
36 | struct of_device *op = of_find_device_by_node(node); | 16 | struct platform_device *op = of_find_device_by_node(node); |
37 | 17 | ||
38 | if (!op || index >= op->num_irqs) | 18 | if (!op || index >= op->archdata.num_irqs) |
39 | return 0; | 19 | return 0; |
40 | 20 | ||
41 | return op->irqs[index]; | 21 | return op->archdata.irqs[index]; |
42 | } | 22 | } |
43 | EXPORT_SYMBOL(irq_of_parse_and_map); | 23 | EXPORT_SYMBOL(irq_of_parse_and_map); |
44 | 24 | ||
45 | /* Take the archdata values for IOMMU, STC, and HOSTDATA found in | 25 | /* Take the archdata values for IOMMU, STC, and HOSTDATA found in |
46 | * BUS and propagate to all child of_device objects. | 26 | * BUS and propagate to all child platform_device objects. |
47 | */ | 27 | */ |
48 | void of_propagate_archdata(struct of_device *bus) | 28 | void of_propagate_archdata(struct platform_device *bus) |
49 | { | 29 | { |
50 | struct dev_archdata *bus_sd = &bus->dev.archdata; | 30 | struct dev_archdata *bus_sd = &bus->dev.archdata; |
51 | struct device_node *bus_dp = bus->dev.of_node; | 31 | struct device_node *bus_dp = bus->dev.of_node; |
52 | struct device_node *dp; | 32 | struct device_node *dp; |
53 | 33 | ||
54 | for (dp = bus_dp->child; dp; dp = dp->sibling) { | 34 | for (dp = bus_dp->child; dp; dp = dp->sibling) { |
55 | struct of_device *op = of_find_device_by_node(dp); | 35 | struct platform_device *op = of_find_device_by_node(dp); |
56 | 36 | ||
57 | op->dev.archdata.iommu = bus_sd->iommu; | 37 | op->dev.archdata.iommu = bus_sd->iommu; |
58 | op->dev.archdata.stc = bus_sd->stc; | 38 | op->dev.archdata.stc = bus_sd->stc; |
@@ -64,9 +44,6 @@ void of_propagate_archdata(struct of_device *bus) | |||
64 | } | 44 | } |
65 | } | 45 | } |
66 | 46 | ||
67 | struct bus_type of_platform_bus_type; | ||
68 | EXPORT_SYMBOL(of_platform_bus_type); | ||
69 | |||
70 | static void get_cells(struct device_node *dp, int *addrc, int *sizec) | 47 | static void get_cells(struct device_node *dp, int *addrc, int *sizec) |
71 | { | 48 | { |
72 | if (addrc) | 49 | if (addrc) |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 8a8363adb8bd..4137579d9adc 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -198,7 +198,7 @@ static unsigned long pci_parse_of_flags(u32 addr0) | |||
198 | * into physical address resources, we only have to figure out the register | 198 | * into physical address resources, we only have to figure out the register |
199 | * mapping. | 199 | * mapping. |
200 | */ | 200 | */ |
201 | static void pci_parse_of_addrs(struct of_device *op, | 201 | static void pci_parse_of_addrs(struct platform_device *op, |
202 | struct device_node *node, | 202 | struct device_node *node, |
203 | struct pci_dev *dev) | 203 | struct pci_dev *dev) |
204 | { | 204 | { |
@@ -248,7 +248,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | |||
248 | { | 248 | { |
249 | struct dev_archdata *sd; | 249 | struct dev_archdata *sd; |
250 | struct pci_slot *slot; | 250 | struct pci_slot *slot; |
251 | struct of_device *op; | 251 | struct platform_device *op; |
252 | struct pci_dev *dev; | 252 | struct pci_dev *dev; |
253 | const char *type; | 253 | const char *type; |
254 | u32 class; | 254 | u32 class; |
@@ -340,7 +340,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | |||
340 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; | 340 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; |
341 | dev->rom_base_reg = PCI_ROM_ADDRESS; | 341 | dev->rom_base_reg = PCI_ROM_ADDRESS; |
342 | 342 | ||
343 | dev->irq = sd->op->irqs[0]; | 343 | dev->irq = sd->op->archdata.irqs[0]; |
344 | if (dev->irq == 0xffffffff) | 344 | if (dev->irq == 0xffffffff) |
345 | dev->irq = PCI_IRQ_NONE; | 345 | dev->irq = PCI_IRQ_NONE; |
346 | } | 346 | } |
diff --git a/arch/sparc/kernel/pci_fire.c b/arch/sparc/kernel/pci_fire.c index 51cfa09e392a..efb896d68754 100644 --- a/arch/sparc/kernel/pci_fire.c +++ b/arch/sparc/kernel/pci_fire.c | |||
@@ -410,7 +410,7 @@ static void pci_fire_hw_init(struct pci_pbm_info *pbm) | |||
410 | } | 410 | } |
411 | 411 | ||
412 | static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm, | 412 | static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm, |
413 | struct of_device *op, u32 portid) | 413 | struct platform_device *op, u32 portid) |
414 | { | 414 | { |
415 | const struct linux_prom64_registers *regs; | 415 | const struct linux_prom64_registers *regs; |
416 | struct device_node *dp = op->dev.of_node; | 416 | struct device_node *dp = op->dev.of_node; |
@@ -455,7 +455,7 @@ static int __devinit pci_fire_pbm_init(struct pci_pbm_info *pbm, | |||
455 | return 0; | 455 | return 0; |
456 | } | 456 | } |
457 | 457 | ||
458 | static int __devinit fire_probe(struct of_device *op, | 458 | static int __devinit fire_probe(struct platform_device *op, |
459 | const struct of_device_id *match) | 459 | const struct of_device_id *match) |
460 | { | 460 | { |
461 | struct device_node *dp = op->dev.of_node; | 461 | struct device_node *dp = op->dev.of_node; |
@@ -518,7 +518,7 @@ static struct of_platform_driver fire_driver = { | |||
518 | 518 | ||
519 | static int __init fire_init(void) | 519 | static int __init fire_init(void) |
520 | { | 520 | { |
521 | return of_register_driver(&fire_driver, &of_bus_type); | 521 | return of_register_platform_driver(&fire_driver); |
522 | } | 522 | } |
523 | 523 | ||
524 | subsys_initcall(fire_init); | 524 | subsys_initcall(fire_init); |
diff --git a/arch/sparc/kernel/pci_impl.h b/arch/sparc/kernel/pci_impl.h index 03186824327e..e20ed5f06e9c 100644 --- a/arch/sparc/kernel/pci_impl.h +++ b/arch/sparc/kernel/pci_impl.h | |||
@@ -91,7 +91,7 @@ struct pci_pbm_info { | |||
91 | char *name; | 91 | char *name; |
92 | 92 | ||
93 | /* OBP specific information. */ | 93 | /* OBP specific information. */ |
94 | struct of_device *op; | 94 | struct platform_device *op; |
95 | u64 ino_bitmap; | 95 | u64 ino_bitmap; |
96 | 96 | ||
97 | /* PBM I/O and Memory space resources. */ | 97 | /* PBM I/O and Memory space resources. */ |
diff --git a/arch/sparc/kernel/pci_psycho.c b/arch/sparc/kernel/pci_psycho.c index 558a70512824..22eab7cf3b11 100644 --- a/arch/sparc/kernel/pci_psycho.c +++ b/arch/sparc/kernel/pci_psycho.c | |||
@@ -285,7 +285,7 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id) | |||
285 | #define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */ | 285 | #define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */ |
286 | static void psycho_register_error_handlers(struct pci_pbm_info *pbm) | 286 | static void psycho_register_error_handlers(struct pci_pbm_info *pbm) |
287 | { | 287 | { |
288 | struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); | 288 | struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node); |
289 | unsigned long base = pbm->controller_regs; | 289 | unsigned long base = pbm->controller_regs; |
290 | u64 tmp; | 290 | u64 tmp; |
291 | int err; | 291 | int err; |
@@ -302,23 +302,23 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm) | |||
302 | * 5: POWER MANAGEMENT | 302 | * 5: POWER MANAGEMENT |
303 | */ | 303 | */ |
304 | 304 | ||
305 | if (op->num_irqs < 6) | 305 | if (op->archdata.num_irqs < 6) |
306 | return; | 306 | return; |
307 | 307 | ||
308 | /* We really mean to ignore the return result here. Two | 308 | /* We really mean to ignore the return result here. Two |
309 | * PCI controller share the same interrupt numbers and | 309 | * PCI controller share the same interrupt numbers and |
310 | * drive the same front-end hardware. | 310 | * drive the same front-end hardware. |
311 | */ | 311 | */ |
312 | err = request_irq(op->irqs[1], psycho_ue_intr, IRQF_SHARED, | 312 | err = request_irq(op->archdata.irqs[1], psycho_ue_intr, IRQF_SHARED, |
313 | "PSYCHO_UE", pbm); | 313 | "PSYCHO_UE", pbm); |
314 | err = request_irq(op->irqs[2], psycho_ce_intr, IRQF_SHARED, | 314 | err = request_irq(op->archdata.irqs[2], psycho_ce_intr, IRQF_SHARED, |
315 | "PSYCHO_CE", pbm); | 315 | "PSYCHO_CE", pbm); |
316 | 316 | ||
317 | /* This one, however, ought not to fail. We can just warn | 317 | /* This one, however, ought not to fail. We can just warn |
318 | * about it since the system can still operate properly even | 318 | * about it since the system can still operate properly even |
319 | * if this fails. | 319 | * if this fails. |
320 | */ | 320 | */ |
321 | err = request_irq(op->irqs[0], psycho_pcierr_intr, IRQF_SHARED, | 321 | err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, IRQF_SHARED, |
322 | "PSYCHO_PCIERR", pbm); | 322 | "PSYCHO_PCIERR", pbm); |
323 | if (err) | 323 | if (err) |
324 | printk(KERN_WARNING "%s: Could not register PCIERR, " | 324 | printk(KERN_WARNING "%s: Could not register PCIERR, " |
@@ -483,7 +483,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, | |||
483 | #define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL | 483 | #define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL |
484 | 484 | ||
485 | static void __devinit psycho_pbm_init(struct pci_pbm_info *pbm, | 485 | static void __devinit psycho_pbm_init(struct pci_pbm_info *pbm, |
486 | struct of_device *op, int is_pbm_a) | 486 | struct platform_device *op, int is_pbm_a) |
487 | { | 487 | { |
488 | psycho_pbm_init_common(pbm, op, "PSYCHO", PBM_CHIP_TYPE_PSYCHO); | 488 | psycho_pbm_init_common(pbm, op, "PSYCHO", PBM_CHIP_TYPE_PSYCHO); |
489 | psycho_pbm_strbuf_init(pbm, is_pbm_a); | 489 | psycho_pbm_strbuf_init(pbm, is_pbm_a); |
@@ -503,7 +503,7 @@ static struct pci_pbm_info * __devinit psycho_find_sibling(u32 upa_portid) | |||
503 | 503 | ||
504 | #define PSYCHO_CONFIGSPACE 0x001000000UL | 504 | #define PSYCHO_CONFIGSPACE 0x001000000UL |
505 | 505 | ||
506 | static int __devinit psycho_probe(struct of_device *op, | 506 | static int __devinit psycho_probe(struct platform_device *op, |
507 | const struct of_device_id *match) | 507 | const struct of_device_id *match) |
508 | { | 508 | { |
509 | const struct linux_prom64_registers *pr_regs; | 509 | const struct linux_prom64_registers *pr_regs; |
@@ -612,7 +612,7 @@ static struct of_platform_driver psycho_driver = { | |||
612 | 612 | ||
613 | static int __init psycho_init(void) | 613 | static int __init psycho_init(void) |
614 | { | 614 | { |
615 | return of_register_driver(&psycho_driver, &of_bus_type); | 615 | return of_register_platform_driver(&psycho_driver); |
616 | } | 616 | } |
617 | 617 | ||
618 | subsys_initcall(psycho_init); | 618 | subsys_initcall(psycho_init); |
diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c index 6dad8e3b7506..5c3f5ec4cabc 100644 --- a/arch/sparc/kernel/pci_sabre.c +++ b/arch/sparc/kernel/pci_sabre.c | |||
@@ -311,7 +311,7 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id) | |||
311 | static void sabre_register_error_handlers(struct pci_pbm_info *pbm) | 311 | static void sabre_register_error_handlers(struct pci_pbm_info *pbm) |
312 | { | 312 | { |
313 | struct device_node *dp = pbm->op->dev.of_node; | 313 | struct device_node *dp = pbm->op->dev.of_node; |
314 | struct of_device *op; | 314 | struct platform_device *op; |
315 | unsigned long base = pbm->controller_regs; | 315 | unsigned long base = pbm->controller_regs; |
316 | u64 tmp; | 316 | u64 tmp; |
317 | int err; | 317 | int err; |
@@ -329,7 +329,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm) | |||
329 | * 2: CE ERR | 329 | * 2: CE ERR |
330 | * 3: POWER FAIL | 330 | * 3: POWER FAIL |
331 | */ | 331 | */ |
332 | if (op->num_irqs < 4) | 332 | if (op->archdata.num_irqs < 4) |
333 | return; | 333 | return; |
334 | 334 | ||
335 | /* We clear the error bits in the appropriate AFSR before | 335 | /* We clear the error bits in the appropriate AFSR before |
@@ -341,7 +341,7 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm) | |||
341 | SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE), | 341 | SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE), |
342 | base + SABRE_UE_AFSR); | 342 | base + SABRE_UE_AFSR); |
343 | 343 | ||
344 | err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm); | 344 | err = request_irq(op->archdata.irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm); |
345 | if (err) | 345 | if (err) |
346 | printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n", | 346 | printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n", |
347 | pbm->name, err); | 347 | pbm->name, err); |
@@ -351,11 +351,11 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm) | |||
351 | base + SABRE_CE_AFSR); | 351 | base + SABRE_CE_AFSR); |
352 | 352 | ||
353 | 353 | ||
354 | err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm); | 354 | err = request_irq(op->archdata.irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm); |
355 | if (err) | 355 | if (err) |
356 | printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n", | 356 | printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n", |
357 | pbm->name, err); | 357 | pbm->name, err); |
358 | err = request_irq(op->irqs[0], psycho_pcierr_intr, 0, | 358 | err = request_irq(op->archdata.irqs[0], psycho_pcierr_intr, 0, |
359 | "SABRE_PCIERR", pbm); | 359 | "SABRE_PCIERR", pbm); |
360 | if (err) | 360 | if (err) |
361 | printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n", | 361 | printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n", |
@@ -443,7 +443,7 @@ static void __devinit sabre_scan_bus(struct pci_pbm_info *pbm, | |||
443 | } | 443 | } |
444 | 444 | ||
445 | static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm, | 445 | static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm, |
446 | struct of_device *op) | 446 | struct platform_device *op) |
447 | { | 447 | { |
448 | psycho_pbm_init_common(pbm, op, "SABRE", PBM_CHIP_TYPE_SABRE); | 448 | psycho_pbm_init_common(pbm, op, "SABRE", PBM_CHIP_TYPE_SABRE); |
449 | pbm->pci_afsr = pbm->controller_regs + SABRE_PIOAFSR; | 449 | pbm->pci_afsr = pbm->controller_regs + SABRE_PIOAFSR; |
@@ -452,7 +452,7 @@ static void __devinit sabre_pbm_init(struct pci_pbm_info *pbm, | |||
452 | sabre_scan_bus(pbm, &op->dev); | 452 | sabre_scan_bus(pbm, &op->dev); |
453 | } | 453 | } |
454 | 454 | ||
455 | static int __devinit sabre_probe(struct of_device *op, | 455 | static int __devinit sabre_probe(struct platform_device *op, |
456 | const struct of_device_id *match) | 456 | const struct of_device_id *match) |
457 | { | 457 | { |
458 | const struct linux_prom64_registers *pr_regs; | 458 | const struct linux_prom64_registers *pr_regs; |
@@ -606,7 +606,7 @@ static struct of_platform_driver sabre_driver = { | |||
606 | 606 | ||
607 | static int __init sabre_init(void) | 607 | static int __init sabre_init(void) |
608 | { | 608 | { |
609 | return of_register_driver(&sabre_driver, &of_bus_type); | 609 | return of_register_platform_driver(&sabre_driver); |
610 | } | 610 | } |
611 | 611 | ||
612 | subsys_initcall(sabre_init); | 612 | subsys_initcall(sabre_init); |
diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c index 97a1ae2e1c02..445a47a2fb3d 100644 --- a/arch/sparc/kernel/pci_schizo.c +++ b/arch/sparc/kernel/pci_schizo.c | |||
@@ -844,7 +844,7 @@ static int pbm_routes_this_ino(struct pci_pbm_info *pbm, u32 ino) | |||
844 | */ | 844 | */ |
845 | static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) | 845 | static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) |
846 | { | 846 | { |
847 | struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); | 847 | struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node); |
848 | u64 tmp, err_mask, err_no_mask; | 848 | u64 tmp, err_mask, err_no_mask; |
849 | int err; | 849 | int err; |
850 | 850 | ||
@@ -857,14 +857,14 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) | |||
857 | */ | 857 | */ |
858 | 858 | ||
859 | if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { | 859 | if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { |
860 | err = request_irq(op->irqs[1], schizo_ue_intr, 0, | 860 | err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0, |
861 | "TOMATILLO_UE", pbm); | 861 | "TOMATILLO_UE", pbm); |
862 | if (err) | 862 | if (err) |
863 | printk(KERN_WARNING "%s: Could not register UE, " | 863 | printk(KERN_WARNING "%s: Could not register UE, " |
864 | "err=%d\n", pbm->name, err); | 864 | "err=%d\n", pbm->name, err); |
865 | } | 865 | } |
866 | if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { | 866 | if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { |
867 | err = request_irq(op->irqs[2], schizo_ce_intr, 0, | 867 | err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0, |
868 | "TOMATILLO_CE", pbm); | 868 | "TOMATILLO_CE", pbm); |
869 | if (err) | 869 | if (err) |
870 | printk(KERN_WARNING "%s: Could not register CE, " | 870 | printk(KERN_WARNING "%s: Could not register CE, " |
@@ -872,10 +872,10 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) | |||
872 | } | 872 | } |
873 | err = 0; | 873 | err = 0; |
874 | if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { | 874 | if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { |
875 | err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, | 875 | err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0, |
876 | "TOMATILLO_PCIERR", pbm); | 876 | "TOMATILLO_PCIERR", pbm); |
877 | } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { | 877 | } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { |
878 | err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, | 878 | err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0, |
879 | "TOMATILLO_PCIERR", pbm); | 879 | "TOMATILLO_PCIERR", pbm); |
880 | } | 880 | } |
881 | if (err) | 881 | if (err) |
@@ -883,7 +883,7 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) | |||
883 | "err=%d\n", pbm->name, err); | 883 | "err=%d\n", pbm->name, err); |
884 | 884 | ||
885 | if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { | 885 | if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { |
886 | err = request_irq(op->irqs[3], schizo_safarierr_intr, 0, | 886 | err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0, |
887 | "TOMATILLO_SERR", pbm); | 887 | "TOMATILLO_SERR", pbm); |
888 | if (err) | 888 | if (err) |
889 | printk(KERN_WARNING "%s: Could not register SERR, " | 889 | printk(KERN_WARNING "%s: Could not register SERR, " |
@@ -939,7 +939,7 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) | |||
939 | 939 | ||
940 | static void schizo_register_error_handlers(struct pci_pbm_info *pbm) | 940 | static void schizo_register_error_handlers(struct pci_pbm_info *pbm) |
941 | { | 941 | { |
942 | struct of_device *op = of_find_device_by_node(pbm->op->dev.of_node); | 942 | struct platform_device *op = of_find_device_by_node(pbm->op->dev.of_node); |
943 | u64 tmp, err_mask, err_no_mask; | 943 | u64 tmp, err_mask, err_no_mask; |
944 | int err; | 944 | int err; |
945 | 945 | ||
@@ -952,14 +952,14 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm) | |||
952 | */ | 952 | */ |
953 | 953 | ||
954 | if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { | 954 | if (pbm_routes_this_ino(pbm, SCHIZO_UE_INO)) { |
955 | err = request_irq(op->irqs[1], schizo_ue_intr, 0, | 955 | err = request_irq(op->archdata.irqs[1], schizo_ue_intr, 0, |
956 | "SCHIZO_UE", pbm); | 956 | "SCHIZO_UE", pbm); |
957 | if (err) | 957 | if (err) |
958 | printk(KERN_WARNING "%s: Could not register UE, " | 958 | printk(KERN_WARNING "%s: Could not register UE, " |
959 | "err=%d\n", pbm->name, err); | 959 | "err=%d\n", pbm->name, err); |
960 | } | 960 | } |
961 | if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { | 961 | if (pbm_routes_this_ino(pbm, SCHIZO_CE_INO)) { |
962 | err = request_irq(op->irqs[2], schizo_ce_intr, 0, | 962 | err = request_irq(op->archdata.irqs[2], schizo_ce_intr, 0, |
963 | "SCHIZO_CE", pbm); | 963 | "SCHIZO_CE", pbm); |
964 | if (err) | 964 | if (err) |
965 | printk(KERN_WARNING "%s: Could not register CE, " | 965 | printk(KERN_WARNING "%s: Could not register CE, " |
@@ -967,10 +967,10 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm) | |||
967 | } | 967 | } |
968 | err = 0; | 968 | err = 0; |
969 | if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { | 969 | if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_A_INO)) { |
970 | err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, | 970 | err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0, |
971 | "SCHIZO_PCIERR", pbm); | 971 | "SCHIZO_PCIERR", pbm); |
972 | } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { | 972 | } else if (pbm_routes_this_ino(pbm, SCHIZO_PCIERR_B_INO)) { |
973 | err = request_irq(op->irqs[0], schizo_pcierr_intr, 0, | 973 | err = request_irq(op->archdata.irqs[0], schizo_pcierr_intr, 0, |
974 | "SCHIZO_PCIERR", pbm); | 974 | "SCHIZO_PCIERR", pbm); |
975 | } | 975 | } |
976 | if (err) | 976 | if (err) |
@@ -978,7 +978,7 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm) | |||
978 | "err=%d\n", pbm->name, err); | 978 | "err=%d\n", pbm->name, err); |
979 | 979 | ||
980 | if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { | 980 | if (pbm_routes_this_ino(pbm, SCHIZO_SERR_INO)) { |
981 | err = request_irq(op->irqs[3], schizo_safarierr_intr, 0, | 981 | err = request_irq(op->archdata.irqs[3], schizo_safarierr_intr, 0, |
982 | "SCHIZO_SERR", pbm); | 982 | "SCHIZO_SERR", pbm); |
983 | if (err) | 983 | if (err) |
984 | printk(KERN_WARNING "%s: Could not register SERR, " | 984 | printk(KERN_WARNING "%s: Could not register SERR, " |
@@ -1307,7 +1307,7 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) | |||
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | static int __devinit schizo_pbm_init(struct pci_pbm_info *pbm, | 1309 | static int __devinit schizo_pbm_init(struct pci_pbm_info *pbm, |
1310 | struct of_device *op, u32 portid, | 1310 | struct platform_device *op, u32 portid, |
1311 | int chip_type) | 1311 | int chip_type) |
1312 | { | 1312 | { |
1313 | const struct linux_prom64_registers *regs; | 1313 | const struct linux_prom64_registers *regs; |
@@ -1413,7 +1413,7 @@ static struct pci_pbm_info * __devinit schizo_find_sibling(u32 portid, | |||
1413 | return NULL; | 1413 | return NULL; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | static int __devinit __schizo_init(struct of_device *op, unsigned long chip_type) | 1416 | static int __devinit __schizo_init(struct platform_device *op, unsigned long chip_type) |
1417 | { | 1417 | { |
1418 | struct device_node *dp = op->dev.of_node; | 1418 | struct device_node *dp = op->dev.of_node; |
1419 | struct pci_pbm_info *pbm; | 1419 | struct pci_pbm_info *pbm; |
@@ -1460,7 +1460,7 @@ out_err: | |||
1460 | return err; | 1460 | return err; |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | static int __devinit schizo_probe(struct of_device *op, | 1463 | static int __devinit schizo_probe(struct platform_device *op, |
1464 | const struct of_device_id *match) | 1464 | const struct of_device_id *match) |
1465 | { | 1465 | { |
1466 | return __schizo_init(op, (unsigned long) match->data); | 1466 | return __schizo_init(op, (unsigned long) match->data); |
@@ -1501,7 +1501,7 @@ static struct of_platform_driver schizo_driver = { | |||
1501 | 1501 | ||
1502 | static int __init schizo_init(void) | 1502 | static int __init schizo_init(void) |
1503 | { | 1503 | { |
1504 | return of_register_driver(&schizo_driver, &of_bus_type); | 1504 | return of_register_platform_driver(&schizo_driver); |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | subsys_initcall(schizo_init); | 1507 | subsys_initcall(schizo_init); |
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index a24af6f7e17f..743344aa6d8a 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -879,7 +879,7 @@ static void pci_sun4v_msi_init(struct pci_pbm_info *pbm) | |||
879 | #endif /* !(CONFIG_PCI_MSI) */ | 879 | #endif /* !(CONFIG_PCI_MSI) */ |
880 | 880 | ||
881 | static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm, | 881 | static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm, |
882 | struct of_device *op, u32 devhandle) | 882 | struct platform_device *op, u32 devhandle) |
883 | { | 883 | { |
884 | struct device_node *dp = op->dev.of_node; | 884 | struct device_node *dp = op->dev.of_node; |
885 | int err; | 885 | int err; |
@@ -918,7 +918,7 @@ static int __devinit pci_sun4v_pbm_init(struct pci_pbm_info *pbm, | |||
918 | return 0; | 918 | return 0; |
919 | } | 919 | } |
920 | 920 | ||
921 | static int __devinit pci_sun4v_probe(struct of_device *op, | 921 | static int __devinit pci_sun4v_probe(struct platform_device *op, |
922 | const struct of_device_id *match) | 922 | const struct of_device_id *match) |
923 | { | 923 | { |
924 | const struct linux_prom64_registers *regs; | 924 | const struct linux_prom64_registers *regs; |
@@ -1019,7 +1019,7 @@ static struct of_platform_driver pci_sun4v_driver = { | |||
1019 | 1019 | ||
1020 | static int __init pci_sun4v_init(void) | 1020 | static int __init pci_sun4v_init(void) |
1021 | { | 1021 | { |
1022 | return of_register_driver(&pci_sun4v_driver, &of_bus_type); | 1022 | return of_register_platform_driver(&pci_sun4v_driver); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | subsys_initcall(pci_sun4v_init); | 1025 | subsys_initcall(pci_sun4v_init); |
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c index 9589d8b9b0c1..94536a85f161 100644 --- a/arch/sparc/kernel/pmc.c +++ b/arch/sparc/kernel/pmc.c | |||
@@ -51,7 +51,7 @@ static void pmc_swift_idle(void) | |||
51 | #endif | 51 | #endif |
52 | } | 52 | } |
53 | 53 | ||
54 | static int __devinit pmc_probe(struct of_device *op, | 54 | static int __devinit pmc_probe(struct platform_device *op, |
55 | const struct of_device_id *match) | 55 | const struct of_device_id *match) |
56 | { | 56 | { |
57 | regs = of_ioremap(&op->resource[0], 0, | 57 | regs = of_ioremap(&op->resource[0], 0, |
@@ -89,7 +89,7 @@ static struct of_platform_driver pmc_driver = { | |||
89 | 89 | ||
90 | static int __init pmc_init(void) | 90 | static int __init pmc_init(void) |
91 | { | 91 | { |
92 | return of_register_driver(&pmc_driver, &of_bus_type); | 92 | return of_register_platform_driver(&pmc_driver); |
93 | } | 93 | } |
94 | 94 | ||
95 | /* This driver is not critical to the boot process | 95 | /* This driver is not critical to the boot process |
diff --git a/arch/sparc/kernel/power.c b/arch/sparc/kernel/power.c index 168d4cb63f5b..2c59f4d387dd 100644 --- a/arch/sparc/kernel/power.c +++ b/arch/sparc/kernel/power.c | |||
@@ -33,10 +33,10 @@ static int __devinit has_button_interrupt(unsigned int irq, struct device_node * | |||
33 | return 1; | 33 | return 1; |
34 | } | 34 | } |
35 | 35 | ||
36 | static int __devinit power_probe(struct of_device *op, const struct of_device_id *match) | 36 | static int __devinit power_probe(struct platform_device *op, const struct of_device_id *match) |
37 | { | 37 | { |
38 | struct resource *res = &op->resource[0]; | 38 | struct resource *res = &op->resource[0]; |
39 | unsigned int irq= op->irqs[0]; | 39 | unsigned int irq = op->archdata.irqs[0]; |
40 | 40 | ||
41 | power_reg = of_ioremap(res, 0, 0x4, "power"); | 41 | power_reg = of_ioremap(res, 0, 0x4, "power"); |
42 | 42 | ||
@@ -70,7 +70,7 @@ static struct of_platform_driver power_driver = { | |||
70 | 70 | ||
71 | static int __init power_init(void) | 71 | static int __init power_init(void) |
72 | { | 72 | { |
73 | return of_register_driver(&power_driver, &of_platform_bus_type); | 73 | return of_register_platform_driver(&power_driver); |
74 | } | 74 | } |
75 | 75 | ||
76 | device_initcall(power_init); | 76 | device_initcall(power_init); |
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h index a8591ef2636d..eeb04a782ec8 100644 --- a/arch/sparc/kernel/prom.h +++ b/arch/sparc/kernel/prom.h | |||
@@ -9,14 +9,6 @@ extern void irq_trans_init(struct device_node *dp); | |||
9 | 9 | ||
10 | extern unsigned int prom_unique_id; | 10 | extern unsigned int prom_unique_id; |
11 | 11 | ||
12 | static inline int is_root_node(const struct device_node *dp) | ||
13 | { | ||
14 | if (!dp) | ||
15 | return 0; | ||
16 | |||
17 | return (dp->parent == NULL); | ||
18 | } | ||
19 | |||
20 | extern char *build_path_component(struct device_node *dp); | 12 | extern char *build_path_component(struct device_node *dp); |
21 | extern void of_console_init(void); | 13 | extern void of_console_init(void); |
22 | 14 | ||
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c index 466a32763ea8..86597d9867fd 100644 --- a/arch/sparc/kernel/prom_64.c +++ b/arch/sparc/kernel/prom_64.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/of_device.h> | 24 | #include <linux/of.h> |
25 | 25 | ||
26 | #include <asm/prom.h> | 26 | #include <asm/prom.h> |
27 | #include <asm/oplib.h> | 27 | #include <asm/oplib.h> |
@@ -81,7 +81,7 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf) | |||
81 | return; | 81 | return; |
82 | 82 | ||
83 | regs = rprop->value; | 83 | regs = rprop->value; |
84 | if (!is_root_node(dp->parent)) { | 84 | if (!of_node_is_root(dp->parent)) { |
85 | sprintf(tmp_buf, "%s@%x,%x", | 85 | sprintf(tmp_buf, "%s@%x,%x", |
86 | dp->name, | 86 | dp->name, |
87 | (unsigned int) (regs->phys_addr >> 32UL), | 87 | (unsigned int) (regs->phys_addr >> 32UL), |
@@ -121,7 +121,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) | |||
121 | return; | 121 | return; |
122 | 122 | ||
123 | regs = prop->value; | 123 | regs = prop->value; |
124 | if (!is_root_node(dp->parent)) { | 124 | if (!of_node_is_root(dp->parent)) { |
125 | sprintf(tmp_buf, "%s@%x,%x", | 125 | sprintf(tmp_buf, "%s@%x,%x", |
126 | dp->name, | 126 | dp->name, |
127 | (unsigned int) (regs->phys_addr >> 32UL), | 127 | (unsigned int) (regs->phys_addr >> 32UL), |
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c index 57ac9e28be0c..1f830da2ddf2 100644 --- a/arch/sparc/kernel/prom_common.c +++ b/arch/sparc/kernel/prom_common.c | |||
@@ -244,7 +244,7 @@ char * __init build_full_name(struct device_node *dp) | |||
244 | 244 | ||
245 | n = prom_early_alloc(len); | 245 | n = prom_early_alloc(len); |
246 | strcpy(n, dp->parent->full_name); | 246 | strcpy(n, dp->parent->full_name); |
247 | if (!is_root_node(dp->parent)) { | 247 | if (!of_node_is_root(dp->parent)) { |
248 | strcpy(n + plen, "/"); | 248 | strcpy(n + plen, "/"); |
249 | plen++; | 249 | plen++; |
250 | } | 250 | } |
diff --git a/arch/sparc/kernel/prom_irqtrans.c b/arch/sparc/kernel/prom_irqtrans.c index 5702ad4710cb..ce651147fabc 100644 --- a/arch/sparc/kernel/prom_irqtrans.c +++ b/arch/sparc/kernel/prom_irqtrans.c | |||
@@ -719,7 +719,7 @@ static unsigned int central_build_irq(struct device_node *dp, | |||
719 | void *_data) | 719 | void *_data) |
720 | { | 720 | { |
721 | struct device_node *central_dp = _data; | 721 | struct device_node *central_dp = _data; |
722 | struct of_device *central_op = of_find_device_by_node(central_dp); | 722 | struct platform_device *central_op = of_find_device_by_node(central_dp); |
723 | struct resource *res; | 723 | struct resource *res; |
724 | unsigned long imap, iclr; | 724 | unsigned long imap, iclr; |
725 | u32 tmp; | 725 | u32 tmp; |
diff --git a/arch/sparc/kernel/psycho_common.c b/arch/sparc/kernel/psycho_common.c index 3f34ac853931..fe2af66bb198 100644 --- a/arch/sparc/kernel/psycho_common.c +++ b/arch/sparc/kernel/psycho_common.c | |||
@@ -447,7 +447,7 @@ int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize, | |||
447 | 447 | ||
448 | } | 448 | } |
449 | 449 | ||
450 | void psycho_pbm_init_common(struct pci_pbm_info *pbm, struct of_device *op, | 450 | void psycho_pbm_init_common(struct pci_pbm_info *pbm, struct platform_device *op, |
451 | const char *chip_name, int chip_type) | 451 | const char *chip_name, int chip_type) |
452 | { | 452 | { |
453 | struct device_node *dp = op->dev.of_node; | 453 | struct device_node *dp = op->dev.of_node; |
diff --git a/arch/sparc/kernel/psycho_common.h b/arch/sparc/kernel/psycho_common.h index 092c278ef28d..590b4ed8ab5e 100644 --- a/arch/sparc/kernel/psycho_common.h +++ b/arch/sparc/kernel/psycho_common.h | |||
@@ -42,7 +42,7 @@ extern int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize, | |||
42 | unsigned long write_complete_offset); | 42 | unsigned long write_complete_offset); |
43 | 43 | ||
44 | extern void psycho_pbm_init_common(struct pci_pbm_info *pbm, | 44 | extern void psycho_pbm_init_common(struct pci_pbm_info *pbm, |
45 | struct of_device *op, | 45 | struct platform_device *op, |
46 | const char *chip_name, int chip_type); | 46 | const char *chip_name, int chip_type); |
47 | 47 | ||
48 | #endif /* _PSYCHO_COMMON_H */ | 48 | #endif /* _PSYCHO_COMMON_H */ |
diff --git a/arch/sparc/kernel/sbus.c b/arch/sparc/kernel/sbus.c index cfeaf04b9cdf..2ca32d13abcf 100644 --- a/arch/sparc/kernel/sbus.c +++ b/arch/sparc/kernel/sbus.c | |||
@@ -57,7 +57,7 @@ | |||
57 | void sbus_set_sbus64(struct device *dev, int bursts) | 57 | void sbus_set_sbus64(struct device *dev, int bursts) |
58 | { | 58 | { |
59 | struct iommu *iommu = dev->archdata.iommu; | 59 | struct iommu *iommu = dev->archdata.iommu; |
60 | struct of_device *op = to_of_device(dev); | 60 | struct platform_device *op = to_platform_device(dev); |
61 | const struct linux_prom_registers *regs; | 61 | const struct linux_prom_registers *regs; |
62 | unsigned long cfg_reg; | 62 | unsigned long cfg_reg; |
63 | int slot; | 63 | int slot; |
@@ -204,7 +204,7 @@ static unsigned long sysio_imap_to_iclr(unsigned long imap) | |||
204 | return imap + diff; | 204 | return imap + diff; |
205 | } | 205 | } |
206 | 206 | ||
207 | static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino) | 207 | static unsigned int sbus_build_irq(struct platform_device *op, unsigned int ino) |
208 | { | 208 | { |
209 | struct iommu *iommu = op->dev.archdata.iommu; | 209 | struct iommu *iommu = op->dev.archdata.iommu; |
210 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; | 210 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; |
@@ -267,7 +267,7 @@ static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino) | |||
267 | #define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ | 267 | #define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ |
268 | static irqreturn_t sysio_ue_handler(int irq, void *dev_id) | 268 | static irqreturn_t sysio_ue_handler(int irq, void *dev_id) |
269 | { | 269 | { |
270 | struct of_device *op = dev_id; | 270 | struct platform_device *op = dev_id; |
271 | struct iommu *iommu = op->dev.archdata.iommu; | 271 | struct iommu *iommu = op->dev.archdata.iommu; |
272 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; | 272 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; |
273 | unsigned long afsr_reg, afar_reg; | 273 | unsigned long afsr_reg, afar_reg; |
@@ -341,7 +341,7 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id) | |||
341 | #define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ | 341 | #define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ |
342 | static irqreturn_t sysio_ce_handler(int irq, void *dev_id) | 342 | static irqreturn_t sysio_ce_handler(int irq, void *dev_id) |
343 | { | 343 | { |
344 | struct of_device *op = dev_id; | 344 | struct platform_device *op = dev_id; |
345 | struct iommu *iommu = op->dev.archdata.iommu; | 345 | struct iommu *iommu = op->dev.archdata.iommu; |
346 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; | 346 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; |
347 | unsigned long afsr_reg, afar_reg; | 347 | unsigned long afsr_reg, afar_reg; |
@@ -420,7 +420,7 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id) | |||
420 | #define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */ | 420 | #define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */ |
421 | static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) | 421 | static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) |
422 | { | 422 | { |
423 | struct of_device *op = dev_id; | 423 | struct platform_device *op = dev_id; |
424 | struct iommu *iommu = op->dev.archdata.iommu; | 424 | struct iommu *iommu = op->dev.archdata.iommu; |
425 | unsigned long afsr_reg, afar_reg, reg_base; | 425 | unsigned long afsr_reg, afar_reg, reg_base; |
426 | unsigned long afsr, afar, error_bits; | 426 | unsigned long afsr, afar, error_bits; |
@@ -488,7 +488,7 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) | |||
488 | #define SYSIO_CE_INO 0x35 | 488 | #define SYSIO_CE_INO 0x35 |
489 | #define SYSIO_SBUSERR_INO 0x36 | 489 | #define SYSIO_SBUSERR_INO 0x36 |
490 | 490 | ||
491 | static void __init sysio_register_error_handlers(struct of_device *op) | 491 | static void __init sysio_register_error_handlers(struct platform_device *op) |
492 | { | 492 | { |
493 | struct iommu *iommu = op->dev.archdata.iommu; | 493 | struct iommu *iommu = op->dev.archdata.iommu; |
494 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; | 494 | unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; |
@@ -534,7 +534,7 @@ static void __init sysio_register_error_handlers(struct of_device *op) | |||
534 | } | 534 | } |
535 | 535 | ||
536 | /* Boot time initialization. */ | 536 | /* Boot time initialization. */ |
537 | static void __init sbus_iommu_init(struct of_device *op) | 537 | static void __init sbus_iommu_init(struct platform_device *op) |
538 | { | 538 | { |
539 | const struct linux_prom64_registers *pr; | 539 | const struct linux_prom64_registers *pr; |
540 | struct device_node *dp = op->dev.of_node; | 540 | struct device_node *dp = op->dev.of_node; |
@@ -663,7 +663,7 @@ static int __init sbus_init(void) | |||
663 | struct device_node *dp; | 663 | struct device_node *dp; |
664 | 664 | ||
665 | for_each_node_by_name(dp, "sbus") { | 665 | for_each_node_by_name(dp, "sbus") { |
666 | struct of_device *op = of_find_device_by_node(dp); | 666 | struct platform_device *op = of_find_device_by_node(dp); |
667 | 667 | ||
668 | sbus_iommu_init(op); | 668 | sbus_iommu_init(op); |
669 | of_propagate_archdata(op); | 669 | of_propagate_archdata(op); |
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c index e404b063be2c..9c743b1886ff 100644 --- a/arch/sparc/kernel/time_32.c +++ b/arch/sparc/kernel/time_32.c | |||
@@ -142,7 +142,7 @@ static struct platform_device m48t59_rtc = { | |||
142 | }, | 142 | }, |
143 | }; | 143 | }; |
144 | 144 | ||
145 | static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match) | 145 | static int __devinit clock_probe(struct platform_device *op, const struct of_device_id *match) |
146 | { | 146 | { |
147 | struct device_node *dp = op->dev.of_node; | 147 | struct device_node *dp = op->dev.of_node; |
148 | const char *model = of_get_property(dp, "model", NULL); | 148 | const char *model = of_get_property(dp, "model", NULL); |
@@ -189,7 +189,7 @@ static struct of_platform_driver clock_driver = { | |||
189 | /* Probe for the mostek real time clock chip. */ | 189 | /* Probe for the mostek real time clock chip. */ |
190 | static int __init clock_init(void) | 190 | static int __init clock_init(void) |
191 | { | 191 | { |
192 | return of_register_driver(&clock_driver, &of_platform_bus_type); | 192 | return of_register_platform_driver(&clock_driver); |
193 | } | 193 | } |
194 | /* Must be after subsys_initcall() so that busses are probed. Must | 194 | /* Must be after subsys_initcall() so that busses are probed. Must |
195 | * be before device_initcall() because things like the RTC driver | 195 | * be before device_initcall() because things like the RTC driver |
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c index 21e9fcae0668..3bc9c9979b92 100644 --- a/arch/sparc/kernel/time_64.c +++ b/arch/sparc/kernel/time_64.c | |||
@@ -419,7 +419,7 @@ static struct platform_device rtc_cmos_device = { | |||
419 | .num_resources = 1, | 419 | .num_resources = 1, |
420 | }; | 420 | }; |
421 | 421 | ||
422 | static int __devinit rtc_probe(struct of_device *op, const struct of_device_id *match) | 422 | static int __devinit rtc_probe(struct platform_device *op, const struct of_device_id *match) |
423 | { | 423 | { |
424 | struct resource *r; | 424 | struct resource *r; |
425 | 425 | ||
@@ -477,7 +477,7 @@ static struct platform_device rtc_bq4802_device = { | |||
477 | .num_resources = 1, | 477 | .num_resources = 1, |
478 | }; | 478 | }; |
479 | 479 | ||
480 | static int __devinit bq4802_probe(struct of_device *op, const struct of_device_id *match) | 480 | static int __devinit bq4802_probe(struct platform_device *op, const struct of_device_id *match) |
481 | { | 481 | { |
482 | 482 | ||
483 | printk(KERN_INFO "%s: BQ4802 regs at 0x%llx\n", | 483 | printk(KERN_INFO "%s: BQ4802 regs at 0x%llx\n", |
@@ -534,7 +534,7 @@ static struct platform_device m48t59_rtc = { | |||
534 | }, | 534 | }, |
535 | }; | 535 | }; |
536 | 536 | ||
537 | static int __devinit mostek_probe(struct of_device *op, const struct of_device_id *match) | 537 | static int __devinit mostek_probe(struct platform_device *op, const struct of_device_id *match) |
538 | { | 538 | { |
539 | struct device_node *dp = op->dev.of_node; | 539 | struct device_node *dp = op->dev.of_node; |
540 | 540 | ||
@@ -586,9 +586,9 @@ static int __init clock_init(void) | |||
586 | if (tlb_type == hypervisor) | 586 | if (tlb_type == hypervisor) |
587 | return platform_device_register(&rtc_sun4v_device); | 587 | return platform_device_register(&rtc_sun4v_device); |
588 | 588 | ||
589 | (void) of_register_driver(&rtc_driver, &of_platform_bus_type); | 589 | (void) of_register_platform_driver(&rtc_driver); |
590 | (void) of_register_driver(&mostek_driver, &of_platform_bus_type); | 590 | (void) of_register_platform_driver(&mostek_driver); |
591 | (void) of_register_driver(&bq4802_driver, &of_platform_bus_type); | 591 | (void) of_register_platform_driver(&bq4802_driver); |
592 | 592 | ||
593 | return 0; | 593 | return 0; |
594 | } | 594 | } |
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index 005e758a4db7..fc58c3e917df 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) | 35 | #define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) |
36 | #define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) | 36 | #define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) |
37 | 37 | ||
38 | static void __init iounit_iommu_init(struct of_device *op) | 38 | static void __init iounit_iommu_init(struct platform_device *op) |
39 | { | 39 | { |
40 | struct iounit_struct *iounit; | 40 | struct iounit_struct *iounit; |
41 | iopte_t *xpt, *xptend; | 41 | iopte_t *xpt, *xptend; |
@@ -74,7 +74,7 @@ static int __init iounit_init(void) | |||
74 | struct device_node *dp; | 74 | struct device_node *dp; |
75 | 75 | ||
76 | for_each_node_by_name(dp, "sbi") { | 76 | for_each_node_by_name(dp, "sbi") { |
77 | struct of_device *op = of_find_device_by_node(dp); | 77 | struct platform_device *op = of_find_device_by_node(dp); |
78 | 78 | ||
79 | iounit_iommu_init(op); | 79 | iounit_iommu_init(op); |
80 | of_propagate_archdata(op); | 80 | of_propagate_archdata(op); |
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 0e8ae298b3c3..07fc6a65d9b6 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c | |||
@@ -56,7 +56,7 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */ | |||
56 | #define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) | 56 | #define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) |
57 | #define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ) | 57 | #define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ) |
58 | 58 | ||
59 | static void __init sbus_iommu_init(struct of_device *op) | 59 | static void __init sbus_iommu_init(struct platform_device *op) |
60 | { | 60 | { |
61 | struct iommu_struct *iommu; | 61 | struct iommu_struct *iommu; |
62 | unsigned int impl, vers; | 62 | unsigned int impl, vers; |
@@ -132,7 +132,7 @@ static int __init iommu_init(void) | |||
132 | struct device_node *dp; | 132 | struct device_node *dp; |
133 | 133 | ||
134 | for_each_node_by_name(dp, "iommu") { | 134 | for_each_node_by_name(dp, "iommu") { |
135 | struct of_device *op = of_find_device_by_node(dp); | 135 | struct platform_device *op = of_find_device_by_node(dp); |
136 | 136 | ||
137 | sbus_iommu_init(op); | 137 | sbus_iommu_init(op); |
138 | of_propagate_archdata(op); | 138 | of_propagate_archdata(op); |
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index da8f176c051e..b7385e077717 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
@@ -2657,7 +2657,7 @@ static int __devinit fore200e_sba_probe(struct of_device *op, | |||
2657 | 2657 | ||
2658 | fore200e->bus = bus; | 2658 | fore200e->bus = bus; |
2659 | fore200e->bus_dev = op; | 2659 | fore200e->bus_dev = op; |
2660 | fore200e->irq = op->irqs[0]; | 2660 | fore200e->irq = op->archdata.irqs[0]; |
2661 | fore200e->phys_base = op->resource[0].start; | 2661 | fore200e->phys_base = op->resource[0].start; |
2662 | 2662 | ||
2663 | sprintf(fore200e->name, "%s-%d", bus->model_name, index); | 2663 | sprintf(fore200e->name, "%s-%d", bus->model_name, index); |
@@ -2795,7 +2795,7 @@ static int __init fore200e_module_init(void) | |||
2795 | printk(FORE200E "FORE Systems 200E-series ATM driver - version " FORE200E_VERSION "\n"); | 2795 | printk(FORE200E "FORE Systems 200E-series ATM driver - version " FORE200E_VERSION "\n"); |
2796 | 2796 | ||
2797 | #ifdef CONFIG_SBUS | 2797 | #ifdef CONFIG_SBUS |
2798 | err = of_register_driver(&fore200e_sba_driver, &of_bus_type); | 2798 | err = of_register_platform_driver(&fore200e_sba_driver); |
2799 | if (err) | 2799 | if (err) |
2800 | return err; | 2800 | return err; |
2801 | #endif | 2801 | #endif |
@@ -2806,7 +2806,7 @@ static int __init fore200e_module_init(void) | |||
2806 | 2806 | ||
2807 | #ifdef CONFIG_SBUS | 2807 | #ifdef CONFIG_SBUS |
2808 | if (err) | 2808 | if (err) |
2809 | of_unregister_driver(&fore200e_sba_driver); | 2809 | of_unregister_platform_driver(&fore200e_sba_driver); |
2810 | #endif | 2810 | #endif |
2811 | 2811 | ||
2812 | return err; | 2812 | return err; |
@@ -2818,7 +2818,7 @@ static void __exit fore200e_module_cleanup(void) | |||
2818 | pci_unregister_driver(&fore200e_pca_driver); | 2818 | pci_unregister_driver(&fore200e_pca_driver); |
2819 | #endif | 2819 | #endif |
2820 | #ifdef CONFIG_SBUS | 2820 | #ifdef CONFIG_SBUS |
2821 | of_unregister_driver(&fore200e_sba_driver); | 2821 | of_unregister_platform_driver(&fore200e_sba_driver); |
2822 | #endif | 2822 | #endif |
2823 | } | 2823 | } |
2824 | 2824 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4d99c8bdfedc..f699fabf403b 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/of_device.h> | ||
15 | #include <linux/module.h> | 16 | #include <linux/module.h> |
16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
17 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
@@ -635,6 +636,12 @@ static struct device_attribute platform_dev_attrs[] = { | |||
635 | static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | 636 | static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) |
636 | { | 637 | { |
637 | struct platform_device *pdev = to_platform_device(dev); | 638 | struct platform_device *pdev = to_platform_device(dev); |
639 | int rc; | ||
640 | |||
641 | /* Some devices have extra OF data and an OF-style MODALIAS */ | ||
642 | rc = of_device_uevent(dev,env); | ||
643 | if (rc != -ENODEV) | ||
644 | return rc; | ||
638 | 645 | ||
639 | add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, | 646 | add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, |
640 | (pdev->id_entry) ? pdev->id_entry->name : pdev->name); | 647 | (pdev->id_entry) ? pdev->id_entry->name : pdev->name); |
@@ -673,7 +680,11 @@ static int platform_match(struct device *dev, struct device_driver *drv) | |||
673 | struct platform_device *pdev = to_platform_device(dev); | 680 | struct platform_device *pdev = to_platform_device(dev); |
674 | struct platform_driver *pdrv = to_platform_driver(drv); | 681 | struct platform_driver *pdrv = to_platform_driver(drv); |
675 | 682 | ||
676 | /* match against the id table first */ | 683 | /* Attempt an OF style match first */ |
684 | if (of_driver_match_device(dev, drv)) | ||
685 | return 1; | ||
686 | |||
687 | /* Then try to match against the id table */ | ||
677 | if (pdrv->id_table) | 688 | if (pdrv->id_table) |
678 | return platform_match_id(pdrv->id_table, pdev) != NULL; | 689 | return platform_match_id(pdrv->id_table, pdev) != NULL; |
679 | 690 | ||
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index 89d871ef8c2f..91917133ae0a 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
25 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
26 | #include <linux/fs.h> | ||
26 | #include <linux/module.h> | 27 | #include <linux/module.h> |
27 | #include <linux/cdev.h> | 28 | #include <linux/cdev.h> |
28 | #include <linux/list.h> | 29 | #include <linux/list.h> |
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 101d5f235547..7a4f080f8356 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c | |||
@@ -762,12 +762,12 @@ static struct of_platform_driver n2rng_driver = { | |||
762 | 762 | ||
763 | static int __init n2rng_init(void) | 763 | static int __init n2rng_init(void) |
764 | { | 764 | { |
765 | return of_register_driver(&n2rng_driver, &of_bus_type); | 765 | return of_register_platform_driver(&n2rng_driver); |
766 | } | 766 | } |
767 | 767 | ||
768 | static void __exit n2rng_exit(void) | 768 | static void __exit n2rng_exit(void) |
769 | { | 769 | { |
770 | of_unregister_driver(&n2rng_driver); | 770 | of_unregister_platform_driver(&n2rng_driver); |
771 | } | 771 | } |
772 | 772 | ||
773 | module_init(n2rng_init); | 773 | module_init(n2rng_init); |
diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index b99c38f23d61..26af2dd5d831 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c | |||
@@ -2247,20 +2247,20 @@ static struct of_platform_driver n2_mau_driver = { | |||
2247 | 2247 | ||
2248 | static int __init n2_init(void) | 2248 | static int __init n2_init(void) |
2249 | { | 2249 | { |
2250 | int err = of_register_driver(&n2_crypto_driver, &of_bus_type); | 2250 | int err = of_register_platform_driver(&n2_crypto_driver); |
2251 | 2251 | ||
2252 | if (!err) { | 2252 | if (!err) { |
2253 | err = of_register_driver(&n2_mau_driver, &of_bus_type); | 2253 | err = of_register_platform_driver(&n2_mau_driver); |
2254 | if (err) | 2254 | if (err) |
2255 | of_unregister_driver(&n2_crypto_driver); | 2255 | of_unregister_platform_driver(&n2_crypto_driver); |
2256 | } | 2256 | } |
2257 | return err; | 2257 | return err; |
2258 | } | 2258 | } |
2259 | 2259 | ||
2260 | static void __exit n2_exit(void) | 2260 | static void __exit n2_exit(void) |
2261 | { | 2261 | { |
2262 | of_unregister_driver(&n2_mau_driver); | 2262 | of_unregister_platform_driver(&n2_mau_driver); |
2263 | of_unregister_driver(&n2_crypto_driver); | 2263 | of_unregister_platform_driver(&n2_crypto_driver); |
2264 | } | 2264 | } |
2265 | 2265 | ||
2266 | module_init(n2_init); | 2266 | module_init(n2_init); |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4e51fe3c1fc4..6a6bd569e1f8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/debugfs.h> | 8 | #include <linux/debugfs.h> |
9 | #include <linux/seq_file.h> | 9 | #include <linux/seq_file.h> |
10 | #include <linux/gpio.h> | 10 | #include <linux/gpio.h> |
11 | #include <linux/of_gpio.h> | ||
11 | #include <linux/idr.h> | 12 | #include <linux/idr.h> |
12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
13 | 14 | ||
@@ -1100,16 +1101,24 @@ int gpiochip_add(struct gpio_chip *chip) | |||
1100 | } | 1101 | } |
1101 | } | 1102 | } |
1102 | 1103 | ||
1104 | of_gpiochip_add(chip); | ||
1105 | |||
1103 | unlock: | 1106 | unlock: |
1104 | spin_unlock_irqrestore(&gpio_lock, flags); | 1107 | spin_unlock_irqrestore(&gpio_lock, flags); |
1105 | if (status == 0) | 1108 | |
1106 | status = gpiochip_export(chip); | 1109 | if (status) |
1110 | goto fail; | ||
1111 | |||
1112 | status = gpiochip_export(chip); | ||
1113 | if (status) | ||
1114 | goto fail; | ||
1115 | |||
1116 | return 0; | ||
1107 | fail: | 1117 | fail: |
1108 | /* failures here can mean systems won't boot... */ | 1118 | /* failures here can mean systems won't boot... */ |
1109 | if (status) | 1119 | pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", |
1110 | pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", | 1120 | chip->base, chip->base + chip->ngpio - 1, |
1111 | chip->base, chip->base + chip->ngpio - 1, | 1121 | chip->label ? : "generic"); |
1112 | chip->label ? : "generic"); | ||
1113 | return status; | 1122 | return status; |
1114 | } | 1123 | } |
1115 | EXPORT_SYMBOL_GPL(gpiochip_add); | 1124 | EXPORT_SYMBOL_GPL(gpiochip_add); |
@@ -1128,6 +1137,8 @@ int gpiochip_remove(struct gpio_chip *chip) | |||
1128 | 1137 | ||
1129 | spin_lock_irqsave(&gpio_lock, flags); | 1138 | spin_lock_irqsave(&gpio_lock, flags); |
1130 | 1139 | ||
1140 | of_gpiochip_remove(chip); | ||
1141 | |||
1131 | for (id = chip->base; id < chip->base + chip->ngpio; id++) { | 1142 | for (id = chip->base; id < chip->base + chip->ngpio; id++) { |
1132 | if (test_bit(FLAG_REQUESTED, &gpio_desc[id].flags)) { | 1143 | if (test_bit(FLAG_REQUESTED, &gpio_desc[id].flags)) { |
1133 | status = -EBUSY; | 1144 | status = -EBUSY; |
@@ -1148,6 +1159,38 @@ int gpiochip_remove(struct gpio_chip *chip) | |||
1148 | } | 1159 | } |
1149 | EXPORT_SYMBOL_GPL(gpiochip_remove); | 1160 | EXPORT_SYMBOL_GPL(gpiochip_remove); |
1150 | 1161 | ||
1162 | /** | ||
1163 | * gpiochip_find() - iterator for locating a specific gpio_chip | ||
1164 | * @data: data to pass to match function | ||
1165 | * @callback: Callback function to check gpio_chip | ||
1166 | * | ||
1167 | * Similar to bus_find_device. It returns a reference to a gpio_chip as | ||
1168 | * determined by a user supplied @match callback. The callback should return | ||
1169 | * 0 if the device doesn't match and non-zero if it does. If the callback is | ||
1170 | * non-zero, this function will return to the caller and not iterate over any | ||
1171 | * more gpio_chips. | ||
1172 | */ | ||
1173 | struct gpio_chip *gpiochip_find(void *data, | ||
1174 | int (*match)(struct gpio_chip *chip, void *data)) | ||
1175 | { | ||
1176 | struct gpio_chip *chip = NULL; | ||
1177 | unsigned long flags; | ||
1178 | int i; | ||
1179 | |||
1180 | spin_lock_irqsave(&gpio_lock, flags); | ||
1181 | for (i = 0; i < ARCH_NR_GPIOS; i++) { | ||
1182 | if (!gpio_desc[i].chip) | ||
1183 | continue; | ||
1184 | |||
1185 | if (match(gpio_desc[i].chip, data)) { | ||
1186 | chip = gpio_desc[i].chip; | ||
1187 | break; | ||
1188 | } | ||
1189 | } | ||
1190 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
1191 | |||
1192 | return chip; | ||
1193 | } | ||
1151 | 1194 | ||
1152 | /* These "optional" allocation calls help prevent drivers from stomping | 1195 | /* These "optional" allocation calls help prevent drivers from stomping |
1153 | * on each other, and help provide better diagnostics in debugfs. | 1196 | * on each other, and help provide better diagnostics in debugfs. |
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c index b8fa65b5bfca..709690995d0d 100644 --- a/drivers/gpio/xilinx_gpio.c +++ b/drivers/gpio/xilinx_gpio.c | |||
@@ -161,14 +161,12 @@ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) | |||
161 | static int __devinit xgpio_of_probe(struct device_node *np) | 161 | static int __devinit xgpio_of_probe(struct device_node *np) |
162 | { | 162 | { |
163 | struct xgpio_instance *chip; | 163 | struct xgpio_instance *chip; |
164 | struct of_gpio_chip *ofchip; | ||
165 | int status = 0; | 164 | int status = 0; |
166 | const u32 *tree_info; | 165 | const u32 *tree_info; |
167 | 166 | ||
168 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 167 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
169 | if (!chip) | 168 | if (!chip) |
170 | return -ENOMEM; | 169 | return -ENOMEM; |
171 | ofchip = &chip->mmchip.of_gc; | ||
172 | 170 | ||
173 | /* Update GPIO state shadow register with default value */ | 171 | /* Update GPIO state shadow register with default value */ |
174 | tree_info = of_get_property(np, "xlnx,dout-default", NULL); | 172 | tree_info = of_get_property(np, "xlnx,dout-default", NULL); |
@@ -182,21 +180,20 @@ static int __devinit xgpio_of_probe(struct device_node *np) | |||
182 | chip->gpio_dir = *tree_info; | 180 | chip->gpio_dir = *tree_info; |
183 | 181 | ||
184 | /* Check device node and parent device node for device width */ | 182 | /* Check device node and parent device node for device width */ |
185 | ofchip->gc.ngpio = 32; /* By default assume full GPIO controller */ | 183 | chip->mmchip.gc.ngpio = 32; /* By default assume full GPIO controller */ |
186 | tree_info = of_get_property(np, "xlnx,gpio-width", NULL); | 184 | tree_info = of_get_property(np, "xlnx,gpio-width", NULL); |
187 | if (!tree_info) | 185 | if (!tree_info) |
188 | tree_info = of_get_property(np->parent, | 186 | tree_info = of_get_property(np->parent, |
189 | "xlnx,gpio-width", NULL); | 187 | "xlnx,gpio-width", NULL); |
190 | if (tree_info) | 188 | if (tree_info) |
191 | ofchip->gc.ngpio = *tree_info; | 189 | chip->mmchip.gc.ngpio = *tree_info; |
192 | 190 | ||
193 | spin_lock_init(&chip->gpio_lock); | 191 | spin_lock_init(&chip->gpio_lock); |
194 | 192 | ||
195 | ofchip->gpio_cells = 2; | 193 | chip->mmchip.gc.direction_input = xgpio_dir_in; |
196 | ofchip->gc.direction_input = xgpio_dir_in; | 194 | chip->mmchip.gc.direction_output = xgpio_dir_out; |
197 | ofchip->gc.direction_output = xgpio_dir_out; | 195 | chip->mmchip.gc.get = xgpio_get; |
198 | ofchip->gc.get = xgpio_get; | 196 | chip->mmchip.gc.set = xgpio_set; |
199 | ofchip->gc.set = xgpio_set; | ||
200 | 197 | ||
201 | chip->mmchip.save_regs = xgpio_save_regs; | 198 | chip->mmchip.save_regs = xgpio_save_regs; |
202 | 199 | ||
diff --git a/drivers/hwmon/ultra45_env.c b/drivers/hwmon/ultra45_env.c index 5da5942cf970..89643261ccdb 100644 --- a/drivers/hwmon/ultra45_env.c +++ b/drivers/hwmon/ultra45_env.c | |||
@@ -311,12 +311,12 @@ static struct of_platform_driver env_driver = { | |||
311 | 311 | ||
312 | static int __init env_init(void) | 312 | static int __init env_init(void) |
313 | { | 313 | { |
314 | return of_register_driver(&env_driver, &of_bus_type); | 314 | return of_register_platform_driver(&env_driver); |
315 | } | 315 | } |
316 | 316 | ||
317 | static void __exit env_exit(void) | 317 | static void __exit env_exit(void) |
318 | { | 318 | { |
319 | of_unregister_driver(&env_driver); | 319 | of_unregister_platform_driver(&env_driver); |
320 | } | 320 | } |
321 | 321 | ||
322 | module_init(env_init); | 322 | module_init(env_init); |
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index b02b4533651d..e591de1bc704 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
@@ -652,6 +652,7 @@ static int __devinit cpm_i2c_probe(struct of_device *ofdev, | |||
652 | cpm->adap = cpm_ops; | 652 | cpm->adap = cpm_ops; |
653 | i2c_set_adapdata(&cpm->adap, cpm); | 653 | i2c_set_adapdata(&cpm->adap, cpm); |
654 | cpm->adap.dev.parent = &ofdev->dev; | 654 | cpm->adap.dev.parent = &ofdev->dev; |
655 | cpm->adap.dev.of_node = of_node_get(ofdev->dev.of_node); | ||
655 | 656 | ||
656 | result = cpm_i2c_setup(cpm); | 657 | result = cpm_i2c_setup(cpm); |
657 | if (result) { | 658 | if (result) { |
@@ -676,11 +677,6 @@ static int __devinit cpm_i2c_probe(struct of_device *ofdev, | |||
676 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", | 677 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", |
677 | cpm->adap.name); | 678 | cpm->adap.name); |
678 | 679 | ||
679 | /* | ||
680 | * register OF I2C devices | ||
681 | */ | ||
682 | of_register_i2c_devices(&cpm->adap, ofdev->dev.of_node); | ||
683 | |||
684 | return 0; | 680 | return 0; |
685 | out_shut: | 681 | out_shut: |
686 | cpm_i2c_shutdown(cpm); | 682 | cpm_i2c_shutdown(cpm); |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index bf344135647a..1168d61418c9 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -745,6 +745,7 @@ static int __devinit iic_probe(struct of_device *ofdev, | |||
745 | /* Register it with i2c layer */ | 745 | /* Register it with i2c layer */ |
746 | adap = &dev->adap; | 746 | adap = &dev->adap; |
747 | adap->dev.parent = &ofdev->dev; | 747 | adap->dev.parent = &ofdev->dev; |
748 | adap->dev.of_node = of_node_get(np); | ||
748 | strlcpy(adap->name, "IBM IIC", sizeof(adap->name)); | 749 | strlcpy(adap->name, "IBM IIC", sizeof(adap->name)); |
749 | i2c_set_adapdata(adap, dev); | 750 | i2c_set_adapdata(adap, dev); |
750 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 751 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
@@ -760,9 +761,6 @@ static int __devinit iic_probe(struct of_device *ofdev, | |||
760 | dev_info(&ofdev->dev, "using %s mode\n", | 761 | dev_info(&ofdev->dev, "using %s mode\n", |
761 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); | 762 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); |
762 | 763 | ||
763 | /* Now register all the child nodes */ | ||
764 | of_register_i2c_devices(adap, np); | ||
765 | |||
766 | return 0; | 764 | return 0; |
767 | 765 | ||
768 | error_cleanup: | 766 | error_cleanup: |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 54247d475fc3..6545d1c99b61 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -625,13 +625,13 @@ static int __devinit fsl_i2c_probe(struct of_device *op, | |||
625 | i2c->adap = mpc_ops; | 625 | i2c->adap = mpc_ops; |
626 | i2c_set_adapdata(&i2c->adap, i2c); | 626 | i2c_set_adapdata(&i2c->adap, i2c); |
627 | i2c->adap.dev.parent = &op->dev; | 627 | i2c->adap.dev.parent = &op->dev; |
628 | i2c->adap.dev.of_node = of_node_get(op->dev.of_node); | ||
628 | 629 | ||
629 | result = i2c_add_adapter(&i2c->adap); | 630 | result = i2c_add_adapter(&i2c->adap); |
630 | if (result < 0) { | 631 | if (result < 0) { |
631 | dev_err(i2c->dev, "failed to add adapter\n"); | 632 | dev_err(i2c->dev, "failed to add adapter\n"); |
632 | goto fail_add; | 633 | goto fail_add; |
633 | } | 634 | } |
634 | of_register_i2c_devices(&i2c->adap, op->dev.of_node); | ||
635 | 635 | ||
636 | return result; | 636 | return result; |
637 | 637 | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 0815e10da7c6..df937df845eb 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | #include <linux/of_i2c.h> | ||
34 | #include <linux/of_device.h> | ||
33 | #include <linux/completion.h> | 35 | #include <linux/completion.h> |
34 | #include <linux/hardirq.h> | 36 | #include <linux/hardirq.h> |
35 | #include <linux/irqflags.h> | 37 | #include <linux/irqflags.h> |
@@ -70,6 +72,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) | |||
70 | if (!client) | 72 | if (!client) |
71 | return 0; | 73 | return 0; |
72 | 74 | ||
75 | /* Attempt an OF style match */ | ||
76 | if (of_driver_match_device(dev, drv)) | ||
77 | return 1; | ||
78 | |||
73 | driver = to_i2c_driver(drv); | 79 | driver = to_i2c_driver(drv); |
74 | /* match on an id table if there is one */ | 80 | /* match on an id table if there is one */ |
75 | if (driver->id_table) | 81 | if (driver->id_table) |
@@ -790,6 +796,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
790 | if (adap->nr < __i2c_first_dynamic_bus_num) | 796 | if (adap->nr < __i2c_first_dynamic_bus_num) |
791 | i2c_scan_static_board_info(adap); | 797 | i2c_scan_static_board_info(adap); |
792 | 798 | ||
799 | /* Register devices from the device tree */ | ||
800 | of_i2c_register_devices(adap); | ||
801 | |||
793 | /* Notify drivers */ | 802 | /* Notify drivers */ |
794 | mutex_lock(&core_lock); | 803 | mutex_lock(&core_lock); |
795 | dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, | 804 | dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, |
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index 1dacae4b43f0..f3bb92e9755f 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -353,14 +353,12 @@ static struct of_platform_driver grover_beep_driver = { | |||
353 | 353 | ||
354 | static int __init sparcspkr_init(void) | 354 | static int __init sparcspkr_init(void) |
355 | { | 355 | { |
356 | int err = of_register_driver(&bbc_beep_driver, | 356 | int err = of_register_platform_driver(&bbc_beep_driver); |
357 | &of_platform_bus_type); | ||
358 | 357 | ||
359 | if (!err) { | 358 | if (!err) { |
360 | err = of_register_driver(&grover_beep_driver, | 359 | err = of_register_platform_driver(&grover_beep_driver); |
361 | &of_platform_bus_type); | ||
362 | if (err) | 360 | if (err) |
363 | of_unregister_driver(&bbc_beep_driver); | 361 | of_unregister_platform_driver(&bbc_beep_driver); |
364 | } | 362 | } |
365 | 363 | ||
366 | return err; | 364 | return err; |
@@ -368,8 +366,8 @@ static int __init sparcspkr_init(void) | |||
368 | 366 | ||
369 | static void __exit sparcspkr_exit(void) | 367 | static void __exit sparcspkr_exit(void) |
370 | { | 368 | { |
371 | of_unregister_driver(&bbc_beep_driver); | 369 | of_unregister_platform_driver(&bbc_beep_driver); |
372 | of_unregister_driver(&grover_beep_driver); | 370 | of_unregister_platform_driver(&grover_beep_driver); |
373 | } | 371 | } |
374 | 372 | ||
375 | module_init(sparcspkr_init); | 373 | module_init(sparcspkr_init); |
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index 04e32f2d1241..cb2a24b94746 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h | |||
@@ -58,9 +58,9 @@ static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_dev | |||
58 | if (!strcmp(dp->name, OBP_PS2KBD_NAME1) || | 58 | if (!strcmp(dp->name, OBP_PS2KBD_NAME1) || |
59 | !strcmp(dp->name, OBP_PS2KBD_NAME2)) { | 59 | !strcmp(dp->name, OBP_PS2KBD_NAME2)) { |
60 | struct of_device *kbd = of_find_device_by_node(dp); | 60 | struct of_device *kbd = of_find_device_by_node(dp); |
61 | unsigned int irq = kbd->irqs[0]; | 61 | unsigned int irq = kbd->archdata.irqs[0]; |
62 | if (irq == 0xffffffff) | 62 | if (irq == 0xffffffff) |
63 | irq = op->irqs[0]; | 63 | irq = op->archdata.irqs[0]; |
64 | i8042_kbd_irq = irq; | 64 | i8042_kbd_irq = irq; |
65 | kbd_iobase = of_ioremap(&kbd->resource[0], | 65 | kbd_iobase = of_ioremap(&kbd->resource[0], |
66 | 0, 8, "kbd"); | 66 | 0, 8, "kbd"); |
@@ -68,9 +68,9 @@ static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_dev | |||
68 | } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) || | 68 | } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) || |
69 | !strcmp(dp->name, OBP_PS2MS_NAME2)) { | 69 | !strcmp(dp->name, OBP_PS2MS_NAME2)) { |
70 | struct of_device *ms = of_find_device_by_node(dp); | 70 | struct of_device *ms = of_find_device_by_node(dp); |
71 | unsigned int irq = ms->irqs[0]; | 71 | unsigned int irq = ms->archdata.irqs[0]; |
72 | if (irq == 0xffffffff) | 72 | if (irq == 0xffffffff) |
73 | irq = op->irqs[0]; | 73 | irq = op->archdata.irqs[0]; |
74 | i8042_aux_irq = irq; | 74 | i8042_aux_irq = irq; |
75 | } | 75 | } |
76 | 76 | ||
@@ -116,8 +116,7 @@ static int __init i8042_platform_init(void) | |||
116 | if (!kbd_iobase) | 116 | if (!kbd_iobase) |
117 | return -ENODEV; | 117 | return -ENODEV; |
118 | } else { | 118 | } else { |
119 | int err = of_register_driver(&sparc_i8042_driver, | 119 | int err = of_register_platform_driver(&sparc_i8042_driver); |
120 | &of_bus_type); | ||
121 | if (err) | 120 | if (err) |
122 | return err; | 121 | return err; |
123 | 122 | ||
@@ -141,7 +140,7 @@ static inline void i8042_platform_exit(void) | |||
141 | struct device_node *root = of_find_node_by_path("/"); | 140 | struct device_node *root = of_find_node_by_path("/"); |
142 | 141 | ||
143 | if (strcmp(root->name, "SUNW,JavaStation-1")) | 142 | if (strcmp(root->name, "SUNW,JavaStation-1")) |
144 | of_unregister_driver(&sparc_i8042_driver); | 143 | of_unregister_platform_driver(&sparc_i8042_driver); |
145 | } | 144 | } |
146 | 145 | ||
147 | #else /* !CONFIG_PCI */ | 146 | #else /* !CONFIG_PCI */ |
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index 6999ce59fd10..6024038a5b9d 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c | |||
@@ -41,10 +41,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf) | |||
41 | static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, | 41 | static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, |
42 | char *buf) | 42 | char *buf) |
43 | { | 43 | { |
44 | struct of_device *ofdev = to_of_device(dev); | 44 | int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); |
45 | int len; | ||
46 | |||
47 | len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); | ||
48 | 45 | ||
49 | buf[len] = '\n'; | 46 | buf[len] = '\n'; |
50 | buf[len+1] = 0; | 47 | buf[len+1] = 0; |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index ad847a24a675..7b0f3ef50f96 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1533,12 +1533,20 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) | |||
1533 | return 0; | 1533 | return 0; |
1534 | } | 1534 | } |
1535 | 1535 | ||
1536 | #if defined(CONFIG_OF) | ||
1537 | static struct of_device_id mmc_spi_of_match_table[] __devinitdata = { | ||
1538 | { .compatible = "mmc-spi-slot", }, | ||
1539 | }; | ||
1540 | #endif | ||
1536 | 1541 | ||
1537 | static struct spi_driver mmc_spi_driver = { | 1542 | static struct spi_driver mmc_spi_driver = { |
1538 | .driver = { | 1543 | .driver = { |
1539 | .name = "mmc_spi", | 1544 | .name = "mmc_spi", |
1540 | .bus = &spi_bus_type, | 1545 | .bus = &spi_bus_type, |
1541 | .owner = THIS_MODULE, | 1546 | .owner = THIS_MODULE, |
1547 | #if defined(CONFIG_OF) | ||
1548 | .of_match_table = mmc_spi_of_match_table, | ||
1549 | #endif | ||
1542 | }, | 1550 | }, |
1543 | .probe = mmc_spi_probe, | 1551 | .probe = mmc_spi_probe, |
1544 | .remove = __devexit_p(mmc_spi_remove), | 1552 | .remove = __devexit_p(mmc_spi_remove), |
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c index 0391c2527bd7..8984236a8d0a 100644 --- a/drivers/mtd/maps/sun_uflash.c +++ b/drivers/mtd/maps/sun_uflash.c | |||
@@ -160,12 +160,12 @@ static struct of_platform_driver uflash_driver = { | |||
160 | 160 | ||
161 | static int __init uflash_init(void) | 161 | static int __init uflash_init(void) |
162 | { | 162 | { |
163 | return of_register_driver(&uflash_driver, &of_bus_type); | 163 | return of_register_platform_driver(&uflash_driver); |
164 | } | 164 | } |
165 | 165 | ||
166 | static void __exit uflash_exit(void) | 166 | static void __exit uflash_exit(void) |
167 | { | 167 | { |
168 | of_unregister_driver(&uflash_driver); | 168 | of_unregister_platform_driver(&uflash_driver); |
169 | } | 169 | } |
170 | 170 | ||
171 | module_init(uflash_init); | 171 | module_init(uflash_init); |
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index b4c41d72c423..f53f850b6418 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/mii.h> | 35 | #include <linux/mii.h> |
36 | #include <linux/phy.h> | 36 | #include <linux/phy.h> |
37 | #include <linux/of.h> | 37 | #include <linux/of.h> |
38 | #include <linux/of_address.h> | ||
38 | #include <linux/of_mdio.h> | 39 | #include <linux/of_mdio.h> |
39 | #include <linux/of_platform.h> | 40 | #include <linux/of_platform.h> |
40 | 41 | ||
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 0f1d4e96cf89..eeec7bc2ce74 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -2339,11 +2339,11 @@ static int __devinit emac_wait_deps(struct emac_instance *dev) | |||
2339 | deps[EMAC_DEP_MDIO_IDX].phandle = dev->mdio_ph; | 2339 | deps[EMAC_DEP_MDIO_IDX].phandle = dev->mdio_ph; |
2340 | if (dev->blist && dev->blist > emac_boot_list) | 2340 | if (dev->blist && dev->blist > emac_boot_list) |
2341 | deps[EMAC_DEP_PREV_IDX].phandle = 0xffffffffu; | 2341 | deps[EMAC_DEP_PREV_IDX].phandle = 0xffffffffu; |
2342 | bus_register_notifier(&of_platform_bus_type, &emac_of_bus_notifier); | 2342 | bus_register_notifier(&platform_bus_type, &emac_of_bus_notifier); |
2343 | wait_event_timeout(emac_probe_wait, | 2343 | wait_event_timeout(emac_probe_wait, |
2344 | emac_check_deps(dev, deps), | 2344 | emac_check_deps(dev, deps), |
2345 | EMAC_PROBE_DEP_TIMEOUT); | 2345 | EMAC_PROBE_DEP_TIMEOUT); |
2346 | bus_unregister_notifier(&of_platform_bus_type, &emac_of_bus_notifier); | 2346 | bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier); |
2347 | err = emac_check_deps(dev, deps) ? 0 : -ENODEV; | 2347 | err = emac_check_deps(dev, deps) ? 0 : -ENODEV; |
2348 | for (i = 0; i < EMAC_DEP_COUNT; i++) { | 2348 | for (i = 0; i < EMAC_DEP_COUNT; i++) { |
2349 | if (deps[i].node) | 2349 | if (deps[i].node) |
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 1a57c3da1f49..04e552aa14ec 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c | |||
@@ -1079,7 +1079,7 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic | |||
1079 | 1079 | ||
1080 | mp->dev = dev; | 1080 | mp->dev = dev; |
1081 | dev->watchdog_timeo = 5*HZ; | 1081 | dev->watchdog_timeo = 5*HZ; |
1082 | dev->irq = op->irqs[0]; | 1082 | dev->irq = op->archdata.irqs[0]; |
1083 | dev->netdev_ops = &myri_ops; | 1083 | dev->netdev_ops = &myri_ops; |
1084 | 1084 | ||
1085 | /* Register interrupt handler now. */ | 1085 | /* Register interrupt handler now. */ |
@@ -1172,12 +1172,12 @@ static struct of_platform_driver myri_sbus_driver = { | |||
1172 | 1172 | ||
1173 | static int __init myri_sbus_init(void) | 1173 | static int __init myri_sbus_init(void) |
1174 | { | 1174 | { |
1175 | return of_register_driver(&myri_sbus_driver, &of_bus_type); | 1175 | return of_register_platform_driver(&myri_sbus_driver); |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | static void __exit myri_sbus_exit(void) | 1178 | static void __exit myri_sbus_exit(void) |
1179 | { | 1179 | { |
1180 | of_unregister_driver(&myri_sbus_driver); | 1180 | of_unregister_platform_driver(&myri_sbus_driver); |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | module_init(myri_sbus_init); | 1183 | module_init(myri_sbus_init); |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index b9b950845b0e..404f2d552888 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -28,10 +28,7 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | 29 | ||
30 | #include <linux/io.h> | 30 | #include <linux/io.h> |
31 | |||
32 | #ifdef CONFIG_SPARC64 | ||
33 | #include <linux/of_device.h> | 31 | #include <linux/of_device.h> |
34 | #endif | ||
35 | 32 | ||
36 | #include "niu.h" | 33 | #include "niu.h" |
37 | 34 | ||
@@ -9114,12 +9111,12 @@ static int __devinit niu_n2_irq_init(struct niu *np, u8 *ldg_num_map) | |||
9114 | if (!int_prop) | 9111 | if (!int_prop) |
9115 | return -ENODEV; | 9112 | return -ENODEV; |
9116 | 9113 | ||
9117 | for (i = 0; i < op->num_irqs; i++) { | 9114 | for (i = 0; i < op->archdata.num_irqs; i++) { |
9118 | ldg_num_map[i] = int_prop[i]; | 9115 | ldg_num_map[i] = int_prop[i]; |
9119 | np->ldg[i].irq = op->irqs[i]; | 9116 | np->ldg[i].irq = op->archdata.irqs[i]; |
9120 | } | 9117 | } |
9121 | 9118 | ||
9122 | np->num_ldg = op->num_irqs; | 9119 | np->num_ldg = op->archdata.num_irqs; |
9123 | 9120 | ||
9124 | return 0; | 9121 | return 0; |
9125 | #else | 9122 | #else |
@@ -10249,14 +10246,14 @@ static int __init niu_init(void) | |||
10249 | niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT); | 10246 | niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT); |
10250 | 10247 | ||
10251 | #ifdef CONFIG_SPARC64 | 10248 | #ifdef CONFIG_SPARC64 |
10252 | err = of_register_driver(&niu_of_driver, &of_bus_type); | 10249 | err = of_register_platform_driver(&niu_of_driver); |
10253 | #endif | 10250 | #endif |
10254 | 10251 | ||
10255 | if (!err) { | 10252 | if (!err) { |
10256 | err = pci_register_driver(&niu_pci_driver); | 10253 | err = pci_register_driver(&niu_pci_driver); |
10257 | #ifdef CONFIG_SPARC64 | 10254 | #ifdef CONFIG_SPARC64 |
10258 | if (err) | 10255 | if (err) |
10259 | of_unregister_driver(&niu_of_driver); | 10256 | of_unregister_platform_driver(&niu_of_driver); |
10260 | #endif | 10257 | #endif |
10261 | } | 10258 | } |
10262 | 10259 | ||
@@ -10267,7 +10264,7 @@ static void __exit niu_exit(void) | |||
10267 | { | 10264 | { |
10268 | pci_unregister_driver(&niu_pci_driver); | 10265 | pci_unregister_driver(&niu_pci_driver); |
10269 | #ifdef CONFIG_SPARC64 | 10266 | #ifdef CONFIG_SPARC64 |
10270 | of_unregister_driver(&niu_of_driver); | 10267 | of_unregister_platform_driver(&niu_of_driver); |
10271 | #endif | 10268 | #endif |
10272 | } | 10269 | } |
10273 | 10270 | ||
diff --git a/drivers/net/niu.h b/drivers/net/niu.h index d6715465f35d..a41fa8ebe05f 100644 --- a/drivers/net/niu.h +++ b/drivers/net/niu.h | |||
@@ -3236,7 +3236,7 @@ struct niu_phy_ops { | |||
3236 | int (*link_status)(struct niu *np, int *); | 3236 | int (*link_status)(struct niu *np, int *); |
3237 | }; | 3237 | }; |
3238 | 3238 | ||
3239 | struct of_device; | 3239 | struct platform_device; |
3240 | struct niu { | 3240 | struct niu { |
3241 | void __iomem *regs; | 3241 | void __iomem *regs; |
3242 | struct net_device *dev; | 3242 | struct net_device *dev; |
@@ -3297,7 +3297,7 @@ struct niu { | |||
3297 | struct niu_vpd vpd; | 3297 | struct niu_vpd vpd; |
3298 | u32 eeprom_len; | 3298 | u32 eeprom_len; |
3299 | 3299 | ||
3300 | struct of_device *op; | 3300 | struct platform_device *op; |
3301 | void __iomem *vir_regs_1; | 3301 | void __iomem *vir_regs_1; |
3302 | void __iomem *vir_regs_2; | 3302 | void __iomem *vir_regs_2; |
3303 | }; | 3303 | }; |
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index 367e96f317d4..09c071bd6ad4 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c | |||
@@ -1201,7 +1201,7 @@ static int __devinit bigmac_ether_init(struct of_device *op, | |||
1201 | dev->watchdog_timeo = 5*HZ; | 1201 | dev->watchdog_timeo = 5*HZ; |
1202 | 1202 | ||
1203 | /* Finish net device registration. */ | 1203 | /* Finish net device registration. */ |
1204 | dev->irq = bp->bigmac_op->irqs[0]; | 1204 | dev->irq = bp->bigmac_op->archdata.irqs[0]; |
1205 | dev->dma = 0; | 1205 | dev->dma = 0; |
1206 | 1206 | ||
1207 | if (register_netdev(dev)) { | 1207 | if (register_netdev(dev)) { |
@@ -1301,12 +1301,12 @@ static struct of_platform_driver bigmac_sbus_driver = { | |||
1301 | 1301 | ||
1302 | static int __init bigmac_init(void) | 1302 | static int __init bigmac_init(void) |
1303 | { | 1303 | { |
1304 | return of_register_driver(&bigmac_sbus_driver, &of_bus_type); | 1304 | return of_register_platform_driver(&bigmac_sbus_driver); |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | static void __exit bigmac_exit(void) | 1307 | static void __exit bigmac_exit(void) |
1308 | { | 1308 | { |
1309 | of_unregister_driver(&bigmac_sbus_driver); | 1309 | of_unregister_platform_driver(&bigmac_sbus_driver); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | module_init(bigmac_init); | 1312 | module_init(bigmac_init); |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 3d9650b8d38f..eec443f64079 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -2561,7 +2561,7 @@ static int __init quattro_sbus_register_irqs(void) | |||
2561 | if (skip) | 2561 | if (skip) |
2562 | continue; | 2562 | continue; |
2563 | 2563 | ||
2564 | err = request_irq(op->irqs[0], | 2564 | err = request_irq(op->archdata.irqs[0], |
2565 | quattro_sbus_interrupt, | 2565 | quattro_sbus_interrupt, |
2566 | IRQF_SHARED, "Quattro", | 2566 | IRQF_SHARED, "Quattro", |
2567 | qp); | 2567 | qp); |
@@ -2590,7 +2590,7 @@ static void quattro_sbus_free_irqs(void) | |||
2590 | if (skip) | 2590 | if (skip) |
2591 | continue; | 2591 | continue; |
2592 | 2592 | ||
2593 | free_irq(op->irqs[0], qp); | 2593 | free_irq(op->archdata.irqs[0], qp); |
2594 | } | 2594 | } |
2595 | } | 2595 | } |
2596 | #endif /* CONFIG_SBUS */ | 2596 | #endif /* CONFIG_SBUS */ |
@@ -2790,7 +2790,7 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) | |||
2790 | /* Happy Meal can do it all... */ | 2790 | /* Happy Meal can do it all... */ |
2791 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; | 2791 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; |
2792 | 2792 | ||
2793 | dev->irq = op->irqs[0]; | 2793 | dev->irq = op->archdata.irqs[0]; |
2794 | 2794 | ||
2795 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) | 2795 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) |
2796 | /* Hook up SBUS register/descriptor accessors. */ | 2796 | /* Hook up SBUS register/descriptor accessors. */ |
@@ -3304,7 +3304,7 @@ static int __init happy_meal_sbus_init(void) | |||
3304 | { | 3304 | { |
3305 | int err; | 3305 | int err; |
3306 | 3306 | ||
3307 | err = of_register_driver(&hme_sbus_driver, &of_bus_type); | 3307 | err = of_register_platform_driver(&hme_sbus_driver); |
3308 | if (!err) | 3308 | if (!err) |
3309 | err = quattro_sbus_register_irqs(); | 3309 | err = quattro_sbus_register_irqs(); |
3310 | 3310 | ||
@@ -3313,7 +3313,7 @@ static int __init happy_meal_sbus_init(void) | |||
3313 | 3313 | ||
3314 | static void happy_meal_sbus_exit(void) | 3314 | static void happy_meal_sbus_exit(void) |
3315 | { | 3315 | { |
3316 | of_unregister_driver(&hme_sbus_driver); | 3316 | of_unregister_platform_driver(&hme_sbus_driver); |
3317 | quattro_sbus_free_irqs(); | 3317 | quattro_sbus_free_irqs(); |
3318 | 3318 | ||
3319 | while (qfe_sbus_list) { | 3319 | while (qfe_sbus_list) { |
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index 7d9c33dd9d1a..ee364fa75634 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
@@ -1474,7 +1474,7 @@ no_link_test: | |||
1474 | dev->ethtool_ops = &sparc_lance_ethtool_ops; | 1474 | dev->ethtool_ops = &sparc_lance_ethtool_ops; |
1475 | dev->netdev_ops = &sparc_lance_ops; | 1475 | dev->netdev_ops = &sparc_lance_ops; |
1476 | 1476 | ||
1477 | dev->irq = op->irqs[0]; | 1477 | dev->irq = op->archdata.irqs[0]; |
1478 | 1478 | ||
1479 | /* We cannot sleep if the chip is busy during a | 1479 | /* We cannot sleep if the chip is busy during a |
1480 | * multicast list update event, because such events | 1480 | * multicast list update event, because such events |
@@ -1558,12 +1558,12 @@ static struct of_platform_driver sunlance_sbus_driver = { | |||
1558 | /* Find all the lance cards on the system and initialize them */ | 1558 | /* Find all the lance cards on the system and initialize them */ |
1559 | static int __init sparc_lance_init(void) | 1559 | static int __init sparc_lance_init(void) |
1560 | { | 1560 | { |
1561 | return of_register_driver(&sunlance_sbus_driver, &of_bus_type); | 1561 | return of_register_platform_driver(&sunlance_sbus_driver); |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | static void __exit sparc_lance_exit(void) | 1564 | static void __exit sparc_lance_exit(void) |
1565 | { | 1565 | { |
1566 | of_unregister_driver(&sunlance_sbus_driver); | 1566 | of_unregister_platform_driver(&sunlance_sbus_driver); |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | module_init(sparc_lance_init); | 1569 | module_init(sparc_lance_init); |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index 72b579c8d812..5f84a5dadedd 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
@@ -803,7 +803,7 @@ static struct sunqec * __devinit get_qec(struct of_device *child) | |||
803 | 803 | ||
804 | qec_init_once(qecp, op); | 804 | qec_init_once(qecp, op); |
805 | 805 | ||
806 | if (request_irq(op->irqs[0], qec_interrupt, | 806 | if (request_irq(op->archdata.irqs[0], qec_interrupt, |
807 | IRQF_SHARED, "qec", (void *) qecp)) { | 807 | IRQF_SHARED, "qec", (void *) qecp)) { |
808 | printk(KERN_ERR "qec: Can't register irq.\n"); | 808 | printk(KERN_ERR "qec: Can't register irq.\n"); |
809 | goto fail; | 809 | goto fail; |
@@ -901,7 +901,7 @@ static int __devinit qec_ether_init(struct of_device *op) | |||
901 | SET_NETDEV_DEV(dev, &op->dev); | 901 | SET_NETDEV_DEV(dev, &op->dev); |
902 | 902 | ||
903 | dev->watchdog_timeo = 5*HZ; | 903 | dev->watchdog_timeo = 5*HZ; |
904 | dev->irq = op->irqs[0]; | 904 | dev->irq = op->archdata.irqs[0]; |
905 | dev->dma = 0; | 905 | dev->dma = 0; |
906 | dev->ethtool_ops = &qe_ethtool_ops; | 906 | dev->ethtool_ops = &qe_ethtool_ops; |
907 | dev->netdev_ops = &qec_ops; | 907 | dev->netdev_ops = &qec_ops; |
@@ -988,18 +988,18 @@ static struct of_platform_driver qec_sbus_driver = { | |||
988 | 988 | ||
989 | static int __init qec_init(void) | 989 | static int __init qec_init(void) |
990 | { | 990 | { |
991 | return of_register_driver(&qec_sbus_driver, &of_bus_type); | 991 | return of_register_platform_driver(&qec_sbus_driver); |
992 | } | 992 | } |
993 | 993 | ||
994 | static void __exit qec_exit(void) | 994 | static void __exit qec_exit(void) |
995 | { | 995 | { |
996 | of_unregister_driver(&qec_sbus_driver); | 996 | of_unregister_platform_driver(&qec_sbus_driver); |
997 | 997 | ||
998 | while (root_qec_dev) { | 998 | while (root_qec_dev) { |
999 | struct sunqec *next = root_qec_dev->next_module; | 999 | struct sunqec *next = root_qec_dev->next_module; |
1000 | struct of_device *op = root_qec_dev->op; | 1000 | struct of_device *op = root_qec_dev->op; |
1001 | 1001 | ||
1002 | free_irq(op->irqs[0], (void *) root_qec_dev); | 1002 | free_irq(op->archdata.irqs[0], (void *) root_qec_dev); |
1003 | of_iounmap(&op->resource[0], root_qec_dev->gregs, | 1003 | of_iounmap(&op->resource[0], root_qec_dev->gregs, |
1004 | GLOB_REG_SIZE); | 1004 | GLOB_REG_SIZE); |
1005 | kfree(root_qec_dev); | 1005 | kfree(root_qec_dev); |
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index d04c5b262050..b2c2f391b29d 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/skbuff.h> | 20 | #include <linux/skbuff.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | 23 | #include <linux/of_address.h> | |
24 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
25 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
26 | #include <linux/of_mdio.h> | 26 | #include <linux/of_mdio.h> |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 7cecc8fea9bd..6acbff389ab6 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -1,35 +1,61 @@ | |||
1 | config OF_FLATTREE | 1 | config DTC |
2 | bool | ||
3 | |||
4 | config OF | ||
2 | bool | 5 | bool |
6 | |||
7 | menu "Flattened Device Tree and Open Firmware support" | ||
3 | depends on OF | 8 | depends on OF |
4 | 9 | ||
10 | config PROC_DEVICETREE | ||
11 | bool "Support for device tree in /proc" | ||
12 | depends on PROC_FS && !SPARC | ||
13 | help | ||
14 | This option adds a device-tree directory under /proc which contains | ||
15 | an image of the device tree that the kernel copies from Open | ||
16 | Firmware or other boot firmware. If unsure, say Y here. | ||
17 | |||
18 | config OF_FLATTREE | ||
19 | bool | ||
20 | select DTC | ||
21 | |||
5 | config OF_DYNAMIC | 22 | config OF_DYNAMIC |
6 | def_bool y | 23 | def_bool y |
7 | depends on OF && PPC_OF | 24 | depends on PPC_OF |
25 | |||
26 | config OF_ADDRESS | ||
27 | def_bool y | ||
28 | depends on !SPARC | ||
29 | |||
30 | config OF_IRQ | ||
31 | def_bool y | ||
32 | depends on !SPARC | ||
8 | 33 | ||
9 | config OF_DEVICE | 34 | config OF_DEVICE |
10 | def_bool y | 35 | def_bool y |
11 | depends on OF && (SPARC || PPC_OF || MICROBLAZE) | ||
12 | 36 | ||
13 | config OF_GPIO | 37 | config OF_GPIO |
14 | def_bool y | 38 | def_bool y |
15 | depends on OF && (PPC_OF || MICROBLAZE) && GPIOLIB | 39 | depends on GPIOLIB && !SPARC |
16 | help | 40 | help |
17 | OpenFirmware GPIO accessors | 41 | OpenFirmware GPIO accessors |
18 | 42 | ||
19 | config OF_I2C | 43 | config OF_I2C |
20 | def_tristate I2C | 44 | def_tristate I2C |
21 | depends on (PPC_OF || MICROBLAZE) && I2C | 45 | depends on I2C && !SPARC |
22 | help | 46 | help |
23 | OpenFirmware I2C accessors | 47 | OpenFirmware I2C accessors |
24 | 48 | ||
25 | config OF_SPI | 49 | config OF_SPI |
26 | def_tristate SPI | 50 | def_tristate SPI |
27 | depends on OF && (PPC_OF || MICROBLAZE) && SPI | 51 | depends on SPI && !SPARC |
28 | help | 52 | help |
29 | OpenFirmware SPI accessors | 53 | OpenFirmware SPI accessors |
30 | 54 | ||
31 | config OF_MDIO | 55 | config OF_MDIO |
32 | def_tristate PHYLIB | 56 | def_tristate PHYLIB |
33 | depends on OF && PHYLIB | 57 | depends on PHYLIB |
34 | help | 58 | help |
35 | OpenFirmware MDIO bus (Ethernet PHY) accessors | 59 | OpenFirmware MDIO bus (Ethernet PHY) accessors |
60 | |||
61 | endmenu # OF | ||
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index f232cc98ce00..0052c405463a 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
@@ -1,5 +1,7 @@ | |||
1 | obj-y = base.o | 1 | obj-y = base.o |
2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o | 2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o |
3 | obj-$(CONFIG_OF_ADDRESS) += address.o | ||
4 | obj-$(CONFIG_OF_IRQ) += irq.o | ||
3 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o | 5 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o |
4 | obj-$(CONFIG_OF_GPIO) += gpio.o | 6 | obj-$(CONFIG_OF_GPIO) += gpio.o |
5 | obj-$(CONFIG_OF_I2C) += of_i2c.o | 7 | obj-$(CONFIG_OF_I2C) += of_i2c.o |
diff --git a/drivers/of/address.c b/drivers/of/address.c new file mode 100644 index 000000000000..fcadb726d4f9 --- /dev/null +++ b/drivers/of/address.c | |||
@@ -0,0 +1,595 @@ | |||
1 | |||
2 | #include <linux/io.h> | ||
3 | #include <linux/ioport.h> | ||
4 | #include <linux/module.h> | ||
5 | #include <linux/of_address.h> | ||
6 | #include <linux/pci_regs.h> | ||
7 | #include <linux/string.h> | ||
8 | |||
9 | /* Max address size we deal with */ | ||
10 | #define OF_MAX_ADDR_CELLS 4 | ||
11 | #define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ | ||
12 | (ns) > 0) | ||
13 | |||
14 | static struct of_bus *of_match_bus(struct device_node *np); | ||
15 | static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | ||
16 | u64 size, unsigned int flags, | ||
17 | struct resource *r); | ||
18 | |||
19 | /* Debug utility */ | ||
20 | #ifdef DEBUG | ||
21 | static void of_dump_addr(const char *s, const u32 *addr, int na) | ||
22 | { | ||
23 | printk(KERN_DEBUG "%s", s); | ||
24 | while (na--) | ||
25 | printk(" %08x", be32_to_cpu(*(addr++))); | ||
26 | printk("\n"); | ||
27 | } | ||
28 | #else | ||
29 | static void of_dump_addr(const char *s, const u32 *addr, int na) { } | ||
30 | #endif | ||
31 | |||
32 | /* Callbacks for bus specific translators */ | ||
33 | struct of_bus { | ||
34 | const char *name; | ||
35 | const char *addresses; | ||
36 | int (*match)(struct device_node *parent); | ||
37 | void (*count_cells)(struct device_node *child, | ||
38 | int *addrc, int *sizec); | ||
39 | u64 (*map)(u32 *addr, const u32 *range, | ||
40 | int na, int ns, int pna); | ||
41 | int (*translate)(u32 *addr, u64 offset, int na); | ||
42 | unsigned int (*get_flags)(const u32 *addr); | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * Default translator (generic bus) | ||
47 | */ | ||
48 | |||
49 | static void of_bus_default_count_cells(struct device_node *dev, | ||
50 | int *addrc, int *sizec) | ||
51 | { | ||
52 | if (addrc) | ||
53 | *addrc = of_n_addr_cells(dev); | ||
54 | if (sizec) | ||
55 | *sizec = of_n_size_cells(dev); | ||
56 | } | ||
57 | |||
58 | static u64 of_bus_default_map(u32 *addr, const u32 *range, | ||
59 | int na, int ns, int pna) | ||
60 | { | ||
61 | u64 cp, s, da; | ||
62 | |||
63 | cp = of_read_number(range, na); | ||
64 | s = of_read_number(range + na + pna, ns); | ||
65 | da = of_read_number(addr, na); | ||
66 | |||
67 | pr_debug("OF: default map, cp=%llx, s=%llx, da=%llx\n", | ||
68 | (unsigned long long)cp, (unsigned long long)s, | ||
69 | (unsigned long long)da); | ||
70 | |||
71 | if (da < cp || da >= (cp + s)) | ||
72 | return OF_BAD_ADDR; | ||
73 | return da - cp; | ||
74 | } | ||
75 | |||
76 | static int of_bus_default_translate(u32 *addr, u64 offset, int na) | ||
77 | { | ||
78 | u64 a = of_read_number(addr, na); | ||
79 | memset(addr, 0, na * 4); | ||
80 | a += offset; | ||
81 | if (na > 1) | ||
82 | addr[na - 2] = cpu_to_be32(a >> 32); | ||
83 | addr[na - 1] = cpu_to_be32(a & 0xffffffffu); | ||
84 | |||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static unsigned int of_bus_default_get_flags(const u32 *addr) | ||
89 | { | ||
90 | return IORESOURCE_MEM; | ||
91 | } | ||
92 | |||
93 | #ifdef CONFIG_PCI | ||
94 | /* | ||
95 | * PCI bus specific translator | ||
96 | */ | ||
97 | |||
98 | static int of_bus_pci_match(struct device_node *np) | ||
99 | { | ||
100 | /* "vci" is for the /chaos bridge on 1st-gen PCI powermacs */ | ||
101 | return !strcmp(np->type, "pci") || !strcmp(np->type, "vci"); | ||
102 | } | ||
103 | |||
104 | static void of_bus_pci_count_cells(struct device_node *np, | ||
105 | int *addrc, int *sizec) | ||
106 | { | ||
107 | if (addrc) | ||
108 | *addrc = 3; | ||
109 | if (sizec) | ||
110 | *sizec = 2; | ||
111 | } | ||
112 | |||
113 | static unsigned int of_bus_pci_get_flags(const u32 *addr) | ||
114 | { | ||
115 | unsigned int flags = 0; | ||
116 | u32 w = addr[0]; | ||
117 | |||
118 | switch((w >> 24) & 0x03) { | ||
119 | case 0x01: | ||
120 | flags |= IORESOURCE_IO; | ||
121 | break; | ||
122 | case 0x02: /* 32 bits */ | ||
123 | case 0x03: /* 64 bits */ | ||
124 | flags |= IORESOURCE_MEM; | ||
125 | break; | ||
126 | } | ||
127 | if (w & 0x40000000) | ||
128 | flags |= IORESOURCE_PREFETCH; | ||
129 | return flags; | ||
130 | } | ||
131 | |||
132 | static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) | ||
133 | { | ||
134 | u64 cp, s, da; | ||
135 | unsigned int af, rf; | ||
136 | |||
137 | af = of_bus_pci_get_flags(addr); | ||
138 | rf = of_bus_pci_get_flags(range); | ||
139 | |||
140 | /* Check address type match */ | ||
141 | if ((af ^ rf) & (IORESOURCE_MEM | IORESOURCE_IO)) | ||
142 | return OF_BAD_ADDR; | ||
143 | |||
144 | /* Read address values, skipping high cell */ | ||
145 | cp = of_read_number(range + 1, na - 1); | ||
146 | s = of_read_number(range + na + pna, ns); | ||
147 | da = of_read_number(addr + 1, na - 1); | ||
148 | |||
149 | pr_debug("OF: PCI map, cp=%llx, s=%llx, da=%llx\n", | ||
150 | (unsigned long long)cp, (unsigned long long)s, | ||
151 | (unsigned long long)da); | ||
152 | |||
153 | if (da < cp || da >= (cp + s)) | ||
154 | return OF_BAD_ADDR; | ||
155 | return da - cp; | ||
156 | } | ||
157 | |||
158 | static int of_bus_pci_translate(u32 *addr, u64 offset, int na) | ||
159 | { | ||
160 | return of_bus_default_translate(addr + 1, offset, na - 1); | ||
161 | } | ||
162 | |||
163 | const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | ||
164 | unsigned int *flags) | ||
165 | { | ||
166 | const u32 *prop; | ||
167 | unsigned int psize; | ||
168 | struct device_node *parent; | ||
169 | struct of_bus *bus; | ||
170 | int onesize, i, na, ns; | ||
171 | |||
172 | /* Get parent & match bus type */ | ||
173 | parent = of_get_parent(dev); | ||
174 | if (parent == NULL) | ||
175 | return NULL; | ||
176 | bus = of_match_bus(parent); | ||
177 | if (strcmp(bus->name, "pci")) { | ||
178 | of_node_put(parent); | ||
179 | return NULL; | ||
180 | } | ||
181 | bus->count_cells(dev, &na, &ns); | ||
182 | of_node_put(parent); | ||
183 | if (!OF_CHECK_COUNTS(na, ns)) | ||
184 | return NULL; | ||
185 | |||
186 | /* Get "reg" or "assigned-addresses" property */ | ||
187 | prop = of_get_property(dev, bus->addresses, &psize); | ||
188 | if (prop == NULL) | ||
189 | return NULL; | ||
190 | psize /= 4; | ||
191 | |||
192 | onesize = na + ns; | ||
193 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) { | ||
194 | u32 val = be32_to_cpu(prop[0]); | ||
195 | if ((val & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { | ||
196 | if (size) | ||
197 | *size = of_read_number(prop + na, ns); | ||
198 | if (flags) | ||
199 | *flags = bus->get_flags(prop); | ||
200 | return prop; | ||
201 | } | ||
202 | } | ||
203 | return NULL; | ||
204 | } | ||
205 | EXPORT_SYMBOL(of_get_pci_address); | ||
206 | |||
207 | int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
208 | struct resource *r) | ||
209 | { | ||
210 | const u32 *addrp; | ||
211 | u64 size; | ||
212 | unsigned int flags; | ||
213 | |||
214 | addrp = of_get_pci_address(dev, bar, &size, &flags); | ||
215 | if (addrp == NULL) | ||
216 | return -EINVAL; | ||
217 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
218 | } | ||
219 | EXPORT_SYMBOL_GPL(of_pci_address_to_resource); | ||
220 | #endif /* CONFIG_PCI */ | ||
221 | |||
222 | /* | ||
223 | * ISA bus specific translator | ||
224 | */ | ||
225 | |||
226 | static int of_bus_isa_match(struct device_node *np) | ||
227 | { | ||
228 | return !strcmp(np->name, "isa"); | ||
229 | } | ||
230 | |||
231 | static void of_bus_isa_count_cells(struct device_node *child, | ||
232 | int *addrc, int *sizec) | ||
233 | { | ||
234 | if (addrc) | ||
235 | *addrc = 2; | ||
236 | if (sizec) | ||
237 | *sizec = 1; | ||
238 | } | ||
239 | |||
240 | static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna) | ||
241 | { | ||
242 | u64 cp, s, da; | ||
243 | |||
244 | /* Check address type match */ | ||
245 | if ((addr[0] ^ range[0]) & 0x00000001) | ||
246 | return OF_BAD_ADDR; | ||
247 | |||
248 | /* Read address values, skipping high cell */ | ||
249 | cp = of_read_number(range + 1, na - 1); | ||
250 | s = of_read_number(range + na + pna, ns); | ||
251 | da = of_read_number(addr + 1, na - 1); | ||
252 | |||
253 | pr_debug("OF: ISA map, cp=%llx, s=%llx, da=%llx\n", | ||
254 | (unsigned long long)cp, (unsigned long long)s, | ||
255 | (unsigned long long)da); | ||
256 | |||
257 | if (da < cp || da >= (cp + s)) | ||
258 | return OF_BAD_ADDR; | ||
259 | return da - cp; | ||
260 | } | ||
261 | |||
262 | static int of_bus_isa_translate(u32 *addr, u64 offset, int na) | ||
263 | { | ||
264 | return of_bus_default_translate(addr + 1, offset, na - 1); | ||
265 | } | ||
266 | |||
267 | static unsigned int of_bus_isa_get_flags(const u32 *addr) | ||
268 | { | ||
269 | unsigned int flags = 0; | ||
270 | u32 w = addr[0]; | ||
271 | |||
272 | if (w & 1) | ||
273 | flags |= IORESOURCE_IO; | ||
274 | else | ||
275 | flags |= IORESOURCE_MEM; | ||
276 | return flags; | ||
277 | } | ||
278 | |||
279 | /* | ||
280 | * Array of bus specific translators | ||
281 | */ | ||
282 | |||
283 | static struct of_bus of_busses[] = { | ||
284 | #ifdef CONFIG_PCI | ||
285 | /* PCI */ | ||
286 | { | ||
287 | .name = "pci", | ||
288 | .addresses = "assigned-addresses", | ||
289 | .match = of_bus_pci_match, | ||
290 | .count_cells = of_bus_pci_count_cells, | ||
291 | .map = of_bus_pci_map, | ||
292 | .translate = of_bus_pci_translate, | ||
293 | .get_flags = of_bus_pci_get_flags, | ||
294 | }, | ||
295 | #endif /* CONFIG_PCI */ | ||
296 | /* ISA */ | ||
297 | { | ||
298 | .name = "isa", | ||
299 | .addresses = "reg", | ||
300 | .match = of_bus_isa_match, | ||
301 | .count_cells = of_bus_isa_count_cells, | ||
302 | .map = of_bus_isa_map, | ||
303 | .translate = of_bus_isa_translate, | ||
304 | .get_flags = of_bus_isa_get_flags, | ||
305 | }, | ||
306 | /* Default */ | ||
307 | { | ||
308 | .name = "default", | ||
309 | .addresses = "reg", | ||
310 | .match = NULL, | ||
311 | .count_cells = of_bus_default_count_cells, | ||
312 | .map = of_bus_default_map, | ||
313 | .translate = of_bus_default_translate, | ||
314 | .get_flags = of_bus_default_get_flags, | ||
315 | }, | ||
316 | }; | ||
317 | |||
318 | static struct of_bus *of_match_bus(struct device_node *np) | ||
319 | { | ||
320 | int i; | ||
321 | |||
322 | for (i = 0; i < ARRAY_SIZE(of_busses); i++) | ||
323 | if (!of_busses[i].match || of_busses[i].match(np)) | ||
324 | return &of_busses[i]; | ||
325 | BUG(); | ||
326 | return NULL; | ||
327 | } | ||
328 | |||
329 | static int of_translate_one(struct device_node *parent, struct of_bus *bus, | ||
330 | struct of_bus *pbus, u32 *addr, | ||
331 | int na, int ns, int pna, const char *rprop) | ||
332 | { | ||
333 | const u32 *ranges; | ||
334 | unsigned int rlen; | ||
335 | int rone; | ||
336 | u64 offset = OF_BAD_ADDR; | ||
337 | |||
338 | /* Normally, an absence of a "ranges" property means we are | ||
339 | * crossing a non-translatable boundary, and thus the addresses | ||
340 | * below the current not cannot be converted to CPU physical ones. | ||
341 | * Unfortunately, while this is very clear in the spec, it's not | ||
342 | * what Apple understood, and they do have things like /uni-n or | ||
343 | * /ht nodes with no "ranges" property and a lot of perfectly | ||
344 | * useable mapped devices below them. Thus we treat the absence of | ||
345 | * "ranges" as equivalent to an empty "ranges" property which means | ||
346 | * a 1:1 translation at that level. It's up to the caller not to try | ||
347 | * to translate addresses that aren't supposed to be translated in | ||
348 | * the first place. --BenH. | ||
349 | * | ||
350 | * As far as we know, this damage only exists on Apple machines, so | ||
351 | * This code is only enabled on powerpc. --gcl | ||
352 | */ | ||
353 | ranges = of_get_property(parent, rprop, &rlen); | ||
354 | #if !defined(CONFIG_PPC) | ||
355 | if (ranges == NULL) { | ||
356 | pr_err("OF: no ranges; cannot translate\n"); | ||
357 | return 1; | ||
358 | } | ||
359 | #endif /* !defined(CONFIG_PPC) */ | ||
360 | if (ranges == NULL || rlen == 0) { | ||
361 | offset = of_read_number(addr, na); | ||
362 | memset(addr, 0, pna * 4); | ||
363 | pr_debug("OF: empty ranges; 1:1 translation\n"); | ||
364 | goto finish; | ||
365 | } | ||
366 | |||
367 | pr_debug("OF: walking ranges...\n"); | ||
368 | |||
369 | /* Now walk through the ranges */ | ||
370 | rlen /= 4; | ||
371 | rone = na + pna + ns; | ||
372 | for (; rlen >= rone; rlen -= rone, ranges += rone) { | ||
373 | offset = bus->map(addr, ranges, na, ns, pna); | ||
374 | if (offset != OF_BAD_ADDR) | ||
375 | break; | ||
376 | } | ||
377 | if (offset == OF_BAD_ADDR) { | ||
378 | pr_debug("OF: not found !\n"); | ||
379 | return 1; | ||
380 | } | ||
381 | memcpy(addr, ranges + na, 4 * pna); | ||
382 | |||
383 | finish: | ||
384 | of_dump_addr("OF: parent translation for:", addr, pna); | ||
385 | pr_debug("OF: with offset: %llx\n", (unsigned long long)offset); | ||
386 | |||
387 | /* Translate it into parent bus space */ | ||
388 | return pbus->translate(addr, offset, pna); | ||
389 | } | ||
390 | |||
391 | /* | ||
392 | * Translate an address from the device-tree into a CPU physical address, | ||
393 | * this walks up the tree and applies the various bus mappings on the | ||
394 | * way. | ||
395 | * | ||
396 | * Note: We consider that crossing any level with #size-cells == 0 to mean | ||
397 | * that translation is impossible (that is we are not dealing with a value | ||
398 | * that can be mapped to a cpu physical address). This is not really specified | ||
399 | * that way, but this is traditionally the way IBM at least do things | ||
400 | */ | ||
401 | u64 __of_translate_address(struct device_node *dev, const u32 *in_addr, | ||
402 | const char *rprop) | ||
403 | { | ||
404 | struct device_node *parent = NULL; | ||
405 | struct of_bus *bus, *pbus; | ||
406 | u32 addr[OF_MAX_ADDR_CELLS]; | ||
407 | int na, ns, pna, pns; | ||
408 | u64 result = OF_BAD_ADDR; | ||
409 | |||
410 | pr_debug("OF: ** translation for device %s **\n", dev->full_name); | ||
411 | |||
412 | /* Increase refcount at current level */ | ||
413 | of_node_get(dev); | ||
414 | |||
415 | /* Get parent & match bus type */ | ||
416 | parent = of_get_parent(dev); | ||
417 | if (parent == NULL) | ||
418 | goto bail; | ||
419 | bus = of_match_bus(parent); | ||
420 | |||
421 | /* Cound address cells & copy address locally */ | ||
422 | bus->count_cells(dev, &na, &ns); | ||
423 | if (!OF_CHECK_COUNTS(na, ns)) { | ||
424 | printk(KERN_ERR "prom_parse: Bad cell count for %s\n", | ||
425 | dev->full_name); | ||
426 | goto bail; | ||
427 | } | ||
428 | memcpy(addr, in_addr, na * 4); | ||
429 | |||
430 | pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n", | ||
431 | bus->name, na, ns, parent->full_name); | ||
432 | of_dump_addr("OF: translating address:", addr, na); | ||
433 | |||
434 | /* Translate */ | ||
435 | for (;;) { | ||
436 | /* Switch to parent bus */ | ||
437 | of_node_put(dev); | ||
438 | dev = parent; | ||
439 | parent = of_get_parent(dev); | ||
440 | |||
441 | /* If root, we have finished */ | ||
442 | if (parent == NULL) { | ||
443 | pr_debug("OF: reached root node\n"); | ||
444 | result = of_read_number(addr, na); | ||
445 | break; | ||
446 | } | ||
447 | |||
448 | /* Get new parent bus and counts */ | ||
449 | pbus = of_match_bus(parent); | ||
450 | pbus->count_cells(dev, &pna, &pns); | ||
451 | if (!OF_CHECK_COUNTS(pna, pns)) { | ||
452 | printk(KERN_ERR "prom_parse: Bad cell count for %s\n", | ||
453 | dev->full_name); | ||
454 | break; | ||
455 | } | ||
456 | |||
457 | pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n", | ||
458 | pbus->name, pna, pns, parent->full_name); | ||
459 | |||
460 | /* Apply bus translation */ | ||
461 | if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop)) | ||
462 | break; | ||
463 | |||
464 | /* Complete the move up one level */ | ||
465 | na = pna; | ||
466 | ns = pns; | ||
467 | bus = pbus; | ||
468 | |||
469 | of_dump_addr("OF: one level translation:", addr, na); | ||
470 | } | ||
471 | bail: | ||
472 | of_node_put(parent); | ||
473 | of_node_put(dev); | ||
474 | |||
475 | return result; | ||
476 | } | ||
477 | |||
478 | u64 of_translate_address(struct device_node *dev, const u32 *in_addr) | ||
479 | { | ||
480 | return __of_translate_address(dev, in_addr, "ranges"); | ||
481 | } | ||
482 | EXPORT_SYMBOL(of_translate_address); | ||
483 | |||
484 | u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr) | ||
485 | { | ||
486 | return __of_translate_address(dev, in_addr, "dma-ranges"); | ||
487 | } | ||
488 | EXPORT_SYMBOL(of_translate_dma_address); | ||
489 | |||
490 | const u32 *of_get_address(struct device_node *dev, int index, u64 *size, | ||
491 | unsigned int *flags) | ||
492 | { | ||
493 | const u32 *prop; | ||
494 | unsigned int psize; | ||
495 | struct device_node *parent; | ||
496 | struct of_bus *bus; | ||
497 | int onesize, i, na, ns; | ||
498 | |||
499 | /* Get parent & match bus type */ | ||
500 | parent = of_get_parent(dev); | ||
501 | if (parent == NULL) | ||
502 | return NULL; | ||
503 | bus = of_match_bus(parent); | ||
504 | bus->count_cells(dev, &na, &ns); | ||
505 | of_node_put(parent); | ||
506 | if (!OF_CHECK_COUNTS(na, ns)) | ||
507 | return NULL; | ||
508 | |||
509 | /* Get "reg" or "assigned-addresses" property */ | ||
510 | prop = of_get_property(dev, bus->addresses, &psize); | ||
511 | if (prop == NULL) | ||
512 | return NULL; | ||
513 | psize /= 4; | ||
514 | |||
515 | onesize = na + ns; | ||
516 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | ||
517 | if (i == index) { | ||
518 | if (size) | ||
519 | *size = of_read_number(prop + na, ns); | ||
520 | if (flags) | ||
521 | *flags = bus->get_flags(prop); | ||
522 | return prop; | ||
523 | } | ||
524 | return NULL; | ||
525 | } | ||
526 | EXPORT_SYMBOL(of_get_address); | ||
527 | |||
528 | static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | ||
529 | u64 size, unsigned int flags, | ||
530 | struct resource *r) | ||
531 | { | ||
532 | u64 taddr; | ||
533 | |||
534 | if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) | ||
535 | return -EINVAL; | ||
536 | taddr = of_translate_address(dev, addrp); | ||
537 | if (taddr == OF_BAD_ADDR) | ||
538 | return -EINVAL; | ||
539 | memset(r, 0, sizeof(struct resource)); | ||
540 | if (flags & IORESOURCE_IO) { | ||
541 | unsigned long port; | ||
542 | port = pci_address_to_pio(taddr); | ||
543 | if (port == (unsigned long)-1) | ||
544 | return -EINVAL; | ||
545 | r->start = port; | ||
546 | r->end = port + size - 1; | ||
547 | } else { | ||
548 | r->start = taddr; | ||
549 | r->end = taddr + size - 1; | ||
550 | } | ||
551 | r->flags = flags; | ||
552 | r->name = dev->full_name; | ||
553 | return 0; | ||
554 | } | ||
555 | |||
556 | /** | ||
557 | * of_address_to_resource - Translate device tree address and return as resource | ||
558 | * | ||
559 | * Note that if your address is a PIO address, the conversion will fail if | ||
560 | * the physical address can't be internally converted to an IO token with | ||
561 | * pci_address_to_pio(), that is because it's either called to early or it | ||
562 | * can't be matched to any host bridge IO space | ||
563 | */ | ||
564 | int of_address_to_resource(struct device_node *dev, int index, | ||
565 | struct resource *r) | ||
566 | { | ||
567 | const u32 *addrp; | ||
568 | u64 size; | ||
569 | unsigned int flags; | ||
570 | |||
571 | addrp = of_get_address(dev, index, &size, &flags); | ||
572 | if (addrp == NULL) | ||
573 | return -EINVAL; | ||
574 | return __of_address_to_resource(dev, addrp, size, flags, r); | ||
575 | } | ||
576 | EXPORT_SYMBOL_GPL(of_address_to_resource); | ||
577 | |||
578 | |||
579 | /** | ||
580 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
581 | * @device: the device whose io range will be mapped | ||
582 | * @index: index of the io range | ||
583 | * | ||
584 | * Returns a pointer to the mapped memory | ||
585 | */ | ||
586 | void __iomem *of_iomap(struct device_node *np, int index) | ||
587 | { | ||
588 | struct resource res; | ||
589 | |||
590 | if (of_address_to_resource(np, index, &res)) | ||
591 | return NULL; | ||
592 | |||
593 | return ioremap(res.start, 1 + res.end - res.start); | ||
594 | } | ||
595 | EXPORT_SYMBOL(of_iomap); | ||
diff --git a/drivers/of/base.c b/drivers/of/base.c index b5ad9740d8b2..aa805250de76 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -545,74 +545,28 @@ struct device_node *of_find_matching_node(struct device_node *from, | |||
545 | EXPORT_SYMBOL(of_find_matching_node); | 545 | EXPORT_SYMBOL(of_find_matching_node); |
546 | 546 | ||
547 | /** | 547 | /** |
548 | * of_modalias_table: Table of explicit compatible ==> modalias mappings | ||
549 | * | ||
550 | * This table allows particulare compatible property values to be mapped | ||
551 | * to modalias strings. This is useful for busses which do not directly | ||
552 | * understand the OF device tree but are populated based on data contained | ||
553 | * within the device tree. SPI and I2C are the two current users of this | ||
554 | * table. | ||
555 | * | ||
556 | * In most cases, devices do not need to be listed in this table because | ||
557 | * the modalias value can be derived directly from the compatible table. | ||
558 | * However, if for any reason a value cannot be derived, then this table | ||
559 | * provides a method to override the implicit derivation. | ||
560 | * | ||
561 | * At the moment, a single table is used for all bus types because it is | ||
562 | * assumed that the data size is small and that the compatible values | ||
563 | * should already be distinct enough to differentiate between SPI, I2C | ||
564 | * and other devices. | ||
565 | */ | ||
566 | struct of_modalias_table { | ||
567 | char *of_device; | ||
568 | char *modalias; | ||
569 | }; | ||
570 | static struct of_modalias_table of_modalias_table[] = { | ||
571 | { "fsl,mcu-mpc8349emitx", "mcu-mpc8349emitx" }, | ||
572 | { "mmc-spi-slot", "mmc_spi" }, | ||
573 | }; | ||
574 | |||
575 | /** | ||
576 | * of_modalias_node - Lookup appropriate modalias for a device node | 548 | * of_modalias_node - Lookup appropriate modalias for a device node |
577 | * @node: pointer to a device tree node | 549 | * @node: pointer to a device tree node |
578 | * @modalias: Pointer to buffer that modalias value will be copied into | 550 | * @modalias: Pointer to buffer that modalias value will be copied into |
579 | * @len: Length of modalias value | 551 | * @len: Length of modalias value |
580 | * | 552 | * |
581 | * Based on the value of the compatible property, this routine will determine | 553 | * Based on the value of the compatible property, this routine will attempt |
582 | * an appropriate modalias value for a particular device tree node. Two | 554 | * to choose an appropriate modalias value for a particular device tree node. |
583 | * separate methods are attempted to derive a modalias value. | 555 | * It does this by stripping the manufacturer prefix (as delimited by a ',') |
556 | * from the first entry in the compatible list property. | ||
584 | * | 557 | * |
585 | * First method is to lookup the compatible value in of_modalias_table. | 558 | * This routine returns 0 on success, <0 on failure. |
586 | * Second is to strip off the manufacturer prefix from the first | ||
587 | * compatible entry and use the remainder as modalias | ||
588 | * | ||
589 | * This routine returns 0 on success | ||
590 | */ | 559 | */ |
591 | int of_modalias_node(struct device_node *node, char *modalias, int len) | 560 | int of_modalias_node(struct device_node *node, char *modalias, int len) |
592 | { | 561 | { |
593 | int i, cplen; | 562 | const char *compatible, *p; |
594 | const char *compatible; | 563 | int cplen; |
595 | const char *p; | ||
596 | |||
597 | /* 1. search for exception list entry */ | ||
598 | for (i = 0; i < ARRAY_SIZE(of_modalias_table); i++) { | ||
599 | compatible = of_modalias_table[i].of_device; | ||
600 | if (!of_device_is_compatible(node, compatible)) | ||
601 | continue; | ||
602 | strlcpy(modalias, of_modalias_table[i].modalias, len); | ||
603 | return 0; | ||
604 | } | ||
605 | 564 | ||
606 | compatible = of_get_property(node, "compatible", &cplen); | 565 | compatible = of_get_property(node, "compatible", &cplen); |
607 | if (!compatible) | 566 | if (!compatible || strlen(compatible) > cplen) |
608 | return -ENODEV; | 567 | return -ENODEV; |
609 | |||
610 | /* 2. take first compatible entry and strip manufacturer */ | ||
611 | p = strchr(compatible, ','); | 568 | p = strchr(compatible, ','); |
612 | if (!p) | 569 | strlcpy(modalias, p ? p + 1 : compatible, len); |
613 | return -ENODEV; | ||
614 | p++; | ||
615 | strlcpy(modalias, p, len); | ||
616 | return 0; | 570 | return 0; |
617 | } | 571 | } |
618 | EXPORT_SYMBOL_GPL(of_modalias_node); | 572 | EXPORT_SYMBOL_GPL(of_modalias_node); |
@@ -651,14 +605,14 @@ EXPORT_SYMBOL(of_find_node_by_phandle); | |||
651 | struct device_node * | 605 | struct device_node * |
652 | of_parse_phandle(struct device_node *np, const char *phandle_name, int index) | 606 | of_parse_phandle(struct device_node *np, const char *phandle_name, int index) |
653 | { | 607 | { |
654 | const phandle *phandle; | 608 | const __be32 *phandle; |
655 | int size; | 609 | int size; |
656 | 610 | ||
657 | phandle = of_get_property(np, phandle_name, &size); | 611 | phandle = of_get_property(np, phandle_name, &size); |
658 | if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) | 612 | if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) |
659 | return NULL; | 613 | return NULL; |
660 | 614 | ||
661 | return of_find_node_by_phandle(phandle[index]); | 615 | return of_find_node_by_phandle(be32_to_cpup(phandle + index)); |
662 | } | 616 | } |
663 | EXPORT_SYMBOL(of_parse_phandle); | 617 | EXPORT_SYMBOL(of_parse_phandle); |
664 | 618 | ||
@@ -714,16 +668,16 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
714 | 668 | ||
715 | while (list < list_end) { | 669 | while (list < list_end) { |
716 | const __be32 *cells; | 670 | const __be32 *cells; |
717 | const phandle *phandle; | 671 | phandle phandle; |
718 | 672 | ||
719 | phandle = list++; | 673 | phandle = be32_to_cpup(list++); |
720 | args = list; | 674 | args = list; |
721 | 675 | ||
722 | /* one cell hole in the list = <>; */ | 676 | /* one cell hole in the list = <>; */ |
723 | if (!*phandle) | 677 | if (!phandle) |
724 | goto next; | 678 | goto next; |
725 | 679 | ||
726 | node = of_find_node_by_phandle(*phandle); | 680 | node = of_find_node_by_phandle(phandle); |
727 | if (!node) { | 681 | if (!node) { |
728 | pr_debug("%s: could not find phandle\n", | 682 | pr_debug("%s: could not find phandle\n", |
729 | np->full_name); | 683 | np->full_name); |
diff --git a/drivers/of/device.c b/drivers/of/device.c index 7d18f8e0b013..0d8a0644f540 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -20,13 +20,13 @@ | |||
20 | const struct of_device_id *of_match_device(const struct of_device_id *matches, | 20 | const struct of_device_id *of_match_device(const struct of_device_id *matches, |
21 | const struct device *dev) | 21 | const struct device *dev) |
22 | { | 22 | { |
23 | if (!dev->of_node) | 23 | if ((!matches) || (!dev->of_node)) |
24 | return NULL; | 24 | return NULL; |
25 | return of_match_node(matches, dev->of_node); | 25 | return of_match_node(matches, dev->of_node); |
26 | } | 26 | } |
27 | EXPORT_SYMBOL(of_match_device); | 27 | EXPORT_SYMBOL(of_match_device); |
28 | 28 | ||
29 | struct of_device *of_dev_get(struct of_device *dev) | 29 | struct platform_device *of_dev_get(struct platform_device *dev) |
30 | { | 30 | { |
31 | struct device *tmp; | 31 | struct device *tmp; |
32 | 32 | ||
@@ -34,13 +34,13 @@ struct of_device *of_dev_get(struct of_device *dev) | |||
34 | return NULL; | 34 | return NULL; |
35 | tmp = get_device(&dev->dev); | 35 | tmp = get_device(&dev->dev); |
36 | if (tmp) | 36 | if (tmp) |
37 | return to_of_device(tmp); | 37 | return to_platform_device(tmp); |
38 | else | 38 | else |
39 | return NULL; | 39 | return NULL; |
40 | } | 40 | } |
41 | EXPORT_SYMBOL(of_dev_get); | 41 | EXPORT_SYMBOL(of_dev_get); |
42 | 42 | ||
43 | void of_dev_put(struct of_device *dev) | 43 | void of_dev_put(struct platform_device *dev) |
44 | { | 44 | { |
45 | if (dev) | 45 | if (dev) |
46 | put_device(&dev->dev); | 46 | put_device(&dev->dev); |
@@ -50,28 +50,25 @@ EXPORT_SYMBOL(of_dev_put); | |||
50 | static ssize_t devspec_show(struct device *dev, | 50 | static ssize_t devspec_show(struct device *dev, |
51 | struct device_attribute *attr, char *buf) | 51 | struct device_attribute *attr, char *buf) |
52 | { | 52 | { |
53 | struct of_device *ofdev; | 53 | struct platform_device *ofdev; |
54 | 54 | ||
55 | ofdev = to_of_device(dev); | 55 | ofdev = to_platform_device(dev); |
56 | return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name); | 56 | return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name); |
57 | } | 57 | } |
58 | 58 | ||
59 | static ssize_t name_show(struct device *dev, | 59 | static ssize_t name_show(struct device *dev, |
60 | struct device_attribute *attr, char *buf) | 60 | struct device_attribute *attr, char *buf) |
61 | { | 61 | { |
62 | struct of_device *ofdev; | 62 | struct platform_device *ofdev; |
63 | 63 | ||
64 | ofdev = to_of_device(dev); | 64 | ofdev = to_platform_device(dev); |
65 | return sprintf(buf, "%s\n", ofdev->dev.of_node->name); | 65 | return sprintf(buf, "%s\n", ofdev->dev.of_node->name); |
66 | } | 66 | } |
67 | 67 | ||
68 | static ssize_t modalias_show(struct device *dev, | 68 | static ssize_t modalias_show(struct device *dev, |
69 | struct device_attribute *attr, char *buf) | 69 | struct device_attribute *attr, char *buf) |
70 | { | 70 | { |
71 | struct of_device *ofdev = to_of_device(dev); | 71 | ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); |
72 | ssize_t len = 0; | ||
73 | |||
74 | len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); | ||
75 | buf[len] = '\n'; | 72 | buf[len] = '\n'; |
76 | buf[len+1] = 0; | 73 | buf[len+1] = 0; |
77 | return len+1; | 74 | return len+1; |
@@ -93,20 +90,25 @@ struct device_attribute of_platform_device_attrs[] = { | |||
93 | */ | 90 | */ |
94 | void of_release_dev(struct device *dev) | 91 | void of_release_dev(struct device *dev) |
95 | { | 92 | { |
96 | struct of_device *ofdev; | 93 | struct platform_device *ofdev; |
97 | 94 | ||
98 | ofdev = to_of_device(dev); | 95 | ofdev = to_platform_device(dev); |
99 | of_node_put(ofdev->dev.of_node); | 96 | of_node_put(ofdev->dev.of_node); |
100 | kfree(ofdev); | 97 | kfree(ofdev); |
101 | } | 98 | } |
102 | EXPORT_SYMBOL(of_release_dev); | 99 | EXPORT_SYMBOL(of_release_dev); |
103 | 100 | ||
104 | int of_device_register(struct of_device *ofdev) | 101 | int of_device_register(struct platform_device *ofdev) |
105 | { | 102 | { |
106 | BUG_ON(ofdev->dev.of_node == NULL); | 103 | BUG_ON(ofdev->dev.of_node == NULL); |
107 | 104 | ||
108 | device_initialize(&ofdev->dev); | 105 | device_initialize(&ofdev->dev); |
109 | 106 | ||
107 | /* name and id have to be set so that the platform bus doesn't get | ||
108 | * confused on matching */ | ||
109 | ofdev->name = dev_name(&ofdev->dev); | ||
110 | ofdev->id = -1; | ||
111 | |||
110 | /* device_add will assume that this device is on the same node as | 112 | /* device_add will assume that this device is on the same node as |
111 | * the parent. If there is no parent defined, set the node | 113 | * the parent. If there is no parent defined, set the node |
112 | * explicitly */ | 114 | * explicitly */ |
@@ -117,25 +119,24 @@ int of_device_register(struct of_device *ofdev) | |||
117 | } | 119 | } |
118 | EXPORT_SYMBOL(of_device_register); | 120 | EXPORT_SYMBOL(of_device_register); |
119 | 121 | ||
120 | void of_device_unregister(struct of_device *ofdev) | 122 | void of_device_unregister(struct platform_device *ofdev) |
121 | { | 123 | { |
122 | device_unregister(&ofdev->dev); | 124 | device_unregister(&ofdev->dev); |
123 | } | 125 | } |
124 | EXPORT_SYMBOL(of_device_unregister); | 126 | EXPORT_SYMBOL(of_device_unregister); |
125 | 127 | ||
126 | ssize_t of_device_get_modalias(struct of_device *ofdev, | 128 | ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) |
127 | char *str, ssize_t len) | ||
128 | { | 129 | { |
129 | const char *compat; | 130 | const char *compat; |
130 | int cplen, i; | 131 | int cplen, i; |
131 | ssize_t tsize, csize, repend; | 132 | ssize_t tsize, csize, repend; |
132 | 133 | ||
133 | /* Name & Type */ | 134 | /* Name & Type */ |
134 | csize = snprintf(str, len, "of:N%sT%s", ofdev->dev.of_node->name, | 135 | csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name, |
135 | ofdev->dev.of_node->type); | 136 | dev->of_node->type); |
136 | 137 | ||
137 | /* Get compatible property if any */ | 138 | /* Get compatible property if any */ |
138 | compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen); | 139 | compat = of_get_property(dev->of_node, "compatible", &cplen); |
139 | if (!compat) | 140 | if (!compat) |
140 | return csize; | 141 | return csize; |
141 | 142 | ||
@@ -170,3 +171,51 @@ ssize_t of_device_get_modalias(struct of_device *ofdev, | |||
170 | 171 | ||
171 | return tsize; | 172 | return tsize; |
172 | } | 173 | } |
174 | |||
175 | /** | ||
176 | * of_device_uevent - Display OF related uevent information | ||
177 | */ | ||
178 | int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
179 | { | ||
180 | const char *compat; | ||
181 | int seen = 0, cplen, sl; | ||
182 | |||
183 | if ((!dev) || (!dev->of_node)) | ||
184 | return -ENODEV; | ||
185 | |||
186 | if (add_uevent_var(env, "OF_NAME=%s", dev->of_node->name)) | ||
187 | return -ENOMEM; | ||
188 | |||
189 | if (add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type)) | ||
190 | return -ENOMEM; | ||
191 | |||
192 | /* Since the compatible field can contain pretty much anything | ||
193 | * it's not really legal to split it out with commas. We split it | ||
194 | * up using a number of environment variables instead. */ | ||
195 | |||
196 | compat = of_get_property(dev->of_node, "compatible", &cplen); | ||
197 | while (compat && *compat && cplen > 0) { | ||
198 | if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat)) | ||
199 | return -ENOMEM; | ||
200 | |||
201 | sl = strlen(compat) + 1; | ||
202 | compat += sl; | ||
203 | cplen -= sl; | ||
204 | seen++; | ||
205 | } | ||
206 | |||
207 | if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen)) | ||
208 | return -ENOMEM; | ||
209 | |||
210 | /* modalias is trickier, we add it in 2 steps */ | ||
211 | if (add_uevent_var(env, "MODALIAS=")) | ||
212 | return -ENOMEM; | ||
213 | |||
214 | sl = of_device_get_modalias(dev, &env->buf[env->buflen-1], | ||
215 | sizeof(env->buf) - env->buflen); | ||
216 | if (sl >= (sizeof(env->buf) - env->buflen)) | ||
217 | return -ENOMEM; | ||
218 | env->buflen += sl; | ||
219 | |||
220 | return 0; | ||
221 | } | ||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index b6987bba8556..65da5aec7552 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -69,9 +69,9 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, | |||
69 | u32 sz = be32_to_cpup((__be32 *)p); | 69 | u32 sz = be32_to_cpup((__be32 *)p); |
70 | p += 8; | 70 | p += 8; |
71 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | 71 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
72 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | 72 | p = ALIGN(p, sz >= 8 ? 8 : 4); |
73 | p += sz; | 73 | p += sz; |
74 | p = _ALIGN(p, 4); | 74 | p = ALIGN(p, 4); |
75 | continue; | 75 | continue; |
76 | } | 76 | } |
77 | if (tag != OF_DT_BEGIN_NODE) { | 77 | if (tag != OF_DT_BEGIN_NODE) { |
@@ -80,7 +80,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, | |||
80 | } | 80 | } |
81 | depth++; | 81 | depth++; |
82 | pathp = (char *)p; | 82 | pathp = (char *)p; |
83 | p = _ALIGN(p + strlen(pathp) + 1, 4); | 83 | p = ALIGN(p + strlen(pathp) + 1, 4); |
84 | if ((*pathp) == '/') { | 84 | if ((*pathp) == '/') { |
85 | char *lp, *np; | 85 | char *lp, *np; |
86 | for (lp = NULL, np = pathp; *np; np++) | 86 | for (lp = NULL, np = pathp; *np; np++) |
@@ -109,7 +109,7 @@ unsigned long __init of_get_flat_dt_root(void) | |||
109 | p += 4; | 109 | p += 4; |
110 | BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); | 110 | BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); |
111 | p += 4; | 111 | p += 4; |
112 | return _ALIGN(p + strlen((char *)p) + 1, 4); | 112 | return ALIGN(p + strlen((char *)p) + 1, 4); |
113 | } | 113 | } |
114 | 114 | ||
115 | /** | 115 | /** |
@@ -138,7 +138,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | |||
138 | noff = be32_to_cpup((__be32 *)(p + 4)); | 138 | noff = be32_to_cpup((__be32 *)(p + 4)); |
139 | p += 8; | 139 | p += 8; |
140 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | 140 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
141 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | 141 | p = ALIGN(p, sz >= 8 ? 8 : 4); |
142 | 142 | ||
143 | nstr = find_flat_dt_string(noff); | 143 | nstr = find_flat_dt_string(noff); |
144 | if (nstr == NULL) { | 144 | if (nstr == NULL) { |
@@ -151,7 +151,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | |||
151 | return (void *)p; | 151 | return (void *)p; |
152 | } | 152 | } |
153 | p += sz; | 153 | p += sz; |
154 | p = _ALIGN(p, 4); | 154 | p = ALIGN(p, 4); |
155 | } while (1); | 155 | } while (1); |
156 | } | 156 | } |
157 | 157 | ||
@@ -169,7 +169,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | |||
169 | if (cp == NULL) | 169 | if (cp == NULL) |
170 | return 0; | 170 | return 0; |
171 | while (cplen > 0) { | 171 | while (cplen > 0) { |
172 | if (strncasecmp(cp, compat, strlen(compat)) == 0) | 172 | if (of_compat_cmp(cp, compat, strlen(compat)) == 0) |
173 | return 1; | 173 | return 1; |
174 | l = strlen(cp) + 1; | 174 | l = strlen(cp) + 1; |
175 | cp += l; | 175 | cp += l; |
@@ -184,7 +184,7 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, | |||
184 | { | 184 | { |
185 | void *res; | 185 | void *res; |
186 | 186 | ||
187 | *mem = _ALIGN(*mem, align); | 187 | *mem = ALIGN(*mem, align); |
188 | res = (void *)*mem; | 188 | res = (void *)*mem; |
189 | *mem += size; | 189 | *mem += size; |
190 | 190 | ||
@@ -220,7 +220,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem, | |||
220 | *p += 4; | 220 | *p += 4; |
221 | pathp = (char *)*p; | 221 | pathp = (char *)*p; |
222 | l = allocl = strlen(pathp) + 1; | 222 | l = allocl = strlen(pathp) + 1; |
223 | *p = _ALIGN(*p + l, 4); | 223 | *p = ALIGN(*p + l, 4); |
224 | 224 | ||
225 | /* version 0x10 has a more compact unit name here instead of the full | 225 | /* version 0x10 has a more compact unit name here instead of the full |
226 | * path. we accumulate the full path size using "fpsize", we'll rebuild | 226 | * path. we accumulate the full path size using "fpsize", we'll rebuild |
@@ -299,7 +299,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem, | |||
299 | noff = be32_to_cpup((__be32 *)((*p) + 4)); | 299 | noff = be32_to_cpup((__be32 *)((*p) + 4)); |
300 | *p += 8; | 300 | *p += 8; |
301 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | 301 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
302 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); | 302 | *p = ALIGN(*p, sz >= 8 ? 8 : 4); |
303 | 303 | ||
304 | pname = find_flat_dt_string(noff); | 304 | pname = find_flat_dt_string(noff); |
305 | if (pname == NULL) { | 305 | if (pname == NULL) { |
@@ -320,20 +320,20 @@ unsigned long __init unflatten_dt_node(unsigned long mem, | |||
320 | if ((strcmp(pname, "phandle") == 0) || | 320 | if ((strcmp(pname, "phandle") == 0) || |
321 | (strcmp(pname, "linux,phandle") == 0)) { | 321 | (strcmp(pname, "linux,phandle") == 0)) { |
322 | if (np->phandle == 0) | 322 | if (np->phandle == 0) |
323 | np->phandle = *((u32 *)*p); | 323 | np->phandle = be32_to_cpup((__be32*)*p); |
324 | } | 324 | } |
325 | /* And we process the "ibm,phandle" property | 325 | /* And we process the "ibm,phandle" property |
326 | * used in pSeries dynamic device tree | 326 | * used in pSeries dynamic device tree |
327 | * stuff */ | 327 | * stuff */ |
328 | if (strcmp(pname, "ibm,phandle") == 0) | 328 | if (strcmp(pname, "ibm,phandle") == 0) |
329 | np->phandle = *((u32 *)*p); | 329 | np->phandle = be32_to_cpup((__be32 *)*p); |
330 | pp->name = pname; | 330 | pp->name = pname; |
331 | pp->length = sz; | 331 | pp->length = sz; |
332 | pp->value = (void *)*p; | 332 | pp->value = (void *)*p; |
333 | *prev_pp = pp; | 333 | *prev_pp = pp; |
334 | prev_pp = &pp->next; | 334 | prev_pp = &pp->next; |
335 | } | 335 | } |
336 | *p = _ALIGN((*p) + sz, 4); | 336 | *p = ALIGN((*p) + sz, 4); |
337 | } | 337 | } |
338 | /* with version 0x10 we may not have the name property, recreate | 338 | /* with version 0x10 we may not have the name property, recreate |
339 | * it here from the unit name if absent | 339 | * it here from the unit name if absent |
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index a1b31a4abae4..905960338fb2 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c | |||
@@ -11,13 +11,14 @@ | |||
11 | * (at your option) any later version. | 11 | * (at your option) any later version. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/device.h> |
15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/module.h> | ||
16 | #include <linux/io.h> | 17 | #include <linux/io.h> |
17 | #include <linux/of.h> | 18 | #include <linux/of.h> |
18 | #include <linux/slab.h> | 19 | #include <linux/of_address.h> |
19 | #include <linux/of_gpio.h> | 20 | #include <linux/of_gpio.h> |
20 | #include <asm/prom.h> | 21 | #include <linux/slab.h> |
21 | 22 | ||
22 | /** | 23 | /** |
23 | * of_get_gpio_flags - Get a GPIO number and flags to use with GPIO API | 24 | * of_get_gpio_flags - Get a GPIO number and flags to use with GPIO API |
@@ -33,32 +34,32 @@ int of_get_gpio_flags(struct device_node *np, int index, | |||
33 | enum of_gpio_flags *flags) | 34 | enum of_gpio_flags *flags) |
34 | { | 35 | { |
35 | int ret; | 36 | int ret; |
36 | struct device_node *gc; | 37 | struct device_node *gpio_np; |
37 | struct of_gpio_chip *of_gc = NULL; | 38 | struct gpio_chip *gc; |
38 | int size; | 39 | int size; |
39 | const void *gpio_spec; | 40 | const void *gpio_spec; |
40 | const __be32 *gpio_cells; | 41 | const __be32 *gpio_cells; |
41 | 42 | ||
42 | ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, | 43 | ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, |
43 | &gc, &gpio_spec); | 44 | &gpio_np, &gpio_spec); |
44 | if (ret) { | 45 | if (ret) { |
45 | pr_debug("%s: can't parse gpios property\n", __func__); | 46 | pr_debug("%s: can't parse gpios property\n", __func__); |
46 | goto err0; | 47 | goto err0; |
47 | } | 48 | } |
48 | 49 | ||
49 | of_gc = gc->data; | 50 | gc = of_node_to_gpiochip(gpio_np); |
50 | if (!of_gc) { | 51 | if (!gc) { |
51 | pr_debug("%s: gpio controller %s isn't registered\n", | 52 | pr_debug("%s: gpio controller %s isn't registered\n", |
52 | np->full_name, gc->full_name); | 53 | np->full_name, gpio_np->full_name); |
53 | ret = -ENODEV; | 54 | ret = -ENODEV; |
54 | goto err1; | 55 | goto err1; |
55 | } | 56 | } |
56 | 57 | ||
57 | gpio_cells = of_get_property(gc, "#gpio-cells", &size); | 58 | gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size); |
58 | if (!gpio_cells || size != sizeof(*gpio_cells) || | 59 | if (!gpio_cells || size != sizeof(*gpio_cells) || |
59 | be32_to_cpup(gpio_cells) != of_gc->gpio_cells) { | 60 | be32_to_cpup(gpio_cells) != gc->of_gpio_n_cells) { |
60 | pr_debug("%s: wrong #gpio-cells for %s\n", | 61 | pr_debug("%s: wrong #gpio-cells for %s\n", |
61 | np->full_name, gc->full_name); | 62 | np->full_name, gpio_np->full_name); |
62 | ret = -EINVAL; | 63 | ret = -EINVAL; |
63 | goto err1; | 64 | goto err1; |
64 | } | 65 | } |
@@ -67,13 +68,13 @@ int of_get_gpio_flags(struct device_node *np, int index, | |||
67 | if (flags) | 68 | if (flags) |
68 | *flags = 0; | 69 | *flags = 0; |
69 | 70 | ||
70 | ret = of_gc->xlate(of_gc, np, gpio_spec, flags); | 71 | ret = gc->of_xlate(gc, np, gpio_spec, flags); |
71 | if (ret < 0) | 72 | if (ret < 0) |
72 | goto err1; | 73 | goto err1; |
73 | 74 | ||
74 | ret += of_gc->gc.base; | 75 | ret += gc->base; |
75 | err1: | 76 | err1: |
76 | of_node_put(gc); | 77 | of_node_put(gpio_np); |
77 | err0: | 78 | err0: |
78 | pr_debug("%s exited with status %d\n", __func__, ret); | 79 | pr_debug("%s exited with status %d\n", __func__, ret); |
79 | return ret; | 80 | return ret; |
@@ -116,7 +117,7 @@ EXPORT_SYMBOL(of_gpio_count); | |||
116 | 117 | ||
117 | /** | 118 | /** |
118 | * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags | 119 | * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags |
119 | * @of_gc: pointer to the of_gpio_chip structure | 120 | * @gc: pointer to the gpio_chip structure |
120 | * @np: device node of the GPIO chip | 121 | * @np: device node of the GPIO chip |
121 | * @gpio_spec: gpio specifier as found in the device tree | 122 | * @gpio_spec: gpio specifier as found in the device tree |
122 | * @flags: a flags pointer to fill in | 123 | * @flags: a flags pointer to fill in |
@@ -125,8 +126,8 @@ EXPORT_SYMBOL(of_gpio_count); | |||
125 | * gpio chips. This function performs only one sanity check: whether gpio | 126 | * gpio chips. This function performs only one sanity check: whether gpio |
126 | * is less than ngpios (that is specified in the gpio_chip). | 127 | * is less than ngpios (that is specified in the gpio_chip). |
127 | */ | 128 | */ |
128 | int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, | 129 | static int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, |
129 | const void *gpio_spec, enum of_gpio_flags *flags) | 130 | const void *gpio_spec, u32 *flags) |
130 | { | 131 | { |
131 | const __be32 *gpio = gpio_spec; | 132 | const __be32 *gpio = gpio_spec; |
132 | const u32 n = be32_to_cpup(gpio); | 133 | const u32 n = be32_to_cpup(gpio); |
@@ -137,12 +138,12 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, | |||
137 | * number and the flags from a single gpio cell -- this is possible, | 138 | * number and the flags from a single gpio cell -- this is possible, |
138 | * but not recommended). | 139 | * but not recommended). |
139 | */ | 140 | */ |
140 | if (of_gc->gpio_cells < 2) { | 141 | if (gc->of_gpio_n_cells < 2) { |
141 | WARN_ON(1); | 142 | WARN_ON(1); |
142 | return -EINVAL; | 143 | return -EINVAL; |
143 | } | 144 | } |
144 | 145 | ||
145 | if (n > of_gc->gc.ngpio) | 146 | if (n > gc->ngpio) |
146 | return -EINVAL; | 147 | return -EINVAL; |
147 | 148 | ||
148 | if (flags) | 149 | if (flags) |
@@ -150,7 +151,6 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, | |||
150 | 151 | ||
151 | return n; | 152 | return n; |
152 | } | 153 | } |
153 | EXPORT_SYMBOL(of_gpio_simple_xlate); | ||
154 | 154 | ||
155 | /** | 155 | /** |
156 | * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) | 156 | * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) |
@@ -161,10 +161,8 @@ EXPORT_SYMBOL(of_gpio_simple_xlate); | |||
161 | * | 161 | * |
162 | * 1) In the gpio_chip structure: | 162 | * 1) In the gpio_chip structure: |
163 | * - all the callbacks | 163 | * - all the callbacks |
164 | * | 164 | * - of_gpio_n_cells |
165 | * 2) In the of_gpio_chip structure: | 165 | * - of_xlate callback (optional) |
166 | * - gpio_cells | ||
167 | * - xlate callback (optional) | ||
168 | * | 166 | * |
169 | * 3) In the of_mm_gpio_chip structure: | 167 | * 3) In the of_mm_gpio_chip structure: |
170 | * - save_regs callback (optional) | 168 | * - save_regs callback (optional) |
@@ -177,8 +175,7 @@ int of_mm_gpiochip_add(struct device_node *np, | |||
177 | struct of_mm_gpio_chip *mm_gc) | 175 | struct of_mm_gpio_chip *mm_gc) |
178 | { | 176 | { |
179 | int ret = -ENOMEM; | 177 | int ret = -ENOMEM; |
180 | struct of_gpio_chip *of_gc = &mm_gc->of_gc; | 178 | struct gpio_chip *gc = &mm_gc->gc; |
181 | struct gpio_chip *gc = &of_gc->gc; | ||
182 | 179 | ||
183 | gc->label = kstrdup(np->full_name, GFP_KERNEL); | 180 | gc->label = kstrdup(np->full_name, GFP_KERNEL); |
184 | if (!gc->label) | 181 | if (!gc->label) |
@@ -190,26 +187,19 @@ int of_mm_gpiochip_add(struct device_node *np, | |||
190 | 187 | ||
191 | gc->base = -1; | 188 | gc->base = -1; |
192 | 189 | ||
193 | if (!of_gc->xlate) | ||
194 | of_gc->xlate = of_gpio_simple_xlate; | ||
195 | |||
196 | if (mm_gc->save_regs) | 190 | if (mm_gc->save_regs) |
197 | mm_gc->save_regs(mm_gc); | 191 | mm_gc->save_regs(mm_gc); |
198 | 192 | ||
199 | np->data = of_gc; | 193 | mm_gc->gc.of_node = np; |
200 | 194 | ||
201 | ret = gpiochip_add(gc); | 195 | ret = gpiochip_add(gc); |
202 | if (ret) | 196 | if (ret) |
203 | goto err2; | 197 | goto err2; |
204 | 198 | ||
205 | /* We don't want to lose the node and its ->data */ | ||
206 | of_node_get(np); | ||
207 | |||
208 | pr_debug("%s: registered as generic GPIO chip, base is %d\n", | 199 | pr_debug("%s: registered as generic GPIO chip, base is %d\n", |
209 | np->full_name, gc->base); | 200 | np->full_name, gc->base); |
210 | return 0; | 201 | return 0; |
211 | err2: | 202 | err2: |
212 | np->data = NULL; | ||
213 | iounmap(mm_gc->regs); | 203 | iounmap(mm_gc->regs); |
214 | err1: | 204 | err1: |
215 | kfree(gc->label); | 205 | kfree(gc->label); |
@@ -219,3 +209,36 @@ err0: | |||
219 | return ret; | 209 | return ret; |
220 | } | 210 | } |
221 | EXPORT_SYMBOL(of_mm_gpiochip_add); | 211 | EXPORT_SYMBOL(of_mm_gpiochip_add); |
212 | |||
213 | void of_gpiochip_add(struct gpio_chip *chip) | ||
214 | { | ||
215 | if ((!chip->of_node) && (chip->dev)) | ||
216 | chip->of_node = chip->dev->of_node; | ||
217 | |||
218 | if (!chip->of_node) | ||
219 | return; | ||
220 | |||
221 | if (!chip->of_xlate) { | ||
222 | chip->of_gpio_n_cells = 2; | ||
223 | chip->of_xlate = of_gpio_simple_xlate; | ||
224 | } | ||
225 | |||
226 | of_node_get(chip->of_node); | ||
227 | } | ||
228 | |||
229 | void of_gpiochip_remove(struct gpio_chip *chip) | ||
230 | { | ||
231 | if (chip->of_node) | ||
232 | of_node_put(chip->of_node); | ||
233 | } | ||
234 | |||
235 | /* Private function for resolving node pointer to gpio_chip */ | ||
236 | static int of_gpiochip_is_match(struct gpio_chip *chip, void *data) | ||
237 | { | ||
238 | return chip->of_node == data; | ||
239 | } | ||
240 | |||
241 | struct gpio_chip *of_node_to_gpiochip(struct device_node *np) | ||
242 | { | ||
243 | return gpiochip_find(np, of_gpiochip_is_match); | ||
244 | } | ||
diff --git a/drivers/of/irq.c b/drivers/of/irq.c new file mode 100644 index 000000000000..6e595e5a3977 --- /dev/null +++ b/drivers/of/irq.c | |||
@@ -0,0 +1,349 @@ | |||
1 | /* | ||
2 | * Derived from arch/i386/kernel/irq.c | ||
3 | * Copyright (C) 1992 Linus Torvalds | ||
4 | * Adapted from arch/i386 by Gary Thomas | ||
5 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) | ||
6 | * Updated and modified by Cort Dougan <cort@fsmlabs.com> | ||
7 | * Copyright (C) 1996-2001 Cort Dougan | ||
8 | * Adapted for Power Macintosh by Paul Mackerras | ||
9 | * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au) | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; either version | ||
14 | * 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This file contains the code used to make IRQ descriptions in the | ||
17 | * device tree to actual irq numbers on an interrupt controller | ||
18 | * driver. | ||
19 | */ | ||
20 | |||
21 | #include <linux/errno.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/of.h> | ||
24 | #include <linux/of_irq.h> | ||
25 | #include <linux/string.h> | ||
26 | |||
27 | /** | ||
28 | * irq_of_parse_and_map - Parse and map an interrupt into linux virq space | ||
29 | * @device: Device node of the device whose interrupt is to be mapped | ||
30 | * @index: Index of the interrupt to map | ||
31 | * | ||
32 | * This function is a wrapper that chains of_irq_map_one() and | ||
33 | * irq_create_of_mapping() to make things easier to callers | ||
34 | */ | ||
35 | unsigned int irq_of_parse_and_map(struct device_node *dev, int index) | ||
36 | { | ||
37 | struct of_irq oirq; | ||
38 | |||
39 | if (of_irq_map_one(dev, index, &oirq)) | ||
40 | return NO_IRQ; | ||
41 | |||
42 | return irq_create_of_mapping(oirq.controller, oirq.specifier, | ||
43 | oirq.size); | ||
44 | } | ||
45 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | ||
46 | |||
47 | /** | ||
48 | * of_irq_find_parent - Given a device node, find its interrupt parent node | ||
49 | * @child: pointer to device node | ||
50 | * | ||
51 | * Returns a pointer to the interrupt parent node, or NULL if the interrupt | ||
52 | * parent could not be determined. | ||
53 | */ | ||
54 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
55 | { | ||
56 | struct device_node *p; | ||
57 | const __be32 *parp; | ||
58 | |||
59 | if (!of_node_get(child)) | ||
60 | return NULL; | ||
61 | |||
62 | do { | ||
63 | parp = of_get_property(child, "interrupt-parent", NULL); | ||
64 | if (parp == NULL) | ||
65 | p = of_get_parent(child); | ||
66 | else { | ||
67 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
68 | p = of_node_get(of_irq_dflt_pic); | ||
69 | else | ||
70 | p = of_find_node_by_phandle(be32_to_cpup(parp)); | ||
71 | } | ||
72 | of_node_put(child); | ||
73 | child = p; | ||
74 | } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); | ||
75 | |||
76 | return p; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * of_irq_map_raw - Low level interrupt tree parsing | ||
81 | * @parent: the device interrupt parent | ||
82 | * @intspec: interrupt specifier ("interrupts" property of the device) | ||
83 | * @ointsize: size of the passed in interrupt specifier | ||
84 | * @addr: address specifier (start of "reg" property of the device) | ||
85 | * @out_irq: structure of_irq filled by this function | ||
86 | * | ||
87 | * Returns 0 on success and a negative number on error | ||
88 | * | ||
89 | * This function is a low-level interrupt tree walking function. It | ||
90 | * can be used to do a partial walk with synthetized reg and interrupts | ||
91 | * properties, for example when resolving PCI interrupts when no device | ||
92 | * node exist for the parent. | ||
93 | */ | ||
94 | int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, | ||
95 | u32 ointsize, const __be32 *addr, struct of_irq *out_irq) | ||
96 | { | ||
97 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
98 | const __be32 *tmp, *imap, *imask; | ||
99 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
100 | int imaplen, match, i; | ||
101 | |||
102 | pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", | ||
103 | parent->full_name, be32_to_cpup(intspec), | ||
104 | be32_to_cpup(intspec + 1), ointsize); | ||
105 | |||
106 | ipar = of_node_get(parent); | ||
107 | |||
108 | /* First get the #interrupt-cells property of the current cursor | ||
109 | * that tells us how to interpret the passed-in intspec. If there | ||
110 | * is none, we are nice and just walk up the tree | ||
111 | */ | ||
112 | do { | ||
113 | tmp = of_get_property(ipar, "#interrupt-cells", NULL); | ||
114 | if (tmp != NULL) { | ||
115 | intsize = be32_to_cpu(*tmp); | ||
116 | break; | ||
117 | } | ||
118 | tnode = ipar; | ||
119 | ipar = of_irq_find_parent(ipar); | ||
120 | of_node_put(tnode); | ||
121 | } while (ipar); | ||
122 | if (ipar == NULL) { | ||
123 | pr_debug(" -> no parent found !\n"); | ||
124 | goto fail; | ||
125 | } | ||
126 | |||
127 | pr_debug("of_irq_map_raw: ipar=%s, size=%d\n", ipar->full_name, intsize); | ||
128 | |||
129 | if (ointsize != intsize) | ||
130 | return -EINVAL; | ||
131 | |||
132 | /* Look for this #address-cells. We have to implement the old linux | ||
133 | * trick of looking for the parent here as some device-trees rely on it | ||
134 | */ | ||
135 | old = of_node_get(ipar); | ||
136 | do { | ||
137 | tmp = of_get_property(old, "#address-cells", NULL); | ||
138 | tnode = of_get_parent(old); | ||
139 | of_node_put(old); | ||
140 | old = tnode; | ||
141 | } while (old && tmp == NULL); | ||
142 | of_node_put(old); | ||
143 | old = NULL; | ||
144 | addrsize = (tmp == NULL) ? 2 : be32_to_cpu(*tmp); | ||
145 | |||
146 | pr_debug(" -> addrsize=%d\n", addrsize); | ||
147 | |||
148 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
149 | while (ipar != NULL) { | ||
150 | /* Now check if cursor is an interrupt-controller and if it is | ||
151 | * then we are done | ||
152 | */ | ||
153 | if (of_get_property(ipar, "interrupt-controller", NULL) != | ||
154 | NULL) { | ||
155 | pr_debug(" -> got it !\n"); | ||
156 | for (i = 0; i < intsize; i++) | ||
157 | out_irq->specifier[i] = | ||
158 | of_read_number(intspec +i, 1); | ||
159 | out_irq->size = intsize; | ||
160 | out_irq->controller = ipar; | ||
161 | of_node_put(old); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* Now look for an interrupt-map */ | ||
166 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | ||
167 | /* No interrupt map, check for an interrupt parent */ | ||
168 | if (imap == NULL) { | ||
169 | pr_debug(" -> no map, getting parent\n"); | ||
170 | newpar = of_irq_find_parent(ipar); | ||
171 | goto skiplevel; | ||
172 | } | ||
173 | imaplen /= sizeof(u32); | ||
174 | |||
175 | /* Look for a mask */ | ||
176 | imask = of_get_property(ipar, "interrupt-map-mask", NULL); | ||
177 | |||
178 | /* If we were passed no "reg" property and we attempt to parse | ||
179 | * an interrupt-map, then #address-cells must be 0. | ||
180 | * Fail if it's not. | ||
181 | */ | ||
182 | if (addr == NULL && addrsize != 0) { | ||
183 | pr_debug(" -> no reg passed in when needed !\n"); | ||
184 | goto fail; | ||
185 | } | ||
186 | |||
187 | /* Parse interrupt-map */ | ||
188 | match = 0; | ||
189 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
190 | /* Compare specifiers */ | ||
191 | match = 1; | ||
192 | for (i = 0; i < addrsize && match; ++i) { | ||
193 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
194 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
195 | } | ||
196 | for (; i < (addrsize + intsize) && match; ++i) { | ||
197 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
198 | match = | ||
199 | ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; | ||
200 | } | ||
201 | imap += addrsize + intsize; | ||
202 | imaplen -= addrsize + intsize; | ||
203 | |||
204 | pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
205 | |||
206 | /* Get the interrupt parent */ | ||
207 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
208 | newpar = of_node_get(of_irq_dflt_pic); | ||
209 | else | ||
210 | newpar = of_find_node_by_phandle(be32_to_cpup(imap)); | ||
211 | imap++; | ||
212 | --imaplen; | ||
213 | |||
214 | /* Check if not found */ | ||
215 | if (newpar == NULL) { | ||
216 | pr_debug(" -> imap parent not found !\n"); | ||
217 | goto fail; | ||
218 | } | ||
219 | |||
220 | /* Get #interrupt-cells and #address-cells of new | ||
221 | * parent | ||
222 | */ | ||
223 | tmp = of_get_property(newpar, "#interrupt-cells", NULL); | ||
224 | if (tmp == NULL) { | ||
225 | pr_debug(" -> parent lacks #interrupt-cells!\n"); | ||
226 | goto fail; | ||
227 | } | ||
228 | newintsize = be32_to_cpu(*tmp); | ||
229 | tmp = of_get_property(newpar, "#address-cells", NULL); | ||
230 | newaddrsize = (tmp == NULL) ? 0 : be32_to_cpu(*tmp); | ||
231 | |||
232 | pr_debug(" -> newintsize=%d, newaddrsize=%d\n", | ||
233 | newintsize, newaddrsize); | ||
234 | |||
235 | /* Check for malformed properties */ | ||
236 | if (imaplen < (newaddrsize + newintsize)) | ||
237 | goto fail; | ||
238 | |||
239 | imap += newaddrsize + newintsize; | ||
240 | imaplen -= newaddrsize + newintsize; | ||
241 | |||
242 | pr_debug(" -> imaplen=%d\n", imaplen); | ||
243 | } | ||
244 | if (!match) | ||
245 | goto fail; | ||
246 | |||
247 | of_node_put(old); | ||
248 | old = of_node_get(newpar); | ||
249 | addrsize = newaddrsize; | ||
250 | intsize = newintsize; | ||
251 | intspec = imap - intsize; | ||
252 | addr = intspec - addrsize; | ||
253 | |||
254 | skiplevel: | ||
255 | /* Iterate again with new parent */ | ||
256 | pr_debug(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); | ||
257 | of_node_put(ipar); | ||
258 | ipar = newpar; | ||
259 | newpar = NULL; | ||
260 | } | ||
261 | fail: | ||
262 | of_node_put(ipar); | ||
263 | of_node_put(old); | ||
264 | of_node_put(newpar); | ||
265 | |||
266 | return -EINVAL; | ||
267 | } | ||
268 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
269 | |||
270 | /** | ||
271 | * of_irq_map_one - Resolve an interrupt for a device | ||
272 | * @device: the device whose interrupt is to be resolved | ||
273 | * @index: index of the interrupt to resolve | ||
274 | * @out_irq: structure of_irq filled by this function | ||
275 | * | ||
276 | * This function resolves an interrupt, walking the tree, for a given | ||
277 | * device-tree node. It's the high level pendant to of_irq_map_raw(). | ||
278 | */ | ||
279 | int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) | ||
280 | { | ||
281 | struct device_node *p; | ||
282 | const __be32 *intspec, *tmp, *addr; | ||
283 | u32 intsize, intlen; | ||
284 | int res = -EINVAL; | ||
285 | |||
286 | pr_debug("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); | ||
287 | |||
288 | /* OldWorld mac stuff is "special", handle out of line */ | ||
289 | if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) | ||
290 | return of_irq_map_oldworld(device, index, out_irq); | ||
291 | |||
292 | /* Get the interrupts property */ | ||
293 | intspec = of_get_property(device, "interrupts", &intlen); | ||
294 | if (intspec == NULL) | ||
295 | return -EINVAL; | ||
296 | intlen /= sizeof(*intspec); | ||
297 | |||
298 | pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen); | ||
299 | |||
300 | /* Get the reg property (if any) */ | ||
301 | addr = of_get_property(device, "reg", NULL); | ||
302 | |||
303 | /* Look for the interrupt parent. */ | ||
304 | p = of_irq_find_parent(device); | ||
305 | if (p == NULL) | ||
306 | return -EINVAL; | ||
307 | |||
308 | /* Get size of interrupt specifier */ | ||
309 | tmp = of_get_property(p, "#interrupt-cells", NULL); | ||
310 | if (tmp == NULL) | ||
311 | goto out; | ||
312 | intsize = be32_to_cpu(*tmp); | ||
313 | |||
314 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | ||
315 | |||
316 | /* Check index */ | ||
317 | if ((index + 1) * intsize > intlen) | ||
318 | goto out; | ||
319 | |||
320 | /* Get new specifier and map it */ | ||
321 | res = of_irq_map_raw(p, intspec + index * intsize, intsize, | ||
322 | addr, out_irq); | ||
323 | out: | ||
324 | of_node_put(p); | ||
325 | return res; | ||
326 | } | ||
327 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
328 | |||
329 | /** | ||
330 | * of_irq_to_resource - Decode a node's IRQ and return it as a resource | ||
331 | * @dev: pointer to device tree node | ||
332 | * @index: zero-based index of the irq | ||
333 | * @r: pointer to resource structure to return result into. | ||
334 | */ | ||
335 | int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | ||
336 | { | ||
337 | int irq = irq_of_parse_and_map(dev, index); | ||
338 | |||
339 | /* Only dereference the resource if both the | ||
340 | * resource and the irq are valid. */ | ||
341 | if (r && irq != NO_IRQ) { | ||
342 | r->start = r->end = irq; | ||
343 | r->flags = IORESOURCE_IRQ; | ||
344 | r->name = dev->full_name; | ||
345 | } | ||
346 | |||
347 | return irq; | ||
348 | } | ||
349 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c index ab6522c8e4fe..0a694debd226 100644 --- a/drivers/of/of_i2c.c +++ b/drivers/of/of_i2c.c | |||
@@ -14,57 +14,65 @@ | |||
14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
15 | #include <linux/of.h> | 15 | #include <linux/of.h> |
16 | #include <linux/of_i2c.h> | 16 | #include <linux/of_i2c.h> |
17 | #include <linux/of_irq.h> | ||
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
18 | 19 | ||
19 | void of_register_i2c_devices(struct i2c_adapter *adap, | 20 | void of_i2c_register_devices(struct i2c_adapter *adap) |
20 | struct device_node *adap_node) | ||
21 | { | 21 | { |
22 | void *result; | 22 | void *result; |
23 | struct device_node *node; | 23 | struct device_node *node; |
24 | 24 | ||
25 | for_each_child_of_node(adap_node, node) { | 25 | /* Only register child devices if the adapter has a node pointer set */ |
26 | if (!adap->dev.of_node) | ||
27 | return; | ||
28 | |||
29 | dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); | ||
30 | |||
31 | for_each_child_of_node(adap->dev.of_node, node) { | ||
26 | struct i2c_board_info info = {}; | 32 | struct i2c_board_info info = {}; |
27 | struct dev_archdata dev_ad = {}; | 33 | struct dev_archdata dev_ad = {}; |
28 | const __be32 *addr; | 34 | const __be32 *addr; |
29 | int len; | 35 | int len; |
30 | 36 | ||
31 | if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) | 37 | dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name); |
38 | |||
39 | if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) { | ||
40 | dev_err(&adap->dev, "of_i2c: modalias failure on %s\n", | ||
41 | node->full_name); | ||
32 | continue; | 42 | continue; |
43 | } | ||
33 | 44 | ||
34 | addr = of_get_property(node, "reg", &len); | 45 | addr = of_get_property(node, "reg", &len); |
35 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { | 46 | if (!addr || (len < sizeof(int))) { |
36 | printk(KERN_ERR | 47 | dev_err(&adap->dev, "of_i2c: invalid reg on %s\n", |
37 | "of-i2c: invalid i2c device entry\n"); | 48 | node->full_name); |
38 | continue; | 49 | continue; |
39 | } | 50 | } |
40 | 51 | ||
41 | info.irq = irq_of_parse_and_map(node, 0); | ||
42 | |||
43 | info.addr = be32_to_cpup(addr); | 52 | info.addr = be32_to_cpup(addr); |
53 | if (info.addr > (1 << 10) - 1) { | ||
54 | dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n", | ||
55 | info.addr, node->full_name); | ||
56 | continue; | ||
57 | } | ||
44 | 58 | ||
45 | info.of_node = node; | 59 | info.irq = irq_of_parse_and_map(node, 0); |
60 | info.of_node = of_node_get(node); | ||
46 | info.archdata = &dev_ad; | 61 | info.archdata = &dev_ad; |
47 | 62 | ||
48 | request_module("%s", info.type); | 63 | request_module("%s", info.type); |
49 | 64 | ||
50 | result = i2c_new_device(adap, &info); | 65 | result = i2c_new_device(adap, &info); |
51 | if (result == NULL) { | 66 | if (result == NULL) { |
52 | printk(KERN_ERR | 67 | dev_err(&adap->dev, "of_i2c: Failure registering %s\n", |
53 | "of-i2c: Failed to load driver for %s\n", | 68 | node->full_name); |
54 | info.type); | 69 | of_node_put(node); |
55 | irq_dispose_mapping(info.irq); | 70 | irq_dispose_mapping(info.irq); |
56 | continue; | 71 | continue; |
57 | } | 72 | } |
58 | |||
59 | /* | ||
60 | * Get the node to not lose the dev_archdata->of_node. | ||
61 | * Currently there is no way to put it back, as well as no | ||
62 | * of_unregister_i2c_devices() call. | ||
63 | */ | ||
64 | of_node_get(node); | ||
65 | } | 73 | } |
66 | } | 74 | } |
67 | EXPORT_SYMBOL(of_register_i2c_devices); | 75 | EXPORT_SYMBOL(of_i2c_register_devices); |
68 | 76 | ||
69 | static int of_dev_node_match(struct device *dev, void *data) | 77 | static int of_dev_node_match(struct device *dev, void *data) |
70 | { | 78 | { |
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 42a6715f8e84..1fce00eb421b 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/phy.h> | 16 | #include <linux/phy.h> |
17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
18 | #include <linux/of_irq.h> | ||
18 | #include <linux/of_mdio.h> | 19 | #include <linux/of_mdio.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
20 | 21 | ||
diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c index 5fed7e3c7da3..1dbce58a58b0 100644 --- a/drivers/of/of_spi.c +++ b/drivers/of/of_spi.c | |||
@@ -9,17 +9,17 @@ | |||
9 | #include <linux/of.h> | 9 | #include <linux/of.h> |
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | #include <linux/spi/spi.h> | 11 | #include <linux/spi/spi.h> |
12 | #include <linux/of_irq.h> | ||
12 | #include <linux/of_spi.h> | 13 | #include <linux/of_spi.h> |
13 | 14 | ||
14 | /** | 15 | /** |
15 | * of_register_spi_devices - Register child devices onto the SPI bus | 16 | * of_register_spi_devices - Register child devices onto the SPI bus |
16 | * @master: Pointer to spi_master device | 17 | * @master: Pointer to spi_master device |
17 | * @np: parent node of SPI device nodes | ||
18 | * | 18 | * |
19 | * Registers an spi_device for each child node of 'np' which has a 'reg' | 19 | * Registers an spi_device for each child node of master node which has a 'reg' |
20 | * property. | 20 | * property. |
21 | */ | 21 | */ |
22 | void of_register_spi_devices(struct spi_master *master, struct device_node *np) | 22 | void of_register_spi_devices(struct spi_master *master) |
23 | { | 23 | { |
24 | struct spi_device *spi; | 24 | struct spi_device *spi; |
25 | struct device_node *nc; | 25 | struct device_node *nc; |
@@ -27,7 +27,10 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) | |||
27 | int rc; | 27 | int rc; |
28 | int len; | 28 | int len; |
29 | 29 | ||
30 | for_each_child_of_node(np, nc) { | 30 | if (!master->dev.of_node) |
31 | return; | ||
32 | |||
33 | for_each_child_of_node(master->dev.of_node, nc) { | ||
31 | /* Alloc an spi_device */ | 34 | /* Alloc an spi_device */ |
32 | spi = spi_alloc_device(master); | 35 | spi = spi_alloc_device(master); |
33 | if (!spi) { | 36 | if (!spi) { |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 7dacc1ebe91e..bb72223c22ae 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -14,8 +14,105 @@ | |||
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/dma-mapping.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/of_address.h> | ||
17 | #include <linux/of_device.h> | 20 | #include <linux/of_device.h> |
21 | #include <linux/of_irq.h> | ||
18 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | static int of_dev_node_match(struct device *dev, void *data) | ||
26 | { | ||
27 | return dev->of_node == data; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * of_find_device_by_node - Find the platform_device associated with a node | ||
32 | * @np: Pointer to device tree node | ||
33 | * | ||
34 | * Returns platform_device pointer, or NULL if not found | ||
35 | */ | ||
36 | struct platform_device *of_find_device_by_node(struct device_node *np) | ||
37 | { | ||
38 | struct device *dev; | ||
39 | |||
40 | dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match); | ||
41 | return dev ? to_platform_device(dev) : NULL; | ||
42 | } | ||
43 | EXPORT_SYMBOL(of_find_device_by_node); | ||
44 | |||
45 | static int platform_driver_probe_shim(struct platform_device *pdev) | ||
46 | { | ||
47 | struct platform_driver *pdrv; | ||
48 | struct of_platform_driver *ofpdrv; | ||
49 | const struct of_device_id *match; | ||
50 | |||
51 | pdrv = container_of(pdev->dev.driver, struct platform_driver, driver); | ||
52 | ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver); | ||
53 | |||
54 | /* There is an unlikely chance that an of_platform driver might match | ||
55 | * on a non-OF platform device. If so, then of_match_device() will | ||
56 | * come up empty. Return -EINVAL in this case so other drivers get | ||
57 | * the chance to bind. */ | ||
58 | match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); | ||
59 | return match ? ofpdrv->probe(pdev, match) : -EINVAL; | ||
60 | } | ||
61 | |||
62 | static void platform_driver_shutdown_shim(struct platform_device *pdev) | ||
63 | { | ||
64 | struct platform_driver *pdrv; | ||
65 | struct of_platform_driver *ofpdrv; | ||
66 | |||
67 | pdrv = container_of(pdev->dev.driver, struct platform_driver, driver); | ||
68 | ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver); | ||
69 | ofpdrv->shutdown(pdev); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * of_register_platform_driver | ||
74 | */ | ||
75 | int of_register_platform_driver(struct of_platform_driver *drv) | ||
76 | { | ||
77 | char *of_name; | ||
78 | |||
79 | /* setup of_platform_driver to platform_driver adaptors */ | ||
80 | drv->platform_driver.driver = drv->driver; | ||
81 | |||
82 | /* Prefix the driver name with 'of:' to avoid namespace collisions | ||
83 | * and bogus matches. There are some drivers in the tree that | ||
84 | * register both an of_platform_driver and a platform_driver with | ||
85 | * the same name. This is a temporary measure until they are all | ||
86 | * cleaned up --gcl July 29, 2010 */ | ||
87 | of_name = kmalloc(strlen(drv->driver.name) + 5, GFP_KERNEL); | ||
88 | if (!of_name) | ||
89 | return -ENOMEM; | ||
90 | sprintf(of_name, "of:%s", drv->driver.name); | ||
91 | drv->platform_driver.driver.name = of_name; | ||
92 | |||
93 | if (drv->probe) | ||
94 | drv->platform_driver.probe = platform_driver_probe_shim; | ||
95 | drv->platform_driver.remove = drv->remove; | ||
96 | if (drv->shutdown) | ||
97 | drv->platform_driver.shutdown = platform_driver_shutdown_shim; | ||
98 | drv->platform_driver.suspend = drv->suspend; | ||
99 | drv->platform_driver.resume = drv->resume; | ||
100 | |||
101 | return platform_driver_register(&drv->platform_driver); | ||
102 | } | ||
103 | EXPORT_SYMBOL(of_register_platform_driver); | ||
104 | |||
105 | void of_unregister_platform_driver(struct of_platform_driver *drv) | ||
106 | { | ||
107 | platform_driver_unregister(&drv->platform_driver); | ||
108 | kfree(drv->platform_driver.driver.name); | ||
109 | drv->platform_driver.driver.name = NULL; | ||
110 | } | ||
111 | EXPORT_SYMBOL(of_unregister_platform_driver); | ||
112 | |||
113 | #if defined(CONFIG_PPC_DCR) | ||
114 | #include <asm/dcr.h> | ||
115 | #endif | ||
19 | 116 | ||
20 | extern struct device_attribute of_platform_device_attrs[]; | 117 | extern struct device_attribute of_platform_device_attrs[]; |
21 | 118 | ||
@@ -33,11 +130,11 @@ static int of_platform_device_probe(struct device *dev) | |||
33 | { | 130 | { |
34 | int error = -ENODEV; | 131 | int error = -ENODEV; |
35 | struct of_platform_driver *drv; | 132 | struct of_platform_driver *drv; |
36 | struct of_device *of_dev; | 133 | struct platform_device *of_dev; |
37 | const struct of_device_id *match; | 134 | const struct of_device_id *match; |
38 | 135 | ||
39 | drv = to_of_platform_driver(dev->driver); | 136 | drv = to_of_platform_driver(dev->driver); |
40 | of_dev = to_of_device(dev); | 137 | of_dev = to_platform_device(dev); |
41 | 138 | ||
42 | if (!drv->probe) | 139 | if (!drv->probe) |
43 | return error; | 140 | return error; |
@@ -55,7 +152,7 @@ static int of_platform_device_probe(struct device *dev) | |||
55 | 152 | ||
56 | static int of_platform_device_remove(struct device *dev) | 153 | static int of_platform_device_remove(struct device *dev) |
57 | { | 154 | { |
58 | struct of_device *of_dev = to_of_device(dev); | 155 | struct platform_device *of_dev = to_platform_device(dev); |
59 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); | 156 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); |
60 | 157 | ||
61 | if (dev->driver && drv->remove) | 158 | if (dev->driver && drv->remove) |
@@ -65,7 +162,7 @@ static int of_platform_device_remove(struct device *dev) | |||
65 | 162 | ||
66 | static void of_platform_device_shutdown(struct device *dev) | 163 | static void of_platform_device_shutdown(struct device *dev) |
67 | { | 164 | { |
68 | struct of_device *of_dev = to_of_device(dev); | 165 | struct platform_device *of_dev = to_platform_device(dev); |
69 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); | 166 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); |
70 | 167 | ||
71 | if (dev->driver && drv->shutdown) | 168 | if (dev->driver && drv->shutdown) |
@@ -76,7 +173,7 @@ static void of_platform_device_shutdown(struct device *dev) | |||
76 | 173 | ||
77 | static int of_platform_legacy_suspend(struct device *dev, pm_message_t mesg) | 174 | static int of_platform_legacy_suspend(struct device *dev, pm_message_t mesg) |
78 | { | 175 | { |
79 | struct of_device *of_dev = to_of_device(dev); | 176 | struct platform_device *of_dev = to_platform_device(dev); |
80 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); | 177 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); |
81 | int ret = 0; | 178 | int ret = 0; |
82 | 179 | ||
@@ -87,7 +184,7 @@ static int of_platform_legacy_suspend(struct device *dev, pm_message_t mesg) | |||
87 | 184 | ||
88 | static int of_platform_legacy_resume(struct device *dev) | 185 | static int of_platform_legacy_resume(struct device *dev) |
89 | { | 186 | { |
90 | struct of_device *of_dev = to_of_device(dev); | 187 | struct platform_device *of_dev = to_platform_device(dev); |
91 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); | 188 | struct of_platform_driver *drv = to_of_platform_driver(dev->driver); |
92 | int ret = 0; | 189 | int ret = 0; |
93 | 190 | ||
@@ -384,15 +481,286 @@ int of_bus_type_init(struct bus_type *bus, const char *name) | |||
384 | 481 | ||
385 | int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) | 482 | int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) |
386 | { | 483 | { |
387 | drv->driver.bus = bus; | 484 | /* |
485 | * Temporary: of_platform_bus used to be distinct from the platform | ||
486 | * bus. It isn't anymore, and so drivers on the platform bus need | ||
487 | * to be registered in a special way. | ||
488 | * | ||
489 | * After all of_platform_bus_type drivers are converted to | ||
490 | * platform_drivers, this exception can be removed. | ||
491 | */ | ||
492 | if (bus == &platform_bus_type) | ||
493 | return of_register_platform_driver(drv); | ||
388 | 494 | ||
389 | /* register with core */ | 495 | /* register with core */ |
496 | drv->driver.bus = bus; | ||
390 | return driver_register(&drv->driver); | 497 | return driver_register(&drv->driver); |
391 | } | 498 | } |
392 | EXPORT_SYMBOL(of_register_driver); | 499 | EXPORT_SYMBOL(of_register_driver); |
393 | 500 | ||
394 | void of_unregister_driver(struct of_platform_driver *drv) | 501 | void of_unregister_driver(struct of_platform_driver *drv) |
395 | { | 502 | { |
396 | driver_unregister(&drv->driver); | 503 | if (drv->driver.bus == &platform_bus_type) |
504 | of_unregister_platform_driver(drv); | ||
505 | else | ||
506 | driver_unregister(&drv->driver); | ||
397 | } | 507 | } |
398 | EXPORT_SYMBOL(of_unregister_driver); | 508 | EXPORT_SYMBOL(of_unregister_driver); |
509 | |||
510 | #if !defined(CONFIG_SPARC) | ||
511 | /* | ||
512 | * The following routines scan a subtree and registers a device for | ||
513 | * each applicable node. | ||
514 | * | ||
515 | * Note: sparc doesn't use these routines because it has a different | ||
516 | * mechanism for creating devices from device tree nodes. | ||
517 | */ | ||
518 | |||
519 | /** | ||
520 | * of_device_make_bus_id - Use the device node data to assign a unique name | ||
521 | * @dev: pointer to device structure that is linked to a device tree node | ||
522 | * | ||
523 | * This routine will first try using either the dcr-reg or the reg property | ||
524 | * value to derive a unique name. As a last resort it will use the node | ||
525 | * name followed by a unique number. | ||
526 | */ | ||
527 | void of_device_make_bus_id(struct device *dev) | ||
528 | { | ||
529 | static atomic_t bus_no_reg_magic; | ||
530 | struct device_node *node = dev->of_node; | ||
531 | const u32 *reg; | ||
532 | u64 addr; | ||
533 | int magic; | ||
534 | |||
535 | #ifdef CONFIG_PPC_DCR | ||
536 | /* | ||
537 | * If it's a DCR based device, use 'd' for native DCRs | ||
538 | * and 'D' for MMIO DCRs. | ||
539 | */ | ||
540 | reg = of_get_property(node, "dcr-reg", NULL); | ||
541 | if (reg) { | ||
542 | #ifdef CONFIG_PPC_DCR_NATIVE | ||
543 | dev_set_name(dev, "d%x.%s", *reg, node->name); | ||
544 | #else /* CONFIG_PPC_DCR_NATIVE */ | ||
545 | u64 addr = of_translate_dcr_address(node, *reg, NULL); | ||
546 | if (addr != OF_BAD_ADDR) { | ||
547 | dev_set_name(dev, "D%llx.%s", | ||
548 | (unsigned long long)addr, node->name); | ||
549 | return; | ||
550 | } | ||
551 | #endif /* !CONFIG_PPC_DCR_NATIVE */ | ||
552 | } | ||
553 | #endif /* CONFIG_PPC_DCR */ | ||
554 | |||
555 | /* | ||
556 | * For MMIO, get the physical address | ||
557 | */ | ||
558 | reg = of_get_property(node, "reg", NULL); | ||
559 | if (reg) { | ||
560 | addr = of_translate_address(node, reg); | ||
561 | if (addr != OF_BAD_ADDR) { | ||
562 | dev_set_name(dev, "%llx.%s", | ||
563 | (unsigned long long)addr, node->name); | ||
564 | return; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | /* | ||
569 | * No BusID, use the node name and add a globally incremented | ||
570 | * counter (and pray...) | ||
571 | */ | ||
572 | magic = atomic_add_return(1, &bus_no_reg_magic); | ||
573 | dev_set_name(dev, "%s.%d", node->name, magic - 1); | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * of_device_alloc - Allocate and initialize an of_device | ||
578 | * @np: device node to assign to device | ||
579 | * @bus_id: Name to assign to the device. May be null to use default name. | ||
580 | * @parent: Parent device. | ||
581 | */ | ||
582 | struct platform_device *of_device_alloc(struct device_node *np, | ||
583 | const char *bus_id, | ||
584 | struct device *parent) | ||
585 | { | ||
586 | struct platform_device *dev; | ||
587 | int rc, i, num_reg = 0, num_irq = 0; | ||
588 | struct resource *res, temp_res; | ||
589 | |||
590 | /* First count how many resources are needed */ | ||
591 | while (of_address_to_resource(np, num_reg, &temp_res) == 0) | ||
592 | num_reg++; | ||
593 | while (of_irq_to_resource(np, num_irq, &temp_res) != NO_IRQ) | ||
594 | num_irq++; | ||
595 | |||
596 | /* Allocate memory for both the struct device and the resource table */ | ||
597 | dev = kzalloc(sizeof(*dev) + (sizeof(*res) * (num_reg + num_irq)), | ||
598 | GFP_KERNEL); | ||
599 | if (!dev) | ||
600 | return NULL; | ||
601 | res = (struct resource *) &dev[1]; | ||
602 | |||
603 | /* Populate the resource table */ | ||
604 | if (num_irq || num_reg) { | ||
605 | dev->num_resources = num_reg + num_irq; | ||
606 | dev->resource = res; | ||
607 | for (i = 0; i < num_reg; i++, res++) { | ||
608 | rc = of_address_to_resource(np, i, res); | ||
609 | WARN_ON(rc); | ||
610 | } | ||
611 | for (i = 0; i < num_irq; i++, res++) { | ||
612 | rc = of_irq_to_resource(np, i, res); | ||
613 | WARN_ON(rc == NO_IRQ); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | dev->dev.of_node = of_node_get(np); | ||
618 | #if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE) | ||
619 | dev->dev.dma_mask = &dev->archdata.dma_mask; | ||
620 | #endif | ||
621 | dev->dev.parent = parent; | ||
622 | dev->dev.release = of_release_dev; | ||
623 | |||
624 | if (bus_id) | ||
625 | dev_set_name(&dev->dev, "%s", bus_id); | ||
626 | else | ||
627 | of_device_make_bus_id(&dev->dev); | ||
628 | |||
629 | return dev; | ||
630 | } | ||
631 | EXPORT_SYMBOL(of_device_alloc); | ||
632 | |||
633 | /** | ||
634 | * of_platform_device_create - Alloc, initialize and register an of_device | ||
635 | * @np: pointer to node to create device for | ||
636 | * @bus_id: name to assign device | ||
637 | * @parent: Linux device model parent device. | ||
638 | */ | ||
639 | struct platform_device *of_platform_device_create(struct device_node *np, | ||
640 | const char *bus_id, | ||
641 | struct device *parent) | ||
642 | { | ||
643 | struct platform_device *dev; | ||
644 | |||
645 | dev = of_device_alloc(np, bus_id, parent); | ||
646 | if (!dev) | ||
647 | return NULL; | ||
648 | |||
649 | #if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE) | ||
650 | dev->archdata.dma_mask = 0xffffffffUL; | ||
651 | #endif | ||
652 | dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
653 | dev->dev.bus = &platform_bus_type; | ||
654 | |||
655 | /* We do not fill the DMA ops for platform devices by default. | ||
656 | * This is currently the responsibility of the platform code | ||
657 | * to do such, possibly using a device notifier | ||
658 | */ | ||
659 | |||
660 | if (of_device_register(dev) != 0) { | ||
661 | of_device_free(dev); | ||
662 | return NULL; | ||
663 | } | ||
664 | |||
665 | return dev; | ||
666 | } | ||
667 | EXPORT_SYMBOL(of_platform_device_create); | ||
668 | |||
669 | /** | ||
670 | * of_platform_bus_create - Create an OF device for a bus node and all its | ||
671 | * children. Optionally recursively instantiate matching busses. | ||
672 | * @bus: device node of the bus to instantiate | ||
673 | * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to | ||
674 | * disallow recursive creation of child busses | ||
675 | */ | ||
676 | static int of_platform_bus_create(const struct device_node *bus, | ||
677 | const struct of_device_id *matches, | ||
678 | struct device *parent) | ||
679 | { | ||
680 | struct device_node *child; | ||
681 | struct platform_device *dev; | ||
682 | int rc = 0; | ||
683 | |||
684 | for_each_child_of_node(bus, child) { | ||
685 | pr_debug(" create child: %s\n", child->full_name); | ||
686 | dev = of_platform_device_create(child, NULL, parent); | ||
687 | if (dev == NULL) | ||
688 | rc = -ENOMEM; | ||
689 | else if (!of_match_node(matches, child)) | ||
690 | continue; | ||
691 | if (rc == 0) { | ||
692 | pr_debug(" and sub busses\n"); | ||
693 | rc = of_platform_bus_create(child, matches, &dev->dev); | ||
694 | } | ||
695 | if (rc) { | ||
696 | of_node_put(child); | ||
697 | break; | ||
698 | } | ||
699 | } | ||
700 | return rc; | ||
701 | } | ||
702 | |||
703 | /** | ||
704 | * of_platform_bus_probe - Probe the device-tree for platform busses | ||
705 | * @root: parent of the first level to probe or NULL for the root of the tree | ||
706 | * @matches: match table, NULL to use the default | ||
707 | * @parent: parent to hook devices from, NULL for toplevel | ||
708 | * | ||
709 | * Note that children of the provided root are not instantiated as devices | ||
710 | * unless the specified root itself matches the bus list and is not NULL. | ||
711 | */ | ||
712 | int of_platform_bus_probe(struct device_node *root, | ||
713 | const struct of_device_id *matches, | ||
714 | struct device *parent) | ||
715 | { | ||
716 | struct device_node *child; | ||
717 | struct platform_device *dev; | ||
718 | int rc = 0; | ||
719 | |||
720 | if (WARN_ON(!matches || matches == OF_NO_DEEP_PROBE)) | ||
721 | return -EINVAL; | ||
722 | if (root == NULL) | ||
723 | root = of_find_node_by_path("/"); | ||
724 | else | ||
725 | of_node_get(root); | ||
726 | if (root == NULL) | ||
727 | return -EINVAL; | ||
728 | |||
729 | pr_debug("of_platform_bus_probe()\n"); | ||
730 | pr_debug(" starting at: %s\n", root->full_name); | ||
731 | |||
732 | /* Do a self check of bus type, if there's a match, create | ||
733 | * children | ||
734 | */ | ||
735 | if (of_match_node(matches, root)) { | ||
736 | pr_debug(" root match, create all sub devices\n"); | ||
737 | dev = of_platform_device_create(root, NULL, parent); | ||
738 | if (dev == NULL) { | ||
739 | rc = -ENOMEM; | ||
740 | goto bail; | ||
741 | } | ||
742 | pr_debug(" create all sub busses\n"); | ||
743 | rc = of_platform_bus_create(root, matches, &dev->dev); | ||
744 | goto bail; | ||
745 | } | ||
746 | for_each_child_of_node(root, child) { | ||
747 | if (!of_match_node(matches, child)) | ||
748 | continue; | ||
749 | |||
750 | pr_debug(" match: %s\n", child->full_name); | ||
751 | dev = of_platform_device_create(child, NULL, parent); | ||
752 | if (dev == NULL) | ||
753 | rc = -ENOMEM; | ||
754 | else | ||
755 | rc = of_platform_bus_create(child, matches, &dev->dev); | ||
756 | if (rc) { | ||
757 | of_node_put(child); | ||
758 | break; | ||
759 | } | ||
760 | } | ||
761 | bail: | ||
762 | of_node_put(root); | ||
763 | return rc; | ||
764 | } | ||
765 | EXPORT_SYMBOL(of_platform_bus_probe); | ||
766 | #endif /* !CONFIG_SPARC */ | ||
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c index 9a5b4b894161..210a6441a066 100644 --- a/drivers/parport/parport_sunbpp.c +++ b/drivers/parport/parport_sunbpp.c | |||
@@ -295,7 +295,7 @@ static int __devinit bpp_probe(struct of_device *op, const struct of_device_id * | |||
295 | void __iomem *base; | 295 | void __iomem *base; |
296 | struct parport *p; | 296 | struct parport *p; |
297 | 297 | ||
298 | irq = op->irqs[0]; | 298 | irq = op->archdata.irqs[0]; |
299 | base = of_ioremap(&op->resource[0], 0, | 299 | base = of_ioremap(&op->resource[0], 0, |
300 | resource_size(&op->resource[0]), | 300 | resource_size(&op->resource[0]), |
301 | "sunbpp"); | 301 | "sunbpp"); |
@@ -393,12 +393,12 @@ static struct of_platform_driver bpp_sbus_driver = { | |||
393 | 393 | ||
394 | static int __init parport_sunbpp_init(void) | 394 | static int __init parport_sunbpp_init(void) |
395 | { | 395 | { |
396 | return of_register_driver(&bpp_sbus_driver, &of_bus_type); | 396 | return of_register_platform_driver(&bpp_sbus_driver); |
397 | } | 397 | } |
398 | 398 | ||
399 | static void __exit parport_sunbpp_exit(void) | 399 | static void __exit parport_sunbpp_exit(void) |
400 | { | 400 | { |
401 | of_unregister_driver(&bpp_sbus_driver); | 401 | of_unregister_platform_driver(&bpp_sbus_driver); |
402 | } | 402 | } |
403 | 403 | ||
404 | MODULE_AUTHOR("Derrick J Brashear"); | 404 | MODULE_AUTHOR("Derrick J Brashear"); |
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index 8bfdd63a1fcb..3e89c313e98d 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c | |||
@@ -317,7 +317,7 @@ static struct bbc_i2c_bus * __init attach_one_i2c(struct of_device *op, int inde | |||
317 | 317 | ||
318 | bp->waiting = 0; | 318 | bp->waiting = 0; |
319 | init_waitqueue_head(&bp->wq); | 319 | init_waitqueue_head(&bp->wq); |
320 | if (request_irq(op->irqs[0], bbc_i2c_interrupt, | 320 | if (request_irq(op->archdata.irqs[0], bbc_i2c_interrupt, |
321 | IRQF_SHARED, "bbc_i2c", bp)) | 321 | IRQF_SHARED, "bbc_i2c", bp)) |
322 | goto fail; | 322 | goto fail; |
323 | 323 | ||
@@ -373,7 +373,7 @@ static int __devinit bbc_i2c_probe(struct of_device *op, | |||
373 | 373 | ||
374 | err = bbc_envctrl_init(bp); | 374 | err = bbc_envctrl_init(bp); |
375 | if (err) { | 375 | if (err) { |
376 | free_irq(op->irqs[0], bp); | 376 | free_irq(op->archdata.irqs[0], bp); |
377 | if (bp->i2c_bussel_reg) | 377 | if (bp->i2c_bussel_reg) |
378 | of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); | 378 | of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); |
379 | if (bp->i2c_control_regs) | 379 | if (bp->i2c_control_regs) |
@@ -392,7 +392,7 @@ static int __devexit bbc_i2c_remove(struct of_device *op) | |||
392 | 392 | ||
393 | bbc_envctrl_cleanup(bp); | 393 | bbc_envctrl_cleanup(bp); |
394 | 394 | ||
395 | free_irq(op->irqs[0], bp); | 395 | free_irq(op->archdata.irqs[0], bp); |
396 | 396 | ||
397 | if (bp->i2c_bussel_reg) | 397 | if (bp->i2c_bussel_reg) |
398 | of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); | 398 | of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); |
@@ -425,12 +425,12 @@ static struct of_platform_driver bbc_i2c_driver = { | |||
425 | 425 | ||
426 | static int __init bbc_i2c_init(void) | 426 | static int __init bbc_i2c_init(void) |
427 | { | 427 | { |
428 | return of_register_driver(&bbc_i2c_driver, &of_bus_type); | 428 | return of_register_platform_driver(&bbc_i2c_driver); |
429 | } | 429 | } |
430 | 430 | ||
431 | static void __exit bbc_i2c_exit(void) | 431 | static void __exit bbc_i2c_exit(void) |
432 | { | 432 | { |
433 | of_unregister_driver(&bbc_i2c_driver); | 433 | of_unregister_platform_driver(&bbc_i2c_driver); |
434 | } | 434 | } |
435 | 435 | ||
436 | module_init(bbc_i2c_init); | 436 | module_init(bbc_i2c_init); |
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index 4ad4d2c91075..47db97583ea7 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c | |||
@@ -277,12 +277,12 @@ static struct of_platform_driver d7s_driver = { | |||
277 | 277 | ||
278 | static int __init d7s_init(void) | 278 | static int __init d7s_init(void) |
279 | { | 279 | { |
280 | return of_register_driver(&d7s_driver, &of_bus_type); | 280 | return of_register_platform_driver(&d7s_driver); |
281 | } | 281 | } |
282 | 282 | ||
283 | static void __exit d7s_exit(void) | 283 | static void __exit d7s_exit(void) |
284 | { | 284 | { |
285 | of_unregister_driver(&d7s_driver); | 285 | of_unregister_platform_driver(&d7s_driver); |
286 | } | 286 | } |
287 | 287 | ||
288 | module_init(d7s_init); | 288 | module_init(d7s_init); |
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index bd0bbc621351..3c27f45e2b6d 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -1140,12 +1140,12 @@ static struct of_platform_driver envctrl_driver = { | |||
1140 | 1140 | ||
1141 | static int __init envctrl_init(void) | 1141 | static int __init envctrl_init(void) |
1142 | { | 1142 | { |
1143 | return of_register_driver(&envctrl_driver, &of_bus_type); | 1143 | return of_register_platform_driver(&envctrl_driver); |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | static void __exit envctrl_exit(void) | 1146 | static void __exit envctrl_exit(void) |
1147 | { | 1147 | { |
1148 | of_unregister_driver(&envctrl_driver); | 1148 | of_unregister_platform_driver(&envctrl_driver); |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | module_init(envctrl_init); | 1151 | module_init(envctrl_init); |
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index ed9494e18859..8bb31c584b64 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c | |||
@@ -219,12 +219,12 @@ static struct of_platform_driver flash_driver = { | |||
219 | 219 | ||
220 | static int __init flash_init(void) | 220 | static int __init flash_init(void) |
221 | { | 221 | { |
222 | return of_register_driver(&flash_driver, &of_bus_type); | 222 | return of_register_platform_driver(&flash_driver); |
223 | } | 223 | } |
224 | 224 | ||
225 | static void __exit flash_cleanup(void) | 225 | static void __exit flash_cleanup(void) |
226 | { | 226 | { |
227 | of_unregister_driver(&flash_driver); | 227 | of_unregister_platform_driver(&flash_driver); |
228 | } | 228 | } |
229 | 229 | ||
230 | module_init(flash_init); | 230 | module_init(flash_init); |
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c index 079da4cb45a5..41eb6725ff5f 100644 --- a/drivers/sbus/char/uctrl.c +++ b/drivers/sbus/char/uctrl.c | |||
@@ -368,7 +368,7 @@ static int __devinit uctrl_probe(struct of_device *op, | |||
368 | goto out_free; | 368 | goto out_free; |
369 | } | 369 | } |
370 | 370 | ||
371 | p->irq = op->irqs[0]; | 371 | p->irq = op->archdata.irqs[0]; |
372 | err = request_irq(p->irq, uctrl_interrupt, 0, "uctrl", p); | 372 | err = request_irq(p->irq, uctrl_interrupt, 0, "uctrl", p); |
373 | if (err) { | 373 | if (err) { |
374 | printk(KERN_ERR "uctrl: Unable to register irq.\n"); | 374 | printk(KERN_ERR "uctrl: Unable to register irq.\n"); |
@@ -438,12 +438,12 @@ static struct of_platform_driver uctrl_driver = { | |||
438 | 438 | ||
439 | static int __init uctrl_init(void) | 439 | static int __init uctrl_init(void) |
440 | { | 440 | { |
441 | return of_register_driver(&uctrl_driver, &of_bus_type); | 441 | return of_register_platform_driver(&uctrl_driver); |
442 | } | 442 | } |
443 | 443 | ||
444 | static void __exit uctrl_exit(void) | 444 | static void __exit uctrl_exit(void) |
445 | { | 445 | { |
446 | of_unregister_driver(&uctrl_driver); | 446 | of_unregister_platform_driver(&uctrl_driver); |
447 | } | 447 | } |
448 | 448 | ||
449 | module_init(uctrl_init); | 449 | module_init(uctrl_init); |
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index ca5c15c779cf..53d7ed0dc169 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -729,7 +729,7 @@ static int __devinit qpti_register_irq(struct qlogicpti *qpti) | |||
729 | { | 729 | { |
730 | struct of_device *op = qpti->op; | 730 | struct of_device *op = qpti->op; |
731 | 731 | ||
732 | qpti->qhost->irq = qpti->irq = op->irqs[0]; | 732 | qpti->qhost->irq = qpti->irq = op->archdata.irqs[0]; |
733 | 733 | ||
734 | /* We used to try various overly-clever things to | 734 | /* We used to try various overly-clever things to |
735 | * reduce the interrupt processing overhead on | 735 | * reduce the interrupt processing overhead on |
@@ -1302,7 +1302,7 @@ static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_devic | |||
1302 | /* Sometimes Antares cards come up not completely | 1302 | /* Sometimes Antares cards come up not completely |
1303 | * setup, and we get a report of a zero IRQ. | 1303 | * setup, and we get a report of a zero IRQ. |
1304 | */ | 1304 | */ |
1305 | if (op->irqs[0] == 0) | 1305 | if (op->archdata.irqs[0] == 0) |
1306 | return -ENODEV; | 1306 | return -ENODEV; |
1307 | 1307 | ||
1308 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); | 1308 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); |
@@ -1467,12 +1467,12 @@ static struct of_platform_driver qpti_sbus_driver = { | |||
1467 | 1467 | ||
1468 | static int __init qpti_init(void) | 1468 | static int __init qpti_init(void) |
1469 | { | 1469 | { |
1470 | return of_register_driver(&qpti_sbus_driver, &of_bus_type); | 1470 | return of_register_platform_driver(&qpti_sbus_driver); |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | static void __exit qpti_exit(void) | 1473 | static void __exit qpti_exit(void) |
1474 | { | 1474 | { |
1475 | of_unregister_driver(&qpti_sbus_driver); | 1475 | of_unregister_platform_driver(&qpti_sbus_driver); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); | 1478 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); |
diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c index 386dd9d602b6..89ba6fe02f80 100644 --- a/drivers/scsi/sun_esp.c +++ b/drivers/scsi/sun_esp.c | |||
@@ -116,7 +116,7 @@ static int __devinit esp_sbus_register_irq(struct esp *esp) | |||
116 | struct Scsi_Host *host = esp->host; | 116 | struct Scsi_Host *host = esp->host; |
117 | struct of_device *op = esp->dev; | 117 | struct of_device *op = esp->dev; |
118 | 118 | ||
119 | host->irq = op->irqs[0]; | 119 | host->irq = op->archdata.irqs[0]; |
120 | return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp); | 120 | return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp); |
121 | } | 121 | } |
122 | 122 | ||
@@ -644,12 +644,12 @@ static struct of_platform_driver esp_sbus_driver = { | |||
644 | 644 | ||
645 | static int __init sunesp_init(void) | 645 | static int __init sunesp_init(void) |
646 | { | 646 | { |
647 | return of_register_driver(&esp_sbus_driver, &of_bus_type); | 647 | return of_register_platform_driver(&esp_sbus_driver); |
648 | } | 648 | } |
649 | 649 | ||
650 | static void __exit sunesp_exit(void) | 650 | static void __exit sunesp_exit(void) |
651 | { | 651 | { |
652 | of_unregister_driver(&esp_sbus_driver); | 652 | of_unregister_platform_driver(&esp_sbus_driver); |
653 | } | 653 | } |
654 | 654 | ||
655 | MODULE_DESCRIPTION("Sun ESP SCSI driver"); | 655 | MODULE_DESCRIPTION("Sun ESP SCSI driver"); |
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index 890f91742962..a779e22d213e 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c | |||
@@ -525,7 +525,7 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m | |||
525 | unsigned long minor; | 525 | unsigned long minor; |
526 | int err; | 526 | int err; |
527 | 527 | ||
528 | if (op->irqs[0] == 0xffffffff) | 528 | if (op->archdata.irqs[0] == 0xffffffff) |
529 | return -ENODEV; | 529 | return -ENODEV; |
530 | 530 | ||
531 | port = kzalloc(sizeof(struct uart_port), GFP_KERNEL); | 531 | port = kzalloc(sizeof(struct uart_port), GFP_KERNEL); |
@@ -557,7 +557,7 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m | |||
557 | 557 | ||
558 | port->membase = (unsigned char __iomem *) __pa(port); | 558 | port->membase = (unsigned char __iomem *) __pa(port); |
559 | 559 | ||
560 | port->irq = op->irqs[0]; | 560 | port->irq = op->archdata.irqs[0]; |
561 | 561 | ||
562 | port->dev = &op->dev; | 562 | port->dev = &op->dev; |
563 | 563 | ||
@@ -644,12 +644,12 @@ static int __init sunhv_init(void) | |||
644 | if (tlb_type != hypervisor) | 644 | if (tlb_type != hypervisor) |
645 | return -ENODEV; | 645 | return -ENODEV; |
646 | 646 | ||
647 | return of_register_driver(&hv_driver, &of_bus_type); | 647 | return of_register_platform_driver(&hv_driver); |
648 | } | 648 | } |
649 | 649 | ||
650 | static void __exit sunhv_exit(void) | 650 | static void __exit sunhv_exit(void) |
651 | { | 651 | { |
652 | of_unregister_driver(&hv_driver); | 652 | of_unregister_platform_driver(&hv_driver); |
653 | } | 653 | } |
654 | 654 | ||
655 | module_init(sunhv_init); | 655 | module_init(sunhv_init); |
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 5e81bc6b48b0..9845fb1cfb1f 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -969,7 +969,7 @@ static int __devinit sunsab_init_one(struct uart_sunsab_port *up, | |||
969 | return -ENOMEM; | 969 | return -ENOMEM; |
970 | up->regs = (union sab82532_async_regs __iomem *) up->port.membase; | 970 | up->regs = (union sab82532_async_regs __iomem *) up->port.membase; |
971 | 971 | ||
972 | up->port.irq = op->irqs[0]; | 972 | up->port.irq = op->archdata.irqs[0]; |
973 | 973 | ||
974 | up->port.fifosize = SAB82532_XMIT_FIFO_SIZE; | 974 | up->port.fifosize = SAB82532_XMIT_FIFO_SIZE; |
975 | up->port.iotype = UPIO_MEM; | 975 | up->port.iotype = UPIO_MEM; |
@@ -1130,12 +1130,12 @@ static int __init sunsab_init(void) | |||
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | return of_register_driver(&sab_driver, &of_bus_type); | 1133 | return of_register_platform_driver(&sab_driver); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | static void __exit sunsab_exit(void) | 1136 | static void __exit sunsab_exit(void) |
1137 | { | 1137 | { |
1138 | of_unregister_driver(&sab_driver); | 1138 | of_unregister_platform_driver(&sab_driver); |
1139 | if (sunsab_reg.nr) { | 1139 | if (sunsab_reg.nr) { |
1140 | sunserial_unregister_minors(&sunsab_reg, sunsab_reg.nr); | 1140 | sunserial_unregister_minors(&sunsab_reg, sunsab_reg.nr); |
1141 | } | 1141 | } |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index ffbf4553f665..3cdf74822db5 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -1443,7 +1443,7 @@ static int __devinit su_probe(struct of_device *op, const struct of_device_id *m | |||
1443 | return -ENOMEM; | 1443 | return -ENOMEM; |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | up->port.irq = op->irqs[0]; | 1446 | up->port.irq = op->archdata.irqs[0]; |
1447 | 1447 | ||
1448 | up->port.dev = &op->dev; | 1448 | up->port.dev = &op->dev; |
1449 | 1449 | ||
@@ -1586,7 +1586,7 @@ static int __init sunsu_init(void) | |||
1586 | return err; | 1586 | return err; |
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | err = of_register_driver(&su_driver, &of_bus_type); | 1589 | err = of_register_platform_driver(&su_driver); |
1590 | if (err && num_uart) | 1590 | if (err && num_uart) |
1591 | sunserial_unregister_minors(&sunsu_reg, num_uart); | 1591 | sunserial_unregister_minors(&sunsu_reg, num_uart); |
1592 | 1592 | ||
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index f9a24f4ebb34..d1e6bcb59546 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -1426,7 +1426,7 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m | |||
1426 | rp = sunzilog_chip_regs[inst]; | 1426 | rp = sunzilog_chip_regs[inst]; |
1427 | 1427 | ||
1428 | if (zilog_irq == -1) | 1428 | if (zilog_irq == -1) |
1429 | zilog_irq = op->irqs[0]; | 1429 | zilog_irq = op->archdata.irqs[0]; |
1430 | 1430 | ||
1431 | up = &sunzilog_port_table[inst * 2]; | 1431 | up = &sunzilog_port_table[inst * 2]; |
1432 | 1432 | ||
@@ -1434,7 +1434,7 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m | |||
1434 | up[0].port.mapbase = op->resource[0].start + 0x00; | 1434 | up[0].port.mapbase = op->resource[0].start + 0x00; |
1435 | up[0].port.membase = (void __iomem *) &rp->channelA; | 1435 | up[0].port.membase = (void __iomem *) &rp->channelA; |
1436 | up[0].port.iotype = UPIO_MEM; | 1436 | up[0].port.iotype = UPIO_MEM; |
1437 | up[0].port.irq = op->irqs[0]; | 1437 | up[0].port.irq = op->archdata.irqs[0]; |
1438 | up[0].port.uartclk = ZS_CLOCK; | 1438 | up[0].port.uartclk = ZS_CLOCK; |
1439 | up[0].port.fifosize = 1; | 1439 | up[0].port.fifosize = 1; |
1440 | up[0].port.ops = &sunzilog_pops; | 1440 | up[0].port.ops = &sunzilog_pops; |
@@ -1451,7 +1451,7 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m | |||
1451 | up[1].port.mapbase = op->resource[0].start + 0x04; | 1451 | up[1].port.mapbase = op->resource[0].start + 0x04; |
1452 | up[1].port.membase = (void __iomem *) &rp->channelB; | 1452 | up[1].port.membase = (void __iomem *) &rp->channelB; |
1453 | up[1].port.iotype = UPIO_MEM; | 1453 | up[1].port.iotype = UPIO_MEM; |
1454 | up[1].port.irq = op->irqs[0]; | 1454 | up[1].port.irq = op->archdata.irqs[0]; |
1455 | up[1].port.uartclk = ZS_CLOCK; | 1455 | up[1].port.uartclk = ZS_CLOCK; |
1456 | up[1].port.fifosize = 1; | 1456 | up[1].port.fifosize = 1; |
1457 | up[1].port.ops = &sunzilog_pops; | 1457 | up[1].port.ops = &sunzilog_pops; |
@@ -1492,12 +1492,12 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m | |||
1492 | "is a %s\n", | 1492 | "is a %s\n", |
1493 | dev_name(&op->dev), | 1493 | dev_name(&op->dev), |
1494 | (unsigned long long) up[0].port.mapbase, | 1494 | (unsigned long long) up[0].port.mapbase, |
1495 | op->irqs[0], sunzilog_type(&up[0].port)); | 1495 | op->archdata.irqs[0], sunzilog_type(&up[0].port)); |
1496 | printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) " | 1496 | printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) " |
1497 | "is a %s\n", | 1497 | "is a %s\n", |
1498 | dev_name(&op->dev), | 1498 | dev_name(&op->dev), |
1499 | (unsigned long long) up[1].port.mapbase, | 1499 | (unsigned long long) up[1].port.mapbase, |
1500 | op->irqs[0], sunzilog_type(&up[1].port)); | 1500 | op->archdata.irqs[0], sunzilog_type(&up[1].port)); |
1501 | kbm_inst++; | 1501 | kbm_inst++; |
1502 | } | 1502 | } |
1503 | 1503 | ||
@@ -1576,7 +1576,7 @@ static int __init sunzilog_init(void) | |||
1576 | goto out_free_tables; | 1576 | goto out_free_tables; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | err = of_register_driver(&zs_driver, &of_bus_type); | 1579 | err = of_register_platform_driver(&zs_driver); |
1580 | if (err) | 1580 | if (err) |
1581 | goto out_unregister_uart; | 1581 | goto out_unregister_uart; |
1582 | 1582 | ||
@@ -1604,7 +1604,7 @@ out: | |||
1604 | return err; | 1604 | return err; |
1605 | 1605 | ||
1606 | out_unregister_driver: | 1606 | out_unregister_driver: |
1607 | of_unregister_driver(&zs_driver); | 1607 | of_unregister_platform_driver(&zs_driver); |
1608 | 1608 | ||
1609 | out_unregister_uart: | 1609 | out_unregister_uart: |
1610 | if (num_sunzilog) { | 1610 | if (num_sunzilog) { |
@@ -1619,7 +1619,7 @@ out_free_tables: | |||
1619 | 1619 | ||
1620 | static void __exit sunzilog_exit(void) | 1620 | static void __exit sunzilog_exit(void) |
1621 | { | 1621 | { |
1622 | of_unregister_driver(&zs_driver); | 1622 | of_unregister_platform_driver(&zs_driver); |
1623 | 1623 | ||
1624 | if (zilog_irq != -1) { | 1624 | if (zilog_irq != -1) { |
1625 | struct uart_sunzilog_port *up = sunzilog_irq_chain; | 1625 | struct uart_sunzilog_port *up = sunzilog_irq_chain; |
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c index 8acccd564378..caf085d3a76a 100644 --- a/drivers/serial/uartlite.c +++ b/drivers/serial/uartlite.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) | 22 | #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) |
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_address.h> | ||
24 | #include <linux/of_device.h> | 25 | #include <linux/of_device.h> |
25 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
26 | 27 | ||
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c index 2534b1ec3edd..10baac3f8ea5 100644 --- a/drivers/spi/mpc512x_psc_spi.c +++ b/drivers/spi/mpc512x_psc_spi.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/of_address.h> | ||
22 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
23 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
24 | #include <linux/completion.h> | 25 | #include <linux/completion.h> |
@@ -440,6 +441,7 @@ static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
440 | master->setup = mpc512x_psc_spi_setup; | 441 | master->setup = mpc512x_psc_spi_setup; |
441 | master->transfer = mpc512x_psc_spi_transfer; | 442 | master->transfer = mpc512x_psc_spi_transfer; |
442 | master->cleanup = mpc512x_psc_spi_cleanup; | 443 | master->cleanup = mpc512x_psc_spi_cleanup; |
444 | master->dev.of_node = dev->of_node; | ||
443 | 445 | ||
444 | tempp = ioremap(regaddr, size); | 446 | tempp = ioremap(regaddr, size); |
445 | if (!tempp) { | 447 | if (!tempp) { |
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 7104cb739da7..66d170147dcc 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -16,8 +16,8 @@ | |||
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/of_address.h> | ||
19 | #include <linux/of_platform.h> | 20 | #include <linux/of_platform.h> |
20 | #include <linux/of_spi.h> | ||
21 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
22 | #include <linux/completion.h> | 22 | #include <linux/completion.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
@@ -398,6 +398,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
398 | master->setup = mpc52xx_psc_spi_setup; | 398 | master->setup = mpc52xx_psc_spi_setup; |
399 | master->transfer = mpc52xx_psc_spi_transfer; | 399 | master->transfer = mpc52xx_psc_spi_transfer; |
400 | master->cleanup = mpc52xx_psc_spi_cleanup; | 400 | master->cleanup = mpc52xx_psc_spi_cleanup; |
401 | master->dev.of_node = dev->of_node; | ||
401 | 402 | ||
402 | mps->psc = ioremap(regaddr, size); | 403 | mps->psc = ioremap(regaddr, size); |
403 | if (!mps->psc) { | 404 | if (!mps->psc) { |
@@ -470,7 +471,6 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
470 | const u32 *regaddr_p; | 471 | const u32 *regaddr_p; |
471 | u64 regaddr64, size64; | 472 | u64 regaddr64, size64; |
472 | s16 id = -1; | 473 | s16 id = -1; |
473 | int rc; | ||
474 | 474 | ||
475 | regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); | 475 | regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); |
476 | if (!regaddr_p) { | 476 | if (!regaddr_p) { |
@@ -491,13 +491,8 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
491 | id = *psc_nump + 1; | 491 | id = *psc_nump + 1; |
492 | } | 492 | } |
493 | 493 | ||
494 | rc = mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, | 494 | return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, |
495 | irq_of_parse_and_map(op->dev.of_node, 0), id); | 495 | irq_of_parse_and_map(op->dev.of_node, 0), id); |
496 | if (rc == 0) | ||
497 | of_register_spi_devices(dev_get_drvdata(&op->dev), | ||
498 | op->dev.of_node); | ||
499 | |||
500 | return rc; | ||
501 | } | 496 | } |
502 | 497 | ||
503 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) | 498 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) |
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c index b1a76bff775f..56136ff00e01 100644 --- a/drivers/spi/mpc52xx_spi.c +++ b/drivers/spi/mpc52xx_spi.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/of_spi.h> | ||
22 | #include <linux/io.h> | 21 | #include <linux/io.h> |
23 | #include <linux/of_gpio.h> | 22 | #include <linux/of_gpio.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -439,6 +438,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op, | |||
439 | master->setup = mpc52xx_spi_setup; | 438 | master->setup = mpc52xx_spi_setup; |
440 | master->transfer = mpc52xx_spi_transfer; | 439 | master->transfer = mpc52xx_spi_transfer; |
441 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; | 440 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; |
441 | master->dev.of_node = op->dev.of_node; | ||
442 | 442 | ||
443 | dev_set_drvdata(&op->dev, master); | 443 | dev_set_drvdata(&op->dev, master); |
444 | 444 | ||
@@ -512,7 +512,6 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op, | |||
512 | if (rc) | 512 | if (rc) |
513 | goto err_register; | 513 | goto err_register; |
514 | 514 | ||
515 | of_register_spi_devices(master, op->dev.of_node); | ||
516 | dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n"); | 515 | dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n"); |
517 | 516 | ||
518 | return rc; | 517 | return rc; |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b3a1f9259b62..1bb1b88780ce 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/mod_devicetable.h> | 27 | #include <linux/mod_devicetable.h> |
28 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/of_spi.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /* SPI bustype and spi_master class are registered after board init code | 32 | /* SPI bustype and spi_master class are registered after board init code |
@@ -540,6 +541,9 @@ int spi_register_master(struct spi_master *master) | |||
540 | /* populate children from any spi device tables */ | 541 | /* populate children from any spi device tables */ |
541 | scan_boardinfo(master); | 542 | scan_boardinfo(master); |
542 | status = 0; | 543 | status = 0; |
544 | |||
545 | /* Register devices from the device tree */ | ||
546 | of_register_spi_devices(master); | ||
543 | done: | 547 | done: |
544 | return status; | 548 | return status; |
545 | } | 549 | } |
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index 97ab0a81338a..aad9ae1b9c69 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/of_platform.h> | 38 | #include <linux/of_platform.h> |
39 | #include <linux/gpio.h> | 39 | #include <linux/gpio.h> |
40 | #include <linux/of_gpio.h> | 40 | #include <linux/of_gpio.h> |
41 | #include <linux/of_spi.h> | ||
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
43 | 42 | ||
44 | #include <sysdev/fsl_soc.h> | 43 | #include <sysdev/fsl_soc.h> |
@@ -1009,6 +1008,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
1009 | master->setup = mpc8xxx_spi_setup; | 1008 | master->setup = mpc8xxx_spi_setup; |
1010 | master->transfer = mpc8xxx_spi_transfer; | 1009 | master->transfer = mpc8xxx_spi_transfer; |
1011 | master->cleanup = mpc8xxx_spi_cleanup; | 1010 | master->cleanup = mpc8xxx_spi_cleanup; |
1011 | master->dev.of_node = dev->of_node; | ||
1012 | 1012 | ||
1013 | mpc8xxx_spi = spi_master_get_devdata(master); | 1013 | mpc8xxx_spi = spi_master_get_devdata(master); |
1014 | mpc8xxx_spi->dev = dev; | 1014 | mpc8xxx_spi->dev = dev; |
@@ -1299,8 +1299,6 @@ static int __devinit of_mpc8xxx_spi_probe(struct of_device *ofdev, | |||
1299 | goto err; | 1299 | goto err; |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | of_register_spi_devices(master, np); | ||
1303 | |||
1304 | return 0; | 1302 | return 0; |
1305 | 1303 | ||
1306 | err: | 1304 | err: |
diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c index d53466a249d9..0f5fa7e2a550 100644 --- a/drivers/spi/spi_ppc4xx.c +++ b/drivers/spi/spi_ppc4xx.c | |||
@@ -407,6 +407,7 @@ static int __init spi_ppc4xx_of_probe(struct of_device *op, | |||
407 | master = spi_alloc_master(dev, sizeof *hw); | 407 | master = spi_alloc_master(dev, sizeof *hw); |
408 | if (master == NULL) | 408 | if (master == NULL) |
409 | return -ENOMEM; | 409 | return -ENOMEM; |
410 | master->dev.of_node = np; | ||
410 | dev_set_drvdata(dev, master); | 411 | dev_set_drvdata(dev, master); |
411 | hw = spi_master_get_devdata(master); | 412 | hw = spi_master_get_devdata(master); |
412 | hw->master = spi_master_get(master); | 413 | hw->master = spi_master_get(master); |
@@ -545,7 +546,6 @@ static int __init spi_ppc4xx_of_probe(struct of_device *op, | |||
545 | } | 546 | } |
546 | 547 | ||
547 | dev_info(dev, "driver initialized\n"); | 548 | dev_info(dev, "driver initialized\n"); |
548 | of_register_spi_devices(master, np); | ||
549 | 549 | ||
550 | return 0; | 550 | return 0; |
551 | 551 | ||
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 1b47363cb73f..80f2db5bcfd6 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -390,6 +390,9 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | |||
390 | 390 | ||
391 | master->bus_num = bus_num; | 391 | master->bus_num = bus_num; |
392 | master->num_chipselect = pdata->num_chipselect; | 392 | master->num_chipselect = pdata->num_chipselect; |
393 | #ifdef CONFIG_OF | ||
394 | master->dev.of_node = dev->of_node; | ||
395 | #endif | ||
393 | 396 | ||
394 | xspi->mem = *mem; | 397 | xspi->mem = *mem; |
395 | xspi->irq = irq; | 398 | xspi->irq = irq; |
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c index 4654805b08d8..f53d3f6b9f61 100644 --- a/drivers/spi/xilinx_spi_of.c +++ b/drivers/spi/xilinx_spi_of.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | 31 | ||
32 | #include <linux/of_address.h> | ||
32 | #include <linux/of_platform.h> | 33 | #include <linux/of_platform.h> |
33 | #include <linux/of_device.h> | 34 | #include <linux/of_device.h> |
34 | #include <linux/of_spi.h> | 35 | #include <linux/of_spi.h> |
@@ -80,9 +81,6 @@ static int __devinit xilinx_spi_of_probe(struct of_device *ofdev, | |||
80 | 81 | ||
81 | dev_set_drvdata(&ofdev->dev, master); | 82 | dev_set_drvdata(&ofdev->dev, master); |
82 | 83 | ||
83 | /* Add any subnodes on the SPI bus */ | ||
84 | of_register_spi_devices(master, ofdev->dev.of_node); | ||
85 | |||
86 | return 0; | 84 | return 0; |
87 | } | 85 | } |
88 | 86 | ||
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 82506ca297d5..9648b75f0283 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
35 | #include <linux/of_address.h> | ||
35 | #include <linux/of_platform.h> | 36 | #include <linux/of_platform.h> |
36 | #include <linux/dma-mapping.h> | 37 | #include <linux/dma-mapping.h> |
37 | #include <linux/usb/ch9.h> | 38 | #include <linux/usb/ch9.h> |
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c index 09f1b9b462f4..c7796637bafd 100644 --- a/drivers/video/bw2.c +++ b/drivers/video/bw2.c | |||
@@ -390,12 +390,12 @@ static int __init bw2_init(void) | |||
390 | if (fb_get_options("bw2fb", NULL)) | 390 | if (fb_get_options("bw2fb", NULL)) |
391 | return -ENODEV; | 391 | return -ENODEV; |
392 | 392 | ||
393 | return of_register_driver(&bw2_driver, &of_bus_type); | 393 | return of_register_platform_driver(&bw2_driver); |
394 | } | 394 | } |
395 | 395 | ||
396 | static void __exit bw2_exit(void) | 396 | static void __exit bw2_exit(void) |
397 | { | 397 | { |
398 | of_unregister_driver(&bw2_driver); | 398 | of_unregister_platform_driver(&bw2_driver); |
399 | } | 399 | } |
400 | 400 | ||
401 | module_init(bw2_init); | 401 | module_init(bw2_init); |
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c index e5dc2241194f..d09fde8beb69 100644 --- a/drivers/video/cg14.c +++ b/drivers/video/cg14.c | |||
@@ -610,12 +610,12 @@ static int __init cg14_init(void) | |||
610 | if (fb_get_options("cg14fb", NULL)) | 610 | if (fb_get_options("cg14fb", NULL)) |
611 | return -ENODEV; | 611 | return -ENODEV; |
612 | 612 | ||
613 | return of_register_driver(&cg14_driver, &of_bus_type); | 613 | return of_register_platform_driver(&cg14_driver); |
614 | } | 614 | } |
615 | 615 | ||
616 | static void __exit cg14_exit(void) | 616 | static void __exit cg14_exit(void) |
617 | { | 617 | { |
618 | of_unregister_driver(&cg14_driver); | 618 | of_unregister_platform_driver(&cg14_driver); |
619 | } | 619 | } |
620 | 620 | ||
621 | module_init(cg14_init); | 621 | module_init(cg14_init); |
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c index 558d73a948a0..64aa29809fb9 100644 --- a/drivers/video/cg3.c +++ b/drivers/video/cg3.c | |||
@@ -477,12 +477,12 @@ static int __init cg3_init(void) | |||
477 | if (fb_get_options("cg3fb", NULL)) | 477 | if (fb_get_options("cg3fb", NULL)) |
478 | return -ENODEV; | 478 | return -ENODEV; |
479 | 479 | ||
480 | return of_register_driver(&cg3_driver, &of_bus_type); | 480 | return of_register_platform_driver(&cg3_driver); |
481 | } | 481 | } |
482 | 482 | ||
483 | static void __exit cg3_exit(void) | 483 | static void __exit cg3_exit(void) |
484 | { | 484 | { |
485 | of_unregister_driver(&cg3_driver); | 485 | of_unregister_platform_driver(&cg3_driver); |
486 | } | 486 | } |
487 | 487 | ||
488 | module_init(cg3_init); | 488 | module_init(cg3_init); |
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c index 480d761a27a8..2389a719dcc7 100644 --- a/drivers/video/cg6.c +++ b/drivers/video/cg6.c | |||
@@ -870,12 +870,12 @@ static int __init cg6_init(void) | |||
870 | if (fb_get_options("cg6fb", NULL)) | 870 | if (fb_get_options("cg6fb", NULL)) |
871 | return -ENODEV; | 871 | return -ENODEV; |
872 | 872 | ||
873 | return of_register_driver(&cg6_driver, &of_bus_type); | 873 | return of_register_platform_driver(&cg6_driver); |
874 | } | 874 | } |
875 | 875 | ||
876 | static void __exit cg6_exit(void) | 876 | static void __exit cg6_exit(void) |
877 | { | 877 | { |
878 | of_unregister_driver(&cg6_driver); | 878 | of_unregister_platform_driver(&cg6_driver); |
879 | } | 879 | } |
880 | 880 | ||
881 | module_init(cg6_init); | 881 | module_init(cg6_init); |
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c index 49fcbe8f18ac..c225dcce89e7 100644 --- a/drivers/video/controlfb.c +++ b/drivers/video/controlfb.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include <linux/vmalloc.h> | 40 | #include <linux/vmalloc.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/of.h> | ||
44 | #include <linux/of_address.h> | ||
43 | #include <linux/fb.h> | 45 | #include <linux/fb.h> |
44 | #include <linux/init.h> | 46 | #include <linux/init.h> |
45 | #include <linux/pci.h> | 47 | #include <linux/pci.h> |
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c index 95c0227f47fc..f6ecfab296d3 100644 --- a/drivers/video/ffb.c +++ b/drivers/video/ffb.c | |||
@@ -1067,12 +1067,12 @@ static int __init ffb_init(void) | |||
1067 | if (fb_get_options("ffb", NULL)) | 1067 | if (fb_get_options("ffb", NULL)) |
1068 | return -ENODEV; | 1068 | return -ENODEV; |
1069 | 1069 | ||
1070 | return of_register_driver(&ffb_driver, &of_bus_type); | 1070 | return of_register_platform_driver(&ffb_driver); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static void __exit ffb_exit(void) | 1073 | static void __exit ffb_exit(void) |
1074 | { | 1074 | { |
1075 | of_unregister_driver(&ffb_driver); | 1075 | of_unregister_platform_driver(&ffb_driver); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | module_init(ffb_init); | 1078 | module_init(ffb_init); |
diff --git a/drivers/video/leo.c b/drivers/video/leo.c index 9e8bf7d5e249..ad677637ffbb 100644 --- a/drivers/video/leo.c +++ b/drivers/video/leo.c | |||
@@ -677,12 +677,12 @@ static int __init leo_init(void) | |||
677 | if (fb_get_options("leofb", NULL)) | 677 | if (fb_get_options("leofb", NULL)) |
678 | return -ENODEV; | 678 | return -ENODEV; |
679 | 679 | ||
680 | return of_register_driver(&leo_driver, &of_bus_type); | 680 | return of_register_platform_driver(&leo_driver); |
681 | } | 681 | } |
682 | 682 | ||
683 | static void __exit leo_exit(void) | 683 | static void __exit leo_exit(void) |
684 | { | 684 | { |
685 | of_unregister_driver(&leo_driver); | 685 | of_unregister_platform_driver(&leo_driver); |
686 | } | 686 | } |
687 | 687 | ||
688 | module_init(leo_init); | 688 | module_init(leo_init); |
diff --git a/drivers/video/offb.c b/drivers/video/offb.c index 46dda7d8aaee..cb163a5397be 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c | |||
@@ -19,13 +19,14 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/of.h> | ||
23 | #include <linux/of_address.h> | ||
22 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
23 | #include <linux/fb.h> | 25 | #include <linux/fb.h> |
24 | #include <linux/init.h> | 26 | #include <linux/init.h> |
25 | #include <linux/ioport.h> | 27 | #include <linux/ioport.h> |
26 | #include <linux/pci.h> | 28 | #include <linux/pci.h> |
27 | #include <asm/io.h> | 29 | #include <asm/io.h> |
28 | #include <asm/prom.h> | ||
29 | 30 | ||
30 | #ifdef CONFIG_PPC64 | 31 | #ifdef CONFIG_PPC64 |
31 | #include <asm/pci-bridge.h> | 32 | #include <asm/pci-bridge.h> |
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c index 6552751e81aa..688b055abab2 100644 --- a/drivers/video/p9100.c +++ b/drivers/video/p9100.c | |||
@@ -367,12 +367,12 @@ static int __init p9100_init(void) | |||
367 | if (fb_get_options("p9100fb", NULL)) | 367 | if (fb_get_options("p9100fb", NULL)) |
368 | return -ENODEV; | 368 | return -ENODEV; |
369 | 369 | ||
370 | return of_register_driver(&p9100_driver, &of_bus_type); | 370 | return of_register_platform_driver(&p9100_driver); |
371 | } | 371 | } |
372 | 372 | ||
373 | static void __exit p9100_exit(void) | 373 | static void __exit p9100_exit(void) |
374 | { | 374 | { |
375 | of_unregister_driver(&p9100_driver); | 375 | of_unregister_platform_driver(&p9100_driver); |
376 | } | 376 | } |
377 | 377 | ||
378 | module_init(p9100_init); | 378 | module_init(p9100_init); |
diff --git a/drivers/video/sunxvr1000.c b/drivers/video/sunxvr1000.c index 489b44e8db81..7288934c0d49 100644 --- a/drivers/video/sunxvr1000.c +++ b/drivers/video/sunxvr1000.c | |||
@@ -213,12 +213,12 @@ static int __init gfb_init(void) | |||
213 | if (fb_get_options("gfb", NULL)) | 213 | if (fb_get_options("gfb", NULL)) |
214 | return -ENODEV; | 214 | return -ENODEV; |
215 | 215 | ||
216 | return of_register_driver(&gfb_driver, &of_bus_type); | 216 | return of_register_platform_driver(&gfb_driver); |
217 | } | 217 | } |
218 | 218 | ||
219 | static void __exit gfb_exit(void) | 219 | static void __exit gfb_exit(void) |
220 | { | 220 | { |
221 | of_unregister_driver(&gfb_driver); | 221 | of_unregister_platform_driver(&gfb_driver); |
222 | } | 222 | } |
223 | 223 | ||
224 | module_init(gfb_init); | 224 | module_init(gfb_init); |
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c index cc039b33d2d8..f375e0db6776 100644 --- a/drivers/video/tcx.c +++ b/drivers/video/tcx.c | |||
@@ -526,12 +526,12 @@ static int __init tcx_init(void) | |||
526 | if (fb_get_options("tcxfb", NULL)) | 526 | if (fb_get_options("tcxfb", NULL)) |
527 | return -ENODEV; | 527 | return -ENODEV; |
528 | 528 | ||
529 | return of_register_driver(&tcx_driver, &of_bus_type); | 529 | return of_register_platform_driver(&tcx_driver); |
530 | } | 530 | } |
531 | 531 | ||
532 | static void __exit tcx_exit(void) | 532 | static void __exit tcx_exit(void) |
533 | { | 533 | { |
534 | of_unregister_driver(&tcx_driver); | 534 | of_unregister_platform_driver(&tcx_driver); |
535 | } | 535 | } |
536 | 536 | ||
537 | module_init(tcx_init); | 537 | module_init(tcx_init); |
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c index d62b9ce8f773..30a2512fd52e 100644 --- a/drivers/watchdog/cpwd.c +++ b/drivers/watchdog/cpwd.c | |||
@@ -545,7 +545,7 @@ static int __devinit cpwd_probe(struct of_device *op, | |||
545 | goto out; | 545 | goto out; |
546 | } | 546 | } |
547 | 547 | ||
548 | p->irq = op->irqs[0]; | 548 | p->irq = op->archdata.irqs[0]; |
549 | 549 | ||
550 | spin_lock_init(&p->lock); | 550 | spin_lock_init(&p->lock); |
551 | 551 | ||
@@ -688,12 +688,12 @@ static struct of_platform_driver cpwd_driver = { | |||
688 | 688 | ||
689 | static int __init cpwd_init(void) | 689 | static int __init cpwd_init(void) |
690 | { | 690 | { |
691 | return of_register_driver(&cpwd_driver, &of_bus_type); | 691 | return of_register_platform_driver(&cpwd_driver); |
692 | } | 692 | } |
693 | 693 | ||
694 | static void __exit cpwd_exit(void) | 694 | static void __exit cpwd_exit(void) |
695 | { | 695 | { |
696 | of_unregister_driver(&cpwd_driver); | 696 | of_unregister_platform_driver(&cpwd_driver); |
697 | } | 697 | } |
698 | 698 | ||
699 | module_init(cpwd_init); | 699 | module_init(cpwd_init); |
diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index 5dceeddc8859..4082b4ace1fc 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c | |||
@@ -250,12 +250,12 @@ static struct of_platform_driver riowd_driver = { | |||
250 | 250 | ||
251 | static int __init riowd_init(void) | 251 | static int __init riowd_init(void) |
252 | { | 252 | { |
253 | return of_register_driver(&riowd_driver, &of_bus_type); | 253 | return of_register_platform_driver(&riowd_driver); |
254 | } | 254 | } |
255 | 255 | ||
256 | static void __exit riowd_exit(void) | 256 | static void __exit riowd_exit(void) |
257 | { | 257 | { |
258 | of_unregister_driver(&riowd_driver); | 258 | of_unregister_platform_driver(&riowd_driver); |
259 | } | 259 | } |
260 | 260 | ||
261 | module_init(riowd_init); | 261 | module_init(riowd_init); |
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 4f3d75e1ad39..c7376bf80b06 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -31,6 +31,7 @@ static inline int gpio_is_valid(int number) | |||
31 | struct device; | 31 | struct device; |
32 | struct seq_file; | 32 | struct seq_file; |
33 | struct module; | 33 | struct module; |
34 | struct device_node; | ||
34 | 35 | ||
35 | /** | 36 | /** |
36 | * struct gpio_chip - abstract a GPIO controller | 37 | * struct gpio_chip - abstract a GPIO controller |
@@ -106,6 +107,17 @@ struct gpio_chip { | |||
106 | const char *const *names; | 107 | const char *const *names; |
107 | unsigned can_sleep:1; | 108 | unsigned can_sleep:1; |
108 | unsigned exported:1; | 109 | unsigned exported:1; |
110 | |||
111 | #if defined(CONFIG_OF_GPIO) | ||
112 | /* | ||
113 | * If CONFIG_OF is enabled, then all GPIO controllers described in the | ||
114 | * device tree automatically may have an OF translation | ||
115 | */ | ||
116 | struct device_node *of_node; | ||
117 | int of_gpio_n_cells; | ||
118 | int (*of_xlate)(struct gpio_chip *gc, struct device_node *np, | ||
119 | const void *gpio_spec, u32 *flags); | ||
120 | #endif | ||
109 | }; | 121 | }; |
110 | 122 | ||
111 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, | 123 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, |
@@ -115,6 +127,9 @@ extern int __must_check gpiochip_reserve(int start, int ngpio); | |||
115 | /* add/remove chips */ | 127 | /* add/remove chips */ |
116 | extern int gpiochip_add(struct gpio_chip *chip); | 128 | extern int gpiochip_add(struct gpio_chip *chip); |
117 | extern int __must_check gpiochip_remove(struct gpio_chip *chip); | 129 | extern int __must_check gpiochip_remove(struct gpio_chip *chip); |
130 | extern struct gpio_chip *gpiochip_find(void *data, | ||
131 | int (*match)(struct gpio_chip *chip, | ||
132 | void *data)); | ||
118 | 133 | ||
119 | 134 | ||
120 | /* Always use the library code for GPIO management calls, | 135 | /* Always use the library code for GPIO management calls, |
diff --git a/include/linux/of.h b/include/linux/of.h index a367e19bb3af..cad7cf0ab278 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -70,6 +70,11 @@ extern struct device_node *allnodes; | |||
70 | extern struct device_node *of_chosen; | 70 | extern struct device_node *of_chosen; |
71 | extern rwlock_t devtree_lock; | 71 | extern rwlock_t devtree_lock; |
72 | 72 | ||
73 | static inline bool of_node_is_root(const struct device_node *node) | ||
74 | { | ||
75 | return node && (node->parent == NULL); | ||
76 | } | ||
77 | |||
73 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) | 78 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) |
74 | { | 79 | { |
75 | return test_bit(flag, &n->_flags); | 80 | return test_bit(flag, &n->_flags); |
@@ -141,6 +146,11 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) | |||
141 | 146 | ||
142 | #define OF_BAD_ADDR ((u64)-1) | 147 | #define OF_BAD_ADDR ((u64)-1) |
143 | 148 | ||
149 | #ifndef of_node_to_nid | ||
150 | static inline int of_node_to_nid(struct device_node *np) { return -1; } | ||
151 | #define of_node_to_nid of_node_to_nid | ||
152 | #endif | ||
153 | |||
144 | extern struct device_node *of_find_node_by_name(struct device_node *from, | 154 | extern struct device_node *of_find_node_by_name(struct device_node *from, |
145 | const char *name); | 155 | const char *name); |
146 | #define for_each_node_by_name(dn, name) \ | 156 | #define for_each_node_by_name(dn, name) \ |
diff --git a/include/linux/of_address.h b/include/linux/of_address.h new file mode 100644 index 000000000000..8aea06f0564c --- /dev/null +++ b/include/linux/of_address.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __OF_ADDRESS_H | ||
2 | #define __OF_ADDRESS_H | ||
3 | #include <linux/ioport.h> | ||
4 | #include <linux/of.h> | ||
5 | |||
6 | extern u64 of_translate_address(struct device_node *np, const u32 *addr); | ||
7 | extern int of_address_to_resource(struct device_node *dev, int index, | ||
8 | struct resource *r); | ||
9 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
10 | |||
11 | /* Extract an address from a device, returns the region size and | ||
12 | * the address space flags too. The PCI version uses a BAR number | ||
13 | * instead of an absolute index | ||
14 | */ | ||
15 | extern const u32 *of_get_address(struct device_node *dev, int index, | ||
16 | u64 *size, unsigned int *flags); | ||
17 | |||
18 | #ifndef pci_address_to_pio | ||
19 | static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } | ||
20 | #define pci_address_to_pio pci_address_to_pio | ||
21 | #endif | ||
22 | |||
23 | #ifdef CONFIG_PCI | ||
24 | extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, | ||
25 | u64 *size, unsigned int *flags); | ||
26 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
27 | struct resource *r); | ||
28 | #else /* CONFIG_PCI */ | ||
29 | static inline int of_pci_address_to_resource(struct device_node *dev, int bar, | ||
30 | struct resource *r) | ||
31 | { | ||
32 | return -ENOSYS; | ||
33 | } | ||
34 | |||
35 | static inline const u32 *of_get_pci_address(struct device_node *dev, | ||
36 | int bar_no, u64 *size, unsigned int *flags) | ||
37 | { | ||
38 | return NULL; | ||
39 | } | ||
40 | #endif /* CONFIG_PCI */ | ||
41 | |||
42 | |||
43 | #endif /* __OF_ADDRESS_H */ | ||
44 | |||
diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 11651facc5f1..35aa44ad9f2c 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h | |||
@@ -1,32 +1,77 @@ | |||
1 | #ifndef _LINUX_OF_DEVICE_H | 1 | #ifndef _LINUX_OF_DEVICE_H |
2 | #define _LINUX_OF_DEVICE_H | 2 | #define _LINUX_OF_DEVICE_H |
3 | 3 | ||
4 | /* | ||
5 | * The of_device *was* a kind of "base class" that was a superset of | ||
6 | * struct device for use by devices attached to an OF node and probed | ||
7 | * using OF properties. However, the important bit of OF-style | ||
8 | * probing, namely the device node pointer, has been moved into the | ||
9 | * common struct device when CONFIG_OF is set to make OF-style probing | ||
10 | * available to all bus types. So now, just make of_device and | ||
11 | * platform_device equivalent so that current of_platform bus users | ||
12 | * can be transparently migrated over to using the platform bus. | ||
13 | * | ||
14 | * This line will go away once all references to of_device are removed | ||
15 | * from the kernel. | ||
16 | */ | ||
17 | #define of_device platform_device | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/of_platform.h> /* temporary until merge */ | ||
20 | |||
4 | #ifdef CONFIG_OF_DEVICE | 21 | #ifdef CONFIG_OF_DEVICE |
5 | #include <linux/device.h> | 22 | #include <linux/device.h> |
6 | #include <linux/of.h> | 23 | #include <linux/of.h> |
7 | #include <linux/mod_devicetable.h> | 24 | #include <linux/mod_devicetable.h> |
8 | 25 | ||
9 | #include <asm/of_device.h> | ||
10 | |||
11 | #define to_of_device(d) container_of(d, struct of_device, dev) | 26 | #define to_of_device(d) container_of(d, struct of_device, dev) |
12 | 27 | ||
13 | extern const struct of_device_id *of_match_device( | 28 | extern const struct of_device_id *of_match_device( |
14 | const struct of_device_id *matches, const struct device *dev); | 29 | const struct of_device_id *matches, const struct device *dev); |
30 | extern void of_device_make_bus_id(struct device *dev); | ||
31 | |||
32 | /** | ||
33 | * of_driver_match_device - Tell if a driver's of_match_table matches a device. | ||
34 | * @drv: the device_driver structure to test | ||
35 | * @dev: the device structure to match against | ||
36 | */ | ||
37 | static inline int of_driver_match_device(const struct device *dev, | ||
38 | const struct device_driver *drv) | ||
39 | { | ||
40 | return of_match_device(drv->of_match_table, dev) != NULL; | ||
41 | } | ||
15 | 42 | ||
16 | extern struct of_device *of_dev_get(struct of_device *dev); | 43 | extern struct platform_device *of_dev_get(struct platform_device *dev); |
17 | extern void of_dev_put(struct of_device *dev); | 44 | extern void of_dev_put(struct platform_device *dev); |
18 | 45 | ||
19 | extern int of_device_register(struct of_device *ofdev); | 46 | extern int of_device_register(struct platform_device *ofdev); |
20 | extern void of_device_unregister(struct of_device *ofdev); | 47 | extern void of_device_unregister(struct platform_device *ofdev); |
21 | extern void of_release_dev(struct device *dev); | 48 | extern void of_release_dev(struct device *dev); |
22 | 49 | ||
23 | static inline void of_device_free(struct of_device *dev) | 50 | static inline void of_device_free(struct platform_device *dev) |
24 | { | 51 | { |
25 | of_release_dev(&dev->dev); | 52 | of_release_dev(&dev->dev); |
26 | } | 53 | } |
27 | 54 | ||
28 | extern ssize_t of_device_get_modalias(struct of_device *ofdev, | 55 | extern ssize_t of_device_get_modalias(struct device *dev, |
29 | char *str, ssize_t len); | 56 | char *str, ssize_t len); |
57 | |||
58 | extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); | ||
59 | |||
60 | |||
61 | #else /* CONFIG_OF_DEVICE */ | ||
62 | |||
63 | static inline int of_driver_match_device(struct device *dev, | ||
64 | struct device_driver *drv) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | static inline int of_device_uevent(struct device *dev, | ||
70 | struct kobj_uevent_env *env) | ||
71 | { | ||
72 | return -ENODEV; | ||
73 | } | ||
74 | |||
30 | #endif /* CONFIG_OF_DEVICE */ | 75 | #endif /* CONFIG_OF_DEVICE */ |
31 | 76 | ||
32 | #endif /* _LINUX_OF_DEVICE_H */ | 77 | #endif /* _LINUX_OF_DEVICE_H */ |
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index fc2472c3c254..6598c04dab01 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h | |||
@@ -33,34 +33,17 @@ enum of_gpio_flags { | |||
33 | #ifdef CONFIG_OF_GPIO | 33 | #ifdef CONFIG_OF_GPIO |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * Generic OF GPIO chip | ||
37 | */ | ||
38 | struct of_gpio_chip { | ||
39 | struct gpio_chip gc; | ||
40 | int gpio_cells; | ||
41 | int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np, | ||
42 | const void *gpio_spec, enum of_gpio_flags *flags); | ||
43 | }; | ||
44 | |||
45 | static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc) | ||
46 | { | ||
47 | return container_of(gc, struct of_gpio_chip, gc); | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * OF GPIO chip for memory mapped banks | 36 | * OF GPIO chip for memory mapped banks |
52 | */ | 37 | */ |
53 | struct of_mm_gpio_chip { | 38 | struct of_mm_gpio_chip { |
54 | struct of_gpio_chip of_gc; | 39 | struct gpio_chip gc; |
55 | void (*save_regs)(struct of_mm_gpio_chip *mm_gc); | 40 | void (*save_regs)(struct of_mm_gpio_chip *mm_gc); |
56 | void __iomem *regs; | 41 | void __iomem *regs; |
57 | }; | 42 | }; |
58 | 43 | ||
59 | static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) | 44 | static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) |
60 | { | 45 | { |
61 | struct of_gpio_chip *of_gc = to_of_gpio_chip(gc); | 46 | return container_of(gc, struct of_mm_gpio_chip, gc); |
62 | |||
63 | return container_of(of_gc, struct of_mm_gpio_chip, of_gc); | ||
64 | } | 47 | } |
65 | 48 | ||
66 | extern int of_get_gpio_flags(struct device_node *np, int index, | 49 | extern int of_get_gpio_flags(struct device_node *np, int index, |
@@ -69,11 +52,12 @@ extern unsigned int of_gpio_count(struct device_node *np); | |||
69 | 52 | ||
70 | extern int of_mm_gpiochip_add(struct device_node *np, | 53 | extern int of_mm_gpiochip_add(struct device_node *np, |
71 | struct of_mm_gpio_chip *mm_gc); | 54 | struct of_mm_gpio_chip *mm_gc); |
72 | extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, | 55 | |
73 | struct device_node *np, | 56 | extern void of_gpiochip_add(struct gpio_chip *gc); |
74 | const void *gpio_spec, | 57 | extern void of_gpiochip_remove(struct gpio_chip *gc); |
75 | enum of_gpio_flags *flags); | 58 | extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np); |
76 | #else | 59 | |
60 | #else /* CONFIG_OF_GPIO */ | ||
77 | 61 | ||
78 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ | 62 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ |
79 | static inline int of_get_gpio_flags(struct device_node *np, int index, | 63 | static inline int of_get_gpio_flags(struct device_node *np, int index, |
@@ -87,6 +71,9 @@ static inline unsigned int of_gpio_count(struct device_node *np) | |||
87 | return 0; | 71 | return 0; |
88 | } | 72 | } |
89 | 73 | ||
74 | static inline void of_gpiochip_add(struct gpio_chip *gc) { } | ||
75 | static inline void of_gpiochip_remove(struct gpio_chip *gc) { } | ||
76 | |||
90 | #endif /* CONFIG_OF_GPIO */ | 77 | #endif /* CONFIG_OF_GPIO */ |
91 | 78 | ||
92 | /** | 79 | /** |
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h index 34974b5a76f7..0efe8d465f55 100644 --- a/include/linux/of_i2c.h +++ b/include/linux/of_i2c.h | |||
@@ -12,12 +12,19 @@ | |||
12 | #ifndef __LINUX_OF_I2C_H | 12 | #ifndef __LINUX_OF_I2C_H |
13 | #define __LINUX_OF_I2C_H | 13 | #define __LINUX_OF_I2C_H |
14 | 14 | ||
15 | #if defined(CONFIG_OF_I2C) || defined(CONFIG_OF_I2C_MODULE) | ||
15 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
16 | 17 | ||
17 | void of_register_i2c_devices(struct i2c_adapter *adap, | 18 | extern void of_i2c_register_devices(struct i2c_adapter *adap); |
18 | struct device_node *adap_node); | ||
19 | 19 | ||
20 | /* must call put_device() when done with returned i2c_client device */ | 20 | /* must call put_device() when done with returned i2c_client device */ |
21 | struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); | 21 | extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); |
22 | |||
23 | #else | ||
24 | static inline void of_i2c_register_devices(struct i2c_adapter *adap) | ||
25 | { | ||
26 | return; | ||
27 | } | ||
28 | #endif /* CONFIG_OF_I2C */ | ||
22 | 29 | ||
23 | #endif /* __LINUX_OF_I2C_H */ | 30 | #endif /* __LINUX_OF_I2C_H */ |
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h new file mode 100644 index 000000000000..5929781c104d --- /dev/null +++ b/include/linux/of_irq.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef __OF_IRQ_H | ||
2 | #define __OF_IRQ_H | ||
3 | |||
4 | #if defined(CONFIG_OF) | ||
5 | struct of_irq; | ||
6 | #include <linux/types.h> | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/ioport.h> | ||
9 | #include <linux/of.h> | ||
10 | |||
11 | /* | ||
12 | * irq_of_parse_and_map() is used ba all OF enabled platforms; but SPARC | ||
13 | * implements it differently. However, the prototype is the same for all, | ||
14 | * so declare it here regardless of the CONFIG_OF_IRQ setting. | ||
15 | */ | ||
16 | extern unsigned int irq_of_parse_and_map(struct device_node *node, int index); | ||
17 | |||
18 | #if defined(CONFIG_OF_IRQ) | ||
19 | /** | ||
20 | * of_irq - container for device_node/irq_specifier pair for an irq controller | ||
21 | * @controller: pointer to interrupt controller device tree node | ||
22 | * @size: size of interrupt specifier | ||
23 | * @specifier: array of cells @size long specifing the specific interrupt | ||
24 | * | ||
25 | * This structure is returned when an interrupt is mapped. The controller | ||
26 | * field needs to be put() after use | ||
27 | */ | ||
28 | #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */ | ||
29 | struct of_irq { | ||
30 | struct device_node *controller; /* Interrupt controller node */ | ||
31 | u32 size; /* Specifier size */ | ||
32 | u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * Workarounds only applied to 32bit powermac machines | ||
37 | */ | ||
38 | #define OF_IMAP_OLDWORLD_MAC 0x00000001 | ||
39 | #define OF_IMAP_NO_PHANDLE 0x00000002 | ||
40 | |||
41 | #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC) | ||
42 | extern unsigned int of_irq_workarounds; | ||
43 | extern struct device_node *of_irq_dflt_pic; | ||
44 | extern int of_irq_map_oldworld(struct device_node *device, int index, | ||
45 | struct of_irq *out_irq); | ||
46 | #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ | ||
47 | #define of_irq_workarounds (0) | ||
48 | #define of_irq_dflt_pic (NULL) | ||
49 | static inline int of_irq_map_oldworld(struct device_node *device, int index, | ||
50 | struct of_irq *out_irq) | ||
51 | { | ||
52 | return -EINVAL; | ||
53 | } | ||
54 | #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ | ||
55 | |||
56 | |||
57 | extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | ||
58 | u32 ointsize, const u32 *addr, | ||
59 | struct of_irq *out_irq); | ||
60 | extern int of_irq_map_one(struct device_node *device, int index, | ||
61 | struct of_irq *out_irq); | ||
62 | extern unsigned int irq_create_of_mapping(struct device_node *controller, | ||
63 | const u32 *intspec, | ||
64 | unsigned int intsize); | ||
65 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
66 | struct resource *r); | ||
67 | |||
68 | #endif /* CONFIG_OF_IRQ */ | ||
69 | #endif /* CONFIG_OF */ | ||
70 | #endif /* __OF_IRQ_H */ | ||
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 1643d3761eb4..4e6d989c06df 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h | |||
@@ -17,29 +17,24 @@ | |||
17 | #include <linux/mod_devicetable.h> | 17 | #include <linux/mod_devicetable.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/of_device.h> | 19 | #include <linux/of_device.h> |
20 | 20 | #include <linux/platform_device.h> | |
21 | /* | ||
22 | * The of_platform_bus_type is a bus type used by drivers that do not | ||
23 | * attach to a macio or similar bus but still use OF probing | ||
24 | * mechanism | ||
25 | */ | ||
26 | extern struct bus_type of_platform_bus_type; | ||
27 | 21 | ||
28 | /* | 22 | /* |
29 | * An of_platform_driver driver is attached to a basic of_device on | 23 | * An of_platform_driver driver is attached to a basic of_device on |
30 | * the "platform bus" (of_platform_bus_type). | 24 | * the "platform bus" (platform_bus_type). |
31 | */ | 25 | */ |
32 | struct of_platform_driver | 26 | struct of_platform_driver |
33 | { | 27 | { |
34 | int (*probe)(struct of_device* dev, | 28 | int (*probe)(struct platform_device* dev, |
35 | const struct of_device_id *match); | 29 | const struct of_device_id *match); |
36 | int (*remove)(struct of_device* dev); | 30 | int (*remove)(struct platform_device* dev); |
37 | 31 | ||
38 | int (*suspend)(struct of_device* dev, pm_message_t state); | 32 | int (*suspend)(struct platform_device* dev, pm_message_t state); |
39 | int (*resume)(struct of_device* dev); | 33 | int (*resume)(struct platform_device* dev); |
40 | int (*shutdown)(struct of_device* dev); | 34 | int (*shutdown)(struct platform_device* dev); |
41 | 35 | ||
42 | struct device_driver driver; | 36 | struct device_driver driver; |
37 | struct platform_driver platform_driver; | ||
43 | }; | 38 | }; |
44 | #define to_of_platform_driver(drv) \ | 39 | #define to_of_platform_driver(drv) \ |
45 | container_of(drv,struct of_platform_driver, driver) | 40 | container_of(drv,struct of_platform_driver, driver) |
@@ -49,20 +44,30 @@ extern int of_register_driver(struct of_platform_driver *drv, | |||
49 | extern void of_unregister_driver(struct of_platform_driver *drv); | 44 | extern void of_unregister_driver(struct of_platform_driver *drv); |
50 | 45 | ||
51 | /* Platform drivers register/unregister */ | 46 | /* Platform drivers register/unregister */ |
52 | static inline int of_register_platform_driver(struct of_platform_driver *drv) | 47 | extern int of_register_platform_driver(struct of_platform_driver *drv); |
53 | { | 48 | extern void of_unregister_platform_driver(struct of_platform_driver *drv); |
54 | return of_register_driver(drv, &of_platform_bus_type); | ||
55 | } | ||
56 | static inline void of_unregister_platform_driver(struct of_platform_driver *drv) | ||
57 | { | ||
58 | of_unregister_driver(drv); | ||
59 | } | ||
60 | 49 | ||
61 | #include <asm/of_platform.h> | 50 | extern struct platform_device *of_device_alloc(struct device_node *np, |
62 | 51 | const char *bus_id, | |
63 | extern struct of_device *of_find_device_by_node(struct device_node *np); | 52 | struct device *parent); |
53 | extern struct platform_device *of_find_device_by_node(struct device_node *np); | ||
64 | 54 | ||
65 | extern int of_bus_type_init(struct bus_type *bus, const char *name); | 55 | extern int of_bus_type_init(struct bus_type *bus, const char *name); |
56 | |||
57 | #if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */ | ||
58 | /* Platform devices and busses creation */ | ||
59 | extern struct platform_device *of_platform_device_create(struct device_node *np, | ||
60 | const char *bus_id, | ||
61 | struct device *parent); | ||
62 | |||
63 | /* pseudo "matches" value to not do deep probe */ | ||
64 | #define OF_NO_DEEP_PROBE ((struct of_device_id *)-1) | ||
65 | |||
66 | extern int of_platform_bus_probe(struct device_node *root, | ||
67 | const struct of_device_id *matches, | ||
68 | struct device *parent); | ||
69 | #endif /* !CONFIG_SPARC */ | ||
70 | |||
66 | #endif /* CONFIG_OF_DEVICE */ | 71 | #endif /* CONFIG_OF_DEVICE */ |
67 | 72 | ||
68 | #endif /* _LINUX_OF_PLATFORM_H */ | 73 | #endif /* _LINUX_OF_PLATFORM_H */ |
diff --git a/include/linux/of_spi.h b/include/linux/of_spi.h index 5f71ee8c0868..9e3e70f78ae6 100644 --- a/include/linux/of_spi.h +++ b/include/linux/of_spi.h | |||
@@ -9,10 +9,15 @@ | |||
9 | #ifndef __LINUX_OF_SPI_H | 9 | #ifndef __LINUX_OF_SPI_H |
10 | #define __LINUX_OF_SPI_H | 10 | #define __LINUX_OF_SPI_H |
11 | 11 | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/spi/spi.h> | 12 | #include <linux/spi/spi.h> |
14 | 13 | ||
15 | extern void of_register_spi_devices(struct spi_master *master, | 14 | #if defined(CONFIG_OF_SPI) || defined(CONFIG_OF_SPI_MODULE) |
16 | struct device_node *np); | 15 | extern void of_register_spi_devices(struct spi_master *master); |
16 | #else | ||
17 | static inline void of_register_spi_devices(struct spi_master *master) | ||
18 | { | ||
19 | return; | ||
20 | } | ||
21 | #endif /* CONFIG_OF_SPI */ | ||
17 | 22 | ||
18 | #endif /* __LINUX_OF_SPI */ | 23 | #endif /* __LINUX_OF_SPI */ |
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 71221fd20944..9eb1a4e0363b 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c | |||
@@ -1010,7 +1010,7 @@ static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_de | |||
1010 | struct snd_amd7930 *amd; | 1010 | struct snd_amd7930 *amd; |
1011 | int err, irq; | 1011 | int err, irq; |
1012 | 1012 | ||
1013 | irq = op->irqs[0]; | 1013 | irq = op->archdata.irqs[0]; |
1014 | 1014 | ||
1015 | if (dev_num >= SNDRV_CARDS) | 1015 | if (dev_num >= SNDRV_CARDS) |
1016 | return -ENODEV; | 1016 | return -ENODEV; |
@@ -1075,7 +1075,7 @@ static struct of_platform_driver amd7930_sbus_driver = { | |||
1075 | 1075 | ||
1076 | static int __init amd7930_init(void) | 1076 | static int __init amd7930_init(void) |
1077 | { | 1077 | { |
1078 | return of_register_driver(&amd7930_sbus_driver, &of_bus_type); | 1078 | return of_register_platform_driver(&amd7930_sbus_driver); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | static void __exit amd7930_exit(void) | 1081 | static void __exit amd7930_exit(void) |
@@ -1092,7 +1092,7 @@ static void __exit amd7930_exit(void) | |||
1092 | 1092 | ||
1093 | amd7930_list = NULL; | 1093 | amd7930_list = NULL; |
1094 | 1094 | ||
1095 | of_unregister_driver(&amd7930_sbus_driver); | 1095 | of_unregister_platform_driver(&amd7930_sbus_driver); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | module_init(amd7930_init); | 1098 | module_init(amd7930_init); |
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index fb4c6f2f29e5..68570ee2c9bb 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c | |||
@@ -1832,14 +1832,14 @@ static int __devinit snd_cs4231_sbus_create(struct snd_card *card, | |||
1832 | chip->c_dma.request = sbus_dma_request; | 1832 | chip->c_dma.request = sbus_dma_request; |
1833 | chip->c_dma.address = sbus_dma_addr; | 1833 | chip->c_dma.address = sbus_dma_addr; |
1834 | 1834 | ||
1835 | if (request_irq(op->irqs[0], snd_cs4231_sbus_interrupt, | 1835 | if (request_irq(op->archdata.irqs[0], snd_cs4231_sbus_interrupt, |
1836 | IRQF_SHARED, "cs4231", chip)) { | 1836 | IRQF_SHARED, "cs4231", chip)) { |
1837 | snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n", | 1837 | snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n", |
1838 | dev, op->irqs[0]); | 1838 | dev, op->archdata.irqs[0]); |
1839 | snd_cs4231_sbus_free(chip); | 1839 | snd_cs4231_sbus_free(chip); |
1840 | return -EBUSY; | 1840 | return -EBUSY; |
1841 | } | 1841 | } |
1842 | chip->irq[0] = op->irqs[0]; | 1842 | chip->irq[0] = op->archdata.irqs[0]; |
1843 | 1843 | ||
1844 | if (snd_cs4231_probe(chip) < 0) { | 1844 | if (snd_cs4231_probe(chip) < 0) { |
1845 | snd_cs4231_sbus_free(chip); | 1845 | snd_cs4231_sbus_free(chip); |
@@ -1870,7 +1870,7 @@ static int __devinit cs4231_sbus_probe(struct of_device *op, const struct of_dev | |||
1870 | card->shortname, | 1870 | card->shortname, |
1871 | rp->flags & 0xffL, | 1871 | rp->flags & 0xffL, |
1872 | (unsigned long long)rp->start, | 1872 | (unsigned long long)rp->start, |
1873 | op->irqs[0]); | 1873 | op->archdata.irqs[0]); |
1874 | 1874 | ||
1875 | err = snd_cs4231_sbus_create(card, op, dev); | 1875 | err = snd_cs4231_sbus_create(card, op, dev); |
1876 | if (err < 0) { | 1876 | if (err < 0) { |
@@ -1979,12 +1979,12 @@ static int __devinit snd_cs4231_ebus_create(struct snd_card *card, | |||
1979 | chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; | 1979 | chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; |
1980 | chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; | 1980 | chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; |
1981 | chip->c_dma.ebus_info.client_cookie = chip; | 1981 | chip->c_dma.ebus_info.client_cookie = chip; |
1982 | chip->c_dma.ebus_info.irq = op->irqs[0]; | 1982 | chip->c_dma.ebus_info.irq = op->archdata.irqs[0]; |
1983 | strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); | 1983 | strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); |
1984 | chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; | 1984 | chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; |
1985 | chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; | 1985 | chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; |
1986 | chip->p_dma.ebus_info.client_cookie = chip; | 1986 | chip->p_dma.ebus_info.client_cookie = chip; |
1987 | chip->p_dma.ebus_info.irq = op->irqs[1]; | 1987 | chip->p_dma.ebus_info.irq = op->archdata.irqs[1]; |
1988 | 1988 | ||
1989 | chip->p_dma.prepare = _ebus_dma_prepare; | 1989 | chip->p_dma.prepare = _ebus_dma_prepare; |
1990 | chip->p_dma.enable = _ebus_dma_enable; | 1990 | chip->p_dma.enable = _ebus_dma_enable; |
@@ -2060,7 +2060,7 @@ static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_dev | |||
2060 | sprintf(card->longname, "%s at 0x%llx, irq %d", | 2060 | sprintf(card->longname, "%s at 0x%llx, irq %d", |
2061 | card->shortname, | 2061 | card->shortname, |
2062 | op->resource[0].start, | 2062 | op->resource[0].start, |
2063 | op->irqs[0]); | 2063 | op->archdata.irqs[0]); |
2064 | 2064 | ||
2065 | err = snd_cs4231_ebus_create(card, op, dev); | 2065 | err = snd_cs4231_ebus_create(card, op, dev); |
2066 | if (err < 0) { | 2066 | if (err < 0) { |
@@ -2120,12 +2120,12 @@ static struct of_platform_driver cs4231_driver = { | |||
2120 | 2120 | ||
2121 | static int __init cs4231_init(void) | 2121 | static int __init cs4231_init(void) |
2122 | { | 2122 | { |
2123 | return of_register_driver(&cs4231_driver, &of_bus_type); | 2123 | return of_register_platform_driver(&cs4231_driver); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | static void __exit cs4231_exit(void) | 2126 | static void __exit cs4231_exit(void) |
2127 | { | 2127 | { |
2128 | of_unregister_driver(&cs4231_driver); | 2128 | of_unregister_platform_driver(&cs4231_driver); |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | module_init(cs4231_init); | 2131 | module_init(cs4231_init); |
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 1557bf132e73..c421901c48d0 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c | |||
@@ -2608,7 +2608,7 @@ static int __devinit dbri_probe(struct of_device *op, const struct of_device_id | |||
2608 | return -ENOENT; | 2608 | return -ENOENT; |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | irq = op->irqs[0]; | 2611 | irq = op->archdata.irqs[0]; |
2612 | if (irq <= 0) { | 2612 | if (irq <= 0) { |
2613 | printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); | 2613 | printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); |
2614 | return -ENODEV; | 2614 | return -ENODEV; |
@@ -2699,12 +2699,12 @@ static struct of_platform_driver dbri_sbus_driver = { | |||
2699 | /* Probe for the dbri chip and then attach the driver. */ | 2699 | /* Probe for the dbri chip and then attach the driver. */ |
2700 | static int __init dbri_init(void) | 2700 | static int __init dbri_init(void) |
2701 | { | 2701 | { |
2702 | return of_register_driver(&dbri_sbus_driver, &of_bus_type); | 2702 | return of_register_platform_driver(&dbri_sbus_driver); |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | static void __exit dbri_exit(void) | 2705 | static void __exit dbri_exit(void) |
2706 | { | 2706 | { |
2707 | of_unregister_driver(&dbri_sbus_driver); | 2707 | of_unregister_platform_driver(&dbri_sbus_driver); |
2708 | } | 2708 | } |
2709 | 2709 | ||
2710 | module_init(dbri_init); | 2710 | module_init(dbri_init); |