Skip to content

Commit d976c6f

Browse files
avpatelrobherring
authored andcommitted
of: property: Add fw_devlink support for interrupt-map property
Some of the PCI host controllers (such as generic PCI host controller) use "interrupt-map" DT property to describe the mapping between PCI endpoints and PCI interrupt pins. This is the only case where the interrupts are not described in DT. Currently, there is no fw_devlink created based on "interrupt-map" DT property so interrupt controller is not guaranteed to be probed before the PCI host controller. This affects every platform where both PCI host controller and interrupt controllers are probed as regular platform devices. This creates fw_devlink between consumers (PCI host controller) and supplier (interrupt controller) based on "interrupt-map" DT property. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20240509120820.1430587-1-apatel@ventanamicro.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
1 parent 9fa6bcf commit d976c6f

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

drivers/of/property.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,57 @@ static struct device_node *parse_interrupts(struct device_node *np,
13011301
return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np;
13021302
}
13031303

1304+
static struct device_node *parse_interrupt_map(struct device_node *np,
1305+
const char *prop_name, int index)
1306+
{
1307+
const __be32 *imap, *imap_end, *addr;
1308+
struct of_phandle_args sup_args;
1309+
u32 addrcells, intcells;
1310+
int i, imaplen;
1311+
1312+
if (!IS_ENABLED(CONFIG_OF_IRQ))
1313+
return NULL;
1314+
1315+
if (strcmp(prop_name, "interrupt-map"))
1316+
return NULL;
1317+
1318+
if (of_property_read_u32(np, "#interrupt-cells", &intcells))
1319+
return NULL;
1320+
addrcells = of_bus_n_addr_cells(np);
1321+
1322+
imap = of_get_property(np, "interrupt-map", &imaplen);
1323+
if (!imap || imaplen <= (addrcells + intcells))
1324+
return NULL;
1325+
imap_end = imap + imaplen;
1326+
1327+
while (imap < imap_end) {
1328+
addr = imap;
1329+
imap += addrcells;
1330+
1331+
sup_args.np = np;
1332+
sup_args.args_count = intcells;
1333+
for (i = 0; i < intcells; i++)
1334+
sup_args.args[i] = be32_to_cpu(imap[i]);
1335+
imap += intcells;
1336+
1337+
/*
1338+
* Upon success, the function of_irq_parse_raw() returns
1339+
* interrupt controller DT node pointer in sup_args.np.
1340+
*/
1341+
if (of_irq_parse_raw(addr, &sup_args))
1342+
return NULL;
1343+
1344+
if (!index)
1345+
return sup_args.np;
1346+
1347+
of_node_put(sup_args.np);
1348+
imap += sup_args.args_count + 1;
1349+
index--;
1350+
}
1351+
1352+
return NULL;
1353+
}
1354+
13041355
static struct device_node *parse_remote_endpoint(struct device_node *np,
13051356
const char *prop_name,
13061357
int index)
@@ -1350,6 +1401,7 @@ static const struct supplier_bindings of_supplier_bindings[] = {
13501401
{ .parse_prop = parse_power_supplies, },
13511402
{ .parse_prop = parse_gpio_compat, },
13521403
{ .parse_prop = parse_interrupts, },
1404+
{ .parse_prop = parse_interrupt_map, },
13531405
{ .parse_prop = parse_regulators, },
13541406
{ .parse_prop = parse_gpio, },
13551407
{ .parse_prop = parse_gpios, },

0 commit comments

Comments
 (0)