Part 11: IIO, RTC, Regulator, Clock Drivers
This part covers four important kernel subsystems: Industrial I/O (IIO) for sensors and data acquisition, Real-Time Clock (RTC) for timekeeping, Regulator framework for power management, and Common Clock Framework (CCF) for clock providers.
flowchart TB
subgraph Subsystems["Kernel Subsystems"]
IIO["IIO<br/>Industrial I/O"]
RTC["RTC<br/>Real-Time Clock"]
REG["Regulator<br/>Framework"]
CLK["Clock<br/>Framework"]
end
subgraph Devices["Device Types"]
ADC["ADC/DAC"]
ACCEL["Accelerometers"]
GYRO["Gyroscopes"]
RTCDEV["RTC Chips"]
PMIC["PMICs"]
LDO["LDOs/Bucks"]
PLL["PLLs"]
CLKGEN["Clock Generators"]
end
subgraph Consumers["Consumers"]
APPS["Applications"]
THERMAL["Thermal"]
DRIVERS["Other Drivers"]
end
ADC --> IIO
ACCEL --> IIO
GYRO --> IIO
RTCDEV --> RTC
PMIC --> REG
LDO --> REG
PLL --> CLK
CLKGEN --> CLK
IIO --> APPS
RTC --> APPS
REG --> DRIVERS
CLK --> DRIVERS
style Subsystems fill:#738f99,stroke:#0277bd
style Devices fill:#7a8f73,stroke:#2e7d32
style Consumers fill:#8f8a73,stroke:#f9a825
What You’ll Learn
Industrial I/O (IIO)
- IIO subsystem architecture
- Channels, attributes, and buffers
- Triggered buffer acquisition
- IIO device registration
Real-Time Clock (RTC)
- RTC subsystem overview
rtc_deviceimplementation- Alarm and wake-up support
- RTC class operations
Regulator Framework
- Voltage regulator concepts
- Provider (supply) drivers
- Consumer API
- Constraints and coupling
Common Clock Framework
- Clock tree hierarchy
clk_hwimplementation- Clock types (fixed, divider, mux, PLL)
- Clock operations
Subsystem Overview
flowchart LR
subgraph IIO_Sub["IIO Subsystem"]
IIODEV["iio_dev"]
IIOCHAN["iio_chan_spec"]
IIOBUF["IIO Buffer"]
IIOTRIG["IIO Trigger"]
end
subgraph RTC_Sub["RTC Subsystem"]
RTCDEV2["rtc_device"]
RTCOPS["rtc_class_ops"]
RTCALARM["Alarms"]
end
subgraph REG_Sub["Regulator Framework"]
REGDEV["regulator_dev"]
REGDESC["regulator_desc"]
REGCON["regulator_consumer"]
end
subgraph CLK_Sub["Clock Framework"]
CLKHW["clk_hw"]
CLKOPS["clk_ops"]
CLKPROV["Clock Provider"]
end
style IIO_Sub fill:#738f99,stroke:#0277bd
style RTC_Sub fill:#7a8f73,stroke:#2e7d32
style REG_Sub fill:#8f8a73,stroke:#f9a825
style CLK_Sub fill:#8f6d72,stroke:#c62828
Key Structures
| Subsystem | Main Structure | Registration Function |
|---|---|---|
| IIO | struct iio_dev |
devm_iio_device_register() |
| RTC | struct rtc_device |
devm_rtc_device_register() |
| Regulator | struct regulator_dev |
devm_regulator_register() |
| Clock | struct clk_hw |
devm_clk_hw_register() |
Common Patterns
These subsystems share several design patterns:
- Provider/Consumer Model: Drivers expose resources; others consume them
- Hierarchical Organization: Clocks in trees, regulators in supplies
- Device Tree Integration: Standard bindings for configuration
- Managed Resources:
devm_*functions for automatic cleanup - Runtime PM Integration: Power-aware operation
In This Part
- IIO Subsystem - IIO architecture overview
- IIO Driver - Implementing iio_dev
- IIO Buffers - Triggered buffer acquisition
- RTC Subsystem - RTC architecture
- RTC Driver - Implementing rtc_device
- Regulator Subsystem - Regulator framework
- Regulator Driver - Provider/consumer implementation
- Clock Framework - CCF overview
- Clock Provider - Implementing clk_hw
Further Reading
- IIO Documentation - Industrial I/O
- RTC Documentation - Real-time clock
- Regulator Documentation - Regulator framework
- Clock Framework - Common clock framework
Prerequisites
Before starting this part, you should understand:
- Platform drivers and Device Tree (Part 8)
- I2C/SPI drivers (Part 9)
- Managed resources (devm_*) - essential for these drivers
- Basic kernel memory management (Part 5)