0

I understand that Linux device trees explain about the different hardware component settings in a system.

The bootloader will load the kernel and the device tree. How exactly does the device tree information then get parsed by the kernel and when?

For example, if we have a driver for Real Time Clock, and various settings for it are desired to be described in the device tree. Is it up to the Kernel device driver for that device to parse this information and set the device up?

However, I thought that the device tree describes which Kernel driver should get loaded in the first place for the device, before the driver code even runs, so i am a bit confused.

Engineer999
  • 3,683
  • 6
  • 33
  • 71
  • Why do you consider these uses exclusionary? Why can't the Device Tree be used for both "*which Kernel driver should get loaded*" as well as "*set the device up*" by the each device drive? Why do you restrict the DT to just one purpose and/or access? – sawdust Aug 10 '22 at 20:41
  • @sawdust This is what I'm wondering about – Engineer999 Aug 11 '22 at 05:38
  • 2
    The `compatible` strings are matched against modules that have called `platform_driver_register`, looking for matches in the `driver.of_match_table` entries or `driver.name` entries. If none found, the `compatible` strings will be used to form module aliases and the system will attempt to load an external module matching the alias (using device ID information stored in the external module). Once a matching driver is found, its `probe` function will be called, and that can retrieve information from the device tree node referenced by the platform device's `dev.of_node` pointer. – Ian Abbott Aug 12 '22 at 09:18
  • There is also a lot of information in https://stackoverflow.com/tags/device-tree/info. Can you clarify if you still have a question? Drivers usually have 'options' that slightly alter behavior depending on the board. The 'compat' entry will create a 'device' which tells the 'driver' which code path to take. So one source driver can exist to handle very similar hardware. Ie, SOC vendor evolve a 'device' over time to extend and alter features while the core functionality is the same. The same architecture can handle multiple devices. – artless noise Aug 15 '22 at 17:08
  • Also, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model is helpful to understanding how device tree fits. – artless noise Aug 15 '22 at 17:14

0 Answers0