forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/bus/fsl-mc/fsl-mc-msi.c
....@@ -13,6 +13,7 @@
1313 #include <linux/irq.h>
1414 #include <linux/irqdomain.h>
1515 #include <linux/msi.h>
16
+#include <linux/acpi_iort.h>
1617
1718 #include "fsl-mc-private.h"
1819
....@@ -177,23 +178,36 @@
177178 return domain;
178179 }
179180
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)
182182 {
183
+ struct device *root_dprc_dev;
184
+ struct device *bus_dev;
183185 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);
185187
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;
191190
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);
193208 }
194209
195
- *mc_msi_domain = msi_domain;
196
- return 0;
210
+ return msi_domain;
197211 }
198212
199213 static void fsl_mc_msi_free_descs(struct device *dev)