12

I am developing a device driver for a device.I wanted to know besides writing the device driver what and when it is necessary for it - a device tree blob (dtb) or a device tree overlay (dtbo).

Is it possible to dynamically insert the dtb (after compiling it using dtc compiler) and test the driver(dynamically loadable) .

For statically building dtb is there any Kconfig for the dtb files which I have to take care of apart from the device driver's Kconfig.

Raulp
  • 7,758
  • 20
  • 93
  • 155
  • I think kernel documentation at below link should help you understand, http://lxr.free-electrons.com/source/Documentation/devicetree/overlay-notes.txt refer this too https://gist.github.com/bodokaiser/6854708. It seems DTBO is similar to DTB with only difference that it can add node in runtime. I don't know this things in much detail. – ART Jul 29 '16 at 12:26

1 Answers1

1

You don't mention what platform this is, but I'm assuming it is one of the architectures that extensively uses devicetrees for HW description e.g. ARM, PPC and that you actually need devicetree.

Device tree overlays require support from userspace, in the form of a overlay manager that knows what overlays to load at runtime. Unless your device is in a very dynamic environment where it might go away, for most cases, you want a simple hardcoded device tree.

After writing your driver, you need to define the compatible property to tell the kernel when to load this driver and then add a node to the devicetree (.dts/.dtsi) file under arch/<foo>/boot/dts/*/* that best describes your board.

e.g. See this compatible registration and the corresponding HW description in a bunch of devicetrees 1,2,3 that are SoC-specific. This one driver works on all those SoC by quirking SoC-specific fucntionality behind compatible flags.

idlethread
  • 1,111
  • 7
  • 16