Day37 – IIO FIFO Mode with Watermark Interrupt¶
Overview¶
In Day36, the driver used a per-sample interrupt model:
This approach is simple but inefficient:
- High interrupt frequency
- Low I2C transfer efficiency
- High CPU overhead
FIFO-Based Design¶
To improve efficiency, FIFO buffering is introduced:
Sensor:
accumulate multiple samples in FIFO
When FIFO >= watermark:
→ trigger IRQ
Driver:
→ read multiple samples in one burst
→ push multiple frames into IIO buffer
FIFO Architecture¶
IRQ Design¶
IRQ is a global interrupt state, not FIFO-specific.
Non-FIFO mode¶
FIFO mode¶
IRQ Edge Behavior¶
Proper IRQ requires level transition:
Without deassert:
- IRQ stays high
- No new interrupts
- Driver stalls
Linux IIO Data Flow (FIFO)¶
IRQ (GPIO)
→ iio_trigger_poll()
→ pollfunc
→ read FIFO_COUNT
→ read FIFO_DATA (burst)
→ unpack frames
→ iio_push_to_buffers()
SMBus Limitation¶
FIFO frame:
Maximum frames per read:
Driver must limit read size accordingly.
FIFO Drain Strategy¶
Critical logic:
Goal:
IIO Design Principle¶
Driver responsibilities:
- read data
- push buffer
User-space responsibilities:
- enable scan elements
- bind trigger
- enable buffer