Code Journal

How the Kernel Knows What Hardware My Phone Has

NOV 16, 2026

Anecdotes
omarchylinuxkerneldevice treehardware

What a device tree is, why a phone needs one and a PC doesn't, and how the bootloader assembles the one the kernel gets, told with real data from my OnePlus 10 Pro.

In the previous entry I wrote 228 lines of device tree for my OnePlus 10 Pro and described it in one sentence: the file that tells the kernel what hardware there is. While I was writing it I realized that sentence wasn't enough, and that the underlying question was exactly the one that got me into this: how does the kernel know what hardware it has. So before trying to boot anything, it's worth stopping to look at what a device tree is, why it exists, and why the one Android's kernel receives isn't a file you can open anywhere.

Why the kernel can't discover a phone's hardware

On a PC, the kernel can discover almost all the hardware by itself. The motherboard firmware hands it some tables (called ACPI) describing the machine, and the buses expansion cards plug into, like PCI, can be walked by asking "who's there?": every device answers with what it is. That's why the same kernel boots on thousands of different computers without knowing in advance which one it's on, and why I never had to think about any of this.

A phone doesn't work like that. My phone's storage controller lives at memory address 0x1d84000, and it just sits there, silent. There's no bus to walk and no device introducing itself. To use it, the kernel needs to know several things nobody is going to announce: that there's a storage controller at that address, which interrupt it uses (the signal a device uses to tell the processor "I'm done, pay attention to me"), which clocks it needs (the signals that set the pace of each block of the chip) and which regulators supply its voltage. If it doesn't know, as far as it's concerned that controller doesn't exist.

For years, on ARM chips (the family phones use), the answer was to write that information in C: one file per board, inside the kernel itself. With hundreds of boards that became unmanageable, and around 2011 the alternative other architectures already used was finally adopted: describe the hardware in a separate file that the bootloader hands to the kernel at boot. That's the device tree.

How to read a device tree, using storage as the example

It's literally a tree of nodes with properties, written as text and compiled into a binary format (the DTB) before it's handed to the kernel. This is the storage controller's node in mainline's description of the SM8450, trimmed:

dts
ufs_mem_hc: ufshc@1d84000 {
    compatible = "qcom,sm8450-ufshc", "qcom,ufshc", "jedec,ufs-2.0";
    reg = <0 0x01d84000 0 0x3000>;
    interrupts = <GIC_SPI 265 IRQ_TYPE_LEVEL_HIGH>;
    phys = <&ufs_mem_phy>;
    ...
};
  • ufshc@1d84000 is the node name, with its address. The same one I saw in the Android capture.
  • reg says where its registers are and how much space they take. Registers are small pieces of memory through which software controls a device: writing to one gives it an order, reading another asks for its status.
  • interrupts says which interrupt it uses.
  • &ufs_mem_phy is a reference to another node, its PHY: the part that handles the electrical signals to the memory chip. That's how the tree gets wired together: nodes point at each other to say "this clock", "this regulator", "this PHY".
  • compatible is the most important property. It's the list of names the kernel uses to find a driver, from most specific to most generic. The ufs-qcom driver says it handles "qcom,ufshc", so it binds to this node. It's the same module that, according to the previous entry, the initramfs would have to load before opening the system.

The chip maker and the phone maker describe different parts

What helped me most was seeing how the work is split between two files. The chip's description (a .dtsi file) declares everything inside the SM8450, but a lot of it comes switched off. The USB PHY, for example:

dts
usb_1_hsphy: phy@88e3000 {
    compatible = "qcom,sm8450-usb-hs-phy", "qcom,usb-snps-hs-7nm-phy";
    reg = <0 0x088e3000 0 0x400>;
    status = "disabled";
    ...
};

The chip has it, but it doesn't know which regulators power it on each phone, because the manufacturer decided that when designing its board. So it leaves it disabled, and each phone's description (a .dts) fills it in and turns it on. On the Galaxy S22:

dts
&usb_1_hsphy {
    vdda-pll-supply = <&vreg_l5b_0p88>;
    vdda18-supply = <&vreg_l1c_1p8>;
    vdda33-supply = <&vreg_l2b_3p07>;

    status = "okay";
};

&usb_1_hsphy doesn't create a new node: it opens the one the chip already declared and adds what's missing. Writing a phone's device tree is largely that: opening the chip's nodes one by one, saying how they're wired on this board and switching them on. When I followed the PHY's regulators in Android's description I got exactly those three voltage sources, because the S22 and the 10 Pro both start from the same Qualcomm test board.

On Android, the bootloader assembles the device tree at boot

Here's what I didn't expect. On the phone, with Android, there's no file that is "the OnePlus 10 Pro device tree". The one the kernel receives is assembled by ABL, the bootloader, at boot time, from three sources:

  1. The base DTB, inside a boot partition called vendor_boot. It describes the chip, just like mainline's .dtsi, but in the vocabulary of Qualcomm's kernel: there the SM8450 is called waipio. My phone has four, one per chip revision, and ABL picks its own using the numbers that identify the chip.
  2. A board overlay, inside another partition, dtbo. An overlay is like a patch: it's applied on top of the base tree and modifies it. The partition holds twelve, including some for OnePlus development boards, and ABL picks its own using the number that identifies the board. That overlay adds the model, describes the panel and the rest of what OnePlus soldered on.
  3. What ABL adds on its own: how much memory there is, the kernel's command line (the options it boots with, like a program's arguments) and what it detected at power-on, like which panel this particular phone has.

How ABL assembles my phone's device tree

How the bootloader assembles my phone's device tree.

  1. SoC

    vendor_boot

    Base DTB, the chip (waipio)

  2. Board

    dtbo

    OnePlus overlay, picked by board-id

    board-id 0x10008 · match

  3. ABL

    Bootloader

    What it injects at boot

Tree the kernel receives

= /sys/firmware/fdt

  1. SoC/
  2. Boardmodel = "Qualcomm Technologies, Inc. Waipio MTP with PM8010, wly"
  3. Boardcompatible = "qcom,waipio-mtp", "qcom,waipio", "qcom,mtp"
  4. Boardqcom,board-id = <0x10008 0x00>
  5. SoCmemory
  6. ABLreg = <…> /* 12 GB */
  7. SoCchosen
  8. ABLbootargs = "… qcom,mdss_dsi_panel_samsung_amb670yf07_1440_3216_dsc_cmd … synaptics-s3908 …"
  9. SoCreserved-memory
  10. SoChyp_region@80000000
  11. SoC/* …and 38 more regions */
  12. SoCsoc@0
  13. SoCufshc@1d84000
  14. SoChsphy@88e3000
  15. Board/* Samsung AMB670YF07 panel, 8 timings */

Simplified: a handful of the 3,171 nodes in the live tree, with their real values (… marks abbreviations). The chip and board layers match the 1302 vendor_boot and dtbo; the final tree, on the other hand, doesn't record where anything came from.

Tree complete: the base DTB, the board overlay and what ABL injected.

The kernel exposes the final result at /sys/firmware/fdt. That's why the root from the previous entry was so worth it: the partitions gave me the pieces separately, but only with root could I read the assembled version, with the memory, the command line and the panel the bootloader chose. Those 39,213 lines are what Android's kernel believes is the truth, and what the mainline kernel will have to reproduce.

The panel is a good example of how the layers split the work. The overlay describes the panel with eight different display modes, and it's the bootloader, at boot, that says on the command line which one is fitted: samsung_amb670yf07_1440_3216_dsc_cmd. Touch is similar: Android ships drivers for three different controllers, and the command line is what says this phone has a Synaptics S3908.

Why Android's device tree doesn't work with the official Linux kernel

My first idea was the obvious one: take that tree and hand it to the mainline kernel. It doesn't work, for a few reasons.

  • The vocabulary is different. The kernel that ships on the phone isn't mainline: it's a version made by Qualcomm and then modified by OnePlus. Its device tree uses different names in compatible (waipio instead of sm8450) and different properties: the USB PHY that asks for a regulator called vdd on Android asks for it as vdda-pll in mainline. Mainline drivers would recognize almost nothing.
  • The numbers can't be copied. Android's tree is compiled, so references between nodes are no longer names like &tlmm but numbers (called phandles). The volume button, for example, says gpios = <0x5a9 0x06 0x01>, and that 0x5a9 only means something inside that tree. Other numbers do carry over: the project has a rule never to copy interrupt numbers between different chips, but here the chip is the same, so Android's interrupts are the hardware's real ones.
  • There are no layers. In mainline, each phone is a single file that includes the chip's description and gets built along with the kernel. What the overlay and the bootloader contribute on Android, I have to write myself, by hand, in mainline's vocabulary.

So Android's tree isn't something you copy: it's the reference you compare against. The USB PHY is a good example of how that translation went, and following it takes knowing a bit about how power is distributed in the phone. Voltages come from PMICs, chips dedicated to power; this phone has several, and each one has many numbered regulators (LDOs are one kind of regulator). On Snapdragons, on top of that, Linux doesn't drive those regulators directly: it asks a small processor dedicated to power, which collects everyone's requests and decides, through a protocol called RPMh.

In Android's tree, the hsphy@88e3000 node asks for three supplies, and each one points to its regulator with a phandle. This is how the first one translated, in two steps:

  1. What I saw on Android. The vdd input points to a phandle. Looking up the node with that number led me to a regulator called pm8350_l5, with a voltage of 0.88 to 0.912 V. That node also carries the name Linux uses to request it from the power processor: ldob5, which reads as "LDO 5 on PMIC b".
  2. What I checked in mainline. There, regulators are declared grouped by PMIC: a block marked as PMIC b (the PM8350) with an ldo5 node inside. Mainline builds the same name from those two pieces, ldob5, so it's the same regulator. On the S22 that node is called vreg_l5b_0p88, and its voltage matches: 0.88 V.

The other two inputs were worked out the same way: the name the power processor uses gives the PMIC and the number, and the voltage confirms it's the same source.

Android inputMainline inputAndroid regulatorVoltageIn mainline
vddvdda-pllpm8350_l50.88–0.912 Vl5b
vdda18vdda18pm8350c_l11.8 Vl1c
vdda33vdda33pm8350_l23.072 Vl2b

The input's name can change (vdd becomes vdda-pll), but the voltage source is the same: same PMIC, same LDO number, same voltage. That's the check I did for every node, looking for its equivalent in the S22 or Qualcomm's test boards before translating it. The table also shows what shouldn't be copied blindly from the S22: on the OnePlus, l5b tops out at 0.912 V, not 0.888 V.

A mistake in reserved memory corrupts data without warning

Almost every mistake in a device tree shows. Describe the USB wrong and there's no USB. Get a regulator wrong and something doesn't power on. It's frustrating, but at least you know where to look.

The exception is reserved-memory. That section tells the kernel which parts of RAM aren't its own, because other processors in the chip use them (the modem, the audio and sensor ones, TrustZone) or the bootloader itself. If a region is missing, the kernel doesn't complain: it just uses it. And the processor that also uses it starts seeing its data change with no warning. That's why, in the previous entry, I compared Android's 39 regions against mainline's and reserved every gap before building anything. It's the part of the device tree where a mistake doesn't look like one.

The kernel believes everything the device tree says

What I take from all this is that the device tree is a contract the kernel signs without reading. It believes everything in it: that there's a storage controller at 0x1d84000, that the framebuffer is 1080×2412, that a certain chunk of memory is free. It has no way to check. If the tree lies, the kernel will act with complete confidence on wrong information.

My sm8450-oneplus-wly.dts is my first draft of that contract, written from what I read off the phone. I don't know yet how many of its clauses are right. A few questions stay open for the first boot: whether the framebuffer resolution was correct, and what the bootloader will do when I hand it a device tree that isn't its own, with OnePlus's overlay still sitting in its partition.