Devicetree: Difference between revisions

Knuxify (talk | contribs)
mNo edit summary
Knuxify (talk | contribs)
No edit summary
Line 3: Line 3:
In simpler terms - a devicetree tells the kernel (or another DT-compatible piece of software/firmware like a bootloader) where each component is in register space/on an I2C or similar bus, and what settings to use to set it up. It is the basic mechanism for discovering components on embedded platforms, including ARM.
In simpler terms - a devicetree tells the kernel (or another DT-compatible piece of software/firmware like a bootloader) where each component is in register space/on an I2C or similar bus, and what settings to use to set it up. It is the basic mechanism for discovering components on embedded platforms, including ARM.


Devicetrees are validated using '''devicetree schema'''; this schema specifies allowed properties for nodes based on their <code>compatible</code> string. Devicetree schema is defined through '''bindings''', YAML files containing schema information (older bindings use TXT format, but this is deprecated). Bindings for most Linux components can be found in <code>Documentation/devicetree/bindings</code>; there is also a [https://github.com/devicetree-org/dt-schema core DT schema] defining the most basic components and syntax.
Devicetrees are validated using '''devicetree schema''', which is described by bindings; see [[/Bindings]] for more information.


== History ==
== History ==
Line 67: Line 67:
On node 2 there is also a property, <code>vendor,baz-companion</code>, which takes a pointer to another node - here the one we labeled "my_node".
On node 2 there is also a property, <code>vendor,baz-companion</code>, which takes a pointer to another node - here the one we labeled "my_node".


== Verifying device tree bindings and device tree sources ==
== Verifying DTS files ==


The Linux kernel has tools for verifying the correctness of device tree schema bindings, as well as making sure that device tree sources (DTS) use the bindings correctly. These are useful when writing device sources; getting both of these checks to pass is also mandatory for upstream inclusion of a binding/DTS.
The Linux kernel has tools for making sure that device tree sources (DTS) use the bindings correctly. These are useful when writing device sources; getting  
 
the DT checks to pass is also mandatory for upstream inclusion of a DTS.
=== Verifying DT bindings ===
 
To verify all DT bindings, run:
 
<syntaxhighlight lang="shell-session">
$ make dt_binding_check
</syntaxhighlight>
 
You can also verify only a specific binding by providing its filename in the <code>DT_SCHEMA_FILES</code> option. This option takes either a filename or a directory name:
 
<syntaxhighlight lang="shell-session">
$ make dt_binding_check DT_SCHEMA_FILES=brcm,bcm590xx.yaml  # Checks all bindings named brcm,bcm590xx.yaml
$ make dt_binding_check DT_SCHEMA_FILES=qcom    # Checks all bindings in any (sub)folder named "qcom"
$ make dt_binding_check DT_SCHEMA_FILES=/gpio/  # Checks all bindings in /gpio folder
</syntaxhighlight>
 
=== Verifying DTS files ===


To verify all DTS files built with the selected defconfig options, run:
To verify all DTS files built with the selected defconfig options, run: