Skip to content

Commit 6e82321

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 b14bf32 commit 6e82321

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-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: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
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-disable``: Disable CRC8 error checking for SPI communications (optional, CRC enabled by default)
27+
* ``reset-gpios``: GPIO pin for hardware reset (optional, falls back to software reset if not specified)
28+
* ``vdd-supply``: Low-Voltage Power Supply from +2.7V to +5.5V (optional)
29+
* ``hvdd-supply``: Positive High-Voltage Power Supply from +8V to (HVSS +24V) for the Output Channels (optional)
30+
* ``hvss-supply``: Negative High-Voltage Power Supply from -2V to 0V for the Output Channels (optional)
31+
32+
Per-channel properties:
33+
* ``adi,dac-latch-mode``: Controls when DAC updates occur
34+
- "ldac-control": LDAC pin controls the latch (default)
35+
- "transparent": Transparent latch mode (immediate update)
36+
37+
* ``adi,mode``: Sets the output mode
38+
- "voltage": Voltage output mode (default)
39+
- "current": Current output mode
40+
41+
Device attributes
42+
=================
43+
44+
The MAX22007 driver provides IIO DAC interfaces that vary based on the
45+
configured channel mode. Each channel appears as a separate IIO device
46+
attribute:
47+
48+
* ``out_voltage_raw`` (voltage mode channels)
49+
* ``out_current_raw`` (current mode channels)
50+
* ``out_voltage_scale`` / ``out_current_scale`` (channel scaling factors)
51+
* ``out_voltage_powermode`` / ``out_current_powermode`` (channel power control)
52+
* ``out_voltage_powermode_available`` / ``out_current_powermode_available`` (available power modes)
53+
* ``ldac_update`` (per-channel LDAC latch control)
54+
55+
The driver automatically configures the IIO channel type based on the configured
56+
channel mode from device tree.
57+
58+
LDAC Update Control
59+
===================
60+
61+
Each channel provides an ``ldac_update`` attribute for runtime LDAC (Latch DAC)
62+
control. This allows precise timing control of when DAC register values are
63+
transferred to the output:
64+
65+
* Write ``1`` to trigger an immediate LDAC update for that specific channel
66+
* Write ``0`` for no operation (returns immediately)
67+
68+
This provides fine-grained control over output timing, which is essential for
69+
applications requiring synchronized DAC updates.
70+
71+
Power Mode Control
72+
==================
73+
74+
Each channel provides ``powermode`` attributes for runtime power control:
75+
76+
* Write ``"on"`` to enable the channel output
77+
* Write ``"off"`` to disable the channel output
78+
* Read the attribute to get the current power state
79+
* Read ``powermode_available`` to see available power modes (always ``"off on"``)
80+
81+
This allows individual channels to be powered on/off independently for power
82+
management and safety purposes.
83+
84+
Usage Examples
85+
==============
86+
87+
Setting DAC output value and triggering LDAC update:
88+
89+
.. code-block:: bash
90+
91+
# Set channel 0 (voltage mode) to raw value 655 (≈2V)
92+
echo 655 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw
93+
94+
# Trigger LDAC update to apply the new value
95+
echo 1 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_ldac_update
96+
97+
# Set channel 1 (current mode) and update
98+
echo 1024 > /sys/bus/iio/devices/iio:deviceX/out_current1_raw
99+
echo 1 > /sys/bus/iio/devices/iio:deviceX/out_current1_ldac_update
100+
101+
Controlling channel power modes:
102+
103+
.. code-block:: bash
104+
105+
# Enable channel 0
106+
echo on > /sys/bus/iio/devices/iio:deviceX/out_voltage0_powermode
107+
108+
# Disable channel 1
109+
echo off > /sys/bus/iio/devices/iio:deviceX/out_current1_powermode
110+
111+
# Check current power state
112+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_powermode
113+
114+
# Check available power modes
115+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_powermode_available
116+
117+
Reading channel values and scale factors:
118+
119+
.. code-block:: bash
120+
121+
# Read raw DAC value
122+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw
123+
124+
# Read scale factor (volts per LSB)
125+
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_scale
126+
127+
Check available channels:
128+
129+
.. code-block:: bash
130+
131+
ls /sys/bus/iio/devices/iio:deviceX/out_*_raw
132+
133+
Scale Calculations
134+
==================
135+
136+
The driver provides accurate scale factors based on the hardware configuration:
137+
138+
**Voltage Mode:**
139+
- Scale = (5 × 2.5V) / 4096 = 0.003051757 V per LSB
140+
- Range: 0V to 12.5V over 12-bit (0-4095)
141+
- Formula: Output = Raw_Value × Scale
142+
143+
**Current Mode:**
144+
- Scale = (2.5V / (2 × 50Ω)) / 4096 = 0.000006103515625 A per LSB
145+
- Range: 0A to 0.025A over 12-bit (0-4095)
146+
- Formula: Output = Raw_Value × Scale
147+
148+
Register Map
149+
------------
150+
151+
The MAX22007 uses the following register mapping:
152+
153+
.. list-table::
154+
:header-rows: 1
155+
156+
* - Address
157+
- Register Name
158+
- Description
159+
* - 0x03
160+
- CONFIG_REG
161+
- Configuration register (CRC enable, DAC latch modes)
162+
* - 0x04
163+
- CONTROL_REG
164+
- LDAC control register for runtime updates
165+
* - 0x05
166+
- CHANNEL_MODE_REG
167+
- Channel mode and power control
168+
* - 0x06
169+
- SOFT_RESET_REG
170+
- Software reset control
171+
* - 0x07-0x0A
172+
- DAC_CHANNEL_REG(0-3)
173+
- DAC data registers for channels 0-3
174+
175+
176+
Driver Architecture
177+
===================
178+
179+
The driver implements the following key features:
180+
181+
* **CRC8 Error Checking**: All SPI communications use CRC8 for data integrity
182+
* **Channel Configuration**: Supports per-channel mode and power configuration
183+
* **Register Map**: Uses regmap for efficient register access and caching
184+
* **IIO Integration**: Full integration with the Linux IIO subsystem
185+
186+
Not Implemented
187+
===============
188+
189+
* Channel configuration (voltage/current mode) is set at device tree parsing
190+
and cannot be changed dynamically
191+
* The driver requires proper device tree configuration for optimal operation
192+
* Simultaneous multi-channel LDAC updates (only single-channel updates supported)

0 commit comments

Comments
 (0)