Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions Documentation/devicetree/bindings/iio/dac/adi,max22007.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/dac/adi,max22007.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices MAX22007 DAC device driver

maintainers:
- Janani Sunil <[email protected]>

description:
The MAX22007 is a quad-channel, 12-bit digital-to-analog converter (DAC)
with integrated precision output amplifiers and current output capability.
Each channel can be independently configured for voltage or current output.
Datasheet available at https://www.analog.com/en/products/max22007.html

$ref: /schemas/spi/spi-peripheral-props.yaml#

properties:
compatible:
const: adi,max22007

reg:
maxItems: 1

spi-max-frequency:
maximum: 500000

'#address-cells':
const: 1

'#size-cells':
const: 0

vdd-supply:
description: Low-Voltage Power Supply from +2.7V to +5.5V.

hvdd-supply:
description:
Positive High-Voltage Power Supply from +8V to (HVSS +24V) for
the Output Channels.

hvss-supply:
description:
Negative High-Voltage Power Supply from -2V to 0V for the Output Channels.

reset-gpios:
maxItems: 1
description:
GPIO used for hardware reset of the device.

patternProperties:
"^channel@[0-3]$":
allOf:
- $ref: /schemas/iio/dac/dac.yaml#
- type: object
description:
Represents the external channels which are connected to the DAC.
Channels not specified in the device tree will be powered off.

properties:
reg:
description: Channel number
maxItems: 1

adi,type:
description: Channel output type.
$ref: /schemas/types.yaml#/definitions/string
enum: [voltage, current]

required:
- reg
- adi,type

unevaluatedProperties: false

required:
- compatible
- reg

anyOf:
- required: [channel@0]
- required: [channel@1]
- required: [channel@2]
- required: [channel@3]

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>
spi {
#address-cells = <1>;
#size-cells = <0>;

dac@0 {
compatible = "adi,max22007";
reg = <0>;
spi-max-frequency = <500000>;
reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>;
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
adi,type = "voltage";
};

channel@1 {
reg = <1>;
adi,type = "current";
};
};
};
...
1 change: 1 addition & 0 deletions Documentation/iio/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ Industrial I/O Kernel Drivers
adxl345
bno055
ep93xx_adc
max22007
opt4060
145 changes: 145 additions & 0 deletions Documentation/iio/max22007.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
.. SPDX-License-Identifier: GPL-2.0-only

===============
MAX22007 driver
===============

Device driver for Analog Devices Inc. MAX22007 quad-channel industrial DAC.
The module name is ``max22007``.

Supported devices
=================

* `MAX22007 <https://www.analog.com/en/products/max22007.html>`_

Wiring connections
==================

The MAX22007 uses a standard SPI interface.

Device Tree Configuration
=========================

The device supports both global and per-channel configuration through device tree.

Global Properties:

* ``reset-gpios``: GPIO pin for hardware reset (optional, falls back to
software reset if not specified)
* ``vdd-supply``: Low-Voltage Power Supply from +2.7V to +5.5V (optional)
* ``hvdd-supply``: Positive High-Voltage Power Supply from +8V to (HVSS +24V)
for the Output Channels (optional)
* ``hvss-supply``: Negative High-Voltage Power Supply from -2V to 0V for the
Output Channels (optional)

Per-channel properties:

* ``adi,type``: Specify the channel output type - must be either "voltage" or "current" (mandatory)

Note: The driver operates in transparent mode (immediate register-to-output updates).
Channel mode is determined by the ``adi,type`` property:

* ``adi,type = "current"``: the channel operates in current mode
* ``adi,type = "voltage"``: the channel operates in voltage mode

Device attributes
=================

The MAX22007 driver provides IIO DAC interfaces that vary based on the
configured channel mode. Each channel appears as a separate IIO device
attribute:

* ``out_voltage_raw`` (voltage mode channels)
* ``out_current_raw`` (current mode channels)
* ``out_voltage_scale`` / ``out_current_scale`` (channel scaling factors)
* ``out_voltage_powerdown`` / ``out_current_powerdown`` (channel power control)

The driver automatically configures the IIO channel type based on the configured
channel mode from device tree.

Power Mode Control
==================

Each channel provides standard IIO ``powerdown`` attributes for runtime power
control:

* Write ``1`` to power down (disable) the channel output
* Write ``0`` to power up (enable) the channel output
* Read the attribute to get the current power state (1=powered down, 0=powered up)

This allows individual channels to be powered on/off independently for power
management and safety purposes.

Usage Examples
==============

Setting DAC output values:

.. code-block:: bash

# Set channel 0 (voltage mode) to raw value 655 (≈2V)
# Output is updated immediately in transparent mode
echo 655 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw

# Set channel 1 (current mode)
# Output is updated immediately in transparent mode
echo 1024 > /sys/bus/iio/devices/iio:deviceX/out_current1_raw

Controlling channel power modes:

.. code-block:: bash

# Enable channel 0 (power up)
echo 0 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown

# Disable channel 1 (power down)
echo 1 > /sys/bus/iio/devices/iio:deviceX/out_current1_powerdown

# Check current power state (0=powered up, 1=powered down)
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown

Reading channel values and scale factors:

.. code-block:: bash

# Read raw DAC value
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw

# Read scale factor (volts per LSB)
cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_scale

Check available channels:

.. code-block:: bash

ls /sys/bus/iio/devices/iio:deviceX/out_*_raw

Scale Calculations
==================

The driver provides accurate scale factors based on the hardware configuration:

**Voltage Mode:**

- Scale = (5 × 2.5V) / 4096 = 0.003051757 V per LSB
- Range: 0V to 12.5V over 12-bit (0-4095)
- Formula: Output = Raw_Value × Scale

**Current Mode:**

- Scale = (2.5V / (2 × 50Ω)) / 4096 = 0.000006103515625 A per LSB
- Range: 0A to 0.025A over 12-bit (0-4095)
- Formula: Output = Raw_Value × Scale

Driver Architecture
===================

The driver implements:

* **CRC8 Error Checking**: Always-enabled CRC8 for SPI data integrity
* **Channel Configuration**: Supports per-channel mode and power configuration

Channel configuration (voltage/current mode) is set via the ``adi,type``
device tree property and cannot be changed dynamically The driver requires
proper device tree configuration with mandatory ``adi,type`` property for each
channel.
9 changes: 9 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,15 @@ W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/dac/adi,ad9739a.yaml
F: drivers/iio/dac/ad9739a.c

ANALOG DEVICES INC MAX22007 DRIVER
M: Janani Sunil <[email protected]>
L: [email protected]
S: Supported
W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/dac/adi,max22007.yaml
F: Documentation/iio/max22007.rst
F: drivers/iio/dac/max22007.c

ANALOG DEVICES INC ADA4250 DRIVER
M: Antoniu Miclaus <[email protected]>
L: [email protected]
Expand Down
13 changes: 13 additions & 0 deletions drivers/iio/dac/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,19 @@ config MAX517
This driver can also be built as a module. If so, the module
will be called max517.

config MAX22007
tristate "Analog Devices MAX22007 DAC Driver"
depends on SPI
select REGMAP_SPI
select CRC8
help
Say Y here if you want to build a driver for Analog Devices MAX22007.

MAX22007 is a quad-channel, 12-bit, voltage-output digital to
analog converter (DAC) with SPI interface.

If compiled as a module, it will be called max22007.

config MAX5522
tristate "Maxim MAX5522 DAC driver"
depends on SPI_MASTER
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/dac/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ obj-$(CONFIG_LTC2664) += ltc2664.o
obj-$(CONFIG_LTC2688) += ltc2688.o
obj-$(CONFIG_M62332) += m62332.o
obj-$(CONFIG_MAX517) += max517.o
obj-$(CONFIG_MAX22007) += max22007.o
obj-$(CONFIG_MAX5522) += max5522.o
obj-$(CONFIG_MAX5821) += max5821.o
obj-$(CONFIG_MCP4725) += mcp4725.o
Expand Down
Loading
Loading