MAX14001

MAX14001 ADC Linux Driver.

Supported Devices

Evaluation Boards

Description

The MAX14001/MAX14002 are isolated, single-channel analog-to-digital converters (ADCs) with programmable voltage comparators and inrush current control optimized for configurable binary input applications. The inrush threshold, current magnitude, and duration are programmable on MAX14001 and fixed on MAX14002.

Source Code

Status

Source

Mainlined?

git

Yes

Files

Hardware configuration

Use the test points for interfacing the MAX14001PMB with a machine running Linux.

The instructions below describe how to set up MAX14001PMB with RPI-5.

There are a number of connections to make between the ADC evaluation board and the Linux machine.

MAX14001PMB pin

Pin Function

RPI-5 Pin function (Pin number)

CS (PMOD-1)

Chip Select

CE0 (pin 24)

CS (PMOD-2)

Chip Select

CE1 (pin 26)

SCLK (PMOD-7)

Serial Clock

SCLK (pin 23)

SDO (PMOD-5)

Serial Data Out

MISO (pin 21)

SDI (PMOD-3)

Serial Data In

MOSI (pin 19)

VDDL (PMOD-11)

Digital Supply Voltage Input

3.3V (pin 17)

GND (PMOD-9)

Power Supply Ground

GND (pin 39)

RPI SPI1 setup:

MAX14001PMB pin

Pin Function

RPI-5 Pin function (Pin number)

CS (PMOD-1)

Chip Select

SPI1 CE0 (pin 12)

CS (PMOD-2)

Chip Select

SPI1 CE1 (pin 11)

SCLK (PMOD-7)

Serial Clock

SPI1 SCLK (pin 40)

SDO (PMOD-5)

Serial Data Out

SPI1 MISO (pin 35)

SDI (PMOD-3)

Serial Data In

SPI1 MOSI (pin 38)

VDDL (PMOD-11)

Digital Supply Voltage Input

3.3V (pin 1)

GND (PMOD-9)

Power Supply Ground

GND (pin 39)

On rpi SPI1 bus, the MAX14001PMB setup should look like the following.

https://wiki.analog.com/_media/resources/eval/max14001/max14001_rpi_spi1_setup.jpg

To enable SPI1 bus on rpi, add `dtoverlay=spi1-2cs` to config.txt and copy the overlay .dtbo file to the overlays directory.

Adding Linux driver support

Kernel configuration

Configure kernel with make menuconfig (alternatively use make xconfig or make qconfig)

Note

The MAX14001 Driver depends on CONFIG_SPI

Linux Kernel Configuration
    Device Drivers  --->
        ...
        <*>     Industrial I/O support --->
            --- Industrial I/O support
            ...
            Analog to digital converters  --->
                ...
                <*>   Analog Devices MAX14001 ADC Driver
                ...
            ...
        ...

Devicetree configuration

spi {
  #address-cells = <1>;
  #size-cells = <0>;

  max14001: adc@0 {
    compatible = "adi,max14001", "adi,max14002";
    reg = <0>;
    spi-max-frequency = <5000000>;
    spi-lsb-first;
    vdd-supply = <&vdd>;
    vddl-supply = <&vddl>;
  };
};
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Overlay for the MAX14001 ADC
 * Based on Marilene's max14001 overlay.
 *
 * Copyright (c) 2025 Marcelo Schmitt <marcelo.scchmitt1@gmail.com>
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2712", "brcm,bcm2711", "brcm,bcm2835";
};

&{/} {
    vdd: fixedregulator@0 {
        compatible = "regulator-fixed";
        regulator-name = "Isolated DC-DC Power Supply Input Voltage";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-boot-on;
        regulator-always-on;
        status = "okay";
    };

    vddl: fixedregulator@1 {
        compatible = "regulator-fixed";
        regulator-name = "Logic Power Supply Voltage";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-boot-on;
        regulator-always-on;
        status = "okay";
    };

    vrefin: fixedregulator@2 {
        compatible = "regulator-fixed";
        regulator-name = "Reference Input Range Voltage";
        regulator-min-microvolt = <1250000>;
        regulator-max-microvolt = <1250000>;
        regulator-boot-on;
        regulator-always-on;
        status = "okay";
    };

    max14001pmb-current-sense {
        compatible = "current-sense-amplifier";
        io-channels = <&max14001_u51 0>;

        sense-resistor-micro-ohms = <10000>;
        sense-gain-mult = <10>;
    };

    max14001pmb-voltage-divider {
        compatible = "voltage-divider";
        io-channels = <&max14001_u11 0>;
        output-ohms = <16000>;
        full-ohms = <32000>;
    };
};

&spi1 {
    status = "okay";
    /* The first ADC measures current */
    max14001_u51: max14001@0 {
        compatible = "adi,max14001";
        reg = <0x0>;
        spi-max-frequency = <1000>;
        vdd-supply = <&vdd>;
        vddl-supply = <&vddl>;
        refin-supply = <&vrefin>;

        status = "okay";
    };
    /* The second ADC measures voltage */
    max14001_u11: max14001@1 {
        compatible = "adi,max14001";
        reg = <0x1>;
        spi-max-frequency = <1000>;
        vdd-supply = <&vdd>;
        vddl-supply = <&vddl>;
        refin-supply = <&vrefin>;
        #io-channel-cells = <1>;
        status = "okay";
    };
};

&spidev0 {
    status = "disabled";
};

&spidev1 {
    status = "disabled";
};

The second ADC sets #io-channel-cells because it is referenced by the IIO consumer above. refin-supply is optional; without it the driver uses the internal 1.25 V reference.

Required properties

  • compatible: "adi,max14001", "adi,max14002" for MAX14001, or "adi,max14002" for MAX14002.

  • reg: SPI chip select number for the device.

  • vdd-supply: Isolated DC-DC power supply input voltage.

  • vddl-supply: Logic power supply.

Driver testing

Basic operation

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 which uses the interface can be found here:

Identify the device

marcelo@rpi5:~ $ cat /sys/bus/iio/devices/iio\:device0/name
max14001

Show channel scale

Description: Scale to be applied to in_voltageX_raw in order to obtain the measured voltage in millivolts

marcelo@rpi5:~ $ cat /sys/bus/iio/devices/iio\:device0/in_voltage0_scale
1.220703125

The driver only exposes read-only in_voltage0_raw and in_voltage0_scale attributes; there is no IIO buffer, trigger or event support, and the comparator and inrush-current hardware features are not exposed through IIO.

root@rpi5:~# ls -l /sys/bus/iio/devices/iio\:device0/
total 0

-r--r--r-- 1 root root 16384 Oct  4 12:19 in_voltage0_raw
-r--r--r-- 1 root root 16384 Oct  4 12:19 in_voltage0_scale
-r--r--r-- 1 root root 16384 Oct  4 12:19 name
lrwxrwxrwx 1 root root     0 Oct  4 12:19 of_node -> ../../../../../../../../../firmware/devicetree/base/axi/pcie@1000120000/rp1/spi@54000/max14001@1
drwxr-xr-x 2 root root     0 Oct  4 12:19 power
lrwxrwxrwx 1 root root     0 Oct  4 12:19 subsystem -> ../../../../../../../../../bus/iio
-rw-r--r-- 1 root root 16384 Oct  4 12:19 uevent
-r--r--r-- 1 root root 16384 Oct  4 12:19 waiting_for_supplier

marcelo@rpi5:~ $ cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
517

in_voltage0_scale is the reference voltage in millivolts divided by 1024 (the ADC resolution), using either the internal 1.25 V reference or the voltage on refin-supply.

More Information