Operating Systems and Embedded Software · Kernel
Device Driver
Also known as driver, kernel driver, platform driver
Software that lets an operating system control a specific hardware device, translating generic requests (read, write, configure) into device-specific register accesses, interrupt handling and DMA transfers.
Explanation
In Linux, drivers live inside the kernel's device model, which provides a common data model for buses, the devices that can appear on them and the drivers that control those devices. Driver binding associates a device with a driver that can control it. When a match is found, the driver's probe routine initialises the hardware. The device hierarchy is exported to user space through the sysfs virtual file system.
Drivers present hardware through standard interfaces (network interfaces for CAN and Ethernet controllers, character and block devices, or subsystem APIs such as video capture), so applications do not need hardware details. On microkernel systems such as QNX, drivers instead run as user-space processes, which isolates driver faults from the kernel.
Driver quality strongly affects reliability and timing. A driver that keeps interrupts disabled for long periods, or allocates memory in time-critical paths, can undermine real-time behaviour across the whole system.
How it works
When a device is registered, for example from the device tree on an SoC or by bus enumeration on PCIe, the bus core compares its identifiers with the ID tables of registered drivers. On a match it calls the driver's probe routine, which maps registers, requests interrupts and DMA channels and registers the device with a subsystem. Runtime requests then flow from the subsystem to the driver's callbacks, and remove and power-management callbacks handle unbinding and suspend.
Automotive applications
- CAN and CAN FD controller drivers exposed through SocketCAN
- Camera and image-signal-processor capture drivers for ADAS
- Ethernet PHY and switch drivers
- Watchdog, GPIO and power-management IC drivers
Example
A CAN FD controller on an SoC is described in the device tree. At boot the platform bus matches its compatible string to the vendor driver. The probe routine maps the registers, requests the controller's interrupt and registers a network device that user space sees as can0.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- The Linux Kernel Device Model (opens in a new tab)
“a common, uniform data model for describing a bus and the devices that can appear under the bus”
- Driver Binding (opens in a new tab)
“Driver binding is the process of associating a device with a device driver that can control it.”
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.