Changes between Version 2 and Version 3 of linux/devicetree


Ignore:
Timestamp:
10/24/2017 04:37:41 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • linux/devicetree

    v2 v3  
    44The modern linux kernel uses a system called 'devicetree' to describe hardware in a consistent fashion to avoid needing custom 'board support' files for boards.
    55
    6 Typically the bootloader will pass a 'flattened device tree' (a compiled binary representation of a device-tree) to the kernel so that the kernel can configure all the components on the board.
     6Typically the bootloader will pass a 'flattened device tree' (a compiled binary representation of a device-tree) to the kernel so that the kernel can configure all the components on the board. 
    77
    88The Gateworks Ventana product family based off the Freescale i.MX6 CPU, uses devicetree (with the exception of the early Yocto 1.3 and Android jellybean BSP's which were based on a 3.0.35 non-device-tree kernel)
     
    1717
    1818== Example Device Tree File ==
    19 You can find the device tree files in {{{arch/arm/boot/dts}}}
     19You can find the device tree files in arch/arm/boot/dts
    2020
    2121For an example, see here: [https://github.com/Gateworks/linux-imx6/blob/gateworks_3.10.53_1.1.0_ga/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi]
    2222
    2323
    24 == Accessing Device Tree from the Bootloader ==
     24== Accessing devicetree from the Bootloader ==
    2525The Ventana u-boot has fdt support enabled and uses this through default bootscripts to load an fdt (based on the board model) from the filesystem of the boot media.  The bootloader then modifies the devicetree to disable components that are possible on the board, but perhaps not loaded on the bill-of-materials (for example, a Gateworks Special build).
    2626
    27 If desired you can use the {{{ftd}}} u-boot command to access/modify the devicetree before the kernel is booted.
     27If desired you can use the ftd u-boot command to access/modify the devicetree before the kernel is booted.
    2828
    2929Examples:
    3030 * display the fdt of a Ventana board (loaded from NAND flash ubifs):
    31 {{{#!bash
     31{{{
    3232setenv fsload 'ubifsload'
    3333ubi part rootfs && ubifsmount ubi0:rootfs
     
    3636}}}
    3737 * disable PCI via device-tree:
    38 {{{#!bash
     38{{{
    3939setenv fsload 'ubifsload'
    4040ubi part rootfs && ubifsmount ubi0:rootfs
     
    4444}}}
    4545
    46 Note the Ventana bootloader has a {{{fixfdt}}} script that can make integrating fixups like this into the boot process easy. See [http://trac.gateworks.com/wiki/ventana/bootloader#Specifyinganalternatedevice-treeblobDTB here] for details.
     46Note the Ventana bootloader has a '''fixfdt''' script that can make integrating fixups like this into the boot process easy. See [http://trac.gateworks.com/wiki/ventana/bootloader#Specifyinganalternatedevice-treeblobDTB here] for details.
    4747
    4848
    49 == Accessing Device Tree from Linux ==
    50 If the kernel is configured with CONFIG_PROC_DEVICETREE (which the Ventana OpenWrt BSP does configure) and procfs is enabled, you can access the devicetree via {{{/proc/device-tree}}}.  This can be useful to obtain information about the board that the bootloader configured, such as board model and serial number.
     49== Accessing devicetree from Linux ==
     50If the kernel is configured with CONFIG_PROC_DEVICETREE (which the Ventana OpenWrt BSP does configure) and procfs is enabled, you can access the devicetree via /proc/device-tree.  This can be useful to obtain information about the board that the bootloader configured, such as board model and serial number.
    5151
    5252Examples:
    5353 * show board model:
    54 {{{#!bash
     54{{{
    5555echo $(cat /proc/device-tree/board)
    5656}}}
    5757 * show board serialnumber
    58 {{{#!bash
     58{{{
    5959echo $(cat /proc/device-tree/system-serial)
    6060}}}
    6161 * show devicetree compatible node (this describes which device-tree was used as there is one per base-board design):
    62 {{{#!bash
     62{{{
    6363echo $(cat /proc/device-tree/compatible)
    6464}}}
    65  * show chosen bootargs (the bootargs passed in by the bootloader, same as {{{/proc/cmdline}}}):
    66 {{{#!bash
     65 * show chosen bootargs (the bootargs passed in by the bootloader, same as /proc/cmdline):
     66{{{
    6767echo $(cat /proc/device-tree/chosen/bootargs)
    68 }}}
    69  * Print the whole device tree:
    70 {{{#!bash
    71 find /proc/device-tree/
    7268}}}
    7369
    7470
    75 == Specifying the Device Tree Used ==
    76 The [wiki:/linux/bootloader bootloader] is responsible for loading the device-tree blob (DTB) and executing the kernel
     71== Specifying the Device-tree that is used ==
     72The [wiki:/linux/bootloader bootloader] is responsible for loading the device-tree blob (DTB) and executing the kernel 
    7773The Gateworks ventana bootloader in a way that it knows where the DTB is loaded.
    7874
    7975Therefore, its the bootloader that decides which DTB to load and from where.
    8076
    81 See [wiki:/ventana/bootloader] for details on how the DTB filename is chosen and loaded.
    82 
    83 == Adding New Devices to the Device Tree ==
    84 For customers interested in adding a new device to an existing controller, see the [wiki:SPI] wiki page for an example of the process.
    85 
    86 == Compiling the Device Tree ==
    87 If you need to change the device-tree you can easily compile it on a Linux system using the {{{dtc}}} app from the device-tree-compiler package:
    88 {{{#!bash
    89 apt-get install device-tree-compiler
    90 dtc -O dtb -o imx6dl-gw51xx.dtb imqx6dl-gw51xx.dts
    91 }}}
    92 
    93 You can also de-compile a dtb back to a dts:
    94 {{{#!bash
    95 $ dtc -I dtb -O dts imx6dl-gw51xx.dtb
    96 }}}
     77See [wiki:/ventana/bootloader] for details on how the DTB filename is chosen and loaded.