Platform Bus Internals¶
Overview¶
The Linux Platform Bus is the most commonly used bus type for SoC-integrated peripherals in Embedded Linux systems.
Examples:
- GPIO Controller
- UART Controller
- SPI Controller
- I2C Controller
- Watchdog
- RTC
- PWM
- DMA
- PCIe Controller
The Platform Bus is built on top of the Linux Driver Model.
Relationship with Driver Core¶
The Platform Bus is not a separate driver framework.
It is a specialization of the Linux Driver Model.
Platform Bus extends these structures:
Platform Bus Architecture¶
The Platform Bus is responsible for matching devices and drivers.
A successful match triggers the driver's probe callback.
Device Creation¶
Platform devices can be created in multiple ways.
Device Tree¶
Most modern ARM systems use Device Tree.
Example:
The kernel creates a corresponding platform device.
Manual Registration¶
A platform device may also be created manually.
This is commonly used for:
- Testing
- Legacy code
- Virtual devices
Driver Registration¶
Platform drivers are registered through:
Internally:
The driver becomes part of the Platform Bus.
Matching Flow¶
The Platform Bus provides its own match callback:
Conceptually:
A successful match allows probing to proceed.
Device Tree Matching¶
The most common matching method on ARM systems uses Device Tree.
Driver:
Device Tree:
Matching:
Name Matching¶
If Device Tree matching is unavailable, Platform Bus may fall back to name matching.
Device:
Driver:
Matching:
Probe Flow¶
The complete flow is:
platform_driver_register()
↓
driver_register()
↓
driver_attach()
↓
platform_match()
↓
really_probe()
↓
platform_probe()
↓
driver probe()
The driver's probe callback is not called directly by Device Tree.
Device Tree and Probe¶
A common misunderstanding is:
This is incorrect.
Actual flow:
Device Tree creates devices.
The Platform Bus performs matching.
MODULE_DEVICE_TABLE(of)¶
Example:
This macro generates OF module aliases.
Example:
Purpose:
It is not responsible for runtime matching.
Runtime matching uses:
Sysfs Representation¶
Platform Bus objects are visible through sysfs.
Bus:
Devices:
Drivers:
Device Tree association:
Driver association:
Key Takeaways¶
Platform Bus is built on top of Driver Core.
Device Tree creates platform_device objects.
Platform Bus performs matching.
Successful matching triggers probe().
Device Tree does not call probe() directly.
Related Topics¶
- Linux Driver Model Fundamentals
- Device Tree Fundamentals
- Platform Driver and Device Tree Binding
- Driver Probe and Remove Lifecycle
Related APIs¶
- platform_driver_register()
- platform_driver_unregister()
- platform_device_register_simple()
- platform_device_unregister()
- MODULE_DEVICE_TABLE()