AnsweredAssumed Answered

ad7785 device driver dts

Question asked by rhmartens on Sep 29, 2015
Latest reply on Oct 1, 2015 by larsc

I’m trying to use the ad7793 device driver to control an ad7785 that is connected to our custom board. When we use the spidev driver it seems to work fine and we get valid data although we get one strange behavior. The Device ID that is returned when requested is 3 yet the data sheet says we should get 0xb?

Below are the changes we’ve made to use the ad7793 driver but I’m unsure of some of the values needed. The driver loads but it always fails to return the correct device ID when requested. I was unsure what to put in for some of the values so could someone look over the changes and give us feedback. Thanks. Rob


changes to ad7793.c to add platform data


static int ad7793_probe(struct spi_device *spi)

{

  const struct ad7793_platform_data *pdata = spi->dev.platform_data;

  struct ad7793_state *st;

  struct iio_dev *indio_dev;

  int ret, vref_mv = 0;


  // added to use default platform data

  if (!pdata) {

    dev_err(&spi->dev, "no platform data? using default\n");

    pdata = &ad7793_default_pdata;

  }

....


static struct ad7793_platform_data ad7793_default_pdata = {

  .clock_src = AD7793_CLK_SRC_EXT,

  //.burnout_current = false,

  //.boost_enable = false,

  .buffered = true,

  .unipolar = false,

  .refsel = AD7793_REFSEL_INTERNAL,

  //.bias_voltage = AD7793_BIAS_VOLTAGE_DISABLED,

  //.exitation_current = AD7793_IX_DISABLED,

  //.current_source_direction = AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1

};



section our board am33xx.dtsi with spi master

    spi1: spi@481a0000 {

      compatible = "ti,omap4-mcspi";

      #address-cells = <1>;

      #size-cells = <0>;

      reg = <0x481a0000 0x400>;

      interrupts = <125>;

      ti,spi-num-cs = <2>;

      ti,hwmods = "spi1";

      dmas = <&edma 42

        &edma 43

        &edma 44

        &edma 45>;

      dma-names = "tx0", "rx0", "tx1", "rx1";

      status = "disabled";

    };


section of ourboard.dts with spi updates to load the ad7793(ad7785) driver


&spi1 {

  status = "okay";

  pinctrl-names = "default", "sleep";

  pinctrl-0 = <&spi1_pins_default>;

  pinctrl-1 = <&spi1_pins_sleep>;

 

  spidev0: spi@0 {

    /*compatible = "spidev";*/

    compatible = "ad7785";

    interrupts = <1>; // not sure what this should be

    reg = <0>;

    spi-max-frequency = <500000>;

    spi-cpha;

    spi-cpol;

    //spi-lsb-first; // not sure what this should be, enabled or not

  };


  spidev1: spi@1 {

    compatible = "spidev";

    reg = <1>;

    spi-max-frequency = <16000000>;

  };

};

Outcomes