Search code examples
clinux-kernellinux-device-driverdevice-tree

Device tree-like structure for Linux driver


I'm trying to build a structure that is similar to a device tree. Basically, i want to get a driver that is built to work with a device tree, to work the same way without it. I want to build the wrapper and the structure that contain all the information a device tree has, and pass it onto the driver.

Anyone has any idea how i can do this or a good place to read abut it? i looked for it but couldn't find anything or any example of something similar on how to do this.

Best regards and thank you for your help


Solution

  • It's already been done in the kernel recently and called unified device property API, in particularly it supports same properties come from DeviceTree, ACPI, or built-in in the platform code. More information about API you may find in the sources include/linux/property.h, drivers/base/property.c. The one of the examples is rfkill_gpio driver, i.e. net/rfkill/rfkill-gpio.c [consumer], arch/arm/mach-tegra/board-paz00.c [provider].