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 /include | |
| 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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/irqdomain.h | 84 |
1 files changed, 64 insertions, 20 deletions
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 | * |
