diff options
Diffstat (limited to 'kernel/irq/irqdomain.c')
-rw-r--r-- | kernel/irq/irqdomain.c | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 6328d9350f04..456e3fc8387f 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -699,25 +699,70 @@ int irq_domain_simple_map(struct irq_domain *d, unsigned int irq, | |||
699 | return 0; | 699 | return 0; |
700 | } | 700 | } |
701 | 701 | ||
702 | int irq_domain_simple_xlate(struct irq_domain *d, | 702 | /** |
703 | struct device_node *controller, | 703 | * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings |
704 | const u32 *intspec, unsigned int intsize, | 704 | * |
705 | unsigned long *out_hwirq, unsigned int *out_type) | 705 | * Device Tree IRQ specifier translation function which works with one cell |
706 | * bindings where the cell value maps directly to the hwirq number. | ||
707 | */ | ||
708 | int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr, | ||
709 | const u32 *intspec, unsigned int intsize, | ||
710 | unsigned long *out_hwirq, unsigned int *out_type) | ||
706 | { | 711 | { |
707 | if (d->of_node != controller) | 712 | if (WARN_ON(intsize < 1)) |
708 | return -EINVAL; | ||
709 | if (intsize < 1) | ||
710 | return -EINVAL; | 713 | return -EINVAL; |
711 | *out_hwirq = intspec[0]; | 714 | *out_hwirq = intspec[0]; |
712 | *out_type = IRQ_TYPE_NONE; | 715 | *out_type = IRQ_TYPE_NONE; |
713 | if (intsize > 1) | ||
714 | *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; | ||
715 | return 0; | 716 | return 0; |
716 | } | 717 | } |
718 | EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell); | ||
719 | |||
720 | /** | ||
721 | * irq_domain_xlate_twocell() - Generic xlate for direct two cell bindings | ||
722 | * | ||
723 | * Device Tree IRQ specifier translation function which works with two cell | ||
724 | * bindings where the cell values map directly to the hwirq number | ||
725 | * and linux irq flags. | ||
726 | */ | ||
727 | int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr, | ||
728 | const u32 *intspec, unsigned int intsize, | ||
729 | irq_hw_number_t *out_hwirq, unsigned int *out_type) | ||
730 | { | ||
731 | if (WARN_ON(intsize < 2)) | ||
732 | return -EINVAL; | ||
733 | *out_hwirq = intspec[0]; | ||
734 | *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; | ||
735 | return 0; | ||
736 | } | ||
737 | EXPORT_SYMBOL_GPL(irq_domain_xlate_twocell); | ||
738 | |||
739 | /** | ||
740 | * irq_domain_xlate_onetwocell() - Generic xlate for one or two cell bindings | ||
741 | * | ||
742 | * Device Tree IRQ specifier translation function which works with either one | ||
743 | * or two cell bindings where the cell values map directly to the hwirq number | ||
744 | * and linux irq flags. | ||
745 | * | ||
746 | * Note: don't use this function unless your interrupt controller explicitly | ||
747 | * supports both one and two cell bindings. For the majority of controllers | ||
748 | * the _onecell() or _twocell() variants above should be used. | ||
749 | */ | ||
750 | int irq_domain_xlate_onetwocell(struct irq_domain *d, | ||
751 | struct device_node *ctrlr, | ||
752 | const u32 *intspec, unsigned int intsize, | ||
753 | unsigned long *out_hwirq, unsigned int *out_type) | ||
754 | { | ||
755 | if (WARN_ON(intsize < 1)) | ||
756 | return -EINVAL; | ||
757 | *out_hwirq = intspec[0]; | ||
758 | *out_type = (intsize > 1) ? intspec[1] : IRQ_TYPE_NONE; | ||
759 | return 0; | ||
760 | } | ||
761 | EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell); | ||
717 | 762 | ||
718 | struct irq_domain_ops irq_domain_simple_ops = { | 763 | struct irq_domain_ops irq_domain_simple_ops = { |
719 | .map = irq_domain_simple_map, | 764 | .map = irq_domain_simple_map, |
720 | .xlate = irq_domain_simple_xlate, | 765 | .xlate = irq_domain_xlate_onetwocell, |
721 | }; | 766 | }; |
722 | EXPORT_SYMBOL_GPL(irq_domain_simple_ops); | 767 | EXPORT_SYMBOL_GPL(irq_domain_simple_ops); |
723 | 768 | ||