aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/IRQ-domain.txt5
-rw-r--r--include/linux/irqdomain.h5
-rw-r--r--kernel/irq/irqdomain.c30
3 files changed, 40 insertions, 0 deletions
diff --git a/Documentation/IRQ-domain.txt b/Documentation/IRQ-domain.txt
index 27dcaabfb4db..1401cece745a 100644
--- a/Documentation/IRQ-domain.txt
+++ b/Documentation/IRQ-domain.txt
@@ -93,6 +93,7 @@ Linux IRQ number into the hardware.
93Most drivers cannot use this mapping. 93Most drivers cannot use this mapping.
94 94
95==== Legacy ==== 95==== Legacy ====
96irq_domain_add_simple()
96irq_domain_add_legacy() 97irq_domain_add_legacy()
97irq_domain_add_legacy_isa() 98irq_domain_add_legacy_isa()
98 99
@@ -115,3 +116,7 @@ The legacy map should only be used if fixed IRQ mappings must be
115supported. For example, ISA controllers would use the legacy map for 116supported. For example, ISA controllers would use the legacy map for
116mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ 117mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ
117numbers. 118numbers.
119
120Most users of legacy mappings should use irq_domain_add_simple() which
121will use a legacy domain only if an IRQ range is supplied by the
122system and will otherwise use a linear domain mapping.
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 5abb533eb8eb..17b60be30fff 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -112,6 +112,11 @@ struct irq_domain {
112}; 112};
113 113
114#ifdef CONFIG_IRQ_DOMAIN 114#ifdef CONFIG_IRQ_DOMAIN
115struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
116 unsigned int size,
117 unsigned int first_irq,
118 const struct irq_domain_ops *ops,
119 void *host_data);
115struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, 120struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
116 unsigned int size, 121 unsigned int size,
117 unsigned int first_irq, 122 unsigned int first_irq,
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 */
159struct 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