Commit 67196fea authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski

irqdomain: Introduce irq_domain_create_simple() API

Linus Walleij pointed out that ird_domain_add_simple() gained
additional functionality and can't be anymore replaced with
a simple conditional. In preparation to upgrade GPIO library
to use fwnode, introduce irq_domain_create_simple() API which is
functional equivalent to the existing irq_domain_add_simple(),
but takes a pointer to the struct fwnode_handle as a parameter.

While at it, amend documentation to mention irq_domain_create_*()
functions where it makes sense.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarMarc Zyngier <maz@kernel.org>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 3fd19d4b
...@@ -42,10 +42,10 @@ irq_domain usage ...@@ -42,10 +42,10 @@ irq_domain usage
================ ================
An interrupt controller driver creates and registers an irq_domain by An interrupt controller driver creates and registers an irq_domain by
calling one of the irq_domain_add_*() functions (each mapping method calling one of the irq_domain_add_*() or irq_domain_create_*() functions
has a different allocator function, more on that later). The function (each mapping method has a different allocator function, more on that later).
will return a pointer to the irq_domain on success. The caller must The function will return a pointer to the irq_domain on success. The caller
provide the allocator function with an irq_domain_ops structure. must provide the allocator function with an irq_domain_ops structure.
In most cases, the irq_domain will begin empty without any mappings In most cases, the irq_domain will begin empty without any mappings
between hwirq and IRQ numbers. Mappings are added to the irq_domain between hwirq and IRQ numbers. Mappings are added to the irq_domain
...@@ -147,6 +147,7 @@ Legacy ...@@ -147,6 +147,7 @@ Legacy
irq_domain_add_simple() irq_domain_add_simple()
irq_domain_add_legacy() irq_domain_add_legacy()
irq_domain_add_legacy_isa() irq_domain_add_legacy_isa()
irq_domain_create_simple()
irq_domain_create_legacy() irq_domain_create_legacy()
The Legacy mapping is a special case for drivers that already have a The Legacy mapping is a special case for drivers that already have a
...@@ -169,13 +170,13 @@ supported. For example, ISA controllers would use the legacy map for ...@@ -169,13 +170,13 @@ supported. For example, ISA controllers would use the legacy map for
mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ
numbers. numbers.
Most users of legacy mappings should use irq_domain_add_simple() which Most users of legacy mappings should use irq_domain_add_simple() or
will use a legacy domain only if an IRQ range is supplied by the irq_domain_create_simple() which will use a legacy domain only if an IRQ range
system and will otherwise use a linear domain mapping. The semantics is supplied by the system and will otherwise use a linear domain mapping.
of this call are such that if an IRQ range is specified then The semantics of this call are such that if an IRQ range is specified then
descriptors will be allocated on-the-fly for it, and if no range is descriptors will be allocated on-the-fly for it, and if no range is
specified it will fall through to irq_domain_add_linear() which means specified it will fall through to irq_domain_add_linear() or
*no* irq descriptors will be allocated. irq_domain_create_linear() which means *no* irq descriptors will be allocated.
A typical use case for simple domains is where an irqchip provider A typical use case for simple domains is where an irqchip provider
is supporting both dynamic and static IRQ assignments. is supporting both dynamic and static IRQ assignments.
...@@ -186,6 +187,7 @@ that the driver using the simple domain call irq_create_mapping() ...@@ -186,6 +187,7 @@ that the driver using the simple domain call irq_create_mapping()
before any irq_find_mapping() since the latter will actually work before any irq_find_mapping() since the latter will actually work
for the static IRQ assignment case. for the static IRQ assignment case.
irq_domain_add_simple() and irq_domain_create_simple() as well as
irq_domain_add_legacy() and irq_domain_create_legacy() are functionally irq_domain_add_legacy() and irq_domain_create_legacy() are functionally
equivalent, except for the first argument is different - the former equivalent, except for the first argument is different - the former
accepts an Open Firmware specific 'struct device_node', while the latter accepts an Open Firmware specific 'struct device_node', while the latter
......
...@@ -256,11 +256,11 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, ...@@ -256,11 +256,11 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
irq_hw_number_t hwirq_max, int direct_max, irq_hw_number_t hwirq_max, int direct_max,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data); void *host_data);
struct irq_domain *irq_domain_add_simple(struct device_node *of_node, struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode,
unsigned int size, unsigned int size,
unsigned int first_irq, unsigned int first_irq,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data); void *host_data);
struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
unsigned int size, unsigned int size,
unsigned int first_irq, unsigned int first_irq,
...@@ -325,6 +325,15 @@ static inline struct irq_domain *irq_find_host(struct device_node *node) ...@@ -325,6 +325,15 @@ static inline struct irq_domain *irq_find_host(struct device_node *node)
return d; return d;
} }
static inline struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
unsigned int size,
unsigned int first_irq,
const struct irq_domain_ops *ops,
void *host_data)
{
return irq_domain_create_simple(of_node_to_fwnode(of_node), size, first_irq, ops, host_data);
}
/** /**
* irq_domain_add_linear() - Allocate and register a linear revmap irq_domain. * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
* @of_node: pointer to interrupt controller's device tree node. * @of_node: pointer to interrupt controller's device tree node.
......
...@@ -295,8 +295,8 @@ void irq_domain_update_bus_token(struct irq_domain *domain, ...@@ -295,8 +295,8 @@ void irq_domain_update_bus_token(struct irq_domain *domain,
EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); EXPORT_SYMBOL_GPL(irq_domain_update_bus_token);
/** /**
* irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs * irq_domain_create_simple() - Register an irq_domain and optionally map a range of irqs
* @of_node: pointer to interrupt controller's device tree node. * @fwnode: firmware node for the interrupt controller
* @size: total number of irqs in mapping * @size: total number of irqs in mapping
* @first_irq: first number of irq block assigned to the domain, * @first_irq: first number of irq block assigned to the domain,
* pass zero to assign irqs on-the-fly. If first_irq is non-zero, then * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then
...@@ -312,15 +312,15 @@ EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); ...@@ -312,15 +312,15 @@ EXPORT_SYMBOL_GPL(irq_domain_update_bus_token);
* irqs get mapped dynamically on the fly. However, if the controller requires * irqs get mapped dynamically on the fly. However, if the controller requires
* static virq assignments (non-DT boot) then it will set that up correctly. * static virq assignments (non-DT boot) then it will set that up correctly.
*/ */
struct irq_domain *irq_domain_add_simple(struct device_node *of_node, struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode,
unsigned int size, unsigned int size,
unsigned int first_irq, unsigned int first_irq,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data) void *host_data)
{ {
struct irq_domain *domain; struct irq_domain *domain;
domain = __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data); domain = __irq_domain_add(fwnode, size, size, 0, ops, host_data);
if (!domain) if (!domain)
return NULL; return NULL;
...@@ -328,7 +328,7 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node, ...@@ -328,7 +328,7 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { if (IS_ENABLED(CONFIG_SPARSE_IRQ)) {
/* attempt to allocated irq_descs */ /* attempt to allocated irq_descs */
int rc = irq_alloc_descs(first_irq, first_irq, size, int rc = irq_alloc_descs(first_irq, first_irq, size,
of_node_to_nid(of_node)); of_node_to_nid(to_of_node(fwnode)));
if (rc < 0) if (rc < 0)
pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
first_irq); first_irq);
...@@ -338,7 +338,7 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node, ...@@ -338,7 +338,7 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
return domain; return domain;
} }
EXPORT_SYMBOL_GPL(irq_domain_add_simple); EXPORT_SYMBOL_GPL(irq_domain_create_simple);
/** /**
* irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain. * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment