diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2015-10-13 07:51:32 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-10-13 13:01:23 -0400 |
commit | 11e4438ee330fab0f216ee7cc1b651cb2ddceb5d (patch) | |
tree | dbae43af6b5b90d852c57c6f1b59cb6cef4866b2 /kernel/irq | |
parent | 130b8c6c8d86075304952241bf2365cea6489df1 (diff) |
irqdomain: Introduce a firmware-specific IRQ specifier structure
So far the closest thing to a generic IRQ specifier structure is
of_phandle_args, which happens to be pretty OF specific (the of_node
pointer in there is quite annoying).
Let's introduce 'struct irq_fwspec' that can be used in place of
of_phandle_args for OF, but also for other firmware implementations
(that'd be ACPI). This is used together with a new 'translate' method
that is the pendent of 'xlate'.
We convert irq_create_of_mapping to use this new structure (with a
small hack that will be removed later).
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-and-tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Graeme Gregory <graeme@xora.org.uk>
Cc: Jake Oshins <jakeo@microsoft.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Link: http://lkml.kernel.org/r/1444737105-31573-5-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq')
-rw-r--r-- | kernel/irq/irqdomain.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 023ab6d488f7..86dfd402ed5e 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -484,30 +484,67 @@ int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base, | |||
484 | } | 484 | } |
485 | EXPORT_SYMBOL_GPL(irq_create_strict_mappings); | 485 | EXPORT_SYMBOL_GPL(irq_create_strict_mappings); |
486 | 486 | ||
487 | static int irq_domain_translate(struct irq_domain *d, | ||
488 | struct irq_fwspec *fwspec, | ||
489 | irq_hw_number_t *hwirq, unsigned int *type) | ||
490 | { | ||
491 | #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY | ||
492 | if (d->ops->translate) | ||
493 | return d->ops->translate(d, fwspec, hwirq, type); | ||
494 | #endif | ||
495 | if (d->ops->xlate) | ||
496 | return d->ops->xlate(d, to_of_node(fwspec->fwnode), | ||
497 | fwspec->param, fwspec->param_count, | ||
498 | hwirq, type); | ||
499 | |||
500 | /* If domain has no translation, then we assume interrupt line */ | ||
501 | *hwirq = fwspec->param[0]; | ||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data, | ||
506 | struct irq_fwspec *fwspec) | ||
507 | { | ||
508 | int i; | ||
509 | |||
510 | fwspec->fwnode = irq_data->np ? &irq_data->np->fwnode : NULL; | ||
511 | fwspec->param_count = irq_data->args_count; | ||
512 | |||
513 | for (i = 0; i < irq_data->args_count; i++) | ||
514 | fwspec->param[i] = irq_data->args[i]; | ||
515 | } | ||
516 | |||
487 | unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) | 517 | unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) |
488 | { | 518 | { |
519 | struct irq_fwspec fwspec; | ||
489 | struct irq_domain *domain; | 520 | struct irq_domain *domain; |
490 | irq_hw_number_t hwirq; | 521 | irq_hw_number_t hwirq; |
491 | unsigned int type = IRQ_TYPE_NONE; | 522 | unsigned int type = IRQ_TYPE_NONE; |
492 | int virq; | 523 | int virq; |
493 | 524 | ||
494 | domain = irq_data->np ? irq_find_host(irq_data->np) : irq_default_domain; | 525 | of_phandle_args_to_fwspec(irq_data, &fwspec); |
526 | |||
527 | if (fwspec.fwnode) | ||
528 | domain = irq_find_matching_fwnode(fwspec.fwnode, DOMAIN_BUS_ANY); | ||
529 | else | ||
530 | domain = irq_default_domain; | ||
531 | |||
495 | if (!domain) { | 532 | if (!domain) { |
496 | pr_warn("no irq domain found for %s !\n", | 533 | pr_warn("no irq domain found for %s !\n", |
497 | of_node_full_name(irq_data->np)); | 534 | of_node_full_name(to_of_node(fwspec.fwnode))); |
498 | return 0; | 535 | return 0; |
499 | } | 536 | } |
500 | 537 | ||
501 | /* If domain has no translation, then we assume interrupt line */ | 538 | if (irq_domain_translate(domain, &fwspec, &hwirq, &type)) |
502 | if (domain->ops->xlate == NULL) | 539 | return 0; |
503 | hwirq = irq_data->args[0]; | ||
504 | else { | ||
505 | if (domain->ops->xlate(domain, irq_data->np, irq_data->args, | ||
506 | irq_data->args_count, &hwirq, &type)) | ||
507 | return 0; | ||
508 | } | ||
509 | 540 | ||
510 | if (irq_domain_is_hierarchy(domain)) { | 541 | if (irq_domain_is_hierarchy(domain)) { |
542 | /* Temporary hack */ | ||
543 | void *desc = &fwspec; | ||
544 | #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY | ||
545 | if (!domain->ops->translate) | ||
546 | desc = irq_data; | ||
547 | #endif | ||
511 | /* | 548 | /* |
512 | * If we've already configured this interrupt, | 549 | * If we've already configured this interrupt, |
513 | * don't do it again, or hell will break loose. | 550 | * don't do it again, or hell will break loose. |
@@ -516,7 +553,7 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) | |||
516 | if (virq) | 553 | if (virq) |
517 | return virq; | 554 | return virq; |
518 | 555 | ||
519 | virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, irq_data); | 556 | virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, desc); |
520 | if (virq <= 0) | 557 | if (virq <= 0) |
521 | return 0; | 558 | return 0; |
522 | } else { | 559 | } else { |