Simon Glass | ac35c2f | 2021-08-01 18:57:10 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Devicetree Introduction |
| 4 | ======================= |
Simon Glass | c5f9e16 | 2021-08-01 18:57:12 -0600 | [diff] [blame] | 5 | |
| 6 | U-Boot uses a devicetree for configuration. This includes the devices used by |
| 7 | the board, the format of the image created with binman, which UART to use for |
| 8 | the console, public keys used for secure boot and many other things. |
| 9 | |
| 10 | See :doc:`control` for more information. |
| 11 | |
| 12 | Why does U-Boot put <thing> in the devicetree? |
| 13 | ---------------------------------------------- |
| 14 | |
| 15 | This question comes up a lot with people new to U-Boot, particular those coming |
| 16 | from Linux who are used to quite strict rules about what can go into the |
| 17 | devicetree. |
| 18 | |
| 19 | U-Boot uses the same devicetree as Linux but adds more things necessary for the |
| 20 | bootloader environment (see :ref:`dttweaks`). |
| 21 | |
| 22 | U-Boot does not have a user space to provide policy and configuration. It cannot |
| 23 | do what Linux does and run programs and look up filesystems to figure out how to |
| 24 | boot. So configuration and runtime information goes into the devicetree in |
| 25 | U-Boot. |
| 26 | |
| 27 | Of course it is possible to: |
| 28 | |
| 29 | - add tables into the rodata section of the U-Boot binary |
| 30 | - append some info to the end of U-Boot in a different format |
| 31 | - modify the linker script to bring in a file with some info in it |
| 32 | - put things in ACPI tables |
| 33 | - link in a UEFI hand-off block structure and put things in there |
| 34 | |
| 35 | but *please don't*. In general, devicetree is the sane place to hold U-Boot's |
| 36 | configuration. |
| 37 | |
| 38 | So, please, do NOT ask why U-Boot puts <thing> in the devicetree. It is the only |
| 39 | place it can go. It is a highly suitable data structure for just about anything |
| 40 | that U-Boot needs to know at runtime. |
| 41 | |
| 42 | Note, it is possible to use platdata directly so drivers avoid devicetreee in |
| 43 | SPL. But of-platdata is the modern way of avoiding devicetree overhead, so |
| 44 | please use that instead. |