| .. | .. |
|---|
| 13 | 13 | #include <linux/irq.h> |
|---|
| 14 | 14 | #include <linux/irqdomain.h> |
|---|
| 15 | 15 | #include <linux/msi.h> |
|---|
| 16 | +#include <linux/acpi_iort.h> |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | #include "fsl-mc-private.h" |
|---|
| 18 | 19 | |
|---|
| .. | .. |
|---|
| 177 | 178 | return domain; |
|---|
| 178 | 179 | } |
|---|
| 179 | 180 | |
|---|
| 180 | | -int fsl_mc_find_msi_domain(struct device *mc_platform_dev, |
|---|
| 181 | | - struct irq_domain **mc_msi_domain) |
|---|
| 181 | +struct irq_domain *fsl_mc_find_msi_domain(struct device *dev) |
|---|
| 182 | 182 | { |
|---|
| 183 | + struct device *root_dprc_dev; |
|---|
| 184 | + struct device *bus_dev; |
|---|
| 183 | 185 | struct irq_domain *msi_domain; |
|---|
| 184 | | - struct device_node *mc_of_node = mc_platform_dev->of_node; |
|---|
| 186 | + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); |
|---|
| 185 | 187 | |
|---|
| 186 | | - msi_domain = of_msi_get_domain(mc_platform_dev, mc_of_node, |
|---|
| 187 | | - DOMAIN_BUS_FSL_MC_MSI); |
|---|
| 188 | | - if (!msi_domain) { |
|---|
| 189 | | - pr_err("Unable to find fsl-mc MSI domain for %pOF\n", |
|---|
| 190 | | - mc_of_node); |
|---|
| 188 | + fsl_mc_get_root_dprc(dev, &root_dprc_dev); |
|---|
| 189 | + bus_dev = root_dprc_dev->parent; |
|---|
| 191 | 190 | |
|---|
| 192 | | - return -ENOENT; |
|---|
| 191 | + if (bus_dev->of_node) { |
|---|
| 192 | + msi_domain = of_msi_map_get_device_domain(dev, |
|---|
| 193 | + mc_dev->icid, |
|---|
| 194 | + DOMAIN_BUS_FSL_MC_MSI); |
|---|
| 195 | + |
|---|
| 196 | + /* |
|---|
| 197 | + * if the msi-map property is missing assume that all the |
|---|
| 198 | + * child containers inherit the domain from the parent |
|---|
| 199 | + */ |
|---|
| 200 | + if (!msi_domain) |
|---|
| 201 | + |
|---|
| 202 | + msi_domain = of_msi_get_domain(bus_dev, |
|---|
| 203 | + bus_dev->of_node, |
|---|
| 204 | + DOMAIN_BUS_FSL_MC_MSI); |
|---|
| 205 | + } else { |
|---|
| 206 | + msi_domain = iort_get_device_domain(dev, mc_dev->icid, |
|---|
| 207 | + DOMAIN_BUS_FSL_MC_MSI); |
|---|
| 193 | 208 | } |
|---|
| 194 | 209 | |
|---|
| 195 | | - *mc_msi_domain = msi_domain; |
|---|
| 196 | | - return 0; |
|---|
| 210 | + return msi_domain; |
|---|
| 197 | 211 | } |
|---|
| 198 | 212 | |
|---|
| 199 | 213 | static void fsl_mc_msi_free_descs(struct device *dev) |
|---|