Platform Bus¶
Overview¶
The Platform Bus is the most commonly used bus type for SoC-integrated peripherals in Embedded Linux systems.
Unlike discoverable buses such as PCIe or USB, platform devices are usually described by firmware information, most commonly through Device Tree.
Typical platform devices include:
- GPIO Controllers
- UART Controllers
- SPI Controllers
- I2C Controllers
- Watchdogs
- RTCs
- PWMs
- DMA Controllers
- PCIe Controllers
The Platform Bus is built on top of the Linux Driver Model.
Relationship with the Linux Driver Model¶
The Linux Driver Model provides three core objects:
The Platform Bus specializes these objects:
As a result, Platform Bus behavior follows the same matching and binding mechanisms used throughout the Driver Core.
Platform Bus Architecture¶
The Platform Bus is responsible for matching devices and drivers.
A successful match establishes a device-driver binding and allows probing to proceed.
Device Creation¶
Platform devices may be created in several ways.
Device Tree¶
Most modern ARM systems use Device Tree.
Example:
The kernel automatically creates a corresponding platform device.
Manual Registration¶
Platform devices may also be created directly by software.
This approach is commonly used for:
- Testing
- Legacy platforms
- Virtual devices
Driver Registration¶
Platform drivers are registered through:
Internally:
The driver becomes part of the Platform Bus and participates in device matching.
Matching Methods¶
The Platform Bus supports several matching mechanisms.
Conceptually:
The matching order is:
The exact implementation may vary between kernel versions.
Device Tree Matching¶
The most common matching method on Embedded Linux systems uses Device Tree.
Driver:
Device Tree:
Matching flow:
If the strings match, the driver can be bound to the device.
Name Matching¶
When Device Tree matching is unavailable, Platform Bus may fall back to name matching.
Device:
Driver:
Matching flow:
Name matching is commonly used in simple examples and legacy code.
Probe Flow¶
A successful match allows the probing process to continue.
Conceptually:
platform_driver_register()
↓
driver_register()
↓
driver_attach()
↓
platform_match()
↓
really_probe()
↓
platform_probe()
↓
driver probe()
The exact internal implementation may vary between kernel versions.
Device Tree and Probe¶
A common misunderstanding is:
This is incorrect.
The actual flow is:
Device Tree creates platform devices.
The Platform Bus performs device-driver matching.
The driver's probe callback is only invoked after a successful bind.
MODULE_DEVICE_TABLE(of)¶
Example:
This macro generates OF module aliases.
Example:
Purpose:
Runtime matching still relies on:
rather than MODULE_DEVICE_TABLE().
Sysfs Representation¶
Platform Bus objects are visible through sysfs.
Bus:
Devices:
Drivers:
Device Tree association:
Driver association:
These relationships can be inspected directly from sysfs.
Key Takeaways¶
Platform Bus is built on top of the Linux Driver Model.
Device Tree creates platform_device objects.
Platform Bus performs matching.
Successful matching triggers probe().
Device Tree does not call probe() directly.