diff options
Diffstat (limited to 'arch/x86/kernel/devicetree.c')
| -rw-r--r-- | arch/x86/kernel/devicetree.c | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 52821799a702..3ae2ced4a874 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <linux/bootmem.h> | 4 | #include <linux/bootmem.h> |
| 5 | #include <linux/export.h> | 5 | #include <linux/export.h> |
| 6 | #include <linux/io.h> | 6 | #include <linux/io.h> |
| 7 | #include <linux/irqdomain.h> | ||
| 7 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
| 8 | #include <linux/list.h> | 9 | #include <linux/list.h> |
| 9 | #include <linux/of.h> | 10 | #include <linux/of.h> |
| @@ -17,64 +18,14 @@ | |||
| 17 | #include <linux/initrd.h> | 18 | #include <linux/initrd.h> |
| 18 | 19 | ||
| 19 | #include <asm/hpet.h> | 20 | #include <asm/hpet.h> |
| 20 | #include <asm/irq_controller.h> | ||
| 21 | #include <asm/apic.h> | 21 | #include <asm/apic.h> |
| 22 | #include <asm/pci_x86.h> | 22 | #include <asm/pci_x86.h> |
| 23 | 23 | ||
| 24 | __initdata u64 initial_dtb; | 24 | __initdata u64 initial_dtb; |
| 25 | char __initdata cmd_line[COMMAND_LINE_SIZE]; | 25 | char __initdata cmd_line[COMMAND_LINE_SIZE]; |
| 26 | static LIST_HEAD(irq_domains); | ||
| 27 | static DEFINE_RAW_SPINLOCK(big_irq_lock); | ||
| 28 | 26 | ||
| 29 | int __initdata of_ioapic; | 27 | int __initdata of_ioapic; |
| 30 | 28 | ||
| 31 | #ifdef CONFIG_X86_IO_APIC | ||
| 32 | static void add_interrupt_host(struct irq_domain *ih) | ||
| 33 | { | ||
| 34 | unsigned long flags; | ||
| 35 | |||
| 36 | raw_spin_lock_irqsave(&big_irq_lock, flags); | ||
| 37 | list_add(&ih->l, &irq_domains); | ||
| 38 | raw_spin_unlock_irqrestore(&big_irq_lock, flags); | ||
| 39 | } | ||
| 40 | #endif | ||
| 41 | |||
| 42 | static struct irq_domain *get_ih_from_node(struct device_node *controller) | ||
| 43 | { | ||
| 44 | struct irq_domain *ih, *found = NULL; | ||
| 45 | unsigned long flags; | ||
| 46 | |||
| 47 | raw_spin_lock_irqsave(&big_irq_lock, flags); | ||
| 48 | list_for_each_entry(ih, &irq_domains, l) { | ||
| 49 | if (ih->controller == controller) { | ||
| 50 | found = ih; | ||
| 51 | break; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | raw_spin_unlock_irqrestore(&big_irq_lock, flags); | ||
| 55 | return found; | ||
| 56 | } | ||
| 57 | |||
| 58 | unsigned int irq_create_of_mapping(struct device_node *controller, | ||
| 59 | const u32 *intspec, unsigned int intsize) | ||
| 60 | { | ||
| 61 | struct irq_domain *ih; | ||
| 62 | u32 virq, type; | ||
| 63 | int ret; | ||
| 64 | |||
| 65 | ih = get_ih_from_node(controller); | ||
| 66 | if (!ih) | ||
| 67 | return 0; | ||
| 68 | ret = ih->xlate(ih, intspec, intsize, &virq, &type); | ||
| 69 | if (ret) | ||
| 70 | return 0; | ||
| 71 | if (type == IRQ_TYPE_NONE) | ||
| 72 | return virq; | ||
| 73 | irq_set_irq_type(virq, type); | ||
| 74 | return virq; | ||
| 75 | } | ||
| 76 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | ||
| 77 | |||
| 78 | unsigned long pci_address_to_pio(phys_addr_t address) | 29 | unsigned long pci_address_to_pio(phys_addr_t address) |
| 79 | { | 30 | { |
| 80 | /* | 31 | /* |
| @@ -354,36 +305,43 @@ static struct of_ioapic_type of_ioapic_type[] = | |||
| 354 | }, | 305 | }, |
| 355 | }; | 306 | }; |
| 356 | 307 | ||
| 357 | static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize, | 308 | static int ioapic_xlate(struct irq_domain *domain, |
| 358 | u32 *out_hwirq, u32 *out_type) | 309 | struct device_node *controller, |
| 310 | const u32 *intspec, u32 intsize, | ||
| 311 | irq_hw_number_t *out_hwirq, u32 *out_type) | ||
| 359 | { | 312 | { |
| 360 | struct mp_ioapic_gsi *gsi_cfg; | ||
| 361 | struct io_apic_irq_attr attr; | 313 | struct io_apic_irq_attr attr; |
| 362 | struct of_ioapic_type *it; | 314 | struct of_ioapic_type *it; |
| 363 | u32 line, idx, type; | 315 | u32 line, idx; |
| 316 | int rc; | ||
| 364 | 317 | ||
| 365 | if (intsize < 2) | 318 | if (WARN_ON(intsize < 2)) |
| 366 | return -EINVAL; | 319 | return -EINVAL; |
| 367 | 320 | ||
| 368 | line = *intspec; | 321 | line = intspec[0]; |
| 369 | idx = (u32) id->priv; | ||
| 370 | gsi_cfg = mp_ioapic_gsi_routing(idx); | ||
| 371 | *out_hwirq = line + gsi_cfg->gsi_base; | ||
| 372 | |||
| 373 | intspec++; | ||
| 374 | type = *intspec; | ||
| 375 | 322 | ||
| 376 | if (type >= ARRAY_SIZE(of_ioapic_type)) | 323 | if (intspec[1] >= ARRAY_SIZE(of_ioapic_type)) |
| 377 | return -EINVAL; | 324 | return -EINVAL; |
| 378 | 325 | ||
| 379 | it = of_ioapic_type + type; | 326 | it = &of_ioapic_type[intspec[1]]; |
| 380 | *out_type = it->out_type; | ||
| 381 | 327 | ||
| 328 | idx = (u32) domain->host_data; | ||
| 382 | set_io_apic_irq_attr(&attr, idx, line, it->trigger, it->polarity); | 329 | set_io_apic_irq_attr(&attr, idx, line, it->trigger, it->polarity); |
| 383 | 330 | ||
| 384 | return io_apic_setup_irq_pin_once(*out_hwirq, cpu_to_node(0), &attr); | 331 | rc = io_apic_setup_irq_pin_once(irq_find_mapping(domain, line), |
| 332 | cpu_to_node(0), &attr); | ||
| 333 | if (rc) | ||
| 334 | return rc; | ||
| 335 | |||
| 336 | *out_hwirq = line; | ||
| 337 | *out_type = it->out_type; | ||
| 338 | return 0; | ||
| 385 | } | 339 | } |
| 386 | 340 | ||
| 341 | const struct irq_domain_ops ioapic_irq_domain_ops = { | ||
| 342 | .xlate = ioapic_xlate, | ||
| 343 | }; | ||
| 344 | |||
| 387 | static void __init ioapic_add_ofnode(struct device_node *np) | 345 | static void __init ioapic_add_ofnode(struct device_node *np) |
| 388 | { | 346 | { |
| 389 | struct resource r; | 347 | struct resource r; |
| @@ -399,13 +357,14 @@ static void __init ioapic_add_ofnode(struct device_node *np) | |||
| 399 | for (i = 0; i < nr_ioapics; i++) { | 357 | for (i = 0; i < nr_ioapics; i++) { |
| 400 | if (r.start == mpc_ioapic_addr(i)) { | 358 | if (r.start == mpc_ioapic_addr(i)) { |
| 401 | struct irq_domain *id; | 359 | struct irq_domain *id; |
| 360 | struct mp_ioapic_gsi *gsi_cfg; | ||
| 361 | |||
| 362 | gsi_cfg = mp_ioapic_gsi_routing(i); | ||
| 402 | 363 | ||
| 403 | id = kzalloc(sizeof(*id), GFP_KERNEL); | 364 | id = irq_domain_add_legacy(np, 32, gsi_cfg->gsi_base, 0, |
| 365 | &ioapic_irq_domain_ops, | ||
| 366 | (void*)i); | ||
| 404 | BUG_ON(!id); | 367 | BUG_ON(!id); |
| 405 | id->controller = np; | ||
| 406 | id->xlate = ioapic_xlate; | ||
| 407 | id->priv = (void *)i; | ||
| 408 | add_interrupt_host(id); | ||
| 409 | return; | 368 | return; |
| 410 | } | 369 | } |
| 411 | } | 370 | } |
