aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/irqdomain.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-02-14 16:06:57 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-02-16 08:11:23 -0500
commit75294957be1dee7d22dd7d90bd31334ba410e836 (patch)
treeafa8e2905af88ceeba2dccb50b56c42568e18ab9 /kernel/irq/irqdomain.c
parent5769089ac72569d024817270ab79fdf0b9046dde (diff)
irq_domain: Remove 'new' irq_domain in favour of the ppc one
This patch removes the simplistic implementation of irq_domains and enables the powerpc infrastructure for all irq_domain users. The powerpc infrastructure includes support for complex mappings between Linux and hardware irq numbers, and can manage allocation of irq_descs. This patch also converts the few users of irq_domain_add()/irq_domain_del() to call irq_domain_add_legacy() instead. v3: Fix bug that set up too many irqs in translation range. v2: Fix removal of irq_alloc_descs() call in gic driver Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Milton Miller <miltonm@bga.com> Tested-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'kernel/irq/irqdomain.c')
-rw-r--r--kernel/irq/irqdomain.c159
1 files changed, 13 insertions, 146 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index c6740d72073e..2981ebfeb40c 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -22,7 +22,6 @@
22static LIST_HEAD(irq_domain_list); 22static LIST_HEAD(irq_domain_list);
23static DEFINE_MUTEX(irq_domain_mutex); 23static DEFINE_MUTEX(irq_domain_mutex);
24 24
25#ifdef CONFIG_PPC
26static DEFINE_MUTEX(revmap_trees_mutex); 25static DEFINE_MUTEX(revmap_trees_mutex);
27static unsigned int irq_virq_count = NR_IRQS; 26static unsigned int irq_virq_count = NR_IRQS;
28static struct irq_domain *irq_default_domain; 27static struct irq_domain *irq_default_domain;
@@ -694,124 +693,11 @@ static int __init irq_debugfs_init(void)
694__initcall(irq_debugfs_init); 693__initcall(irq_debugfs_init);
695#endif /* CONFIG_VIRQ_DEBUG */ 694#endif /* CONFIG_VIRQ_DEBUG */
696 695
697#else /* CONFIG_PPC */ 696int irq_domain_simple_map(struct irq_domain *d, unsigned int irq,
698 697 irq_hw_number_t hwirq)
699/**
700 * irq_domain_add() - Register an irq_domain
701 * @domain: ptr to initialized irq_domain structure
702 *
703 * Registers an irq_domain structure. The irq_domain must at a minimum be
704 * initialized with an ops structure pointer, and either a ->to_irq hook or
705 * a valid irq_base value. Everything else is optional.
706 */
707void irq_domain_add(struct irq_domain *domain)
708{
709 struct irq_data *d;
710 int hwirq, irq;
711
712 /*
713 * This assumes that the irq_domain owner has already allocated
714 * the irq_descs. This block will be removed when support for dynamic
715 * allocation of irq_descs is added to irq_domain.
716 */
717 irq_domain_for_each_irq(domain, hwirq, irq) {
718 d = irq_get_irq_data(irq);
719 if (!d) {
720 WARN(1, "error: assigning domain to non existant irq_desc");
721 return;
722 }
723 if (d->domain) {
724 /* things are broken; just report, don't clean up */
725 WARN(1, "error: irq_desc already assigned to a domain");
726 return;
727 }
728 d->domain = domain;
729 d->hwirq = hwirq;
730 }
731
732 mutex_lock(&irq_domain_mutex);
733 list_add(&domain->link, &irq_domain_list);
734 mutex_unlock(&irq_domain_mutex);
735}
736
737/**
738 * irq_domain_del() - Unregister an irq_domain
739 * @domain: ptr to registered irq_domain.
740 */
741void irq_domain_del(struct irq_domain *domain)
742{
743 struct irq_data *d;
744 int hwirq, irq;
745
746 mutex_lock(&irq_domain_mutex);
747 list_del(&domain->link);
748 mutex_unlock(&irq_domain_mutex);
749
750 /* Clear the irq_domain assignments */
751 irq_domain_for_each_irq(domain, hwirq, irq) {
752 d = irq_get_irq_data(irq);
753 d->domain = NULL;
754 }
755}
756
757#if defined(CONFIG_OF_IRQ)
758/**
759 * irq_create_of_mapping() - Map a linux irq number from a DT interrupt spec
760 *
761 * Used by the device tree interrupt mapping code to translate a device tree
762 * interrupt specifier to a valid linux irq number. Returns either a valid
763 * linux IRQ number or 0.
764 *
765 * When the caller no longer need the irq number returned by this function it
766 * should arrange to call irq_dispose_mapping().
767 */
768unsigned int irq_create_of_mapping(struct device_node *controller,
769 const u32 *intspec, unsigned int intsize)
770{
771 struct irq_domain *domain;
772 unsigned long hwirq;
773 unsigned int irq, type;
774 int rc = -EINVAL;
775
776 /* Find a domain which can translate the irq spec */
777 mutex_lock(&irq_domain_mutex);
778 list_for_each_entry(domain, &irq_domain_list, link) {
779 if (!domain->ops->xlate)
780 continue;
781 rc = domain->ops->xlate(domain, controller,
782 intspec, intsize, &hwirq, &type);
783 if (rc == 0)
784 break;
785 }
786 mutex_unlock(&irq_domain_mutex);
787
788 if (rc != 0)
789 return 0;
790
791 irq = irq_domain_to_irq(domain, hwirq);
792 if (type != IRQ_TYPE_NONE)
793 irq_set_irq_type(irq, type);
794 pr_debug("%s: mapped hwirq=%i to irq=%i, flags=%x\n",
795 controller->full_name, (int)hwirq, irq, type);
796 return irq;
797}
798EXPORT_SYMBOL_GPL(irq_create_of_mapping);
799
800/**
801 * irq_dispose_mapping() - Discard a mapping created by irq_create_of_mapping()
802 * @irq: linux irq number to be discarded
803 *
804 * Calling this function indicates the caller no longer needs a reference to
805 * the linux irq number returned by a prior call to irq_create_of_mapping().
806 */
807void irq_dispose_mapping(unsigned int irq)
808{ 698{
809 /* 699 return 0;
810 * nothing yet; will be filled when support for dynamic allocation of
811 * irq_descs is added to irq_domain
812 */
813} 700}
814EXPORT_SYMBOL_GPL(irq_dispose_mapping);
815 701
816int irq_domain_simple_xlate(struct irq_domain *d, 702int irq_domain_simple_xlate(struct irq_domain *d,
817 struct device_node *controller, 703 struct device_node *controller,
@@ -822,10 +708,6 @@ int irq_domain_simple_xlate(struct irq_domain *d,
822 return -EINVAL; 708 return -EINVAL;
823 if (intsize < 1) 709 if (intsize < 1)
824 return -EINVAL; 710 return -EINVAL;
825 if (d->nr_irq && ((intspec[0] < d->hwirq_base) ||
826 (intspec[0] >= d->hwirq_base + d->nr_irq)))
827 return -EINVAL;
828
829 *out_hwirq = intspec[0]; 711 *out_hwirq = intspec[0];
830 *out_type = IRQ_TYPE_NONE; 712 *out_type = IRQ_TYPE_NONE;
831 if (intsize > 1) 713 if (intsize > 1)
@@ -833,23 +715,17 @@ int irq_domain_simple_xlate(struct irq_domain *d,
833 return 0; 715 return 0;
834} 716}
835 717
836/** 718struct irq_domain_ops irq_domain_simple_ops = {
837 * irq_domain_create_simple() - Set up a 'simple' translation range 719 .map = irq_domain_simple_map,
838 */ 720 .xlate = irq_domain_simple_xlate,
721};
722EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
723
724#ifdef CONFIG_OF_IRQ
839void irq_domain_add_simple(struct device_node *controller, int irq_base) 725void irq_domain_add_simple(struct device_node *controller, int irq_base)
840{ 726{
841 struct irq_domain *domain; 727 irq_domain_add_legacy(controller, 32, irq_base, 0,
842 728 &irq_domain_simple_ops, NULL);
843 domain = kzalloc(sizeof(*domain), GFP_KERNEL);
844 if (!domain) {
845 WARN_ON(1);
846 return;
847 }
848
849 domain->irq_base = irq_base;
850 domain->of_node = of_node_get(controller);
851 domain->ops = &irq_domain_simple_ops;
852 irq_domain_add(domain);
853} 729}
854EXPORT_SYMBOL_GPL(irq_domain_add_simple); 730EXPORT_SYMBOL_GPL(irq_domain_add_simple);
855 731
@@ -864,13 +740,4 @@ void irq_domain_generate_simple(const struct of_device_id *match,
864 irq_domain_add_simple(node, irq_start); 740 irq_domain_add_simple(node, irq_start);
865} 741}
866EXPORT_SYMBOL_GPL(irq_domain_generate_simple); 742EXPORT_SYMBOL_GPL(irq_domain_generate_simple);
867#endif /* CONFIG_OF_IRQ */ 743#endif
868
869struct irq_domain_ops irq_domain_simple_ops = {
870#ifdef CONFIG_OF_IRQ
871 .xlate = irq_domain_simple_xlate,
872#endif /* CONFIG_OF_IRQ */
873};
874EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
875
876#endif /* !CONFIG_PPC */