Skip to content

Commit 4e963a2

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 4b4d0ba commit 4e963a2

File tree

3 files changed

+172
-0
lines changed

3 files changed

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

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ S: Supported
14261426
W: https://ez.analog.com/linux-software-drivers
14271427
F: Documentation/devicetree/bindings/iio/dac/adi,max22007.yaml
14281428
F: drivers/iio/dac/max22007.c
1429+
F: Documentation/iio/max22007.rst
14291430

14301431
ANALOG DEVICES INC ADA4250 DRIVER
14311432
M: Antoniu Miclaus <[email protected]>

0 commit comments

Comments
 (0)