Day72 - Platform Bus Internals¶
Objective¶
Understand how the Linux Platform Bus is built on top of the Linux Driver Model and how Device Tree creates platform devices that are matched against platform drivers.
Topics covered:
platform_bus_typeplatform_deviceplatform_driver- Device Tree integration
of_match_table- Name matching
- Compatible matching
MODULE_DEVICE_TABLE(of)- Platform Bus sysfs hierarchy
Lab 1 - Observe Real Platform Bus Devices¶
Inspect Platform Bus¶
Example output:
Inspect Platform Devices¶
Example output:
Inspect Device Binding¶
Example output:
Inspect Driver Side¶
Example output:
Inspect Device Tree Node¶
Example output:
Inspect Compatible String¶
Example output:
Lab 2 - Minimal Platform Driver¶
Goal¶
Register a platform driver without creating any platform device.
Driver Registration¶
static struct platform_driver demo_driver = {
.probe = demo_probe,
.remove = demo_remove,
.driver = {
.name = "demo_platform",
},
};
Verify Driver Registration¶
Expected log:
No probe should occur.
Verify Sysfs¶
Expected:
No device symlink exists.
Lab 3 - Name Matching¶
Goal¶
Create a platform device manually and verify name-based matching.
Create Platform Device¶
Register Driver¶
Verify Probe¶
Expected log:
Verify Binding¶
Driver side:
Device side:
Registration Order Test¶
Driver First¶
Device First¶
Result:
Lab 4 - Device Tree Compatible Matching¶
Goal¶
Verify Device Tree based matching using of_match_table.
Device Tree Overlay¶
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2712";
fragment@0 {
target-path = "/";
__overlay__ {
demo_platform: demo-platform {
compatible = "demo,platform-bus";
status = "okay";
};
};
};
};
Driver Match Table¶
Driver Definition¶
Load Driver First¶
Expected:
Apply Overlay¶
Expected:
Remove Overlay¶
Expected:
Verify Device Tree Node¶
Expected:
Verify Compatible¶
Expected:
Lab 5 - Compatible Match Failure¶
Goal¶
Verify that matching fails when compatible strings differ.
Modify Driver¶
Load Driver¶
Apply Overlay¶
Expected:
No probe should occur.
Conclusion¶
Successful registration does not imply successful binding.
Lab 6 - MODULE_DEVICE_TABLE(of)¶
Goal¶
Inspect generated OF aliases.
Inspect Module Metadata¶
Example output:
Conclusion¶
Result¶
Verified:
- Real Raspberry Pi 5 Platform Bus hierarchy
- Platform driver registration
- Name-based matching
- Device Tree compatible matching
- Match failure behavior
- Registration order independence
- Platform Bus sysfs hierarchy
- Device Tree integration
- MODULE_DEVICE_TABLE(of) behavior