Post Go back to editing

AD7124 on Petalinux for Zynq SoC:: error while loading kernel module: "ad7124: probe of spi1.0 failed with error -2 "

Category: Hardware
Product Number: AD7124-8

Hello,

I'm trying to configure ADC AD7124-8 on a petalinux 2021.2 running on a Zynq SoC (FPGA + ARM).

I've activated the SPI0 on Vivado (which will be know as "SPI1 on Petalinux, SPI0 is reserved for a QSPI) and set the Pins and clock frequency at 166MHz.

I've also configurer the devicetree

system-user.dtsi:

----

&spi0 {
    is-decoded-cs = <0>;
    num-cs = <3>;
    status = "okay";

    adc@0 {
        compatible = "adi,ad7124-8";
        reg = <0>;
        spi-max-frequency = <5000000>;
        #address-cells = <1>;
        #size-cells = <0>;
        //spi-cpol;

        channel@0 {
            reg = <0>;
            diff-channels = <2 3>;
        };
        channel@1 {
            reg = <1>;
            diff-channels = <4 5>;
        };

        channel@2 {
            reg = <2>;
            diff-channels = <6 7>;
        };
        
        channel@3 {
            reg = <3>;
            diff-channels = <8 9>;
        };
    };
};

---

(I tried to use "insert code" but it removes all text with < >)

On the kernel configuration, I added the AD7124 driver as module) and "user mod SPI device driver support".

After compilation I connect to the system, and then try to activate the SPi device and I get:

# modprobe ad7124
[  855.870532] ad7124: probe of spi1.0 failed with error -2

and below, I get some values related to the devices:

root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/driver_override

root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/modalias
spi:ad7124-8
root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/uevent
OF_NAME=adc
OF_FULLNAME=/axi/spi@e0006000/adc@0
OF_COMPATIBLE_0=adi,ad7124-8
OF_COMPATIBLE_N=1
MODALIAS=spi:ad7124-8
root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/
#address-cells     channel@0/         channel@2/         compatible         reg
#size-cells        channel@1/         channel@3/         name               spi-max-frequency
root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/reg
root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/spi-max-frequency
LK@root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/name
adcroot@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/#address-cells
root@petalinux:~# cat /sys/bus/spi/devices/spi1.0/of_node/#size-cells
root@petalinux:~#

I got for example "LK@" for spi-max-frequency, which makes obviously no sense, and some parameters are not defined (emplty) like #address-cells, #size-cells, all reg parameters etc..

I have yet no idea I to go further, I only have this pithy message to help me, "error -2", which seems to correspond to "ENOEN No such file or directory", which file? which directory?

What could I do to  help me discover what I did wrong?

Thread Notes

  • Hi,

    I have moved this question to the Linux Software Drivers community.  Someone here should be able to assist you.

    Thanks,
    Janine

  • Hi Janine,

    thank you, you're right: I realize now that it's more of a Linux/Driver problem than a hardware one.

    Regards

  • +1
    •  Analog Employees 
    in reply to jr4g

    Hi,

    Looking at your devicetree, I can see that, at least, mclk is missing which could explain the -ENOENT. Take a look at the bindings and make sure the required properties are present.

    - Nuno Sá

  • Hi Nuno,

    I've try to add clock-names = "mlck", but i did not work.

    If I understand the Zynq/Petalinux environment well, somewhere in the toolchain (FSBL, or xdc file), some defaults are configured, and if I do not give info on the device tree, it will load standard values according to what I did on Vivado. I can get the values used in the system by reading the generated devices tree (using dtc to convert it to a dts file):

    spi@e0006000 {
      compatible = "xlnx,zynq-spi-r1p6";
      reg = <0xe0006000 0x1000>;
      status = "okay";
      interrupt-parent = <0x04>;
      interrupts = <0x00 0x1a 0x04>;
      clocks = <0x01 0x19 0x01 0x22>;
      clock-names = "ref_clk\0pclk";
      #address-cells = <0x01>;
      #size-cells = <0x00>;
      is-decoded-cs = <0x00>;
      num-cs = <0x03>;
      phandle = <0x21>;

    ...

    I have to check now what corresponds the clock addresses.

    But, nevertheless, it gave me a hint to investigate further, but checking internal register of the Zynq:

    In main SPI config (0xF8000158), the field SRCSEL give me IO_PLL for the base clock, which is correct from my configuration, but I try to switch to the ARM_PLL and.suprise, the module loads without error, and I got a brand new spi1.0 device in "/sys/bus/spi/devices" (but I expected to be in "iio" instead of "spi", but never mind)

    So it still not doesn't work (I can't see any clk signal), I guess it's a problem of frequencies and clock, and Vivado configuration. So I know how to go on.

    Thank you.