|
| 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 | +* ``output-range-microvolt``: Specify the channel output range in microvolts for voltage mode channels |
| 33 | +* ``output-range-microamp``: Specify the channel output range in microamperes for current mode channels |
| 34 | + |
| 35 | +Note: The driver operates in transparent mode (immediate register-to-output updates). |
| 36 | +Channel mode is determined by the presence of output-range properties: |
| 37 | +- If ``output-range-microamp`` is present, the channel operates in current mode |
| 38 | +- Otherwise, the channel defaults to voltage mode |
| 39 | + |
| 40 | +Device attributes |
| 41 | +================= |
| 42 | + |
| 43 | +The MAX22007 driver provides IIO DAC interfaces that vary based on the |
| 44 | +configured channel mode. Each channel appears as a separate IIO device |
| 45 | +attribute: |
| 46 | + |
| 47 | +* ``out_voltage_raw`` (voltage mode channels) |
| 48 | +* ``out_current_raw`` (current mode channels) |
| 49 | +* ``out_voltage_scale`` / ``out_current_scale`` (channel scaling factors) |
| 50 | +* ``out_voltage_powerdown`` / ``out_current_powerdown`` (channel power control) |
| 51 | +* ``crc_enable`` (device-wide CRC8 error checking 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 | +CRC Control |
| 69 | +=========== |
| 70 | + |
| 71 | +The driver provides runtime control over SPI CRC8 error checking through the |
| 72 | +``crc_enable`` attribute: |
| 73 | + |
| 74 | +* Write ``1`` to enable CRC8 error checking for data integrity (default) |
| 75 | +* Write ``0`` to disable CRC8 checking for improved performance |
| 76 | +* Read the attribute to get the current CRC state (1=enabled, 0=disabled) |
| 77 | + |
| 78 | +CRC is enabled by default at driver initialization to ensure data integrity, |
| 79 | +but can be disabled at runtime if needed for performance optimization. |
| 80 | + |
| 81 | +Usage Examples |
| 82 | +============== |
| 83 | + |
| 84 | +Setting DAC output values: |
| 85 | + |
| 86 | +.. code-block:: bash |
| 87 | +
|
| 88 | + # Set channel 0 (voltage mode) to raw value 655 (≈2V) |
| 89 | + # Output is updated immediately in transparent mode |
| 90 | + echo 655 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw |
| 91 | +
|
| 92 | + # Set channel 1 (current mode) |
| 93 | + # Output is updated immediately in transparent mode |
| 94 | + echo 1024 > /sys/bus/iio/devices/iio:deviceX/out_current1_raw |
| 95 | +
|
| 96 | +Controlling channel power modes: |
| 97 | + |
| 98 | +.. code-block:: bash |
| 99 | +
|
| 100 | + # Enable channel 0 (power up) |
| 101 | + echo 0 > /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown |
| 102 | +
|
| 103 | + # Disable channel 1 (power down) |
| 104 | + echo 1 > /sys/bus/iio/devices/iio:deviceX/out_current1_powerdown |
| 105 | +
|
| 106 | + # Check current power state (0=powered up, 1=powered down) |
| 107 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_powerdown |
| 108 | +
|
| 109 | +Controlling CRC error checking: |
| 110 | + |
| 111 | +.. code-block:: bash |
| 112 | +
|
| 113 | + # Enable CRC8 checking (default) |
| 114 | + echo 1 > /sys/bus/iio/devices/iio:deviceX/crc_enable |
| 115 | +
|
| 116 | + # Disable CRC8 checking for performance |
| 117 | + echo 0 > /sys/bus/iio/devices/iio:deviceX/crc_enable |
| 118 | +
|
| 119 | + # Check current CRC state (1=enabled, 0=disabled) |
| 120 | + cat /sys/bus/iio/devices/iio:deviceX/crc_enable |
| 121 | +
|
| 122 | +Reading channel values and scale factors: |
| 123 | + |
| 124 | +.. code-block:: bash |
| 125 | +
|
| 126 | + # Read raw DAC value |
| 127 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_raw |
| 128 | +
|
| 129 | + # Read scale factor (volts per LSB) |
| 130 | + cat /sys/bus/iio/devices/iio:deviceX/out_voltage0_scale |
| 131 | +
|
| 132 | +Check available channels: |
| 133 | + |
| 134 | +.. code-block:: bash |
| 135 | +
|
| 136 | + ls /sys/bus/iio/devices/iio:deviceX/out_*_raw |
| 137 | +
|
| 138 | +Scale Calculations |
| 139 | +================== |
| 140 | + |
| 141 | +The driver provides accurate scale factors based on the hardware configuration: |
| 142 | + |
| 143 | +**Voltage Mode:** |
| 144 | + - Scale = (5 × 2.5V) / 4096 = 0.003051757 V per LSB |
| 145 | + - Range: 0V to 12.5V over 12-bit (0-4095) |
| 146 | + - Formula: Output = Raw_Value × Scale |
| 147 | + |
| 148 | +**Current Mode:** |
| 149 | + - Scale = (2.5V / (2 × 50Ω)) / 4096 = 0.000006103515625 A per LSB |
| 150 | + - Range: 0A to 0.025A over 12-bit (0-4095) |
| 151 | + - Formula: Output = Raw_Value × Scale |
| 152 | + |
| 153 | +Register Map |
| 154 | +------------ |
| 155 | + |
| 156 | +The MAX22007 uses the following register mapping: |
| 157 | + |
| 158 | +.. list-table:: |
| 159 | + :header-rows: 1 |
| 160 | + |
| 161 | + * - Address |
| 162 | + - Register Name |
| 163 | + - Description |
| 164 | + * - 0x03 |
| 165 | + - CONFIG_REG |
| 166 | + - Configuration register (CRC enable, DAC latch modes) |
| 167 | + * - 0x04 |
| 168 | + - CONTROL_REG |
| 169 | + - LDAC control register for runtime updates |
| 170 | + * - 0x05 |
| 171 | + - CHANNEL_MODE_REG |
| 172 | + - Channel mode and power control |
| 173 | + * - 0x06 |
| 174 | + - SOFT_RESET_REG |
| 175 | + - Software reset control |
| 176 | + * - 0x07-0x0A |
| 177 | + - DAC_CHANNEL_REG(0-3) |
| 178 | + - DAC data registers for channels 0-3 |
| 179 | + |
| 180 | + |
| 181 | +Driver Architecture |
| 182 | +=================== |
| 183 | + |
| 184 | +The driver implements the following key features: |
| 185 | + |
| 186 | +* **CRC8 Error Checking**: Runtime configurable CRC8 for SPI data integrity (enabled by default) |
| 187 | +* **Channel Configuration**: Supports per-channel mode and power configuration |
| 188 | +* **Register Map**: Uses regmap for efficient register access and caching |
| 189 | +* **IIO Integration**: Full integration with the Linux IIO subsystem |
| 190 | + |
| 191 | +Not Implemented |
| 192 | +=============== |
| 193 | + |
| 194 | +* Channel configuration (voltage/current mode) is set at device tree parsing |
| 195 | + and cannot be changed dynamically |
| 196 | +* The driver requires proper device tree configuration for optimal operation |
| 197 | +* Simultaneous multi-channel LDAC updates (only single-channel updates supported) |
0 commit comments