Skip to content

Devicetree

Device Tree (DT) is a data structure that describes non-discoverable hardware components of a computer system, providing a standardized way for operating systems to identify and configure hardware. It is a tree-like data structure, hence the name, composed of named nodes and properties that describe the hardware components.

In the context of Linux and Android, the Device Tree is used to support a wide range of hardware configurations used by Android-powered devices. Hardware vendors supply their own Device Tree Source (DTS) files, which are compiled into a Device Tree Blob (DTB) file using the Device Tree Compiler. The DTB file is then passed to the kernel during boot, allowing it to discover and configure the hardware components.

The Device Tree contains information such as:

  1. Node names and properties: Describe hardware components, such as CPUs, memory, buses, and integrated peripherals.
  2. Phandles: Unique identifiers for nodes, used to reference them in property values.
  3. Compatible lists: Allow the kernel to identify the best match between the Device Tree and the machine’s hardware.

The Device Tree is used by the kernel to:

  1. Identify and configure hardware components.
  2. Initialize hardware at boot time.
  3. Provide runtime and configuration data to the kernel.

Key benefits of the Device Tree include:

  1. Platform independence: Allows the kernel to support multiple hardware platforms without requiring extensive platform-specific code.
  2. Flexibility: Enables hardware vendors to customize their Device Tree to describe their specific hardware configurations.
  3. Reusability: Reduces the need for platform-specific code and makes it easier to port the kernel to new hardware platforms.

In summary, the Device Tree is a standardized data structure that describes non-discoverable hardware components, enabling operating systems to identify and configure hardware in a platform-independent and flexible manner.

gpio: gpio@40000000 {
    #gpio-cells = <2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    reg = <0x40000000 0x100>;
    gpio-controller;
    interrupt-parent = <&interrupt_controller>;
    interrupts = <1 2>; /* IRQ numbers for GPIO interrupts */
    xlnx,all-inputs;
    xlnx,gpio-width = <32>; /* GPIO width */
    xlnx,tri-default = <1>; /* Default tri-state mode */
};
  • gpio is the node name for the AXI GPIO device.
  • @40000000 specifies the base address of the device.
  • #gpio-cells = <2> indicates that the device has two cells for GPIO pin configuration (pin number and optional parameters).
  • compatible specifies the compatible string for the device, which is “xlnx,xps-gpio-1.00.a” according to the search results.
  • gpio-controller marks the device as a GPIO controller.
  • interrupt-parent specifies the parent interrupt controller node.
  • interrupts specifies the IRQ numbers for GPIO interrupts.
  • xlnx,all-inputs, xlnx,gpio-width, and xlnx,tri-default are optional properties that configure the GPIO device’s behavior.