Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How linux kernel get data from the Device tree?

I am a beginner to the Linux Kernel.
In my knowledge, in the older versions of the Kernel there was a board specific file, in which all the devices were registered (by using some API s like platform_get_register, etc).
And in newer versions of the kernel the information needed for the devices are passed through the Device Tree.
My Questions are how the Kernel take the information for the drivers from device tree? How devices get registered in kernel through Device Tree?

like image 621
Vineesh Vijayan Avatar asked Nov 28 '14 11:11

Vineesh Vijayan


1 Answers

If you mean the OpenFirmware device trees, those are packed into a special format (dtb image) and put in RAM by the bootloader, together with the kernel image. Bootloader then invokes the kernel entry point passing the address of the dtb image in RAM as one of the parameters.

A kernel subsystem located in <kernel>/drivers/of subdirectory will then walk the tree and for each device entry supported it will attempt 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, that driver's *_probe() call back will be able to obtain the parameters found in the OF device entry from the (possibly sub-classed) device object passed to it.

like image 69
oakad Avatar answered Sep 29 '22 10:09

oakad