diff options
Diffstat (limited to 'arch')
53 files changed, 258 insertions, 2958 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 505a08592423..206222a13a23 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -17,6 +17,8 @@ config MICROBLAZE | |||
17 | select HAVE_DMA_ATTRS | 17 | select HAVE_DMA_ATTRS |
18 | select HAVE_DMA_API_DEBUG | 18 | select HAVE_DMA_API_DEBUG |
19 | select TRACING_SUPPORT | 19 | select TRACING_SUPPORT |
20 | select OF | ||
21 | select OF_FLATTREE | ||
20 | 22 | ||
21 | config SWAP | 23 | config SWAP |
22 | def_bool n | 24 | def_bool n |
@@ -75,9 +77,6 @@ config LOCKDEP_SUPPORT | |||
75 | config HAVE_LATENCYTOP_SUPPORT | 77 | config HAVE_LATENCYTOP_SUPPORT |
76 | def_bool y | 78 | def_bool y |
77 | 79 | ||
78 | config DTC | ||
79 | def_bool y | ||
80 | |||
81 | source "init/Kconfig" | 80 | source "init/Kconfig" |
82 | 81 | ||
83 | source "kernel/Kconfig.freezer" | 82 | source "kernel/Kconfig.freezer" |
@@ -124,18 +123,6 @@ config CMDLINE_FORCE | |||
124 | Set this to have arguments from the default kernel command string | 123 | Set this to have arguments from the default kernel command string |
125 | override those passed by the boot loader. | 124 | override those passed by the boot loader. |
126 | 125 | ||
127 | config OF | ||
128 | def_bool y | ||
129 | select OF_FLATTREE | ||
130 | |||
131 | config PROC_DEVICETREE | ||
132 | bool "Support for device tree in /proc" | ||
133 | depends on PROC_FS | ||
134 | help | ||
135 | This option adds a device-tree directory under /proc which contains | ||
136 | an image of the device tree that the kernel copies from Open | ||
137 | Firmware or other boot firmware. If unsure, say Y here. | ||
138 | |||
139 | endmenu | 126 | endmenu |
140 | 127 | ||
141 | menu "Advanced setup" | 128 | 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 index 73cb98040982..47e8d42aee8f 100644 --- a/arch/microblaze/include/asm/of_device.h +++ b/arch/microblaze/include/asm/of_device.h | |||
@@ -10,35 +10,4 @@ | |||
10 | 10 | ||
11 | #ifndef _ASM_MICROBLAZE_OF_DEVICE_H | 11 | #ifndef _ASM_MICROBLAZE_OF_DEVICE_H |
12 | #define _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 */ | 13 | #endif /* _ASM_MICROBLAZE_OF_DEVICE_H */ |
diff --git a/arch/microblaze/include/asm/of_platform.h b/arch/microblaze/include/asm/of_platform.h index 37491276c6ca..353d8f651e30 100644 --- a/arch/microblaze/include/asm/of_platform.h +++ b/arch/microblaze/include/asm/of_platform.h | |||
@@ -14,41 +14,6 @@ | |||
14 | /* This is just here during the transition */ | 14 | /* This is just here during the transition */ |
15 | #include <linux/of_platform.h> | 15 | #include <linux/of_platform.h> |
16 | 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); | 17 | extern void of_instantiate_rtc(void); |
53 | 18 | ||
54 | #endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */ | 19 | #endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */ |
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h index 464ff32bee3d..2fd476126260 100644 --- a/arch/microblaze/include/asm/page.h +++ b/arch/microblaze/include/asm/page.h | |||
@@ -39,13 +39,6 @@ | |||
39 | #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) | 39 | #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) |
40 | #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) | 40 | #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) |
41 | 41 | ||
42 | /* align addr on a size boundary - adjust address up/down if needed */ | ||
43 | #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1))) | ||
44 | #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1))) | ||
45 | |||
46 | /* align addr on a size boundary - adjust address up if needed */ | ||
47 | #define _ALIGN(addr, size) _ALIGN_UP(addr, size) | ||
48 | |||
49 | #ifndef CONFIG_MMU | 42 | #ifndef CONFIG_MMU |
50 | /* | 43 | /* |
51 | * PAGE_OFFSET -- the first address of the first page of memory. When not | 44 | * 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..cb9c3dd9a23b 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #ifndef __ASSEMBLY__ | 20 | #ifndef __ASSEMBLY__ |
21 | 21 | ||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/of_address.h> | ||
24 | #include <linux/of_irq.h> | ||
23 | #include <linux/of_fdt.h> | 25 | #include <linux/of_fdt.h> |
24 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
25 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
@@ -50,10 +52,6 @@ extern void pci_create_OF_bus_map(void); | |||
50 | * OF address retreival & translation | 52 | * OF address retreival & translation |
51 | */ | 53 | */ |
52 | 54 | ||
53 | /* Translate an OF address block into a CPU physical address | ||
54 | */ | ||
55 | extern u64 of_translate_address(struct device_node *np, const u32 *addr); | ||
56 | |||
57 | /* Extract an address from a device, returns the region size and | 55 | /* Extract an address from a device, returns the region size and |
58 | * the address space flags too. The PCI version uses a BAR number | 56 | * the address space flags too. The PCI version uses a BAR number |
59 | * instead of an absolute index | 57 | * instead of an absolute index |
@@ -63,17 +61,18 @@ extern const u32 *of_get_address(struct device_node *dev, int index, | |||
63 | extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, | 61 | extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, |
64 | u64 *size, unsigned int *flags); | 62 | u64 *size, unsigned int *flags); |
65 | 63 | ||
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, | 64 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
75 | struct resource *r); | 65 | struct resource *r); |
76 | 66 | ||
67 | #ifdef CONFIG_PCI | ||
68 | extern unsigned long pci_address_to_pio(phys_addr_t address); | ||
69 | #else | ||
70 | static inline unsigned long pci_address_to_pio(phys_addr_t address) | ||
71 | { | ||
72 | return (unsigned long)-1; | ||
73 | } | ||
74 | #endif /* CONFIG_PCI */ | ||
75 | |||
77 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and | 76 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and |
78 | * size parameters. | 77 | * size parameters. |
79 | */ | 78 | */ |
@@ -88,69 +87,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | |||
88 | /* Get the MAC address */ | 87 | /* Get the MAC address */ |
89 | extern const void *of_get_mac_address(struct device_node *np); | 88 | extern const void *of_get_mac_address(struct device_node *np); |
90 | 89 | ||
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 | /** | 90 | /** |
155 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 91 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
156 | * @pdev: the device whose interrupt is to be resolved | 92 | * @pdev: the device whose interrupt is to be resolved |
@@ -165,18 +101,6 @@ extern int of_irq_map_one(struct device_node *device, int index, | |||
165 | struct pci_dev; | 101 | struct pci_dev; |
166 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 102 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
167 | 103 | ||
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__ */ | 104 | #endif /* __ASSEMBLY__ */ |
181 | #endif /* __KERNEL__ */ | 105 | #endif /* __KERNEL__ */ |
182 | #endif /* _ASM_MICROBLAZE_PROM_H */ | 106 | #endif /* _ASM_MICROBLAZE_PROM_H */ |
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile index e51bc1520825..727e2cbff9c6 100644 --- a/arch/microblaze/kernel/Makefile +++ b/arch/microblaze/kernel/Makefile | |||
@@ -15,7 +15,7 @@ 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 | of_platform.o process.o prom.o prom_parse.o ptrace.o \ |
20 | setup.o signal.o sys_microblaze.o timer.o traps.o reset.o | 20 | setup.o signal.o sys_microblaze.o timer.o traps.o reset.o |
21 | 21 | ||
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c index 8f120aca123d..dd32b09b4a3c 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) |
@@ -104,7 +94,7 @@ unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq) | |||
104 | EXPORT_SYMBOL_GPL(irq_create_mapping); | 94 | EXPORT_SYMBOL_GPL(irq_create_mapping); |
105 | 95 | ||
106 | unsigned int irq_create_of_mapping(struct device_node *controller, | 96 | unsigned int irq_create_of_mapping(struct device_node *controller, |
107 | u32 *intspec, unsigned int intsize) | 97 | const u32 *intspec, unsigned int intsize) |
108 | { | 98 | { |
109 | return intspec[0]; | 99 | return intspec[0]; |
110 | } | 100 | } |
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 index ccf6f4257f4b..da79edf45420 100644 --- a/arch/microblaze/kernel/of_platform.c +++ b/arch/microblaze/kernel/of_platform.c | |||
@@ -37,132 +37,27 @@ static int __init of_bus_driver_init(void) | |||
37 | } | 37 | } |
38 | postcore_initcall(of_bus_driver_init); | 38 | postcore_initcall(of_bus_driver_init); |
39 | 39 | ||
40 | struct of_device *of_platform_device_create(struct device_node *np, | 40 | /* |
41 | const char *bus_id, | 41 | * The list of OF IDs below is used for matching bus types in the |
42 | struct device *parent) | 42 | * system whose devices are to be exposed as of_platform_devices. |
43 | { | 43 | * |
44 | struct of_device *dev; | 44 | * This is the default list valid for most platforms. This file provides |
45 | 45 | * functions who can take an explicit list if necessary though | |
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 | * | 46 | * |
108 | * Note that children of the provided root are not instanciated as devices | 47 | * The search is always performed recursively looking for children of |
109 | * unless the specified root itself matches the bus list and is not NULL. | 48 | * the provided device_node and recursively if such a children matches |
49 | * a bus type in the list | ||
110 | */ | 50 | */ |
111 | 51 | ||
112 | int of_platform_bus_probe(struct device_node *root, | 52 | const struct of_device_id of_default_bus_ids[] = { |
113 | const struct of_device_id *matches, | 53 | { .type = "soc", }, |
114 | struct device *parent) | 54 | { .compatible = "soc", }, |
115 | { | 55 | { .type = "plb5", }, |
116 | struct device_node *child; | 56 | { .type = "plb4", }, |
117 | struct of_device *dev; | 57 | { .type = "opb", }, |
118 | int rc = 0; | 58 | { .type = "simple", }, |
119 | 59 | {}, | |
120 | if (matches == NULL) | 60 | }; |
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 | 61 | ||
167 | static int of_dev_node_match(struct device *dev, void *data) | 62 | static int of_dev_node_match(struct device *dev, void *data) |
168 | { | 63 | { |
@@ -180,21 +75,3 @@ struct of_device *of_find_device_by_node(struct device_node *np) | |||
180 | return NULL; | 75 | return NULL; |
181 | } | 76 | } |
182 | EXPORT_SYMBOL(of_find_device_by_node); | 77 | 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/powerpc/Kconfig b/arch/powerpc/Kconfig index 2031a2846865..5bf34019bd66 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 |
@@ -172,10 +174,6 @@ config ARCH_MAY_HAVE_PC_FDC | |||
172 | config PPC_OF | 174 | config PPC_OF |
173 | def_bool y | 175 | def_bool y |
174 | 176 | ||
175 | config OF | ||
176 | def_bool y | ||
177 | select OF_FLATTREE | ||
178 | |||
179 | config PPC_UDBG_16550 | 177 | config PPC_UDBG_16550 |
180 | bool | 178 | bool |
181 | default n | 179 | default n |
@@ -198,10 +196,6 @@ config SYS_SUPPORTS_APM_EMULATION | |||
198 | default y if PMAC_APM_EMU | 196 | default y if PMAC_APM_EMU |
199 | bool | 197 | bool |
200 | 198 | ||
201 | config DTC | ||
202 | bool | ||
203 | default y | ||
204 | |||
205 | config DEFAULT_UIMAGE | 199 | config DEFAULT_UIMAGE |
206 | bool | 200 | bool |
207 | help | 201 | help |
@@ -578,14 +572,6 @@ config SCHED_SMT | |||
578 | when dealing with POWER5 cpus at a cost of slightly increased | 572 | when dealing with POWER5 cpus at a cost of slightly increased |
579 | overhead in some places. If unsure say N here. | 573 | overhead in some places. If unsure say N here. |
580 | 574 | ||
581 | config PROC_DEVICETREE | ||
582 | bool "Support for device tree in /proc" | ||
583 | depends on PROC_FS | ||
584 | help | ||
585 | This option adds a device-tree directory under /proc which contains | ||
586 | an image of the device tree that the kernel copies from Open | ||
587 | Firmware or other boot firmware. If unsure, say Y here. | ||
588 | |||
589 | config CMDLINE_BOOL | 575 | config CMDLINE_BOOL |
590 | bool "Default bootloader kernel arguments" | 576 | bool "Default bootloader kernel arguments" |
591 | 577 | ||
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/of_device.h b/arch/powerpc/include/asm/of_device.h index 444e97e2982e..04f76717f82c 100644 --- a/arch/powerpc/include/asm/of_device.h +++ b/arch/powerpc/include/asm/of_device.h | |||
@@ -1,27 +1,3 @@ | |||
1 | #ifndef _ASM_POWERPC_OF_DEVICE_H | 1 | #ifndef _ASM_POWERPC_OF_DEVICE_H |
2 | #define _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 */ | 3 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ |
diff --git a/arch/powerpc/include/asm/of_platform.h b/arch/powerpc/include/asm/of_platform.h index d4aaa3489440..d506aa61db83 100644 --- a/arch/powerpc/include/asm/of_platform.h +++ b/arch/powerpc/include/asm/of_platform.h | |||
@@ -11,19 +11,6 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 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); | 14 | extern void of_instantiate_rtc(void); |
28 | 15 | ||
29 | #endif /* _ASM_POWERPC_OF_PLATFORM_H */ | 16 | #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..f864722679e8 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h | |||
@@ -18,6 +18,8 @@ | |||
18 | */ | 18 | */ |
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/of_fdt.h> | 20 | #include <linux/of_fdt.h> |
21 | #include <linux/of_address.h> | ||
22 | #include <linux/of_irq.h> | ||
21 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
22 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
23 | #include <asm/irq.h> | 25 | #include <asm/irq.h> |
@@ -43,10 +45,6 @@ extern void pci_create_OF_bus_map(void); | |||
43 | * OF address retreival & translation | 45 | * OF address retreival & translation |
44 | */ | 46 | */ |
45 | 47 | ||
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 */ | 48 | /* Translate a DMA address from device space to CPU space */ |
51 | extern u64 of_translate_dma_address(struct device_node *dev, | 49 | extern u64 of_translate_dma_address(struct device_node *dev, |
52 | const u32 *in_addr); | 50 | const u32 *in_addr); |
@@ -68,14 +66,6 @@ static inline const u32 *of_get_pci_address(struct device_node *dev, | |||
68 | } | 66 | } |
69 | #endif /* CONFIG_PCI */ | 67 | #endif /* CONFIG_PCI */ |
70 | 68 | ||
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 | 69 | #ifdef CONFIG_PCI |
80 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, | 70 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
81 | struct resource *r); | 71 | struct resource *r); |
@@ -87,6 +77,15 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar, | |||
87 | } | 77 | } |
88 | #endif /* CONFIG_PCI */ | 78 | #endif /* CONFIG_PCI */ |
89 | 79 | ||
80 | #ifdef CONFIG_PCI | ||
81 | extern unsigned long pci_address_to_pio(phys_addr_t address); | ||
82 | #else | ||
83 | static inline unsigned long pci_address_to_pio(phys_addr_t address) | ||
84 | { | ||
85 | return (unsigned long)-1; | ||
86 | } | ||
87 | #endif /* CONFIG_PCI */ | ||
88 | |||
90 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and | 89 | /* Parse the ibm,dma-window property of an OF node into the busno, phys and |
91 | * size parameters. | 90 | * size parameters. |
92 | */ | 91 | */ |
@@ -104,70 +103,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np); | |||
104 | /* Get the MAC address */ | 103 | /* Get the MAC address */ |
105 | extern const void *of_get_mac_address(struct device_node *np); | 104 | extern const void *of_get_mac_address(struct device_node *np); |
106 | 105 | ||
107 | /* | ||
108 | * OF interrupt mapping | ||
109 | */ | ||
110 | |||
111 | /* This structure is returned when an interrupt is mapped. The controller | ||
112 | * field needs to be put() after use | ||
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 | |||
171 | /** | 106 | /** |
172 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 107 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
173 | * @pdev: the device whose interrupt is to be resolved | 108 | * @pdev: the device whose interrupt is to be resolved |
@@ -182,17 +117,5 @@ extern int of_irq_map_one(struct device_node *device, int index, | |||
182 | struct pci_dev; | 117 | struct pci_dev; |
183 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 118 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
184 | 119 | ||
185 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
186 | struct resource *r); | ||
187 | |||
188 | /** | ||
189 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
190 | * @device: the device whose io range will be mapped | ||
191 | * @index: index of the io range | ||
192 | * | ||
193 | * Returns a pointer to the mapped memory | ||
194 | */ | ||
195 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
196 | |||
197 | #endif /* __KERNEL__ */ | 120 | #endif /* __KERNEL__ */ |
198 | #endif /* _POWERPC_PROM_H */ | 121 | #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/kernel/Makefile b/arch/powerpc/kernel/Makefile index 58d0572de6f9..83aa1fd0908f 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -40,7 +40,7 @@ obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o | |||
40 | obj-$(CONFIG_PPC64) += vdso64/ | 40 | obj-$(CONFIG_PPC64) += vdso64/ |
41 | obj-$(CONFIG_ALTIVEC) += vecemu.o | 41 | obj-$(CONFIG_ALTIVEC) += vecemu.o |
42 | obj-$(CONFIG_PPC_970_NAP) += idle_power4.o | 42 | obj-$(CONFIG_PPC_970_NAP) += idle_power4.o |
43 | obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o | 43 | obj-$(CONFIG_PPC_OF) += of_platform.o prom_parse.o |
44 | obj-$(CONFIG_PPC_CLOCK) += clock.o | 44 | obj-$(CONFIG_PPC_CLOCK) += clock.o |
45 | procfs-y := proc_powerpc.o | 45 | procfs-y := proc_powerpc.o |
46 | obj-$(CONFIG_PROC_FS) += $(procfs-y) | 46 | obj-$(CONFIG_PROC_FS) += $(procfs-y) |
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 77be3d058a65..60d39b7414c0 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> |
@@ -804,18 +806,6 @@ unsigned int irq_create_of_mapping(struct device_node *controller, | |||
804 | } | 806 | } |
805 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | 807 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); |
806 | 808 | ||
807 | unsigned int irq_of_parse_and_map(struct device_node *dev, int index) | ||
808 | { | ||
809 | struct of_irq oirq; | ||
810 | |||
811 | if (of_irq_map_one(dev, index, &oirq)) | ||
812 | return NO_IRQ; | ||
813 | |||
814 | return irq_create_of_mapping(oirq.controller, oirq.specifier, | ||
815 | oirq.size); | ||
816 | } | ||
817 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | ||
818 | |||
819 | void irq_dispose_mapping(unsigned int virq) | 809 | void irq_dispose_mapping(unsigned int virq) |
820 | { | 810 | { |
821 | struct irq_host *host; | 811 | struct irq_host *host; |
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..4e0a2f7c1dd3 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c | |||
@@ -40,7 +40,7 @@ | |||
40 | * a bus type in the list | 40 | * a bus type in the list |
41 | */ | 41 | */ |
42 | 42 | ||
43 | static const struct of_device_id of_default_bus_ids[] = { | 43 | const struct of_device_id of_default_bus_ids[] = { |
44 | { .type = "soc", }, | 44 | { .type = "soc", }, |
45 | { .compatible = "soc", }, | 45 | { .compatible = "soc", }, |
46 | { .type = "spider", }, | 46 | { .type = "spider", }, |
@@ -64,135 +64,6 @@ static int __init of_bus_driver_init(void) | |||
64 | 64 | ||
65 | postcore_initcall(of_bus_driver_init); | 65 | postcore_initcall(of_bus_driver_init); |
66 | 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) | 67 | static int of_dev_node_match(struct device *dev, void *data) |
197 | { | 68 | { |
198 | return to_of_device(dev)->dev.of_node == data; | 69 | return to_of_device(dev)->dev.of_node == data; |
@@ -210,25 +81,6 @@ struct of_device *of_find_device_by_node(struct device_node *np) | |||
210 | } | 81 | } |
211 | EXPORT_SYMBOL(of_find_device_by_node); | 82 | EXPORT_SYMBOL(of_find_device_by_node); |
212 | 83 | ||
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 | 84 | #ifdef CONFIG_PPC_OF_PLATFORM_PCI |
233 | 85 | ||
234 | /* The probing of PCI controllers from of_platform is currently | 86 | /* The probing of PCI controllers from of_platform is currently |
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/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c index ca5305a5bd61..0855e804fc0d 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c | |||
@@ -152,21 +152,20 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, | |||
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) |
@@ -315,7 +314,7 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_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..5d7d607617cd 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 | ||
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/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/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/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/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/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/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..fb220e482039 100644 --- a/arch/sparc/include/asm/device.h +++ b/arch/sparc/include/asm/device.h | |||
@@ -6,18 +6,23 @@ | |||
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 | ||
20 | struct pdev_archdata { | 22 | struct pdev_archdata { |
23 | struct resource resource[PROMREG_MAX]; | ||
24 | unsigned int irqs[PROMINTR_MAX]; | ||
25 | int num_irqs; | ||
21 | }; | 26 | }; |
22 | 27 | ||
23 | #endif /* _ASM_SPARC_DEVICE_H */ | 28 | #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..4f5bde638f72 100644 --- a/arch/sparc/include/asm/floppy_64.h +++ b/arch/sparc/include/asm/floppy_64.h | |||
@@ -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. |
diff --git a/arch/sparc/include/asm/of_device.h b/arch/sparc/include/asm/of_device.h index f320246a0586..22b9828fe693 100644 --- a/arch/sparc/include/asm/of_device.h +++ b/arch/sparc/include/asm/of_device.h | |||
@@ -7,25 +7,6 @@ | |||
7 | #include <linux/mod_devicetable.h> | 7 | #include <linux/mod_devicetable.h> |
8 | #include <asm/openprom.h> | 8 | #include <asm/openprom.h> |
9 | 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); | 10 | 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); | 11 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); |
31 | 12 | ||
diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h index c333b8d0949b..0c34a8792fc7 100644 --- a/arch/sparc/include/asm/parport.h +++ b/arch/sparc/include/asm/parport.h | |||
@@ -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); |
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h index f845828ca4c6..ac695742df85 100644 --- a/arch/sparc/include/asm/prom.h +++ b/arch/sparc/include/asm/prom.h | |||
@@ -56,7 +56,6 @@ extern void of_fill_in_cpu_data(void); | |||
56 | * register them in the of_device objects, whereas powerpc computes them | 56 | * register them in the of_device objects, whereas powerpc computes them |
57 | * on request. | 57 | * on request. |
58 | */ | 58 | */ |
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) | 59 | static inline void irq_dispose_mapping(unsigned int virq) |
61 | { | 60 | { |
62 | } | 61 | } |
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 47e63f1e719c..331de91ad2bc 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c | |||
@@ -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]; |
@@ -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 | ||
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 1dae8079f728..5e8cbb942d3d 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
@@ -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]; |
@@ -644,31 +646,25 @@ 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 = &of_platform_bus_type; |
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c index 10c6c36a6e75..016c947d4cae 100644 --- a/arch/sparc/kernel/of_device_common.c +++ b/arch/sparc/kernel/of_device_common.c | |||
@@ -35,10 +35,10 @@ unsigned int irq_of_parse_and_map(struct device_node *node, int index) | |||
35 | { | 35 | { |
36 | struct of_device *op = of_find_device_by_node(node); | 36 | struct of_device *op = of_find_device_by_node(node); |
37 | 37 | ||
38 | if (!op || index >= op->num_irqs) | 38 | if (!op || index >= op->archdata.num_irqs) |
39 | return 0; | 39 | return 0; |
40 | 40 | ||
41 | return op->irqs[index]; | 41 | return op->archdata.irqs[index]; |
42 | } | 42 | } |
43 | EXPORT_SYMBOL(irq_of_parse_and_map); | 43 | EXPORT_SYMBOL(irq_of_parse_and_map); |
44 | 44 | ||
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 8a8363adb8bd..1523290db0a1 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -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_psycho.c b/arch/sparc/kernel/pci_psycho.c index 558a70512824..93011e6e7ddc 100644 --- a/arch/sparc/kernel/pci_psycho.c +++ b/arch/sparc/kernel/pci_psycho.c | |||
@@ -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, " |
diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c index 6dad8e3b7506..99c6dba7d4fd 100644 --- a/arch/sparc/kernel/pci_sabre.c +++ b/arch/sparc/kernel/pci_sabre.c | |||
@@ -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", |
diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c index 97a1ae2e1c02..9041dae7aaca 100644 --- a/arch/sparc/kernel/pci_schizo.c +++ b/arch/sparc/kernel/pci_schizo.c | |||
@@ -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, " |
@@ -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, " |
diff --git a/arch/sparc/kernel/power.c b/arch/sparc/kernel/power.c index 168d4cb63f5b..1cfee577f6b5 100644 --- a/arch/sparc/kernel/power.c +++ b/arch/sparc/kernel/power.c | |||
@@ -36,7 +36,7 @@ static int __devinit has_button_interrupt(unsigned int irq, struct device_node * | |||
36 | static int __devinit power_probe(struct of_device *op, const struct of_device_id *match) | 36 | static int __devinit power_probe(struct of_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 | ||
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 | } |