diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2012-02-14 16:06:48 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-02-14 16:06:48 -0500 |
commit | 7bb69bade0d41715bdf1b24f5ef0b8f798769fe9 (patch) | |
tree | b024fa6c54e56bf1c9ea19c1ff76e86607a2a265 | |
parent | e1964c50a83d1ce53731c88271d12ac92292a880 (diff) |
irq_domain: Make irq_domain structure match powerpc's irq_host
Part of the series to unify the irq remapping mechanisms in the
kernel. A follow up patch will copy the powerpc implementation into
kernel/irq/irqdomain.c, which will be a lot easier if the structures
are identical.
Where they differ, I've chose to use the powerpc names since there is
a lot more code using those names.
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>
-rw-r--r-- | arch/arm/common/gic.c | 14 | ||||
-rw-r--r-- | include/linux/irqdomain.h | 84 | ||||
-rw-r--r-- | kernel/irq/irqdomain.c | 14 |
3 files changed, 78 insertions, 34 deletions
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index c47d6199b784..dc19862be0a8 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c | |||
@@ -619,10 +619,10 @@ static void __init gic_pm_init(struct gic_chip_data *gic) | |||
619 | #endif | 619 | #endif |
620 | 620 | ||
621 | #ifdef CONFIG_OF | 621 | #ifdef CONFIG_OF |
622 | static int gic_irq_domain_dt_translate(struct irq_domain *d, | 622 | static int gic_irq_domain_xlate(struct irq_domain *d, |
623 | struct device_node *controller, | 623 | struct device_node *controller, |
624 | const u32 *intspec, unsigned int intsize, | 624 | const u32 *intspec, unsigned int intsize, |
625 | unsigned long *out_hwirq, unsigned int *out_type) | 625 | unsigned long *out_hwirq, unsigned int *out_type) |
626 | { | 626 | { |
627 | if (d->of_node != controller) | 627 | if (d->of_node != controller) |
628 | return -EINVAL; | 628 | return -EINVAL; |
@@ -641,9 +641,9 @@ static int gic_irq_domain_dt_translate(struct irq_domain *d, | |||
641 | } | 641 | } |
642 | #endif | 642 | #endif |
643 | 643 | ||
644 | const struct irq_domain_ops gic_irq_domain_ops = { | 644 | struct irq_domain_ops gic_irq_domain_ops = { |
645 | #ifdef CONFIG_OF | 645 | #ifdef CONFIG_OF |
646 | .dt_translate = gic_irq_domain_dt_translate, | 646 | .xlate = gic_irq_domain_xlate, |
647 | #endif | 647 | #endif |
648 | }; | 648 | }; |
649 | 649 | ||
@@ -721,7 +721,7 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start, | |||
721 | irq_start); | 721 | irq_start); |
722 | domain->irq_base = irq_start; | 722 | domain->irq_base = irq_start; |
723 | } | 723 | } |
724 | domain->priv = gic; | 724 | domain->host_data = gic; |
725 | domain->ops = &gic_irq_domain_ops; | 725 | domain->ops = &gic_irq_domain_ops; |
726 | irq_domain_add(domain); | 726 | irq_domain_add(domain); |
727 | 727 | ||
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index bd4272b61a14..35b9ff382e45 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h | |||
@@ -9,61 +9,105 @@ | |||
9 | * representation into a hardware irq number that can be mapped back to a | 9 | * representation into a hardware irq number that can be mapped back to a |
10 | * Linux irq number without any extra platform support code. | 10 | * Linux irq number without any extra platform support code. |
11 | * | 11 | * |
12 | * irq_domain is expected to be embedded in an interrupt controller's private | 12 | * Interrupt controller "domain" data structure. This could be defined as a |
13 | * data structure. | 13 | * irq domain controller. That is, it handles the mapping between hardware |
14 | * and virtual interrupt numbers for a given interrupt domain. The domain | ||
15 | * structure is generally created by the PIC code for a given PIC instance | ||
16 | * (though a domain can cover more than one PIC if they have a flat number | ||
17 | * model). It's the domain callbacks that are responsible for setting the | ||
18 | * irq_chip on a given irq_desc after it's been mapped. | ||
14 | */ | 19 | */ |
20 | |||
15 | #ifndef _LINUX_IRQDOMAIN_H | 21 | #ifndef _LINUX_IRQDOMAIN_H |
16 | #define _LINUX_IRQDOMAIN_H | 22 | #define _LINUX_IRQDOMAIN_H |
17 | 23 | ||
18 | #include <linux/irq.h> | 24 | #include <linux/types.h> |
19 | #include <linux/mod_devicetable.h> | 25 | #include <linux/radix-tree.h> |
20 | 26 | ||
21 | #ifdef CONFIG_IRQ_DOMAIN | ||
22 | struct device_node; | 27 | struct device_node; |
23 | struct irq_domain; | 28 | struct irq_domain; |
29 | struct of_device_id; | ||
30 | |||
31 | /* This type is the placeholder for a hardware interrupt number. It has to | ||
32 | * be big enough to enclose whatever representation is used by a given | ||
33 | * platform. | ||
34 | */ | ||
35 | typedef unsigned long irq_hw_number_t; | ||
24 | 36 | ||
25 | /** | 37 | /** |
26 | * struct irq_domain_ops - Methods for irq_domain objects | 38 | * struct irq_domain_ops - Methods for irq_domain objects |
39 | * @match: Match an interrupt controller device node to a host, returns | ||
40 | * 1 on a match | ||
41 | * @map: Create or update a mapping between a virtual irq number and a hw | ||
42 | * irq number. This is called only once for a given mapping. | ||
43 | * @unmap: Dispose of such a mapping | ||
27 | * @to_irq: (optional) given a local hardware irq number, return the linux | 44 | * @to_irq: (optional) given a local hardware irq number, return the linux |
28 | * irq number. If to_irq is not implemented, then the irq_domain | 45 | * irq number. If to_irq is not implemented, then the irq_domain |
29 | * will use this translation: irq = (domain->irq_base + hwirq) | 46 | * will use this translation: irq = (domain->irq_base + hwirq) |
30 | * @dt_translate: Given a device tree node and interrupt specifier, decode | 47 | * @xlate: Given a device tree node and interrupt specifier, decode |
31 | * the hardware irq number and linux irq type value. | 48 | * the hardware irq number and linux irq type value. |
49 | * | ||
50 | * Functions below are provided by the driver and called whenever a new mapping | ||
51 | * is created or an old mapping is disposed. The driver can then proceed to | ||
52 | * whatever internal data structures management is required. It also needs | ||
53 | * to setup the irq_desc when returning from map(). | ||
32 | */ | 54 | */ |
33 | struct irq_domain_ops { | 55 | struct irq_domain_ops { |
56 | int (*match)(struct irq_domain *d, struct device_node *node); | ||
57 | int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw); | ||
58 | void (*unmap)(struct irq_domain *d, unsigned int virq); | ||
34 | unsigned int (*to_irq)(struct irq_domain *d, unsigned long hwirq); | 59 | unsigned int (*to_irq)(struct irq_domain *d, unsigned long hwirq); |
35 | 60 | int (*xlate)(struct irq_domain *d, struct device_node *node, | |
36 | #ifdef CONFIG_OF | 61 | const u32 *intspec, unsigned int intsize, |
37 | int (*dt_translate)(struct irq_domain *d, struct device_node *node, | 62 | unsigned long *out_hwirq, unsigned int *out_type); |
38 | const u32 *intspec, unsigned int intsize, | ||
39 | unsigned long *out_hwirq, unsigned int *out_type); | ||
40 | #endif /* CONFIG_OF */ | ||
41 | }; | 63 | }; |
42 | 64 | ||
43 | /** | 65 | /** |
44 | * struct irq_domain - Hardware interrupt number translation object | 66 | * struct irq_domain - Hardware interrupt number translation object |
45 | * @list: Element in global irq_domain list. | 67 | * @link: Element in global irq_domain list. |
68 | * @revmap_type: Method used for reverse mapping hwirq numbers to linux irq. This | ||
69 | * will be one of the IRQ_DOMAIN_MAP_* values. | ||
70 | * @revmap_data: Revmap method specific data. | ||
71 | * @ops: pointer to irq_domain methods | ||
72 | * @host_data: private data pointer for use by owner. Not touched by irq_domain | ||
73 | * core code. | ||
46 | * @irq_base: Start of irq_desc range assigned to the irq_domain. The creator | 74 | * @irq_base: Start of irq_desc range assigned to the irq_domain. The creator |
47 | * of the irq_domain is responsible for allocating the array of | 75 | * of the irq_domain is responsible for allocating the array of |
48 | * irq_desc structures. | 76 | * irq_desc structures. |
49 | * @nr_irq: Number of irqs managed by the irq domain | 77 | * @nr_irq: Number of irqs managed by the irq domain |
50 | * @hwirq_base: Starting number for hwirqs managed by the irq domain | 78 | * @hwirq_base: Starting number for hwirqs managed by the irq domain |
51 | * @ops: pointer to irq_domain methods | ||
52 | * @priv: private data pointer for use by owner. Not touched by irq_domain | ||
53 | * core code. | ||
54 | * @of_node: (optional) Pointer to device tree nodes associated with the | 79 | * @of_node: (optional) Pointer to device tree nodes associated with the |
55 | * irq_domain. Used when decoding device tree interrupt specifiers. | 80 | * irq_domain. Used when decoding device tree interrupt specifiers. |
56 | */ | 81 | */ |
57 | struct irq_domain { | 82 | struct irq_domain { |
58 | struct list_head list; | 83 | struct list_head link; |
84 | |||
85 | /* type of reverse mapping_technique */ | ||
86 | unsigned int revmap_type; | ||
87 | #define IRQ_DOMAIN_MAP_LEGACY 0 /* legacy 8259, gets irqs 1..15 */ | ||
88 | #define IRQ_DOMAIN_MAP_NOMAP 1 /* no fast reverse mapping */ | ||
89 | #define IRQ_DOMAIN_MAP_LINEAR 2 /* linear map of interrupts */ | ||
90 | #define IRQ_DOMAIN_MAP_TREE 3 /* radix tree */ | ||
91 | union { | ||
92 | struct { | ||
93 | unsigned int size; | ||
94 | unsigned int *revmap; | ||
95 | } linear; | ||
96 | struct radix_tree_root tree; | ||
97 | } revmap_data; | ||
98 | struct irq_domain_ops *ops; | ||
99 | void *host_data; | ||
100 | irq_hw_number_t inval_irq; | ||
101 | |||
59 | unsigned int irq_base; | 102 | unsigned int irq_base; |
60 | unsigned int nr_irq; | 103 | unsigned int nr_irq; |
61 | unsigned int hwirq_base; | 104 | unsigned int hwirq_base; |
62 | const struct irq_domain_ops *ops; | 105 | |
63 | void *priv; | 106 | /* Optional device node pointer */ |
64 | struct device_node *of_node; | 107 | struct device_node *of_node; |
65 | }; | 108 | }; |
66 | 109 | ||
110 | #ifdef CONFIG_IRQ_DOMAIN | ||
67 | /** | 111 | /** |
68 | * irq_domain_to_irq() - Translate from a hardware irq to a linux irq number | 112 | * irq_domain_to_irq() - Translate from a hardware irq to a linux irq number |
69 | * | 113 | * |
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index cc2cd43ec740..509adb8762d7 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -43,7 +43,7 @@ void irq_domain_add(struct irq_domain *domain) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | mutex_lock(&irq_domain_mutex); | 45 | mutex_lock(&irq_domain_mutex); |
46 | list_add(&domain->list, &irq_domain_list); | 46 | list_add(&domain->link, &irq_domain_list); |
47 | mutex_unlock(&irq_domain_mutex); | 47 | mutex_unlock(&irq_domain_mutex); |
48 | } | 48 | } |
49 | 49 | ||
@@ -57,7 +57,7 @@ void irq_domain_del(struct irq_domain *domain) | |||
57 | int hwirq, irq; | 57 | int hwirq, irq; |
58 | 58 | ||
59 | mutex_lock(&irq_domain_mutex); | 59 | mutex_lock(&irq_domain_mutex); |
60 | list_del(&domain->list); | 60 | list_del(&domain->link); |
61 | mutex_unlock(&irq_domain_mutex); | 61 | mutex_unlock(&irq_domain_mutex); |
62 | 62 | ||
63 | /* Clear the irq_domain assignments */ | 63 | /* Clear the irq_domain assignments */ |
@@ -88,10 +88,10 @@ unsigned int irq_create_of_mapping(struct device_node *controller, | |||
88 | 88 | ||
89 | /* Find a domain which can translate the irq spec */ | 89 | /* Find a domain which can translate the irq spec */ |
90 | mutex_lock(&irq_domain_mutex); | 90 | mutex_lock(&irq_domain_mutex); |
91 | list_for_each_entry(domain, &irq_domain_list, list) { | 91 | list_for_each_entry(domain, &irq_domain_list, link) { |
92 | if (!domain->ops->dt_translate) | 92 | if (!domain->ops->xlate) |
93 | continue; | 93 | continue; |
94 | rc = domain->ops->dt_translate(domain, controller, | 94 | rc = domain->ops->xlate(domain, controller, |
95 | intspec, intsize, &hwirq, &type); | 95 | intspec, intsize, &hwirq, &type); |
96 | if (rc == 0) | 96 | if (rc == 0) |
97 | break; | 97 | break; |
@@ -126,7 +126,7 @@ void irq_dispose_mapping(unsigned int irq) | |||
126 | } | 126 | } |
127 | EXPORT_SYMBOL_GPL(irq_dispose_mapping); | 127 | EXPORT_SYMBOL_GPL(irq_dispose_mapping); |
128 | 128 | ||
129 | int irq_domain_simple_dt_translate(struct irq_domain *d, | 129 | int irq_domain_simple_xlate(struct irq_domain *d, |
130 | struct device_node *controller, | 130 | struct device_node *controller, |
131 | const u32 *intspec, unsigned int intsize, | 131 | const u32 *intspec, unsigned int intsize, |
132 | unsigned long *out_hwirq, unsigned int *out_type) | 132 | unsigned long *out_hwirq, unsigned int *out_type) |
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(irq_domain_generate_simple); | |||
181 | 181 | ||
182 | struct irq_domain_ops irq_domain_simple_ops = { | 182 | struct irq_domain_ops irq_domain_simple_ops = { |
183 | #ifdef CONFIG_OF_IRQ | 183 | #ifdef CONFIG_OF_IRQ |
184 | .dt_translate = irq_domain_simple_dt_translate, | 184 | .xlate = irq_domain_simple_xlate, |
185 | #endif /* CONFIG_OF_IRQ */ | 185 | #endif /* CONFIG_OF_IRQ */ |
186 | }; | 186 | }; |
187 | EXPORT_SYMBOL_GPL(irq_domain_simple_ops); | 187 | EXPORT_SYMBOL_GPL(irq_domain_simple_ops); |