How does linux kernel get data from device tree?

I am new to Linux kernel.
As far as I know, in older kernel versions there was a specific board file in which all devices were registered (using some APIs like platform_get_register

etc).
And in newer versions of the kernel, the information needed for devices is passed through the Device Tree.
My questions are: How does the kernel retrieve information for drivers from the device tree? How do devices register to the kernel via Device Tree?

+3


source to share


1 answer


If you mean OpenFirmware device trees, they are packaged in a special format (dtb image) and placed in RAM by the bootloader along with the kernel image. The bootloader then calls the kernel entry point, passing the dtb image address in RAM as one of the parameters.



The kernel subsystem, located in a subdirectory <kernel>/drivers/of

, will then walk the tree and, for every supported device entry, it will try to create the required device via device_add()

and friends (the usual process for creating devices in Linux). If the driver subsystem can find a suitable driver, this callback *_probe()

can retrieve the parameters found in the OF device entry from the object (possibly a subclass) passed to it device

.

+3


source







All Articles