Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| linux_device_trees [2018/11/17 16:03] – [Internal wiki pages] rpjday | linux_device_trees [2018/12/11 13:03] (current) – [Internal wiki pages] rpjday | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Stuff related to device trees and the Linux kernel, using examples from the current Linux kernel. | Stuff related to device trees and the Linux kernel, using examples from the current Linux kernel. | ||
| - | To do: | + | ===== TO DO ===== |
| * overlays | * overlays | ||
| + | * keywords (/plugin/, / | ||
| + | |||
| + | ===== MISC (for now) ===== | ||
| + | |||
| + | * "The unit-address must match the first address specified in the reg property of the node. If the node has no reg property, the @unit-address must be omitted and the node-name alone differentiates the node from other nodes at the same level in the tree. The binding for a particular bus may specify additional, more specific requirements for the format of reg and the unit-address." | ||
| ===== Some links ===== | ===== Some links ===== | ||
| Line 46: | Line 51: | ||
| * [[Device tree naming conventions]] | * [[Device tree naming conventions]] | ||
| * [[Proper device tree design]] | * [[Proper device tree design]] | ||
| - | * [[Comparing device trees]] | + | * [[Device tree standard properties]] |
| - | + | * [[Device tree node requirements]] | |
| - | ===== Proper device tree design ===== | + | * [[Comparing device |
| - | + | | |
| - | ==== One board, one .dts file ==== | + | |
| - | + | ||
| - | Every distinct board merits its own '' | + | |
| - | + | ||
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | ==== Proper use of .dtsi files ==== | + | |
| - | + | ||
| - | There is **//no reason//** to make local copies of kernel-supplied '' | + | |
| - | + | ||
| - | * ''/ | + | |
| - | * ''/ | + | |
| - | + | ||
| - | This functionality was introduced into the Linux kernel file '' | + | |
| - | + | ||
| - | < | + | |
| - | commit cd296721a9645f9f28800a072490fa15458d1fb7 | + | |
| - | Author: Stephen Warren < | + | |
| - | Date: Fri Sep 28 21:25:59 2012 +0000 | + | |
| - | + | ||
| - | dtc: import latest upstream dtc | + | |
| - | + | ||
| - | This updates scripts/dtc to commit 317a5d9 "dtc: zero out new label | + | |
| - | objects" | + | |
| - | + | ||
| - | This adds features such as: | + | |
| - | * /bits/ syntax for cell data. | + | |
| - | * Math expressions within cell data. | + | |
| - | * The ability to delete properties or nodes. | + | |
| - | * Support for #line directives in the input file, which allows the use of | + | |
| - | cpp on *.dts. | + | |
| - | * -i command-line option (/include/ path) | + | |
| - | * -W/-E command-line options for error/ | + | |
| - | * Removal of spew to STDOUT containing the filename being compiled. | + | |
| - | * Many additions to the libfdt API. | + | |
| - | + | ||
| - | Signed-off-by: | + | |
| - | Acked-by: Jon Loeliger < | + | |
| - | Signed-off-by: | + | |
| - | </ | + | |
| - | + | ||
| - | Examples can be seen [[https:// | + | |
| - | + | ||
| - | ==== Examples of / | + | |
| - | + | ||
| - | === imx6dl-tx6s-8034.dts === | + | |
| - | + | ||
| - | < | + | |
| - | #include " | + | |
| - | #include " | + | |
| - | + | ||
| - | / { | + | |
| - | model = "Ka-Ro electronics TX6S-8034 Module"; | + | |
| - | compatible = " | + | |
| - | + | ||
| - | aliases { | + | |
| - | display = & | + | |
| - | ipu1 = & | + | |
| - | }; | + | |
| - | + | ||
| - | cpus { | + | |
| - | / | + | |
| - | }; | + | |
| - | </ | + | |
| - | + | ||
| - | === imx6q-utilite-pro.dts === | + | |
| - | + | ||
| - | < | + | |
| - | #include < | + | |
| - | #include " | + | |
| - | + | ||
| - | / { | + | |
| - | model = " | + | |
| - | compatible = " | + | |
| - | + | ||
| - | ... | + | |
| - | + | ||
| - | }; | + | |
| - | + | ||
| - | /* | + | |
| - | * A single IPU is not able to drive both display interfaces available on the | + | |
| - | * Utilite Pro at high resolution due to its bandwidth limitation. Since the | + | |
| - | * tfp410 encoder is wired up to IPU1, sever the link between IPU1 and the | + | |
| - | * SoC-internal Designware HDMI encoder forcing the latter to be connected to | + | |
| - | * IPU2 instead of IPU1. | + | |
| - | */ | + | |
| - | / | + | |
| - | / | + | |
| - | / | + | |
| - | / | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | ==== Examples of / | + | |
| - | + | ||
| - | === imx6qp.dtsi === | + | |
| - | + | ||
| - | < | + | |
| - | #include " | + | |
| - | + | ||
| - | / { | + | |
| - | soc { | + | |
| - | + | ||
| - | ... | + | |
| - | + | ||
| - | }; | + | |
| - | + | ||
| - | &fec { | + | |
| - | / | + | |
| - | interrupts = <0 118 IRQ_TYPE_LEVEL_HIGH>, | + | |
| - | <0 119 IRQ_TYPE_LEVEL_HIGH>; | + | |
| - | }; | + | |
| - | </ | + | |
| - | + | ||
| - | === imx6ul-tx6ul-mainboard.dts === | + | |
| - | + | ||
| - | < | + | |
| - | #include " | + | |
| - | #include " | + | |
| - | + | ||
| - | / { | + | |
| - | model = "Ka-Ro electronics TXUL-0010 Module on TXUL Mainboard"; | + | |
| - | compatible = " | + | |
| - | + | ||
| - | aliases { | + | |
| - | lcdif_24bit_pins_a = & | + | |
| - | mmc0 = & | + | |
| - | / | + | |
| - | serial2 = & | + | |
| - | serial4 = & | + | |
| - | }; | + | |
| - | / | + | |
| - | }; | + | |
| - | + | ||
| - | ... | + | |
| - | + | ||
| - | &usdhc1 { | + | |
| - | pinctrl-0 = <& | + | |
| - | non-removable; | + | |
| - | / | + | |
| - | cap-sdio-irq; | + | |
| - | }; | + | |
| - | + | ||
| - | &uart1 { | + | |
| - | pinctrl-0 = <& | + | |
| - | / | + | |
| - | }; | + | |
| - | + | ||
| - | &uart2 { | + | |
| - | pinctrl-0 = <& | + | |
| - | / | + | |
| - | status = " | + | |
| - | }; | + | |
| - | </ | + | |
| - | + | ||
| - | ===== Comparing | + | |
| - | + | ||
| - | Here's how to properly compare two device | + | |
| - | + | ||
| - | ==== Preparing for comparison ==== | + | |
| - | + | ||
| - | First, given a kernel source tree at '' | + | |
| - | + | ||
| - | < | + | |
| - | $ cd ~/k/git | + | |
| - | $ PATH=~/ | + | |
| - | $ export ARCH=arm | + | |
| - | </ | + | |
| - | + | ||
| - | Note that setting the PATH as above will add access to all of the executables (scripts and possible binary executables) under the kernel' | + | |
| - | + | ||
| - | I mention this so you know that if you already had a ''/ | + | |
| - | + | ||
| - | ==== Comparing two .dts files already in the kernel source tree (Part one) ==== | + | |
| - | + | ||
| - | If you're located at the top of the relevant kernel source tree, and you want to compare two device tree source files already there, say, under '' | + | |
| - | + | ||
| - | < | + | |
| - | $ dtx_diff arch/ | + | |
| - | --- arch/ | + | |
| - | +++ arch/ | + | |
| - | @@ -3,8 +3,8 @@ | + | |
| - | / { | + | |
| - | # | + | |
| - | #size-cells = < | + | |
| - | - | + | |
| - | - model = " | + | |
| - | + | + | |
| - | + model = " | + | |
| - | + | ||
| - | aliases { | + | |
| - | can0 = "/ | + | |
| - | @@ -44,14 +44,14 @@ | + | |
| - | brightness-levels = <0x0 0x4 0x8 0x10 0x20 0x40 0x80 0xff>; | + | |
| - | compatible = " | + | |
| - | default-brightness-level = < | + | |
| - | - | + | |
| - | - pwms = <0x78 0x0 0x4c4b40>; | + | |
| - | + | + | |
| - | + pwms = <0x80 0x0 0x4c4b40>; | + | |
| - | status = " | + | |
| - | }; | + | |
| - | + | ||
| - | .. etc etc ... | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Comparing two .dts files already in the kernel source tree (Part deux) ==== | + | |
| - | + | ||
| - | In the above example, you were located in the root directory of the relevant kernel source tree, which is the default for the '' | + | |
| - | + | ||
| - | < | + | |
| - | $ cd arch/ | + | |
| - | $ dtx_diff imx6q{, | + | |
| - | + | ||
| - | ... snip ... | + | |
| - | + | ||
| - | In file included from imx6qp.dtsi: | + | |
| - | from imx6qp-sabresd.dts: | + | |
| - | imx6q.dtsi: | + | |
| - | # | + | |
| - | + | ||
| - | ... snip ... | + | |
| - | + | ||
| - | | + | |
| - | Is $ARCH=' | + | |
| - | Possible fix: use ' | + | |
| - | + | ||
| - | ./arch/arm/ does not exist | + | |
| - | Is $ARCH=' | + | |
| - | Possible fix: use ' | + | |
| - | Possible fix: use ' | + | |
| - | + | ||
| - | Possible fix: use ' | + | |
| - | $ | + | |
| - | </ | + | |
| - | + | ||
| - | Instead, you need to use one of these two variations, depending on whether you're in a Git repository, or just a regular source tree: | + | |
| - | + | ||
| - | < | + | |
| - | $ dtx_diff -s ~/k/git imx6q{, | + | |
| - | $ dtx_diff -S imx6q{, | + | |
| - | </ | + | |
| - | + | ||
| - | In short, as long as you're still inside the relevant kernel source tree, comparisons will work -- you just need to make sure the '' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ==== Comparing two device | + | |
| - | + | ||
| - | What doesn' | + | |
| - | + | ||
| - | < | + | |
| - | $ cp imx6q{, | + | |
| - | $ cd /tmp | + | |
| - | $ dtx_diff -s ~/k/git imx6q{, | + | |
| - | imx6qp-sabresd.dts: | + | |
| - | # | + | |
| - | ^~~~~~~~~~~~~ | + | |
| - | imx6q-sabresd.dts: | + | |
| - | # | + | |
| - | ^~~~~~~~~~~~ | + | |
| - | compilation terminated. | + | |
| - | compilation terminated. | + | |
| - | Error: imx6qp-sabresd.dts: | + | |
| - | + | ||
| - | FATAL ERROR: FATAL ERROR: Unable to parse input tree | + | |
| - | Unable to parse input tree | + | |
| - | + | ||
| - | Possible hints to resolve the above error: | + | |
| - | + | ||
| - | (hints might not fix the problem) | + | |
| - | Possible hints to resolve the above error: | + | |
| - | (hints might not fix the problem) | + | |
| - | + | ||
| - | + | ||
| - | No hints available. | + | |
| - | No hints available. | + | |
| - | $ | + | |
| - | </ | + | |
| - | + | ||
| - | I have no idea why this fails -- obviously, even when telling '' | + | |