← Back to articles
LINUX & DRIVERS · PRACTICAL GUIDE

Device Tree: How Linux Describes Hardware

Device Tree separates a board's hardware description from much of the driver code. It tells Linux which devices exist, where their registers are, and which resources they need.

Why Device Tree exists

Embedded boards may share a processor family but differ in attached peripherals, memory maps, clocks, GPIO wiring, and interrupts. Device Tree represents those differences as data rather than hard-coding every board variation into a driver.

A small example

sensor@48 {
    compatible = "acme,example-sensor";
    reg = <0x48>;
    status = "okay";
};

This is illustrative only: the node belongs under the correct bus controller, and the meaning of reg depends on that bus's address and size cells. For I²C, the address is typically a bus address, not a CPU physical register address.

From DTS to probe()

  1. A board description is compiled from DTS into a DTB.
  2. The bootloader passes the DTB to the kernel.
  3. The kernel creates device objects from enabled nodes.
  4. A driver's of_match_table matches the node's compatible string.
  5. The driver core calls probe() when matching and dependencies permit it.

Resources and dependencies

Drivers should retrieve resources through subsystem APIs rather than parsing arbitrary properties manually. Clocks, regulators, resets, GPIOs, and interrupts may be described as dependencies. Deferred probing can occur when a required provider is not ready yet.

Debugging checklist

Device Tree is an interface contract between firmware, board description, and drivers. Keep it consistent with the actual hardware and kernel binding documentation.

Final takeaway

Low-level engineering is about understanding the contract between hardware, firmware, and the operating system. Start with the specification, form a testable hypothesis, collect evidence, and validate behavior on the target platform.