How does a compatible string bind a device to a kernel driver?
The compatible string is the primary mechanism that connects a device tree node to its kernel driver. Each device tree node has a compatible property — a list of one or more strings, ordered from most specific to most generic. For example: compatible = "ti,am335x-uart", "ti,omap3-uart", "ns16550a";. Each kernel driver has a match table (of_match_table) listing the compatible strings it supports.
When the kernel walks the device tree at boot, it creates a platform_device for each node and tries to find a matching driver. The matching process checks the device's compatible strings against every registered driver's match table. The first compatible string that matches wins. This is why the list is ordered from specific to generic — the most specific driver gets priority, but if no specific driver exists, a generic one (like ns16550a for basic 16550 UARTs) can take over.
A common interview debugging scenario: your driver's probe() function is never called. The most frequent cause is a mismatch between the compatible string in the device tree and the string in the driver's of_match_table. Even a single character difference (a typo, a missing vendor prefix) will prevent binding. Always verify with cat /sys/bus/platform/devices/*/of_node/compatible and compare against the driver source. Another cause is forgetting to set the device tree node's status property to "okay" — nodes with status = "disabled" are skipped.
Source: Embedded Linux Q&A
