diff options
| -rw-r--r-- | arch/x86/include/asm/prom.h | 14 | ||||
| -rw-r--r-- | arch/x86/kernel/devicetree.c | 83 | ||||
| -rw-r--r-- | drivers/of/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/of/of_pci.c | 1 |
4 files changed, 99 insertions, 1 deletions
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h index 35ec32b4750..8fcd519a44d 100644 --- a/arch/x86/include/asm/prom.h +++ b/arch/x86/include/asm/prom.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <linux/pci.h> | ||
| 19 | 20 | ||
| 20 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
| 21 | #include <asm/atomic.h> | 22 | #include <asm/atomic.h> |
| @@ -29,8 +30,21 @@ extern void add_dtb(u64 data); | |||
| 29 | void x86_dtb_find_config(void); | 30 | void x86_dtb_find_config(void); |
| 30 | void x86_dtb_get_config(unsigned int unused); | 31 | void x86_dtb_get_config(unsigned int unused); |
| 31 | void add_interrupt_host(struct irq_domain *ih); | 32 | void add_interrupt_host(struct irq_domain *ih); |
| 33 | void __cpuinit x86_of_pci_init(void); | ||
| 34 | |||
| 35 | static inline struct device_node *pci_device_to_OF_node(struct pci_dev *pdev) | ||
| 36 | { | ||
| 37 | return pdev ? pdev->dev.of_node : NULL; | ||
| 38 | } | ||
| 39 | |||
| 40 | static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) | ||
| 41 | { | ||
| 42 | return pci_device_to_OF_node(bus->self); | ||
| 43 | } | ||
| 44 | |||
| 32 | #else | 45 | #else |
| 33 | static inline void add_dtb(u64 data) { } | 46 | static inline void add_dtb(u64 data) { } |
| 47 | static inline void x86_of_pci_init(void) { } | ||
| 34 | #define x86_dtb_find_config x86_init_noop | 48 | #define x86_dtb_find_config x86_init_noop |
| 35 | #define x86_dtb_get_config x86_init_uint_noop | 49 | #define x86_dtb_get_config x86_init_uint_noop |
| 36 | #define of_ioapic 0 | 50 | #define of_ioapic 0 |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index dbb3bda40af..7b574226e0a 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; |
| 19 | char __initdata cmd_line[COMMAND_LINE_SIZE]; | 23 | char __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 | ||
| 107 | static 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 | |||
| 132 | static void x86_of_pci_irq_disable(struct pci_dev *dev) | ||
| 133 | { | ||
| 134 | } | ||
| 135 | |||
| 136 | void __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 | |||
| 102 | static void __init dtb_setup_hpet(void) | 185 | static void __init dtb_setup_hpet(void) |
| 103 | { | 186 | { |
| 104 | struct device_node *dn; | 187 | struct device_node *dn; |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index efabbf9dd60..d06a6374ed6 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
| @@ -71,7 +71,7 @@ config OF_MDIO | |||
| 71 | 71 | ||
| 72 | config OF_PCI | 72 | config OF_PCI |
| 73 | def_tristate PCI | 73 | def_tristate PCI |
| 74 | depends on PCI && (PPC || MICROBLAZE) | 74 | depends on PCI && (PPC || MICROBLAZE || X86) |
| 75 | help | 75 | help |
| 76 | OpenFirmware PCI bus accessors | 76 | OpenFirmware PCI bus accessors |
| 77 | 77 | ||
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 314535fa32c..ac1ec54e4fd 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/of_pci.h> | 2 | #include <linux/of_pci.h> |
| 3 | #include <linux/of_irq.h> | ||
| 3 | #include <asm/prom.h> | 4 | #include <asm/prom.h> |
| 4 | 5 | ||
| 5 | /** | 6 | /** |
