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>
18 * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
19 * @gsi: GSI IRQ number to map
20 * @irq: pointer where linux IRQ number is stored
22 * irq location updated with irq value [>0 on success, 0 on failure]
25 * -EINVAL on failure
27 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) in acpi_gsi_to_irq() argument
32 *irq = irq_find_mapping(d, gsi); in acpi_gsi_to_irq()
34 * *irq == 0 means no mapping, that should in acpi_gsi_to_irq()
37 return (*irq > 0) ? 0 : -EINVAL; in acpi_gsi_to_irq()
42 * acpi_register_gsi() - Map a GSI to a linux IRQ number
43 * @dev: device for which IRQ has to be mapped
44 * @gsi: GSI IRQ number
48 * Returns: a valid linux IRQ number on success
49 * -EINVAL on failure
51 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, in acpi_register_gsi()
55 unsigned int irq; in acpi_register_gsi() local
59 return -EINVAL; in acpi_register_gsi()
67 irq = irq_create_fwspec_mapping(&fwspec); in acpi_register_gsi()
68 if (!irq) in acpi_register_gsi()
69 return -EINVAL; in acpi_register_gsi()
71 return irq; in acpi_register_gsi()
76 * acpi_unregister_gsi() - Free a GSI<->linux IRQ number mapping
77 * @gsi: GSI IRQ number
83 int irq = irq_find_mapping(d, gsi); in acpi_unregister_gsi() local
85 irq_dispose_mapping(irq); in acpi_unregister_gsi()
90 * acpi_get_irq_source_fwhandle() - Retrieve fwhandle from IRQ resource source.
94 * Retrieve the fwhandle of the device referenced by the given IRQ resource
98 * The referenced device fwhandle or NULL on failure
104 struct acpi_device *device; in acpi_get_irq_source_fwhandle() local
108 if (!source->string_length) in acpi_get_irq_source_fwhandle()
111 status = acpi_get_handle(NULL, source->string_ptr, &handle); in acpi_get_irq_source_fwhandle()
115 device = acpi_bus_get_acpi_device(handle); in acpi_get_irq_source_fwhandle()
116 if (WARN_ON(!device)) in acpi_get_irq_source_fwhandle()
119 result = &device->fwnode; in acpi_get_irq_source_fwhandle()
120 acpi_bus_put_acpi_device(device); in acpi_get_irq_source_fwhandle()
125 * Context for the resource walk used to lookup IRQ resources.
137 * acpi_irq_parse_one_match - Handle a matching IRQ resource.
139 * @hwirq: hardware IRQ number
147 * Handle a matching IRQ resource by populating the given ctx with
157 ctx->rc = 0; in acpi_irq_parse_one_match()
158 *ctx->res_flags = acpi_dev_irq_flags(triggering, polarity, shareable); in acpi_irq_parse_one_match()
159 ctx->fwspec->fwnode = fwnode; in acpi_irq_parse_one_match()
160 ctx->fwspec->param[0] = hwirq; in acpi_irq_parse_one_match()
161 ctx->fwspec->param[1] = acpi_dev_get_irq_type(triggering, polarity); in acpi_irq_parse_one_match()
162 ctx->fwspec->param_count = 2; in acpi_irq_parse_one_match()
166 * acpi_irq_parse_one_cb - Handle the given resource.
172 * the _CRS method. We only inspect IRQ resources. Since IRQ resources
174 * one's interrupt array, otherwise we subtract the current resource IRQ
181 * IRQ resource was found.
187 struct acpi_resource_irq *irq; in acpi_irq_parse_one_cb() local
191 switch (ares->type) { in acpi_irq_parse_one_cb()
193 irq = &ares->data.irq; in acpi_irq_parse_one_cb()
194 if (ctx->index >= irq->interrupt_count) { in acpi_irq_parse_one_cb()
195 ctx->index -= irq->interrupt_count; in acpi_irq_parse_one_cb()
199 acpi_irq_parse_one_match(fwnode, irq->interrupts[ctx->index], in acpi_irq_parse_one_cb()
200 irq->triggering, irq->polarity, in acpi_irq_parse_one_cb()
201 irq->shareable, ctx); in acpi_irq_parse_one_cb()
204 eirq = &ares->data.extended_irq; in acpi_irq_parse_one_cb()
205 if (eirq->producer_consumer == ACPI_PRODUCER) in acpi_irq_parse_one_cb()
207 if (ctx->index >= eirq->interrupt_count) { in acpi_irq_parse_one_cb()
208 ctx->index -= eirq->interrupt_count; in acpi_irq_parse_one_cb()
211 fwnode = acpi_get_irq_source_fwhandle(&eirq->resource_source); in acpi_irq_parse_one_cb()
212 acpi_irq_parse_one_match(fwnode, eirq->interrupts[ctx->index], in acpi_irq_parse_one_cb()
213 eirq->triggering, eirq->polarity, in acpi_irq_parse_one_cb()
214 eirq->shareable, ctx); in acpi_irq_parse_one_cb()
222 * acpi_irq_parse_one - Resolve an interrupt for a device
223 * @handle: the device whose interrupt is to be resolved
229 * Resolves an interrupt for a device by walking its CRS resources to find
230 * the appropriate ACPI IRQ resource and populating the given struct irq_fwspec
234 * The result stored in ctx.rc by the callback, or the default -EINVAL value
240 struct acpi_irq_parse_one_ctx ctx = { -EINVAL, index, flags, fwspec }; in acpi_irq_parse_one()
247 * acpi_irq_get - Lookup an ACPI IRQ resource and use it to initialize resource.
248 * @handle: ACPI device handle
249 * @index: ACPI IRQ resource index to lookup
250 * @res: Linux IRQ resource to initialize
253 * Look for the ACPI IRQ resource with the given index and use it to initialize
254 * the given Linux IRQ resource.
258 * -EINVAL if an error occurs
259 * -EPROBE_DEFER if the IRQ lookup/conversion failed
274 return -EPROBE_DEFER; in acpi_irq_get()
278 return -EINVAL; in acpi_irq_get()
280 res->start = rc; in acpi_irq_get()
281 res->end = rc; in acpi_irq_get()
282 res->flags = flags; in acpi_irq_get()
289 * acpi_set_irq_model - Setup the GSI irqdomain information
302 * acpi_irq_create_hierarchy - Create a hierarchical IRQ domain with the default
304 * @flags: Irq domain flags associated with the domain