diff options
| author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-05 07:19:19 -0400 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2012-07-11 09:59:17 -0400 |
| commit | 781d0f46d81e2c26c70649903b503bcfe817efc8 (patch) | |
| tree | 11794b64c41e8468db6d14243c5becce3b5b64c8 /kernel | |
| parent | aed98048bd1c83469d96932c1901e867d9ba519a (diff) | |
irq_domain: Standardise legacy/linear domain selection
A large proportion of interrupt controllers that support legacy mappings
do so because non-DT systems need to use fixed IRQ numbers when registering
devices via buses but can otherwise use a linear mapping. The interrupt
controller itself typically is not affected by the mapping used and best
practice is to use a linear mapping where possible so drivers frequently
select at runtime depending on if a legacy range has been allocated to
them.
Standardise this behaviour by providing irq_domain_register_simple() which
will allocate a linear mapping unless a positive first_irq is provided in
which case it will fall back to a legacy mapping. This helps make best
practice for irq_domain adoption clearer.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/irq/irqdomain.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index d3968e91bfd2..0c51958c6335 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
| @@ -140,6 +140,36 @@ static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain, | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /** | 142 | /** |
| 143 | * irq_domain_add_simple() - Allocate and register a simple irq_domain. | ||
| 144 | * @of_node: pointer to interrupt controller's device tree node. | ||
| 145 | * @size: total number of irqs in mapping | ||
| 146 | * @first_irq: first number of irq block assigned to the domain | ||
| 147 | * @ops: map/unmap domain callbacks | ||
| 148 | * @host_data: Controller private data pointer | ||
| 149 | * | ||
| 150 | * Allocates a legacy irq_domain if irq_base is positive or a linear | ||
| 151 | * domain otherwise. | ||
| 152 | * | ||
| 153 | * This is intended to implement the expected behaviour for most | ||
| 154 | * interrupt controllers which is that a linear mapping should | ||
| 155 | * normally be used unless the system requires a legacy mapping in | ||
| 156 | * order to support supplying interrupt numbers during non-DT | ||
| 157 | * registration of devices. | ||
| 158 | */ | ||
| 159 | struct irq_domain *irq_domain_add_simple(struct device_node *of_node, | ||
| 160 | unsigned int size, | ||
| 161 | unsigned int first_irq, | ||
| 162 | const struct irq_domain_ops *ops, | ||
| 163 | void *host_data) | ||
| 164 | { | ||
| 165 | if (first_irq > 0) | ||
| 166 | return irq_domain_add_legacy(of_node, size, first_irq, 0, | ||
| 167 | ops, host_data); | ||
| 168 | else | ||
| 169 | return irq_domain_add_linear(of_node, size, ops, host_data); | ||
| 170 | } | ||
| 171 | |||
| 172 | /** | ||
| 143 | * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain. | 173 | * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain. |
| 144 | * @of_node: pointer to interrupt controller's device tree node. | 174 | * @of_node: pointer to interrupt controller's device tree node. |
| 145 | * @size: total number of irqs in legacy mapping | 175 | * @size: total number of irqs in legacy mapping |
