Lines Matching +full:interrupt +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 1995-1996 Gary Thomas ([email protected])
8 * Copyright (C) 1996-2001 Cort Dougan
13 * device tree to actual irq numbers on an interrupt controller
32 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space
33 * @dev: Device node of the device whose interrupt is to be mapped
34 * @index: Index of the interrupt to map
55 * of_irq_find_parent - Given a device node, find its interrupt parent node
58 * Return: A pointer to the interrupt parent node, or NULL if the interrupt
70 if (of_property_read_u32(child, "interrupt-parent", &parent)) { in of_irq_find_parent()
80 } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); in of_irq_find_parent()
87 * These interrupt controllers abuse interrupt-map for unspeakable
90 * non-sensical interrupt-map that is better left ignored.
97 "CBEA,platform-spider-pic",
98 "sti,platform-spider-pic",
99 "realtek,rtl-intc",
100 "fsl,ls1021a-extirq",
101 "fsl,ls1043a-extirq",
102 "fsl,ls1088a-extirq",
103 "renesas,rza1-irqc",
113 /* Get the interrupt parent */ in of_irq_parse_imap_parent()
119 len--; in of_irq_parse_imap_parent()
123 pr_debug(" -> imap parent not found !\n"); in of_irq_parse_imap_parent()
127 /* Get #interrupt-cells and #address-cells of new parent */ in of_irq_parse_imap_parent()
128 if (of_property_read_u32(np, "#interrupt-cells", in of_irq_parse_imap_parent()
130 pr_debug(" -> parent lacks #interrupt-cells!\n"); in of_irq_parse_imap_parent()
134 if (of_property_read_u32(np, "#address-cells", in of_irq_parse_imap_parent()
138 pr_debug(" -> intsize=%d, addrsize=%d\n", in of_irq_parse_imap_parent()
148 pr_debug(" -> imaplen=%d\n", len); in of_irq_parse_imap_parent()
152 out_irq->np = np; in of_irq_parse_imap_parent()
154 out_irq->args[i] = be32_to_cpup(imap - intsize + i); in of_irq_parse_imap_parent()
155 out_irq->args_count = intsize; in of_irq_parse_imap_parent()
161 * of_irq_parse_raw - Low level interrupt tree parsing
165 * This function is a low-level interrupt tree walking function. It
168 * node exist for the parent. It takes an interrupt specifier structure as
169 * input, walks the tree looking for any interrupt-map properties, translates
170 * the specifier for each map, and then returns the translated map.
174 * Note: refcount of node @out_irq->np is increased by 1 on success.
181 const __be32 *tmp, dummy_imask[] = { [0 ... (MAX_PHANDLE_ARGS - 1)] = cpu_to_be32(~0) }; in of_irq_parse_raw()
183 int i, rc = -EINVAL; in of_irq_parse_raw()
189 ipar = of_node_get(out_irq->np); in of_irq_parse_raw()
191 /* First get the #interrupt-cells property of the current cursor in of_irq_parse_raw()
192 * that tells us how to interpret the passed-in intspec. If there in of_irq_parse_raw()
196 if (!of_property_read_u32(ipar, "#interrupt-cells", &intsize)) in of_irq_parse_raw()
203 pr_debug(" -> no parent found !\n"); in of_irq_parse_raw()
209 if (out_irq->args_count != intsize) in of_irq_parse_raw()
212 /* Look for this #address-cells. We have to implement the old linux in of_irq_parse_raw()
213 * trick of looking for the parent here as some device-trees rely on it in of_irq_parse_raw()
217 tmp = of_get_property(old, "#address-cells", NULL); in of_irq_parse_raw()
226 pr_debug(" -> addrsize=%d\n", addrsize); in of_irq_parse_raw()
230 rc = -EFAULT; in of_irq_parse_raw()
234 /* Precalculate the match array - this simplifies match loop */ in of_irq_parse_raw()
238 initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]); in of_irq_parse_raw()
240 /* Now start the actual "proper" walk of the interrupt tree */ in of_irq_parse_raw()
246 * Now check if cursor is an interrupt-controller and in of_irq_parse_raw()
248 * interrupt-map which takes precedence except on one in of_irq_parse_raw()
250 * interrupt-map themselves for $reason. in of_irq_parse_raw()
252 bool intc = of_property_read_bool(ipar, "interrupt-controller"); in of_irq_parse_raw()
254 imap = of_get_property(ipar, "interrupt-map", &imaplen); in of_irq_parse_raw()
257 pr_debug(" -> got it !\n"); in of_irq_parse_raw()
262 * interrupt-map parsing does not work without a reg in of_irq_parse_raw()
263 * property when #address-cells != 0 in of_irq_parse_raw()
266 pr_debug(" -> no reg passed in when needed !\n"); in of_irq_parse_raw()
270 /* No interrupt map, check for an interrupt parent */ in of_irq_parse_raw()
272 pr_debug(" -> no map, getting parent\n"); in of_irq_parse_raw()
279 imask = of_get_property(ipar, "interrupt-map-mask", NULL); in of_irq_parse_raw()
283 /* Parse interrupt-map */ in of_irq_parse_raw()
288 for (i = 0; i < (addrsize + intsize); i++, imaplen--) in of_irq_parse_raw()
291 pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); in of_irq_parse_raw()
298 match &= of_device_is_available(out_irq->np); in of_irq_parse_raw()
302 of_node_put(out_irq->np); in of_irq_parse_raw()
303 imaplen -= imap - oldimap; in of_irq_parse_raw()
304 pr_debug(" -> imaplen=%d\n", imaplen); in of_irq_parse_raw()
310 * Successfully parsed an interrupt-map translation; copy new in of_irq_parse_raw()
311 * interrupt specifier into the out_irq structure in of_irq_parse_raw()
315 newpar = out_irq->np; in of_irq_parse_raw()
316 intsize = out_irq->args_count; in of_irq_parse_raw()
317 addrsize = (imap - match_array) - intsize; in of_irq_parse_raw()
326 pr_debug("%pOF interrupt-map entry to self\n", ipar); in of_irq_parse_raw()
332 pr_debug(" -> new parent: %pOF\n", newpar); in of_irq_parse_raw()
337 rc = -ENOENT; /* No interrupt-map found */ in of_irq_parse_raw()
347 * of_irq_parse_one - Resolve an interrupt for a device
348 * @device: the device whose interrupt is to be resolved
349 * @index: index of the interrupt to resolve
352 * This function resolves an interrupt for a node by walking the interrupt tree,
353 * finding which interrupt controller node it is attached to, and returning the
354 * interrupt specifier that can be used to retrieve a Linux IRQ number.
356 * Note: refcount of node @out_irq->np is increased by 1 on success.
376 /* Prevent out-of-bounds read in case of longer interrupt parent address size */ in of_irq_parse_one()
382 /* Try the new-style interrupts-extended first */ in of_irq_parse_one()
383 res = of_parse_phandle_with_args(device, "interrupts-extended", in of_irq_parse_one()
384 "#interrupt-cells", index, out_irq); in of_irq_parse_one()
386 p = out_irq->np; in of_irq_parse_one()
388 /* Look for the interrupt parent. */ in of_irq_parse_one()
390 /* Get size of interrupt specifier */ in of_irq_parse_one()
391 if (!p || of_property_read_u32(p, "#interrupt-cells", &intsize)) in of_irq_parse_one()
392 return -EINVAL; in of_irq_parse_one()
397 out_irq->np = p; in of_irq_parse_one()
398 out_irq->args_count = intsize; in of_irq_parse_one()
402 out_irq->args + i); in of_irq_parse_one()
407 pr_debug(" intspec=%d\n", *out_irq->args); in of_irq_parse_one()
410 /* Check if there are any interrupt-map translations to process */ in of_irq_parse_one()
416 * of_irq_to_resource - Decode a node's IRQ and return it as a resource
418 * @index: zero-based index of the irq
435 * Get optional "interrupt-names" property to add a name in of_irq_to_resource()
438 of_property_read_string_index(dev, "interrupt-names", index, in of_irq_to_resource()
442 r->flags |= irq_get_trigger_type(irq); in of_irq_to_resource()
450 * of_irq_get - Decode a node's IRQ and return it as a Linux IRQ number
452 * @index: zero-based index of the IRQ
455 * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
470 rc = -EPROBE_DEFER; in of_irq_get()
483 * of_irq_get_byname - Decode a node's IRQ and return it as a Linux IRQ number
488 * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
496 return -EINVAL; in of_irq_get_byname()
498 index = of_property_match_string(dev, "interrupt-names", name); in of_irq_get_byname()
507 * of_irq_count - Count the number of IRQs a node uses
524 * of_irq_to_resource_table - Fill in resource table with node's IRQ info
552 * of_irq_init - Scan and init matching interrupt controllers in DT
555 * This function scans the device tree for matching interrupt controller nodes,
569 if (!of_property_read_bool(np, "interrupt-controller") || in of_irq_init()
573 if (WARN(!match->data, "of_irq_init: no init function for %s\n", in of_irq_init()
574 match->compatible)) in of_irq_init()
579 * pointer, interrupt-parent device_node etc. in of_irq_init()
587 desc->irq_init_cb = match->data; in of_irq_init()
588 desc->dev = of_node_get(np); in of_irq_init()
590 * interrupts-extended can reference multiple parent domains. in of_irq_init()
594 desc->interrupt_parent = of_parse_phandle(np, "interrupts-extended", 0); in of_irq_init()
595 if (!desc->interrupt_parent) in of_irq_init()
596 desc->interrupt_parent = of_irq_find_parent(np); in of_irq_init()
597 if (desc->interrupt_parent == np) { in of_irq_init()
598 of_node_put(desc->interrupt_parent); in of_irq_init()
599 desc->interrupt_parent = NULL; in of_irq_init()
601 list_add_tail(&desc->list, &intc_desc_list); in of_irq_init()
605 * The root irq controller is the one without an interrupt-parent. in of_irq_init()
618 if (desc->interrupt_parent != parent) in of_irq_init()
621 list_del(&desc->list); in of_irq_init()
623 of_node_set_flag(desc->dev, OF_POPULATED); in of_irq_init()
626 desc->dev, in of_irq_init()
627 desc->dev, desc->interrupt_parent); in of_irq_init()
628 ret = desc->irq_init_cb(desc->dev, in of_irq_init()
629 desc->interrupt_parent); in of_irq_init()
632 __func__, desc->dev, desc->dev, in of_irq_init()
633 desc->interrupt_parent); in of_irq_init()
634 of_node_clear_flag(desc->dev, OF_POPULATED); in of_irq_init()
635 of_node_put(desc->interrupt_parent); in of_irq_init()
636 of_node_put(desc->dev); in of_irq_init()
645 list_add_tail(&desc->list, &intc_parent_list); in of_irq_init()
655 list_del(&desc->list); in of_irq_init()
656 parent = desc->dev; in of_irq_init()
661 list_del(&desc->list); in of_irq_init()
666 list_del(&desc->list); in of_irq_init()
667 of_node_put(desc->interrupt_parent); in of_irq_init()
668 of_node_put(desc->dev); in of_irq_init()
681 * "msi-map" property. in __of_msi_map_id()
683 for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent) in __of_msi_map_id()
684 if (!of_map_id(parent_dev->of_node, id_in, "msi-map", in __of_msi_map_id()
685 "msi-map-mask", np, &id_out)) in __of_msi_map_id()
691 * of_msi_map_id - Map a MSI ID for a device.
696 * Walk up the device hierarchy looking for devices with a "msi-map"
707 * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain
712 * Walk up the device hierarchy looking for devices with a "msi-map"
727 * of_msi_get_domain - Use msi-parent to find the relevant MSI domain
732 * Parse the msi-parent property and returns the corresponding MSI domain.
744 of_for_each_phandle(&it, err, np, "msi-parent", "#msi-cells", 0) { in of_msi_get_domain()
755 * of_msi_configure - Set the msi_domain field of a device