Linux device driver for AD5693

Hi,

 

I want to add AD5693 nanoDAC converter into one of my upcoming product. I am not able to find a matching Linux device driver for the AD5693 converter at Linux Drivers [Analog Devices Wiki] 

1) Please let me know where I can get the reference Linux source code for the AD5693 converter.

2) I want to develop a new driver for the same in case the drivers for the same are not readily available. Which is source code which I can use from the above link which I can use as a reference for building my driver from scratch. 

 

Thanks in advance.

 

Regards,

Sonu 

Parents
  • Hi Lars,

    Thanks for the info. Based on your input I wrote a test driver module AD5963 based on the IIO framework . The driver is loaded on my imx28evk board from Freescale. The driver talks to the  EVAL-AD5693RSDZ using the I2C interface. I have connected I2C SDA and SCL pins on the imx28EVK board to the SDA and SCL pins on the EVAL-AD5693RSDZ board. I have connected the micro USB cable on SDP to the USB host to power the EVAL-AD5693RSDZ board. I am not getting the AD5963 board detected by i2cdetect tool from i2c-tools package running on imx28EVK board. I am running Angstrom Linux distribution 2016.12 version running 4.8.17-fslc kernel.

    I have added the device tree entires for the AD5693R device and my driver gets loaded successfully using the below mentioned device tree.
    My device tree entries for the AD5693 device are as follows
    i2c0: i2c@80058000 {
                    pinctrl-names = "default";
                    pinctrl-0 = <&i2c0_pins_a>;
                    status = "okay";

                    sgtl5000: codec@0a {
                        compatible = "fsl,sgtl5000";
                        reg = <0x0a>;
                        VDDA-supply = <&reg_3p3v>;
                        VDDIO-supply = <&reg_3p3v>;
                        clocks = <&saif0>;
                    };

                    at24@51 {
                        compatible = "at24,24c32";
                        pagesize = <32>;
                        reg = <0x51>;
                    };
                    
                    ad5693@4c {
                        compatible = "adi,ad5693";
                                       reg = <0x4c>;
                    };
        
                };


    When I try to run i2cdetect -a -q 0 from the imx28evk board login,I get the following output

    root@imx28evk:~# i2cdetect -a -q 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0 using quick write commands.
    I will probe address range 0x00-0x7f.
    Continue? [Y/n] y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    I am confused why the tool returns  UU instead of 4C for my device at address 0x4C .


    When i remove my driver and run the same command I get the below output
    root@imx28evk:~# i2cdetect -a -q 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0 using quick write commands.
    I will probe address range 0x00-0x7f.
    Continue? [Y/n] y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    I have the following doubts regarding the

    1) Do I need to change any jumper settings on the board (A1, A11, LINK) when wiring it with imx28evk board ?
    2) Do I need to use any external supply as the reference voltage . Do I need to connect anything to the green Jumper J2(AGND/VPOS_EXT) .
    3) Does IIO based drivers work with i2cdetect from i2c-tools package ?
    4) Is my IIO driver required to be loaded to get response of 4C for the i2cdetect command issued? Are the i2cdetect commands routed through the IIO driver to get response for device detection?
    5) How do i set the channel parameters for my AD5693 driver . What values should i pass for
    bits , storage and shift when using AD5693_CHANNEL(bits, storage, shift).

    static const struct ad5693_chip_info ad5693_i2c_chip_info[] = {
        [ID_AD5693] = {
            .channel = AD5693_CHANNEL(16, 16, 4),
            .write = ad5693_write,
        },
    };
     


    #define _AD5693_CHANNEL(bits, storage, _shift, ext) { \
        .type = IIO_VOLTAGE, \
        .indexed = 1, \
        .output = 1, \
        .channel = 0, \
        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
        .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
        .scan_type = { \
            .sign = 'u', \
            .realbits = (bits), \
            .storagebits = (storage), \
            .shift = (_shift), \
            }, \
        .ext_info = (ext), \
    }

    #define AD5693_CHANNEL(bits, storage, shift) \
        _AD5693_CHANNEL(bits, storage, shift, NULL)

    #define AD5693_CHANNEL_POWERDOWN(bits, storage, shift) \
        _AD5693_CHANNEL(bits, storage, shift, ad5693_ext_info_powerdown)

    6) How do I test my AD5693 driver for functionality?

    7) Is there any settings which I have missed out so that the device gets detected on the imx28evk board.


    Thanks in advance,
    Sonu Abraham

Reply
  • Hi Lars,

    Thanks for the info. Based on your input I wrote a test driver module AD5963 based on the IIO framework . The driver is loaded on my imx28evk board from Freescale. The driver talks to the  EVAL-AD5693RSDZ using the I2C interface. I have connected I2C SDA and SCL pins on the imx28EVK board to the SDA and SCL pins on the EVAL-AD5693RSDZ board. I have connected the micro USB cable on SDP to the USB host to power the EVAL-AD5693RSDZ board. I am not getting the AD5963 board detected by i2cdetect tool from i2c-tools package running on imx28EVK board. I am running Angstrom Linux distribution 2016.12 version running 4.8.17-fslc kernel.

    I have added the device tree entires for the AD5693R device and my driver gets loaded successfully using the below mentioned device tree.
    My device tree entries for the AD5693 device are as follows
    i2c0: i2c@80058000 {
                    pinctrl-names = "default";
                    pinctrl-0 = <&i2c0_pins_a>;
                    status = "okay";

                    sgtl5000: codec@0a {
                        compatible = "fsl,sgtl5000";
                        reg = <0x0a>;
                        VDDA-supply = <&reg_3p3v>;
                        VDDIO-supply = <&reg_3p3v>;
                        clocks = <&saif0>;
                    };

                    at24@51 {
                        compatible = "at24,24c32";
                        pagesize = <32>;
                        reg = <0x51>;
                    };
                    
                    ad5693@4c {
                        compatible = "adi,ad5693";
                                       reg = <0x4c>;
                    };
        
                };


    When I try to run i2cdetect -a -q 0 from the imx28evk board login,I get the following output

    root@imx28evk:~# i2cdetect -a -q 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0 using quick write commands.
    I will probe address range 0x00-0x7f.
    Continue? [Y/n] y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    I am confused why the tool returns  UU instead of 4C for my device at address 0x4C .


    When i remove my driver and run the same command I get the below output
    root@imx28evk:~# i2cdetect -a -q 0
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0 using quick write commands.
    I will probe address range 0x00-0x7f.
    Continue? [Y/n] y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    I have the following doubts regarding the

    1) Do I need to change any jumper settings on the board (A1, A11, LINK) when wiring it with imx28evk board ?
    2) Do I need to use any external supply as the reference voltage . Do I need to connect anything to the green Jumper J2(AGND/VPOS_EXT) .
    3) Does IIO based drivers work with i2cdetect from i2c-tools package ?
    4) Is my IIO driver required to be loaded to get response of 4C for the i2cdetect command issued? Are the i2cdetect commands routed through the IIO driver to get response for device detection?
    5) How do i set the channel parameters for my AD5693 driver . What values should i pass for
    bits , storage and shift when using AD5693_CHANNEL(bits, storage, shift).

    static const struct ad5693_chip_info ad5693_i2c_chip_info[] = {
        [ID_AD5693] = {
            .channel = AD5693_CHANNEL(16, 16, 4),
            .write = ad5693_write,
        },
    };
     


    #define _AD5693_CHANNEL(bits, storage, _shift, ext) { \
        .type = IIO_VOLTAGE, \
        .indexed = 1, \
        .output = 1, \
        .channel = 0, \
        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
        .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
        .scan_type = { \
            .sign = 'u', \
            .realbits = (bits), \
            .storagebits = (storage), \
            .shift = (_shift), \
            }, \
        .ext_info = (ext), \
    }

    #define AD5693_CHANNEL(bits, storage, shift) \
        _AD5693_CHANNEL(bits, storage, shift, NULL)

    #define AD5693_CHANNEL_POWERDOWN(bits, storage, shift) \
        _AD5693_CHANNEL(bits, storage, shift, ad5693_ext_info_powerdown)

    6) How do I test my AD5693 driver for functionality?

    7) Is there any settings which I have missed out so that the device gets detected on the imx28evk board.


    Thanks in advance,
    Sonu Abraham

Children
No Data