|
| 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 | +* ``output-range-microvolt``: Specify the channel output range in microvolts for voltage mode channels |
| 34 | +* ``output-range-microamp``: Specify the channel output range in microamperes for current mode channels |
| 35 | + |
| 36 | +Note: The driver operates in transparent mode (immediate register-to-output updates). |
| 37 | +Channel mode is determined by the presence of output-range properties: |
| 38 | +- If ``output-range-microamp`` is present, the channel operates in current mode |
| 39 | +- Otherwise, the channel defaults to voltage 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_powerdown`` / ``out_current_powerdown`` (channel power control) |
| 52 | + |
| 53 | +The driver automatically configures the IIO channel type based on the configured |
| 54 | +channel mode from device tree. |
| 55 | + |
| 56 | +Power Mode Control |
| 57 | +================== |
| 58 | + |
| 59 | +Each channel provides standard IIO ``powerdown`` attributes for runtime power control: |
| 60 | + |
| 61 | +* Write ``1`` to power down (disable) the channel output |
| 62 | +* Write ``0`` to power up (enable) the channel output |
| 63 | +* Read the attribute to get the current power state (1=powered down, 0=powered up) |
| 64 | + |
| 65 | +This allows individual channels to be powered on/off independently for power |
| 66 | +management and safety purposes. |
| 67 | + |
| 68 | +Usage Examples |
| 69 | +============== |
| 70 | + |
| 71 | +Setting DAC output values: |
| 72 | + |
| 73 | +.. code-block:: bash |
| 74 | +
|
| 75 | + # Set channel 0 (voltage mode) to raw value 655 (≈2V) |
| 76 | + # Output is updated immediately in transparent mode |
| 77 | + echo 655 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw |
| 78 | +
|
| 79 | + # Set channel 1 (current mode) |
| 80 | + # Output is updated immediately in transparent mode |
| 81 | + echo 1024 > /sys/bus/iio/devices/iio:deviceX/out_current1_raw |
| 82 | +
|
| 83 | +Controlling channel power modes: |
| 84 | + |
| 85 | +.. code-block:: bash |
| 86 | +
|
| 87 | + # Enable channel 0 (power up) |
| 88 | + echo 0 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown |
| 89 | +
|
| 90 | + # Disable channel 1 (power down) |
| 91 | + echo 1 > /sys/bus/iio/devices/iio:deviceX/out_current1_powerdown |
| 92 | +
|
| 93 | + # Check current power state (0=powered up, 1=powered down) |
| 94 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown |
| 95 | +
|
| 96 | +Reading channel values and scale factors: |
| 97 | + |
| 98 | +.. code-block:: bash |
| 99 | +
|
| 100 | + # Read raw DAC value |
| 101 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw |
| 102 | +
|
| 103 | + # Read scale factor (volts per LSB) |
| 104 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_scale |
| 105 | +
|
| 106 | +Check available channels: |
| 107 | + |
| 108 | +.. code-block:: bash |
| 109 | +
|
| 110 | + ls /sys/bus/iio/devices/iio:deviceX/out_*_raw |
| 111 | +
|
| 112 | +Scale Calculations |
| 113 | +================== |
| 114 | + |
| 115 | +The driver provides accurate scale factors based on the hardware configuration: |
| 116 | + |
| 117 | +**Voltage Mode:** |
| 118 | + - Scale = (5 × 2.5V) / 4096 = 0.003051757 V per LSB |
| 119 | + - Range: 0V to 12.5V over 12-bit (0-4095) |
| 120 | + - Formula: Output = Raw_Value × Scale |
| 121 | + |
| 122 | +**Current Mode:** |
| 123 | + - Scale = (2.5V / (2 × 50Ω)) / 4096 = 0.000006103515625 A per LSB |
| 124 | + - Range: 0A to 0.025A over 12-bit (0-4095) |
| 125 | + - Formula: Output = Raw_Value × Scale |
| 126 | + |
| 127 | +Register Map |
| 128 | +------------ |
| 129 | + |
| 130 | +The MAX22007 uses the following register mapping: |
| 131 | + |
| 132 | +.. list-table:: |
| 133 | + :header-rows: 1 |
| 134 | + |
| 135 | + * - Address |
| 136 | + - Register Name |
| 137 | + - Description |
| 138 | + * - 0x03 |
| 139 | + - CONFIG_REG |
| 140 | + - Configuration register (CRC enable, DAC latch modes) |
| 141 | + * - 0x04 |
| 142 | + - CONTROL_REG |
| 143 | + - LDAC control register for runtime updates |
| 144 | + * - 0x05 |
| 145 | + - CHANNEL_MODE_REG |
| 146 | + - Channel mode and power control |
| 147 | + * - 0x06 |
| 148 | + - SOFT_RESET_REG |
| 149 | + - Software reset control |
| 150 | + * - 0x07-0x0A |
| 151 | + - DAC_CHANNEL_REG(0-3) |
| 152 | + - DAC data registers for channels 0-3 |
| 153 | + |
| 154 | + |
| 155 | +Driver Architecture |
| 156 | +=================== |
| 157 | + |
| 158 | +The driver implements the following key features: |
| 159 | + |
| 160 | +* **CRC8 Error Checking**: All SPI communications use CRC8 for data integrity |
| 161 | +* **Channel Configuration**: Supports per-channel mode and power configuration |
| 162 | +* **Register Map**: Uses regmap for efficient register access and caching |
| 163 | +* **IIO Integration**: Full integration with the Linux IIO subsystem |
| 164 | + |
| 165 | +Not Implemented |
| 166 | +=============== |
| 167 | + |
| 168 | +* Channel configuration (voltage/current mode) is set at device tree parsing |
| 169 | + and cannot be changed dynamically |
| 170 | +* The driver requires proper device tree configuration for optimal operation |
| 171 | +* Simultaneous multi-channel LDAC updates (only single-channel updates supported) |
0 commit comments