Re: [PATCH v4 2/2] iio: adc: max14001: New driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 13, 2023 at 8:46 AM Kim Seer Paller
<kimseer.paller@xxxxxxxxxx> wrote:
>
> The MAX14001 is a configurable, isolated 10-bit ADC for multi-range
> binary inputs.

...

> +struct max14001_state {
> +       struct spi_device       *spi;
> +       /*
> +        * lock protect agains multiple concurrent accesses, RMW sequence, and

against

> +        * SPI transfer
> +        */
> +       struct mutex            lock;
> +       int                     vref_mv;
> +       /*
> +        * DMA (thus cache coherency maintenance) requires the
> +        * transfer buffers to live in their own cache lines.
> +        */
> +       __be16                  spi_tx_buffer __aligned(IIO_DMA_MINALIGN);
> +       __be16                  spi_rx_buffer;
> +};
> +
> +static int max14001_read(void *context, unsigned int reg_addr, unsigned int *data)
> +{
> +       struct max14001_state *st = context;
> +       int ret;
> +
> +       struct spi_transfer xfers[] = {
> +               {
> +                       .tx_buf = &st->spi_tx_buffer,
> +                       .len = 2,

sizeof()

> +                       .cs_change = 1,
> +               }, {
> +                       .rx_buf = &st->spi_rx_buffer,
> +                       .len = 2,

sizeof()

> +               },
> +       };
> +
> +       st->spi_tx_buffer = bitrev16(cpu_to_be16(FIELD_PREP(MAX14001_ADDR_MASK,
> +                                                               reg_addr)));
> +
> +       ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
> +       if (ret)
> +               return ret;
> +
> +       *data = bitrev16(be16_to_cpu(st->spi_rx_buffer)) & MAX14001_DATA_MASK;
> +
> +       return 0;
> +}

...

> +static const struct iio_chan_spec max14001_channels[] = {
> +       {
> +               .type = IIO_VOLTAGE,
> +               .channel = 0,

Is it required?

> +               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +                                     BIT(IIO_CHAN_INFO_SCALE),
> +       }
> +};

-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux