User:Knuxify/Draft:Devicetree take 2: Difference between revisions

From Mainlining Wiki
Jump to navigation Jump to search
Knuxify (talk | contribs)
No edit summary
Knuxify (talk | contribs)
Blanked the page
Tag: Blanking
 
Line 1: Line 1:
{{Navbox devicetree}}
The '''devicetree''' (device tree, DT) is a tree structure that describes the hardware register layout and configuration of a device.


Devicetrees are written in a plaintext format known as the '''Devicetree Source (DTS)''' format. The DTS is later compiled into a '''Devicetree Blob (DTB)'''; in this form, it can be loaded by software/firmware.
Devicetrees are validated using '''devicetree schema''', which is described in '''DT bindings'''; see [[/Bindings]] for more information.
In the Linux kernel, as well as in other DT-using projects like U-Boot, it is the primary method of discovering peripherals on embedded platforms such as ARM.
== Introduction ==
An SoC (System-on-Chip) comprises of many subcomponents: timer, clock controller, I2C/SPI controller, GPIO, interrupt controller, SDHCI storage, USB, and so on. Each needs its own driver, and for most parts the exact implementation differs between chip manufacturers. Most of them expose a static range of addresses in MMIO (memory-mapped IO) space that the system can use to communicate with them.
Additionally, there may be other peripherals connected to the system - often through a bus like I2C or SPI, or as a simple device controlled by a GPIO.
On a standard x86 system, peripherals are usually autodetected, either through ACPI, or by being on a bus like PCI or USB. On most embedded platforms like ARM, however,  there is no such autodetection method, and the hardware needs to be described manually.
The solution for this, used by both the Linux kernel, as well as a variety of other projects like U-Boot, is the '''devicetree'''.
The devicetree acts like a map of the hardware; it describes where each component is in register space, and stores configuration values for them. It also describes components located on buses like I2C and SPI, and can carry some metadata about the board/device (like the RAM size/base address, model code or chassis type).
Devicetrees are written in the '''DTS''' (Device Tree Source) format; the source file can then be compiled into a '''DTB''' (Device Tree Blob), which software can parse to get all the necessary information about a given platform.
On modern systems, the bootloader loads the DTB into a set place in memory; the Linux kernel then decodes the information from the DTB and initializes all the components based on it. (On 32-bit ARM, which predates widespread adoption of DTBs and DTB-capable bootloaders, an alternative mechanism exists in Linux to load a DTB appended to the kernel image).

Latest revision as of 20:42, 27 February 2025