16 | | You can find the device tree files in arch/arm/boot/dts |
17 | | |
18 | | For the Gateworks Venice platform, the device tree files are at arch/arm64/boot/dts/freescale/ |
19 | | - Note device tree source code (eg GW7200) is located in kernel source code at path: linux-venice/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx.dtsi |
20 | | - Link for the Venice kernel source code [https://github.com/Gateworks/linux-venice here] |
21 | | |
22 | | For an example, see [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi imx6qdl-gw54xx.dtsi] |
| 26 | Device tree files exist in: |
| 27 | * Linux kernel tree: |
| 28 | - arch/arm/boot/dts for 32bit ARM |
| 29 | - arch/arm64/boot/dts for 64bit ARM |
| 30 | * U-Boot bootloader: |
| 31 | - arch/arm/dts for ARM |
| 32 | |
| 33 | For Gateworks Kernels: |
| 34 | - Venice: [https://github.com/Gateworks/linux-venice/tree/v5.10.76-venice/arch/arm64/boot/dts/freescale arch/arm64/boot/dts/freescale] imx8*-venice-*.dts* |
| 35 | - Newport: [https://github.com/Gateworks/dts-newport dts-newport] gw*.dts* (Note Newport dt source is not in the Mainline Linux kernel) |
| 36 | - Ventana: [https://github.com/Gateworks/linux-imx6/tree/gateworks_5.4.45/arch/arm/boot/dts/ arch/arm/boot/dts] imx6*-gw-*.dts* |
71 | | |
72 | | == Specifying the Device-tree that is used == |
73 | | The [wiki:/linux/bootloader bootloader] is responsible for loading the device-tree blob (DTB) and executing the kernel |
74 | | The Gateworks ventana bootloader in a way that it knows where the DTB is loaded. |
75 | | |
76 | | Therefore, its the bootloader that decides which DTB to load and from where. |
77 | | |
78 | | See [wiki:/ventana/bootloader] for details on how the DTB filename is chosen and loaded. |
79 | | |
80 | | == Adding New Devices to the Device Tree |
81 | | For customers interested in adding a new device to an existing controller, see the [wiki:/SPI SPI] wiki page for an example of the process. |
| 89 | == Device Tree Overlays (aka Fragments) == |
| 90 | The device-tree compiler and the U-Boot bootloader support the concept of applying changes to a base device-tree to make it easy to implement add-on boards such as a touchscreen display or camera that require dt bindings. |
| 91 | |
| 92 | Some specific requirements: |
| 93 | - requires '/plugin/' specified |
| 94 | - requires '&{/} { compatible };' node that specifies the board this fragment is compatible with |
| 95 | - requires using handles of nodes that are defined in the base devicetree |
| 96 | - requires compiling with the-@ flag |
| 97 | |
| 98 | To provide a simple example consider adding a simple SPI NOR flash device on an off-board SPI connector. Such a device has a Linux kernel driver and requires using device-tree bindings: |
| 99 | {{{ |
| 100 | /dts-v1/; |
| 101 | /plugin/; |
| 102 | |
| 103 | &{/} { |
| 104 | compatible = "gw,imx8mm-gw73xx-0x", "fsl,imx8mm"; |
| 105 | }; |
| 106 | |
| 107 | /* off-board header */ |
| 108 | &ecspi2 { |
| 109 | flash@0 { |
| 110 | compatible = "spansion,m25p128", "jedec,spi-nor"; |
| 111 | spi-max-frequency = <30000000>; |
| 112 | reg = <0>; |
| 113 | #address-cells = <1>; |
| 114 | #size-cells = <1>; |
| 115 | m25p,fast-read; |
| 116 | |
| 117 | partition@0 { |
| 118 | label = "data"; |
| 119 | reg = <0x0 0x1000000>; |
| 120 | }; |
| 121 | }; |
| 122 | }; |
| 123 | }}} |
| 124 | - Note the compatible string specifies the board this is compatible with |
| 125 | - Note the board in question's base dt specifies the ecspi2 handle which we modify here |
| 126 | |
| 127 | To compile this fragment: |
| 128 | {{{#!bash |
| 129 | dtc -@ -I dts -O dtb -o imx8mm-gw73xx-0x-spinor.dtbo imx8mm-gw73xx-0x-spinor.dts |
| 130 | }}} |
| 131 | |
| 132 | And to use it on a Venice imx8mm-gw73xx-0x make sure the dtbo exits alongside the kernel in the directory the bootscript resides (ie /boot) |
| 133 | {{{#!bash |
| 134 | setenv fdt_overlays "imx8mm-gw73xx-0x-spinor.dtbo" |
| 135 | saveenv |
| 136 | }}} |
| 137 | |
| 138 | Notes: |
| 139 | * Support for compiling dtbo files appeared in the Linux kernel somewhere between 5.10 and 5.15 |
| 140 | * Gateworks uses dtbo's to provide support for adding a RaspberryPi v2.0 camera module and a RaspberryPi DFROBOT touchscreen display to a gw72xx/gw73xx baseboard for example. |
| 141 | |
| 142 | |
| 143 | == Gateworks Product family notes |
| 144 | |
| 145 | [=#venice] |
| 146 | === Venice |
| 147 | For Venice: |
| 148 | * U-Boot is controlled by device-tree, the DTB used is decided upon by the SPL based on EEPROM contents describing the board model, exists in a FIT image along with the ARM Trusted Firmware (ATF) and U-Boot proper and is specified by a 'DTB' banner before the SPL boots U-Boot proper. |
| 149 | * The Linux device-tree comes from the kernel source tree (arch/arm64/boot/dts/freescale) and is loaded and modified by the bootloader. The {{{loadfdt}}} script is used to load the device-tree blob (dtb) and will attempt to load several board dtb files starting with the most specific names possible including board PCB revisions and ending with a generic file represending the baseboard. |
| 150 | * A list of optional files specified by {{{fdt_overlays}}} will be loaded and applied as overlays and if defined {{{fixfdt}}} will be run as well. |
| 151 | |
| 152 | |
| 153 | [=#newport] |
| 154 | === Newport |
| 155 | For Newport: |
| 156 | * U-Boot is controlled by device-tree, the dtb used is loaded by BDK from the embedded FATFS based on the model from the board EEPROM. |
| 157 | * DTS source files are in the [https://github.com/Gateworks/dts-newport dts-newport] repo and built by the BSP Makefile and populated in the FATFS |
| 158 | * The bootscript uses the U-Boot 'live' device-tree used by U-Boot for Linux as well (by passing the bootm command '$fdtcontroladdr'). This is not required and if needed you could load your own dtb and pass the address instead however note that the DTS files for CN80xx do not exist in the kernel tree. |
| 159 | |
| 160 | |
| 161 | [=#ventana] |
| 162 | === Ventana |
| 163 | For Ventana: |
| 164 | * The latest Gateworks gateworks_v2017.05 U-Boot is not controlled by device tree and instead board support in U-Boot is handled by code based off the board model from the EEPROM |
| 165 | * DTS source files are in the Linux kernel in the arch/arm/boot/dts directory and placed with the kernel uImage in the same directory as the bootscript in the root filesystem (ie /boot) |
| 166 | * The bootloader {{{loadfdt}}} script is used to load the device-tree blob (dtb) in all standard boot cases for the Gateworks bootloader. This script attempts to load a dtb three times, each time with a more generic filename (from the {{{fdt_file}}}, {{{fdt_file1}}}, and {{{fdt_file2}}}) env variable which if not set (overridden) will get set per the board model defined in the Gateworks EEPROM. For example a GW5400-C would have the following: |
| 167 | {{{#!bash |
| 168 | Ventana > print fdt_file |
| 169 | fdt_file=imx6q-gw5400-c.dtb |
| 170 | Ventana > print fdt_file1 |
| 171 | fdt_file1=imx6q-gw5400.dtb |
| 172 | Ventana > print fdt_file2 |
| 173 | fdt_file2=imx6q-gw54xx.dtb |
| 174 | }}} |
| 175 | |
| 176 | |
| 177 | === Laguna |
| 178 | The Laguna bootloader and Linux kernel do not use device-tree for board configuration. |
| 179 | |
| 180 | |
| 181 | == Adding New Devices to the Device Tree |
| 182 | For customers interested in adding a new device to a board's device-tree (for example something connected to an off-board header) see the following examples: |
| 183 | * [wiki:/SPI SPI] |
| 184 | |
| 185 | |
| 186 | [=#dtc] |
| 187 | == Device Tree Compiler |