summaryrefslogtreecommitdiffstats
path: root/drivers/pci/of_property.c
diff options
context:
space:
mode:
authorHerve Codina <herve.codina@bootlin.com>2024-05-27 18:14:44 +0200
committerRob Herring (Arm) <robh@kernel.org>2024-07-09 01:40:30 +0200
commitdc12273fa3d8a84f1e2def49bcf93bea59480f68 (patch)
tree068ff3fed55958897d758a632317986fcfc8d5b5 /drivers/pci/of_property.c
parentof: unittest: Add a test case for of_changeset_add_prop_bool() (diff)
downloadlinux-dc12273fa3d8a84f1e2def49bcf93bea59480f68.tar.xz
linux-dc12273fa3d8a84f1e2def49bcf93bea59480f68.zip
PCI: of_property: Add interrupt-controller property in PCI device nodes
PCI devices and bridges DT nodes created during the PCI scan are created with the interrupt-map property set to handle interrupts. In order to set this interrupt-map property at a specific level, a phandle to the parent interrupt controller is needed. On systems that are not fully described by a device-tree, the parent interrupt controller may be unavailable (i.e. not described by the device-tree). As mentioned in the [1], avoiding the use of the interrupt-map property and considering a PCI device as an interrupt controller itself avoid the use of a parent interrupt phandle. In that case, the PCI device itself as an interrupt controller is responsible for routing the interrupts described in the device-tree world (DT overlay) to the PCI interrupts. Add the 'interrupt-controller' property in the PCI device DT node. [1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/ Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20240527161450.326615-18-herve.codina@bootlin.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Diffstat (limited to 'drivers/pci/of_property.c')
-rw-r--r--drivers/pci/of_property.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index 03539e505372..5a0b98e69795 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -183,6 +183,26 @@ static int of_pci_prop_interrupts(struct pci_dev *pdev,
return of_changeset_add_prop_u32(ocs, np, "interrupts", (u32)pin);
}
+static int of_pci_prop_intr_ctrl(struct pci_dev *pdev, struct of_changeset *ocs,
+ struct device_node *np)
+{
+ int ret;
+ u8 pin;
+
+ ret = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
+ if (ret != 0)
+ return ret;
+
+ if (!pin)
+ return 0;
+
+ ret = of_changeset_add_prop_u32(ocs, np, "#interrupt-cells", 1);
+ if (ret)
+ return ret;
+
+ return of_changeset_add_prop_bool(ocs, np, "interrupt-controller");
+}
+
static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
struct device_node *np)
{
@@ -336,6 +356,10 @@ int of_pci_add_properties(struct pci_dev *pdev, struct of_changeset *ocs,
ret = of_pci_prop_intr_map(pdev, ocs, np);
if (ret)
return ret;
+ } else {
+ ret = of_pci_prop_intr_ctrl(pdev, ocs, np);
+ if (ret)
+ return ret;
}
ret = of_pci_prop_ranges(pdev, ocs, np);