0

I am building a kernel module for PCIe device on Linux v5.15.60 on x86. This module connects to my FPGA (containing multiple soft cores) and creates a platform_device. For an other driver to use it.

The FPGA embed its own device tree blob in a memory region read by my kernel module. I would like to use __unflatten_device_tree, or of_fdt_unflatten_tree kernel functions to parse the blob and create new device_nodes associated with the created platform_device.

Unfortunately I can't access __unflatten_device_tree, and of_fdt_unflatten_tree would require the user to recompile the kernel with CONFIG_OF=y.

Is there any other kernel function than of_fdt_unflatten_tree to do this? I just need to parse a new blob but not to overlay the current device tree.

Edit: Once I have my device tree root in a struct device_node, can I create a list of struct devices or structe platform_devices automatically?

0andriy
  • 4,183
  • 1
  • 24
  • 37
cykoenig
  • 1
  • 1
  • You don't need that. It should be done by FPGA framework: https://www.kernel.org/doc/html/latest/driver-api/fpga/fpga-region.html – 0andriy Mar 02 '23 at 20:38
  • Presumably, the drivers for those created devices would need access to the properties in the device tree nodes? I think this is a bit of a non-starter for a non-device-tree-based system. – Ian Abbott Mar 03 '23 at 16:47
  • @0andriy : in this case the FPGA is an emulation platform and I woud like to consider as a normal PCI device – cykoenig Mar 06 '23 at 15:27
  • @IanAbbott I did not know x86 was non-device-tree, I found some patches that should solve this problem https://lore.kernel.org/lkml/20220427094502.456111-1-clement.leger@bootlin.com/T/ – cykoenig Mar 06 '23 at 15:28
  • @cykoenig There are a couple of x86 platforms that use device trees, but not your typical PC. The OLPC ("One Laptop Per Child") and the Intel "CE4100 TV platform" are X86 platforms that use device trees. – Ian Abbott Mar 06 '23 at 16:39
  • @IanAbbott, you missed the third one (SpreadTrum): https://www.anandtech.com/show/11196/mwc-2017-spreadtrum-launches-8core-intel-airmontbased-soc-with-cat-7-lte-for-smartphones/ – 0andriy Mar 07 '23 at 12:40
  • For any chip the PCI device should be self discoverable. In that sense you just add respective PCI IDs to the drivers and that's it. You don't need any tables at all for the basic cases (the tables are needed usually for some special cases to assist with what PCI can't do). – 0andriy Mar 07 '23 at 12:41

0 Answers0