MAX22530
MAX22530/MAX22531/MAX22532 ADC Linux Driver.
Supported Devices
Evaluation Boards
Status
Files
Function |
File |
|
|---|---|---|
driver |
||
devicetree bindings |
||
rpi5 devicetree overlay |
Overview
The MAX22530–MAX22532 are galvanically isolated, 4-channel, multiplexed, 12-bit, analog-to-digital converters (ADC) in the MAXSafeTM family product line. An integrated, isolated, DC-DC converter powers all field-side circuitry, and this allows field-side diagnostics even when no input signal is present.
Hardware configuration
Use the test points for interfacing the MAX22531_EVKIT_A with a machine running Linux.
The instructions below describe how to set up :[adi:MAX22531_EVKIT_A <en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max22531evkit.html#eb-overview> with RPI-5.
For the jumper links, use the following configuration:
Change SW1 to OFF.
J3 disconnected to provide 5V supply to VDDPL through VDDPL test point.
J4 connection 1-2 to provide 3.3V VDDL supply to MAX22531 logic-side circuitry through EVAL J1 (11) and J1(12).
There are a number of connections to make between the ADC evaluation board and the Linux machine.
MAX22531_EVKIT_A test point |
Pin Function |
RPI-5 Pin function (Pin number) |
|---|---|---|
CS (J1-1) |
Chip Select |
CE0 (pin 24) |
SCLK (J1-7) |
Serial Clock |
SCLK (pin 23) |
SDO (J1-5) |
Serial Data Out |
MISO (pin 21) |
SDI (J1-3) |
Serial Data In |
MOSI (pin 19) |
VDDL (J1-11) |
Digital Supply Voltage Input |
3.3V (pin 17 |
VDDPL |
Analog side power supply |
5V (pin 3) |
GND (J1-9) |
Power Supply Ground |
GND (pin 39) |
After the changes in the link positions and soldering links, the MAX22531_EVKIT_A setup should look like the following.
Analog Devices ADALM2000 can be used to debug data transfer and to provide input test signals.
Here is how it looks after everything is connected.
The collection of jumpers looks messy and hard to follow so review the textual description in case of doubt.
Adding Linux driver support
Enabling the driver
Configure kernel with make menuconfig (alternatively use make xconfig or
make qconfig)
Note
The MAX22531 Driver depends on CONFIG_SPI
Linux Kernel Configuration
Device Drivers --->
...
<*> Industrial I/O support --->
--- Industrial I/O support
...
Analog to digital converters --->
...
<*> Analog Devices MAX22531 ADC Driver
...
...
...
Adding a device tree entry
Required properties
compatible: Must be one of
adi,max22530,adi,max22531,adi,max22532.reg: number of SPI chip select id for the device.
vddl-supply: Logic power supply.
vddpl-supply: Isolated DC-DC converter power supply.
Device tree generic example
spi {
#address-cells = <1>;
#size-cells = <0>;
max22531: adc@0 {
compatible = "adi,max22531";
reg = <0>;
spi-max-frequency = <5000000>;
vddl-supply = <&vddl>;
vddpl-supply = <&vddpl>;
};
};
Device tree overlay example
// SPDX-License-Identifier: (GPL-2.0+)
/*
* Device Tree Overlay for MAX22531
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2711", "brcm,bcm2712";
vddl_1v8: fixedregulator@0 {
compatible = "regulator-fixed";
regulator-name = "Power Input for the Logic-Side";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-boot-on;
regulator-always-on;
};
vddpl_3v3: fixedregulator@1 {
compatible = "regulator-fixed";
regulator-name = "Power Input for the Isolated DC-DC Converter";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
};
&spi0 {
status = "okay";
max22531@0 {
compatible = "adi,max22531";
reg = <0>; /* Using CS0 on spi0 */
spi-max-frequency = <5000000>;
vddl-supply = <&vddl_1v8>;
vddpl-supply = <&vddpl_3v3>;
};
};
&spidev0 {
status = "disabled";
};
Driver testing
Each and every IIO device, typically a hardware chip, has a device folder under
/sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under
every of these directory folders reside a set of files, depending on the
characteristics and features of the hardware device in question. These files
are consistently generalized and documented in the IIO ABI documentation. In
order to determine which IIO deviceX corresponds to which hardware device, the
user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case
the sequence in which the iio device drivers are loaded/registered is constant,
the numbering is constant and may be known in advance.
Tip
An example program whiroot@analog:/sys/bus/iio/devices# ls -lch uses the interface can be found here:
Show device name
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/name
max22531
Show channel scale
Description: Scale to be applied to in_voltageX_raw in order to obtain the measured voltage in millivolts
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
0.439453125
Example test single-shot readings through IIO device sysfs interface.
root@rpi5:~# ls -l /sys/bus/iio/devices/iio\:device0/
total 0
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage0_mean_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage0_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage1_mean_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage1_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage2_mean_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage2_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage3_mean_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage3_raw
-rw-r--r-- 1 root root 16384 Aug 21 22:44 in_voltage_scale
-r--r--r-- 1 root root 16384 Aug 21 22:41 name
lrwxrwxrwx 1 root root 0 Aug 21 22:44 of_node -> ../../../../../../../../../firmware/devicetree/base/axi/pcie@1000120000/rp1/spi@50000/max22531@0
drwxr-xr-x 2 root root 0 Aug 21 22:44 power
lrwxrwxrwx 1 root root 0 Aug 21 22:44 subsystem -> ../../../../../../../../../bus/iio
-rw-r--r-- 1 root root 16384 Aug 21 22:41 uevent
-r--r--r-- 1 root root 16384 Aug 21 22:44 waiting_for_supplier
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
131
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
133
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage2_raw
1
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw
1
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_mean_raw
131
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_mean_raw
133
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage2_mean_raw
1
root@rpi5:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage3_mean_raw
1