ADC ad7091r connected to Raspberry Pi but does not work yet
I am trying to create a dts file for the AD7091r analog-to-digital converter, it is supposed to talk over SPI with the Linux on the Raspberry Pi.
The device is supported with the driver "AD7476".
On the electronic side, I have a developer board from Analog Devices Inc. for the ad7091r connected. It is plugged in connected through PMOD, using an Digilent Designspark PMod Hat Adapter.
Now I think the next step is to add a line in the /boot/config.txt, like dtoverlay=abcdef. For the AD7091r there is no compiled .dtbo device tree file, so I would need to create one.
Here I do not know what to put. How can I get the device running?
The ADC is supposed to show up in:
ls /sys/bus/iio/devices/iio\:device0 `
checking driver in kernel config
Using the arm linux image from Analog Device, ADI Kuiper Linux, flashed it on sdcard and booted it up. Then I had a look at the kernel config of it:
# enable access to the kernel configuration which is in use and save it
sudo modprobe configs
zcat /proc/config.gz > actual.config
Cloned the ADI Kuiper linux kernel and checked what modules are enabled by loading that config into menuconfig:
git clone https://github.com/analogdevicesinc/linux
cd linux
git checkout rpi-6.1.y
make menuconfig // <load> actual.config
I can find there that following is marked build-in with * -> Device Drivers -> Industrial I/O support -> Analog to digital converters -> Analog Devices AD7476 1-channel ADCs driver and other similar devices from AD and TI.
trying to create a device tree overlay
I tried to compile the example from https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7091r8 with just editing the device name, naming the file ad7091r.dts:
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
/plugin/;
include <dt-bindings/interrupt-controller/irq.h>
include <dt-bindings/gpio/gpio.h>
/ {
compatible = "brcm,bcm2835", "brcm,bcm2711";
};
&gpio {
ad7091r_pins: ad7091r_pins {
brcm,pins = <22>; // interrupt
brcm,function = <0>; // input
};
};
&spi0 {
status = "okay";
cs-gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
ad7091r@0 {
compatible = "adi,ad7091r";
reg = <0x0>;
spi-max-frequency = <1000000>;
convst-gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&ad7091r_pins>;
interrupt-parent = <&gpio>;
interrupts = <22 IRQ_TYPE_EDGE_FALLING>;
};
};
&spidev0 {
status = "disabled";
};
&spidev1 {
status = "disabled";
};
But it does not even compile using:
dtc -O dtb -o ad7091r.dto ad7091r.dts
The output is:
Error: ad7091r.dts:6.1-8 syntax error
FATAL ERROR: Unable to parse input tree