Skip to content

Commit 39b2409

Browse files
committed
docs: iio: Add documentation for MAX22007 driver
Add documentation for MAX22007 driver which describes how the user can access the driver using dtoverlays Signed-off-by: Janani Sunil <[email protected]>
1 parent 3d1364f commit 39b2409

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed

Documentation/iio/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Industrial I/O Kernel Drivers
3131
adxl380
3232
bno055
3333
ep93xx_adc
34+
max22007

Documentation/iio/max22007.rst

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
.. SPDX-License-Identifier: GPL-2.0-only
2+
3+
===============
4+
MAX22007 driver
5+
===============
6+
7+
Device driver for Analog Devices Inc. MAX22007 quad-channel industrial DAC.
8+
The module name is ``max22007``.
9+
10+
Supported devices
11+
=================
12+
13+
* `MAX22007 <https://www.analog.com/en/products/max22007.html>`_
14+
15+
Wiring connections
16+
==================
17+
18+
The MAX22007 uses a standard SPI interface.
19+
20+
Device Tree Configuration
21+
=========================
22+
23+
The device supports both global and per-channel configuration through device tree.
24+
25+
Global Properties:
26+
* ``adi,crc-enable``: Enable CRC8 error checking for SPI communications (optional)
27+
28+
Per-channel properties:
29+
* ``adi,dac-latch-mode``: Controls when DAC updates occur
30+
- 0: LDAC pin controls the latch (default)
31+
- 1: Transparent latch mode (immediate update)
32+
33+
* ``adi,mode``: Sets the output mode
34+
- 0: Voltage output mode (default)
35+
- 1: Current output mode
36+
37+
Device attributes
38+
=================
39+
40+
The MAX22007 driver provides IIO DAC interfaces that vary based on the
41+
configured channel mode. Each channel appears as a separate IIO device
42+
attribute:
43+
44+
* ``out_voltage_raw`` (voltage mode channels)
45+
* ``out_current_raw`` (current mode channels)
46+
* ``out_voltage_scale`` / ``out_current_scale`` (channel scaling factors)
47+
* ``ldac_update`` (per-channel LDAC latch control)
48+
49+
The driver automatically configures the IIO channel type based on the configured
50+
channel mode from device tree.
51+
52+
LDAC Update Control
53+
===================
54+
55+
Each channel provides an ``ldac_update`` attribute for runtime LDAC (Latch DAC)
56+
control. This allows precise timing control of when DAC register values are
57+
transferred to the output:
58+
59+
* Write ``1`` to trigger an immediate LDAC update for that specific channel
60+
* Write ``0`` for no operation (returns immediately)
61+
62+
This provides fine-grained control over output timing, which is essential for
63+
applications requiring synchronized DAC updates.
64+
65+
Usage Examples
66+
==============
67+
68+
Setting DAC output value and triggering LDAC update:
69+
70+
.. code-block:: bash
71+
72+
# Set channel 0 (voltage mode) to raw value 655 (≈2V)
73+
echo 655 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw
74+
75+
# Trigger LDAC update to apply the new value
76+
echo 1 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_ldac_update
77+
78+
# Set channel 1 (current mode) and update
79+
echo 1024 > /sys/bus/iio/devices/iio:deviceX/out_current1_raw
80+
echo 1 > /sys/bus/iio/devices/iio:deviceX/out_current1_ldac_update
81+
82+
Reading channel values and scale factors:
83+
84+
.. code-block:: bash
85+
86+
# Read raw DAC value
87+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw
88+
89+
# Read scale factor (volts per LSB)
90+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_scale
91+
92+
Check available channels:
93+
94+
.. code-block:: bash
95+
96+
ls /sys/bus/iio/devices/iio:deviceX/out_*_raw
97+
98+
Scale Calculations
99+
==================
100+
101+
The driver provides accurate scale factors based on the hardware configuration:
102+
103+
**Voltage Mode:**
104+
- Scale = (5 × 2.5V) / 4096 = 0.003051757 V per LSB
105+
- Range: 0V to 12.5V over 12-bit (0-4095)
106+
- Formula: Output = Raw_Value × Scale
107+
108+
**Current Mode:**
109+
- Scale = (2.5V / (2 × 50Ω)) / 4096 = 0.000006103515625 A per LSB
110+
- Range: 0A to 0.025A over 12-bit (0-4095)
111+
- Formula: Output = Raw_Value × Scale
112+
113+
Register Map
114+
------------
115+
116+
The MAX22007 uses the following register mapping:
117+
118+
.. list-table::
119+
:header-rows: 1
120+
121+
* - Address
122+
- Register Name
123+
- Description
124+
* - 0x03
125+
- CONFIG_REG
126+
- Configuration register (CRC enable, DAC latch modes)
127+
* - 0x04
128+
- CONTROL_REG
129+
- LDAC control register for runtime updates
130+
* - 0x05
131+
- CHANNEL_MODE_REG
132+
- Channel mode and power control
133+
* - 0x06
134+
- SOFT_RESET_REG
135+
- Software reset control
136+
* - 0x07-0x0A
137+
- DAC_CHANNEL_REG(0-3)
138+
- DAC data registers for channels 0-3
139+
140+
141+
Driver Architecture
142+
===================
143+
144+
The driver implements the following key features:
145+
146+
* **CRC8 Error Checking**: All SPI communications use CRC8 for data integrity
147+
* **Channel Configuration**: Supports per-channel mode and power configuration
148+
* **Register Map**: Uses regmap for efficient register access and caching
149+
* **IIO Integration**: Full integration with the Linux IIO subsystem
150+
151+
Not Implemented
152+
===============
153+
154+
* Channel configuration (voltage/current mode) is set at device tree parsing
155+
and cannot be changed dynamically
156+
* The driver requires proper device tree configuration for optimal operation
157+
* Simultaneous multi-channel LDAC updates (only single-channel updates supported)

0 commit comments

Comments
 (0)