AnsweredAssumed Answered

AD5933 IIO instantiation

Question asked by evlshroom on Sep 21, 2016
Latest reply on Oct 6, 2016 by mhennerich

Hi,

 

I am trying to use AD5933 as a Linux IIO device, following the instructions on AD5933 IIO Impedance Converter and Network Analyzer Linux Driver
Based on How to instantiate I2C devices I successfully instantiate AD5933 using command:

 

echo ad5933 0x0d > /sys/bus/i2c/devices/i2c-2/new_device

 

which makes an iio device appear in


/sys/bus/iio/devices/iio\:device0


From there i can read or configure features like in_voltage0_scale_available, in_voltage0_scale, out_voltage0_freq_increment and so on, with one exception. The read from out_voltage0_scale_available always returns zeros:


root@beaglebone:/sys/bus/iio/devices/iio:device0# cat out_voltage0_scale_available
0 0 0 0


The AD5933 kernel driver, reading only zeros as possible values, prevents me from setting any valid scale:


root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 1980 > out_voltage0_scale
-bash: echo: write error: Invalid argument


I figured out that the issue is about the driver not knowing AD5933's reference voltage. Somehow the default platform data

static struct ad5933_platform_data ad5933_default_pdata  = {
    .vref_mv = 3300,
};

doesn't load so I think I have to manually pass the reference voltage value to the driver.

 

I tried to initialize AD5933 using device tree overlays. Both using voltage regulator framework:

/dts-v1/;
/plugin/;
/ {
        compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
        fragment@0 {
                target-path="/";
                __overlay__ {
                        ad5933_reg: fixedregulator@0 {
                                compatible = "regulator-fixed";
                                regulator-name = "ad5933-regulator";
                                regulator-min-microvolt = <3300000>;
                                regulator-max-microvolt = <3300000>;
                        };
                };
        };
        fragment@1 {
                target = <&i2c2>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        ad5933@0d {
                                compatible = "adi,ad5933";
                                reg = <0x0d>;
                                vref-supply = <&ad5933_reg>;
                                vcc-supply = <&ad5933_reg>;
                         };
                };
        };
};

and trying to pass the parameter directly:

/dts-v1/;
/plugin/;
/ {
        compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
        fragment@0 {
                target = <&i2c2>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        ad5933@0d {
                                compatible = "adi,ad5933";
                                reg = <0x0d>;
                                vref-mv = <3300>;
                                vref_mv = <3300>;
                         };
                };
        };
};

I am not sure what device tree parameter names are bound with vref_mv variable in AD5933 driver or if there are any at all. AD5933 website lacks any documentation in this matter.

 

Results of my experiments with device tree are the same as of instantiation from user space. I get an IIO device but I don't read proper available output voltage scale.

 

Is there any way of proper AD5933 instantiation that doesn't require kernel compilation?

 

Regards,
Michal

Outcomes