Lines Matching +full:msi +full:- +full:parent

1 // SPDX-License-Identifier: GPL-2.0
3 * AMD CDX bus driver MSI support
5 * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
14 #include <linux/msi.h>
22 struct cdx_device *cdx_dev = to_cdx_device(msi_desc->dev); in cdx_msi_write_msg()
27 msi_desc->msg = *msg; in cdx_msi_write_msg()
28 cdx_dev->msi_write_pending = true; in cdx_msi_write_msg()
34 struct cdx_device *cdx_dev = to_cdx_device(msi_desc->dev); in cdx_msi_write_irq_lock()
36 mutex_lock(&cdx_dev->irqchip_lock); in cdx_msi_write_irq_lock()
42 struct cdx_device *cdx_dev = to_cdx_device(msi_desc->dev); in cdx_msi_write_irq_unlock()
43 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_msi_write_irq_unlock()
46 if (!cdx_dev->msi_write_pending) { in cdx_msi_write_irq_unlock()
47 mutex_unlock(&cdx_dev->irqchip_lock); in cdx_msi_write_irq_unlock()
51 cdx_dev->msi_write_pending = false; in cdx_msi_write_irq_unlock()
52 mutex_unlock(&cdx_dev->irqchip_lock); in cdx_msi_write_irq_unlock()
54 dev_config.msi.msi_index = msi_desc->msi_index; in cdx_msi_write_irq_unlock()
55 dev_config.msi.data = msi_desc->msg.data; in cdx_msi_write_irq_unlock()
56 dev_config.msi.addr = ((u64)(msi_desc->msg.address_hi) << 32) | msi_desc->msg.address_lo; in cdx_msi_write_irq_unlock()
64 if (cdx->ops->dev_configure) in cdx_msi_write_irq_unlock()
65 cdx->ops->dev_configure(cdx, cdx_dev->bus_num, cdx_dev->dev_num, &dev_config); in cdx_msi_write_irq_unlock()
70 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_enable_msi()
75 if (cdx->ops->dev_configure) { in cdx_enable_msi()
76 return cdx->ops->dev_configure(cdx, cdx_dev->bus_num, cdx_dev->dev_num, in cdx_enable_msi()
80 return -EOPNOTSUPP; in cdx_enable_msi()
86 struct cdx_controller *cdx = cdx_dev->cdx; in cdx_disable_msi()
91 if (cdx->ops->dev_configure) in cdx_disable_msi()
92 cdx->ops->dev_configure(cdx, cdx_dev->bus_num, cdx_dev->dev_num, &dev_config); in cdx_disable_msi()
97 .name = "CDX-MSI",
111 return ((irq_hw_number_t)dev->msi_dev_id << 10) | desc->msi_index; in cdx_domain_calc_hwirq()
116 arg->desc = desc; in cdx_msi_set_desc()
117 arg->hwirq = cdx_domain_calc_hwirq(to_cdx_device(desc->dev), desc); in cdx_msi_set_desc()
125 struct device *parent = cdx_dev->cdx->dev; in cdx_msi_prepare() local
130 /* Retrieve device ID from requestor ID using parent device */ in cdx_msi_prepare()
131 ret = of_map_id(parent->of_node, cdx_dev->msi_dev_id, "msi-map", "msi-map-mask", in cdx_msi_prepare()
134 dev_err(dev, "of_map_id failed for MSI: %d\n", ret); in cdx_msi_prepare()
139 /* Set the device Id to be passed to the GIC-ITS */ in cdx_msi_prepare()
140 info->scratchpad[0].ul = dev_id; in cdx_msi_prepare()
143 msi_info = msi_get_domain_info(msi_domain->parent); in cdx_msi_prepare()
145 return msi_info->ops->msi_prepare(msi_domain->parent, dev, nvec, info); in cdx_msi_prepare()
162 struct device_node *np = dev->of_node; in cdx_msi_domain_init()
166 struct irq_domain *parent; in cdx_msi_domain_init() local
170 parent_node = of_parse_phandle(np, "msi-map", 1); in cdx_msi_domain_init()
172 dev_err(dev, "msi-map not present on cdx controller\n"); in cdx_msi_domain_init()
176 parent = irq_find_matching_fwnode(of_node_to_fwnode(parent_node), DOMAIN_BUS_NEXUS); in cdx_msi_domain_init()
177 if (!parent || !msi_get_domain_info(parent)) { in cdx_msi_domain_init()
182 cdx_msi_domain = msi_create_irq_domain(fwnode_handle, &cdx_msi_domain_info, parent); in cdx_msi_domain_init()
184 dev_err(dev, "unable to create CDX-MSI domain\n"); in cdx_msi_domain_init()
188 dev_dbg(dev, "CDX-MSI domain created\n"); in cdx_msi_domain_init()