Lines Matching +full:irq +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ACPI GSI IRQ layer
9 #include <linux/irq.h>
19 * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
20 * @gsi: GSI IRQ number to map
21 * @irq: pointer where linux IRQ number is stored
23 * irq location updated with irq value [>0 on success, 0 on failure]
26 * -EINVAL on failure
28 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) in acpi_gsi_to_irq() argument
34 *irq = irq_find_mapping(d, gsi); in acpi_gsi_to_irq()
36 * *irq == 0 means no mapping, that should be reported as a in acpi_gsi_to_irq()
37 * failure, unless there is an arch-specific fallback handler. in acpi_gsi_to_irq()
39 if (!*irq && acpi_gsi_to_irq_fallback) in acpi_gsi_to_irq()
40 *irq = acpi_gsi_to_irq_fallback(gsi); in acpi_gsi_to_irq()
42 return (*irq > 0) ? 0 : -EINVAL; in acpi_gsi_to_irq()
47 * acpi_register_gsi() - Map a GSI to a linux IRQ number
48 * @dev: device for which IRQ has to be mapped
49 * @gsi: GSI IRQ number
53 * Returns: a valid linux IRQ number on success
54 * -EINVAL on failure
56 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, in acpi_register_gsi()
60 unsigned int irq; in acpi_register_gsi() local
65 return -EINVAL; in acpi_register_gsi()
72 irq = irq_create_fwspec_mapping(&fwspec); in acpi_register_gsi()
73 if (!irq) in acpi_register_gsi()
74 return -EINVAL; in acpi_register_gsi()
76 return irq; in acpi_register_gsi()
81 * acpi_unregister_gsi() - Free a GSI<->linux IRQ number mapping
82 * @gsi: GSI IRQ number
87 int irq; in acpi_unregister_gsi() local
94 irq = irq_find_mapping(d, gsi); in acpi_unregister_gsi()
95 irq_dispose_mapping(irq); in acpi_unregister_gsi()
100 * acpi_get_irq_source_fwhandle() - Retrieve fwhandle from IRQ resource source.
102 * @gsi: GSI IRQ number
105 * Retrieve the fwhandle of the device referenced by the given IRQ resource
109 * The referenced device fwhandle or NULL on failure
116 struct acpi_device *device; in acpi_get_irq_source_fwhandle() local
120 if (!source->string_length) in acpi_get_irq_source_fwhandle()
123 status = acpi_get_handle(NULL, source->string_ptr, &handle); in acpi_get_irq_source_fwhandle()
127 device = acpi_get_acpi_dev(handle); in acpi_get_irq_source_fwhandle()
128 if (WARN_ON(!device)) in acpi_get_irq_source_fwhandle()
131 result = &device->fwnode; in acpi_get_irq_source_fwhandle()
132 acpi_put_acpi_dev(device); in acpi_get_irq_source_fwhandle()
137 * Context for the resource walk used to lookup IRQ resources.
149 * acpi_irq_parse_one_match - Handle a matching IRQ resource.
151 * @hwirq: hardware IRQ number
160 * Handle a matching IRQ resource by populating the given ctx with
171 ctx->rc = 0; in acpi_irq_parse_one_match()
172 *ctx->res_flags = acpi_dev_irq_flags(triggering, polarity, shareable, wake_capable); in acpi_irq_parse_one_match()
173 ctx->fwspec->fwnode = fwnode; in acpi_irq_parse_one_match()
174 ctx->fwspec->param[0] = hwirq; in acpi_irq_parse_one_match()
175 ctx->fwspec->param[1] = acpi_dev_get_irq_type(triggering, polarity); in acpi_irq_parse_one_match()
176 ctx->fwspec->param_count = 2; in acpi_irq_parse_one_match()
180 * acpi_irq_parse_one_cb - Handle the given resource.
186 * the _CRS method. We only inspect IRQ resources. Since IRQ resources
188 * one's interrupt array, otherwise we subtract the current resource IRQ
195 * IRQ resource was found.
201 struct acpi_resource_irq *irq; in acpi_irq_parse_one_cb() local
205 switch (ares->type) { in acpi_irq_parse_one_cb()
207 irq = &ares->data.irq; in acpi_irq_parse_one_cb()
208 if (ctx->index >= irq->interrupt_count) { in acpi_irq_parse_one_cb()
209 ctx->index -= irq->interrupt_count; in acpi_irq_parse_one_cb()
212 fwnode = acpi_get_gsi_domain_id(irq->interrupts[ctx->index]); in acpi_irq_parse_one_cb()
213 acpi_irq_parse_one_match(fwnode, irq->interrupts[ctx->index], in acpi_irq_parse_one_cb()
214 irq->triggering, irq->polarity, in acpi_irq_parse_one_cb()
215 irq->shareable, irq->wake_capable, ctx); in acpi_irq_parse_one_cb()
218 eirq = &ares->data.extended_irq; in acpi_irq_parse_one_cb()
219 if (eirq->producer_consumer == ACPI_PRODUCER) in acpi_irq_parse_one_cb()
221 if (ctx->index >= eirq->interrupt_count) { in acpi_irq_parse_one_cb()
222 ctx->index -= eirq->interrupt_count; in acpi_irq_parse_one_cb()
225 fwnode = acpi_get_irq_source_fwhandle(&eirq->resource_source, in acpi_irq_parse_one_cb()
226 eirq->interrupts[ctx->index]); in acpi_irq_parse_one_cb()
227 acpi_irq_parse_one_match(fwnode, eirq->interrupts[ctx->index], in acpi_irq_parse_one_cb()
228 eirq->triggering, eirq->polarity, in acpi_irq_parse_one_cb()
229 eirq->shareable, eirq->wake_capable, ctx); in acpi_irq_parse_one_cb()
237 * acpi_irq_parse_one - Resolve an interrupt for a device
238 * @handle: the device whose interrupt is to be resolved
244 * Resolves an interrupt for a device by walking its CRS resources to find
245 * the appropriate ACPI IRQ resource and populating the given struct irq_fwspec
249 * The result stored in ctx.rc by the callback, or the default -EINVAL value
255 struct acpi_irq_parse_one_ctx ctx = { -EINVAL, index, flags, fwspec }; in acpi_irq_parse_one()
262 * acpi_irq_get - Lookup an ACPI IRQ resource and use it to initialize resource.
263 * @handle: ACPI device handle
264 * @index: ACPI IRQ resource index to lookup
265 * @res: Linux IRQ resource to initialize
268 * Look for the ACPI IRQ resource with the given index and use it to initialize
269 * the given Linux IRQ resource.
273 * -EINVAL if an error occurs
274 * -EPROBE_DEFER if the IRQ lookup/conversion failed
289 return -EPROBE_DEFER; in acpi_irq_get()
293 return -EINVAL; in acpi_irq_get()
295 res->start = rc; in acpi_irq_get()
296 res->end = rc; in acpi_irq_get()
297 res->flags = flags; in acpi_irq_get()
304 * acpi_set_irq_model - Setup the GSI irqdomain information
317 * acpi_set_gsi_to_irq_fallback - Register a GSI transfer
319 * @fn: arch-specific fallback handler
327 * acpi_irq_create_hierarchy - Create a hierarchical IRQ domain with the default
329 * @flags: Irq domain flags associated with the domain