In this lesson, you will learn how to formally describe a peripheral’s physical properties, such as register addresses, interrupt signals, and clock requirements, within a Linux Device Tree node.
When the Linux kernel boots, it needs a "map" to understand the hardware layout of your specific SoC. Because we can no longer hard-code every register offset into drivers, we use the Device Tree to represent these hardware components as nodes. A peripheral node acts as a container that maps the physical silicon to the kernel’s resource management subsystems.
Defining Hardware Resources
To make a peripheral functional, the kernel requires three critical pieces of information mapped within the device node:
reg(Memory-Mapped I/O): This property defines the base address and size of the peripheral's register space. It tells the kernel exactly where in the system memory map the hardware lives.interrupts: This identifies the specific interrupt line connected to the peripheral. By mapping this, the kernel knows which interrupt controller input to trigger when the hardware requires attention.clocks: This specifies the clock source provided by the SoC’s clock manager. It allows the kernel's clock framework to gate or scale the peripheral's frequency dynamically.
Example: Mapping a UART Controller
Consider this snippet for a hypothetical serial controller:
uart@48000000 {
compatible = "vendor,my-uart";
reg = <0x48000000 0x1000>; /* Base addr 0x48000000, size 0x1000 */
interrupts = <0 15 4>; /* Interrupt controller mapping */
clocks = <&clk_manager 10>; /* Reference to clock source */
status = "okay";
};
In this structure, the reg property maps the physical memory range into the virtual address space during driver initialization. The interrupts property allows the kernel to register an Interrupt Service Routine (ISR) linked to that hardware line. Finally, the clocks property ensures the kernel keeps the hardware powered by enabling the necessary gate in the clock tree. By aggregating these properties, you decouple the driver logic from the physical wiring of the board, allowing the same driver to support multiple hardware revisions simply by updating the Device Tree.
Key Takeaway: The Device Tree node acts as a hardware manifest, mapping physical memory addresses, interrupt lines, and clock paths into a unified structure that the Linux kernel uses to configure and communicate with peripherals.