I have a problem with getting a device tree information from Linux PCI driver. The driver type is pci_driver and it tries to access device tree information. When loaded, pci_dev->dev->of_node is NULL. Where pci_dev is struct pci_dev *
In my driver I have:
static const struct of_device_id casin_of_ids[] = {
{ .compatible = "ccx,casin-mfd" },
{}
};
MODULE_DEVICE_TABLE(of, casin_of_ids);
static struct pci_driver sample_pci_mfd_driver = {
.driver = {
.name = "casin",
.of_match_table = casin_of_ids,
},
.name = DRIVER_NAME,
.id_table = casin_pci_ids,
.probe = casin_pci_probe,
.remove = casin_pci_remove,
};
Inside probe function:
if (dev->of_node) {
of_id = of_match_device(casin_of_ids, &pci_dev->dev);
} else {
dev->of_node = of_find_node_by_name(NULL, "casin");
of_id = of_match_device(casin_of_ids, &pci_dev->dev);
}
I can find the node with of_find_node_by_name(NULL, "casin") if dev->of_node was NULL and afterwards when I remove and modprobe module it has the dev->of_node assigned at probe function. Is there a way to do it without manually finding name in the device tree?
Device tree:
casin {
compatible = "ccx,casin-mfd", "simple-mfd";
reg = <0x01000 0x1000>;
led {
compatible = "ccx,casin";
offset = <0x08>;
mask = <0x01>;
label = "myled";
default-state = "on";
};
};
I need the device tree to get info about the I2C devices accessed via PCI. I have also tried do add the node under PCI node:
pcie@33800000 {
compatible = "fsl,imx8mm-pcie\0snps,dw-pcie";
reg = <0x33800000 0x400000 0x1ff00000 0x80000>;
reg-names = "dbi\0config";
#address-cells = <0x03>;
#size-cells = <0x02>;
device_type = "pci";
bus-range = <0x00 0xff>;
...
...
pci@1,0 {
compatible = "ccx,casin-mfd", "simple-mfd";
status = "okay"
};
of_node was still NULL
Running on Linux kernel v5.15.32 on imx8mm build via Yocto Kirkstone.