^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Derived from arch/i386/kernel/irq.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 1992 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Adapted from arch/i386 by Gary Thomas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Updated and modified by Cort Dougan <cort@fsmlabs.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 1996-2001 Cort Dougan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Adapted for Power Macintosh by Paul Mackerras
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This file contains the code used to make IRQ descriptions in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * device tree to actual irq numbers on an interrupt controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define pr_fmt(fmt) "OF: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/of_irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * irq_of_parse_and_map - Parse and map an interrupt into linux virq space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @dev: Device node of the device whose interrupt is to be mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @index: Index of the interrupt to map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * This function is a wrapper that chains of_irq_parse_one() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * irq_create_of_mapping() to make things easier to callers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct of_phandle_args oirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (of_irq_parse_one(dev, index, &oirq))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return irq_create_of_mapping(&oirq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * of_irq_find_parent - Given a device node, find its interrupt parent node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @child: pointer to device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Returns a pointer to the interrupt parent node, or NULL if the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * parent could not be determined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct device_node *of_irq_find_parent(struct device_node *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct device_node *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) phandle parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (!of_node_get(child))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (of_property_read_u32(child, "interrupt-parent", &parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) p = of_get_parent(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) p = of_node_get(of_irq_dflt_pic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) p = of_find_node_by_phandle(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) of_node_put(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) child = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) EXPORT_SYMBOL_GPL(of_irq_find_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * of_irq_parse_raw - Low level interrupt tree parsing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * @addr: address specifier (start of "reg" property of the device) in be32 format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @out_irq: structure of_phandle_args updated by this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Returns 0 on success and a negative number on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * This function is a low-level interrupt tree walking function. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * can be used to do a partial walk with synthetized reg and interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * properties, for example when resolving PCI interrupts when no device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * node exist for the parent. It takes an interrupt specifier structure as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * input, walks the tree looking for any interrupt-map properties, translates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * the specifier for each map, and then returns the translated map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __be32 initial_match_array[MAX_PHANDLE_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) const __be32 *match_array = initial_match_array;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int imaplen, match, i, rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) of_print_phandle_args("of_irq_parse_raw: ", out_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ipar = of_node_get(out_irq->np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* First get the #interrupt-cells property of the current cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * that tells us how to interpret the passed-in intspec. If there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * is none, we are nice and just walk up the tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (!of_property_read_u32(ipar, "#interrupt-cells", &intsize))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) tnode = ipar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ipar = of_irq_find_parent(ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) of_node_put(tnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) } while (ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (ipar == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) pr_debug(" -> no parent found !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) pr_debug("of_irq_parse_raw: ipar=%pOF, size=%d\n", ipar, intsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (out_irq->args_count != intsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* Look for this #address-cells. We have to implement the old linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * trick of looking for the parent here as some device-trees rely on it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) old = of_node_get(ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) tmp = of_get_property(old, "#address-cells", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) tnode = of_get_parent(old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) of_node_put(old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) old = tnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) } while (old && tmp == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) of_node_put(old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) old = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) addrsize = (tmp == NULL) ? 2 : be32_to_cpu(*tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) pr_debug(" -> addrsize=%d\n", addrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Range check so that the temporary buffer doesn't overflow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (WARN_ON(addrsize + intsize > MAX_PHANDLE_ARGS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Precalculate the match array - this simplifies match loop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) for (i = 0; i < addrsize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) initial_match_array[i] = addr ? addr[i] : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) for (i = 0; i < intsize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* Now start the actual "proper" walk of the interrupt tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) while (ipar != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* Now check if cursor is an interrupt-controller and if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * then we are done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (of_property_read_bool(ipar, "interrupt-controller")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) pr_debug(" -> got it !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * interrupt-map parsing does not work without a reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * property when #address-cells != 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (addrsize && !addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) pr_debug(" -> no reg passed in when needed !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* Now look for an interrupt-map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) imap = of_get_property(ipar, "interrupt-map", &imaplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* No interrupt map, check for an interrupt parent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (imap == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) pr_debug(" -> no map, getting parent\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) newpar = of_irq_find_parent(ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) goto skiplevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) imaplen /= sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /* Look for a mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) imask = of_get_property(ipar, "interrupt-map-mask", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (!imask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) imask = dummy_imask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Parse interrupt-map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) match = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) while (imaplen > (addrsize + intsize + 1) && !match) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* Compare specifiers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) match = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) for (i = 0; i < (addrsize + intsize); i++, imaplen--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) match &= !((match_array[i] ^ *imap++) & imask[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /* Get the interrupt parent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) newpar = of_node_get(of_irq_dflt_pic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) newpar = of_find_node_by_phandle(be32_to_cpup(imap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) imap++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) --imaplen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* Check if not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (newpar == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pr_debug(" -> imap parent not found !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (!of_device_is_available(newpar))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) match = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* Get #interrupt-cells and #address-cells of new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (of_property_read_u32(newpar, "#interrupt-cells",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) &newintsize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) pr_debug(" -> parent lacks #interrupt-cells!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (of_property_read_u32(newpar, "#address-cells",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) &newaddrsize))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) newaddrsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) pr_debug(" -> newintsize=%d, newaddrsize=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) newintsize, newaddrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /* Check for malformed properties */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (WARN_ON(newaddrsize + newintsize > MAX_PHANDLE_ARGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) || (imaplen < (newaddrsize + newintsize))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) imap += newaddrsize + newintsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) imaplen -= newaddrsize + newintsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) pr_debug(" -> imaplen=%d\n", imaplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (!match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * Successfully parsed an interrrupt-map translation; copy new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * interrupt specifier into the out_irq structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) match_array = imap - newaddrsize - newintsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) for (i = 0; i < newintsize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) out_irq->args[i] = be32_to_cpup(imap - newintsize + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) out_irq->args_count = intsize = newintsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) addrsize = newaddrsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) skiplevel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) /* Iterate again with new parent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) out_irq->np = newpar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) pr_debug(" -> new parent: %pOF\n", newpar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) of_node_put(ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ipar = newpar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) newpar = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) rc = -ENOENT; /* No interrupt-map found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) of_node_put(ipar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) of_node_put(newpar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) EXPORT_SYMBOL_GPL(of_irq_parse_raw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * of_irq_parse_one - Resolve an interrupt for a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * @device: the device whose interrupt is to be resolved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * @index: index of the interrupt to resolve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * @out_irq: structure of_phandle_args filled by this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * This function resolves an interrupt for a node by walking the interrupt tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * finding which interrupt controller node it is attached to, and returning the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * interrupt specifier that can be used to retrieve a Linux IRQ number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct device_node *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) const __be32 *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) u32 intsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) int i, res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) pr_debug("of_irq_parse_one: dev=%pOF, index=%d\n", device, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /* OldWorld mac stuff is "special", handle out of line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return of_irq_parse_oldworld(device, index, out_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Get the reg property (if any) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) addr = of_get_property(device, "reg", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /* Try the new-style interrupts-extended first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) res = of_parse_phandle_with_args(device, "interrupts-extended",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) "#interrupt-cells", index, out_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) if (!res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) return of_irq_parse_raw(addr, out_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* Look for the interrupt parent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) p = of_irq_find_parent(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (p == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /* Get size of interrupt specifier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) if (of_property_read_u32(p, "#interrupt-cells", &intsize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) res = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) pr_debug(" parent=%pOF, intsize=%d\n", p, intsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* Copy intspec into irq structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) out_irq->np = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) out_irq->args_count = intsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) for (i = 0; i < intsize; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) res = of_property_read_u32_index(device, "interrupts",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) (index * intsize) + i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) out_irq->args + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) pr_debug(" intspec=%d\n", *out_irq->args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /* Check if there are any interrupt-map translations to process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) res = of_irq_parse_raw(addr, out_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) of_node_put(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) EXPORT_SYMBOL_GPL(of_irq_parse_one);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * of_irq_to_resource - Decode a node's IRQ and return it as a resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * @dev: pointer to device tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * @index: zero-based index of the irq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * @r: pointer to resource structure to return result into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) int irq = of_irq_get(dev, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (irq < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /* Only dereference the resource if both the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * resource and the irq are valid. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (r && irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) const char *name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) memset(r, 0, sizeof(*r));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * Get optional "interrupt-names" property to add a name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * to the resource.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) of_property_read_string_index(dev, "interrupt-names", index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) r->start = r->end = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) r->flags = IORESOURCE_IRQ | irqd_get_trigger_type(irq_get_irq_data(irq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) r->name = name ? name : of_node_full_name(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) EXPORT_SYMBOL_GPL(of_irq_to_resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * of_irq_get - Decode a node's IRQ and return it as a Linux IRQ number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * @dev: pointer to device tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * @index: zero-based index of the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * of any other failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) int of_irq_get(struct device_node *dev, int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct of_phandle_args oirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) struct irq_domain *domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) rc = of_irq_parse_one(dev, index, &oirq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) domain = irq_find_host(oirq.np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (!domain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) return -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return irq_create_of_mapping(&oirq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) EXPORT_SYMBOL_GPL(of_irq_get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * of_irq_get_byname - Decode a node's IRQ and return it as a Linux IRQ number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * @dev: pointer to device tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * @name: IRQ name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * of any other failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) int of_irq_get_byname(struct device_node *dev, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (unlikely(!name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) index = of_property_match_string(dev, "interrupt-names", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (index < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) return index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return of_irq_get(dev, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) EXPORT_SYMBOL_GPL(of_irq_get_byname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * of_irq_count - Count the number of IRQs a node uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * @dev: pointer to device tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) int of_irq_count(struct device_node *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct of_phandle_args irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) int nr = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) while (of_irq_parse_one(dev, nr, &irq) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) nr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * of_irq_to_resource_table - Fill in resource table with node's IRQ info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) * @dev: pointer to device tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) * @res: array of resources to fill in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) * @nr_irqs: the number of IRQs (and upper bound for num of @res elements)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * Returns the size of the filled in table (up to @nr_irqs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) int of_irq_to_resource_table(struct device_node *dev, struct resource *res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) int nr_irqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) for (i = 0; i < nr_irqs; i++, res++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) if (of_irq_to_resource(dev, i, res) <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) EXPORT_SYMBOL_GPL(of_irq_to_resource_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct of_intc_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) of_irq_init_cb_t irq_init_cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct device_node *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct device_node *interrupt_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * of_irq_init - Scan and init matching interrupt controllers in DT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * @matches: 0 terminated array of nodes to match and init function to call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * This function scans the device tree for matching interrupt controller nodes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * and calls their initialization functions in order with parents first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) void __init of_irq_init(const struct of_device_id *matches)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) const struct of_device_id *match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct device_node *np, *parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) struct of_intc_desc *desc, *temp_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) struct list_head intc_desc_list, intc_parent_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) INIT_LIST_HEAD(&intc_desc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) INIT_LIST_HEAD(&intc_parent_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) for_each_matching_node_and_match(np, matches, &match) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (!of_property_read_bool(np, "interrupt-controller") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) !of_device_is_available(np))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if (WARN(!match->data, "of_irq_init: no init function for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) match->compatible))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * Here, we allocate and populate an of_intc_desc with the node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * pointer, interrupt-parent device_node etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) desc = kzalloc(sizeof(*desc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) if (!desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) desc->irq_init_cb = match->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) desc->dev = of_node_get(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) desc->interrupt_parent = of_irq_find_parent(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (desc->interrupt_parent == np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) desc->interrupt_parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) list_add_tail(&desc->list, &intc_desc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) * The root irq controller is the one without an interrupt-parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * That one goes first, followed by the controllers that reference it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * followed by the ones that reference the 2nd level controllers, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) while (!list_empty(&intc_desc_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * Process all controllers with the current 'parent'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * First pass will be looking for NULL as the parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * The assumption is that NULL parent means a root controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (desc->interrupt_parent != parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) list_del(&desc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) of_node_set_flag(desc->dev, OF_POPULATED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) pr_debug("of_irq_init: init %pOF (%p), parent %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) desc->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) desc->dev, desc->interrupt_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) ret = desc->irq_init_cb(desc->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) desc->interrupt_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) of_node_clear_flag(desc->dev, OF_POPULATED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) kfree(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * This one is now set up; add it to the parent list so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * its children can get processed in a subsequent pass.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) list_add_tail(&desc->list, &intc_parent_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) /* Get the next pending parent that might have children */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) desc = list_first_entry_or_null(&intc_parent_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) typeof(*desc), list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) if (!desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) pr_err("of_irq_init: children remain, but no parents\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) list_del(&desc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) parent = desc->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) kfree(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) list_del(&desc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) kfree(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) list_del(&desc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) of_node_put(desc->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) kfree(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) static u32 __of_msi_map_id(struct device *dev, struct device_node **np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) u32 id_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct device *parent_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) u32 id_out = id_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * Walk up the device parent links looking for one with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * "msi-map" property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) if (!of_map_id(parent_dev->of_node, id_in, "msi-map",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) "msi-map-mask", np, &id_out))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) return id_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) * of_msi_map_id - Map a MSI ID for a device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * @dev: device for which the mapping is to be done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * @msi_np: device node of the expected msi controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * @id_in: unmapped MSI ID for the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * Walk up the device hierarchy looking for devices with a "msi-map"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * property. If found, apply the mapping to @id_in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * Returns the mapped MSI ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) u32 of_msi_map_id(struct device *dev, struct device_node *msi_np, u32 id_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return __of_msi_map_id(dev, &msi_np, id_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * @dev: device for which the mapping is to be done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * @id: Device ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * @bus_token: Bus token
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) * Walk up the device hierarchy looking for devices with a "msi-map"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) * Returns: the MSI domain for this device (or NULL on failure)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) u32 bus_token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) struct device_node *np = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) __of_msi_map_id(dev, &np, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return irq_find_matching_host(np, bus_token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) * of_msi_get_domain - Use msi-parent to find the relevant MSI domain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) * @dev: device for which the domain is requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) * @np: device node for @dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) * @token: bus type for this domain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) * Parse the msi-parent property (both the simple and the complex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) * versions), and returns the corresponding MSI domain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) * Returns: the MSI domain for this device (or NULL on failure).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) struct irq_domain *of_msi_get_domain(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) enum irq_domain_bus_token token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) struct device_node *msi_np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) struct irq_domain *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) /* Check for a single msi-parent property */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) msi_np = of_parse_phandle(np, "msi-parent", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) d = irq_find_matching_host(msi_np, token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (!d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) of_node_put(msi_np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) return d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) if (token == DOMAIN_BUS_PLATFORM_MSI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /* Check for the complex msi-parent version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) struct of_phandle_args args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) int index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) while (!of_parse_phandle_with_args(np, "msi-parent",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) "#msi-cells",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) index, &args)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) d = irq_find_matching_host(args.np, token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) if (d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) return d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) of_node_put(args.np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) * of_msi_configure - Set the msi_domain field of a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) * @dev: device structure to associate with an MSI irq domain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) * @np: device node for that device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) void of_msi_configure(struct device *dev, struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) dev_set_msi_domain(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) of_msi_get_domain(dev, np, DOMAIN_BUS_PLATFORM_MSI));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) EXPORT_SYMBOL_GPL(of_msi_configure);