Linux Driver Model¶
Overview¶
The Linux Driver Model provides a unified framework for managing:
- Devices
- Drivers
- Buses
and their relationships.
Most Linux driver subsystems are built on top of this architecture, including:
- Platform
- I2C
- SPI
- USB
- PCI
Understanding the Linux Driver Model is essential before studying subsystem-specific drivers.
Why the Driver Model Exists¶
Without a common framework, every subsystem would need to implement:
- Device discovery
- Driver registration
- Device-driver matching
- sysfs integration
- Power management
independently.
The Linux Driver Model centralizes these responsibilities inside the Driver Core.
Architecture¶
The Linux Driver Model consists of three core objects:
Relationship:
Core Objects¶
Device¶
Represents hardware.
Examples:
- Platform Device
- I2C Device
- SPI Device
- USB Device
- PCI Device
Kernel object:
Driver¶
Represents software capable of controlling a device.
Kernel object:
Examples:
- platform_driver
- i2c_driver
- spi_driver
Bus¶
Acts as the matching framework between devices and drivers.
Kernel object:
Examples:
- platform_bus_type
- i2c_bus_type
- spi_bus_type
- usb_bus_type
- pci_bus_type
Registration Flow¶
The Driver Core supports independent registration.
or
Registration order does not matter.
Matching¶
Matching is performed by the bus.
Different buses use different matching criteria.
Examples:
| Bus | Matching Method |
|---|---|
| Platform | Device Tree compatible string |
| USB | Vendor ID / Product ID |
| PCI | Vendor ID / Device ID |
| I2C | Device ID / Device Tree |
| SPI | Device ID / Device Tree |
Probe and Remove Lifecycle¶
After a successful match:
The probe callback initializes the device and establishes the driver-device relationship.
Removal performs:
and releases allocated resources.
Driver Wrapper Pattern¶
Most Linux subsystems extend:
through wrapper structures.
Example:
Benefits:
- Generic Driver Core reuse
- Subsystem-specific callbacks
- Consistent driver architecture
sysfs Representation¶
The Driver Model is exposed through sysfs.
Important locations:
Real device hierarchy.
Bus-centric view.
User-oriented functional view.
Relationship with Device Tree¶
Device Tree does not directly create drivers.
Instead:
The Driver Model sits between Device Tree and Driver implementation.
Learning Roadmap¶
Recommended follow-up topics:
- Linux Driver Model
- Platform Bus Internals
- Platform Driver Matching
- kobject and sysfs
- Driver Core
- Device Tree Integration
- I2C Subsystem
- SPI Subsystem
Related Notes¶
- Linux Driver Model Fundamentals
Related Labs¶
- Day71 - Linux Driver Model Fundamentals
Related APIs¶
- bus_register()
- bus_unregister()
- device_register()
- device_unregister()
- driver_register()
- driver_unregister()