aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/devicetree.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-02-22 15:07:42 -0500
committerThomas Gleixner <tglx@linutronix.de>2011-02-23 16:27:53 -0500
commit96e0a0797eba35b5420c710b928f19094b2d5c45 (patch)
tree4a9073fc9415b024437a5d8b56791632a14153cf /arch/x86/kernel/devicetree.c
parentffb9fc68dff38f811eeb24c15aba0418b6a8ee53 (diff)
x86: dtb: Add support for PCI devices backed by dtb nodes
x86_of_pci_init() does two things: - it provides a generic irq enable and disable function. enable queries the device tree for the interrupt information, calls ->xlate on the irq host and updates the pci->irq information for the device. - it walks through PCI bus(es) in the device tree and adds its children (device) nodes to appropriate pci_dev nodes in kernel. So the dtb node information is available at probe time of the PCI device. Adding a PCI bus based on the information in the device tree is currently not supported. Right now direct access via ioports is used. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Tested-by: Dirk Brandewie <dirk.brandewie@gmail.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Cc: sodaville@linutronix.de Cc: devicetree-discuss@lists.ozlabs.org LKML-Reference: <1298405266-1624-8-git-send-email-bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/devicetree.c')
-rw-r--r--arch/x86/kernel/devicetree.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index dbb3bda40af9..7b574226e0a8 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -9,11 +9,15 @@
9#include <linux/of_fdt.h> 9#include <linux/of_fdt.h>
10#include <linux/of_address.h> 10#include <linux/of_address.h>
11#include <linux/of_platform.h> 11#include <linux/of_platform.h>
12#include <linux/of_irq.h>
12#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/pci.h>
15#include <linux/of_pci.h>
13 16
14#include <asm/hpet.h> 17#include <asm/hpet.h>
15#include <asm/irq_controller.h> 18#include <asm/irq_controller.h>
16#include <asm/apic.h> 19#include <asm/apic.h>
20#include <asm/pci_x86.h>
17 21
18__initdata u64 initial_dtb; 22__initdata u64 initial_dtb;
19char __initdata cmd_line[COMMAND_LINE_SIZE]; 23char __initdata cmd_line[COMMAND_LINE_SIZE];
@@ -99,6 +103,85 @@ void __init add_dtb(u64 data)
99 initial_dtb = data + offsetof(struct setup_data, data); 103 initial_dtb = data + offsetof(struct setup_data, data);
100} 104}
101 105
106#ifdef CONFIG_PCI
107static int x86_of_pci_irq_enable(struct pci_dev *dev)
108{
109 struct of_irq oirq;
110 u32 virq;
111 int ret;
112 u8 pin;
113
114 ret = pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
115 if (ret)
116 return ret;
117 if (!pin)
118 return 0;
119
120 ret = of_irq_map_pci(dev, &oirq);
121 if (ret)
122 return ret;
123
124 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
125 oirq.size);
126 if (virq == 0)
127 return -EINVAL;
128 dev->irq = virq;
129 return 0;
130}
131
132static void x86_of_pci_irq_disable(struct pci_dev *dev)
133{
134}
135
136void __cpuinit x86_of_pci_init(void)
137{
138 struct device_node *np;
139
140 pcibios_enable_irq = x86_of_pci_irq_enable;
141 pcibios_disable_irq = x86_of_pci_irq_disable;
142
143 for_each_node_by_type(np, "pci") {
144 const void *prop;
145 struct pci_bus *bus;
146 unsigned int bus_min;
147 struct device_node *child;
148
149 prop = of_get_property(np, "bus-range", NULL);
150 if (!prop)
151 continue;
152 bus_min = be32_to_cpup(prop);
153
154 bus = pci_find_bus(0, bus_min);
155 if (!bus) {
156 printk(KERN_ERR "Can't find a node for bus %s.\n",
157 np->full_name);
158 continue;
159 }
160
161 if (bus->self)
162 bus->self->dev.of_node = np;
163 else
164 bus->dev.of_node = np;
165
166 for_each_child_of_node(np, child) {
167 struct pci_dev *dev;
168 u32 devfn;
169
170 prop = of_get_property(child, "reg", NULL);
171 if (!prop)
172 continue;
173
174 devfn = (be32_to_cpup(prop) >> 8) & 0xff;
175 dev = pci_get_slot(bus, devfn);
176 if (!dev)
177 continue;
178 dev->dev.of_node = child;
179 pci_dev_put(dev);
180 }
181 }
182}
183#endif
184
102static void __init dtb_setup_hpet(void) 185static void __init dtb_setup_hpet(void)
103{ 186{
104 struct device_node *dn; 187 struct device_node *dn;