From: Jonathan Cameron <jic23@kernel.org>
To: Stefan Popa <stefan.popa@analog.com>
Cc: <Michael.Hennerich@analog.com>, <knaack.h@gmx.de>,
<lars@metafoo.de>, <pmeerw@pmeerw.net>,
<gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
<linux-iio@vger.kernel.org>
Subject: Re: [PATCH v5 1/4] iio: ad_sigma_delta: Allow to provide custom data register address
Date: Sat, 17 Nov 2018 16:30:54 +0000 [thread overview]
Message-ID: <20181117163054.11a1d829@archlinux> (raw)
In-Reply-To: <1542108024-3307-1-git-send-email-stefan.popa@analog.com>
On Tue, 13 Nov 2018 13:20:24 +0200
Stefan Popa <stefan.popa@analog.com> wrote:
> From: Lars-Peter Clausen <lars@metafoo.de>
>
> Some newer devices from the Sigma-Delta ADC family do have their data
> register at a different address than the current default address. Add a
> parameter to the ad_sigma_delta_info struct which allows to override the
> default address.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> Changes in v2:
> - Added this commit.
> Changes in v3:
> - Nothing changed.
> Changes in v4:
> - Nothing changed.
> Changes in v5:
> - Nothing changed.
>
> drivers/iio/adc/ad_sigma_delta.c | 22 +++++++++++++++++-----
> include/linux/iio/adc/ad_sigma_delta.h | 3 +++
> 2 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
> index fc95107..ff5f2da 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -278,6 +278,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
> {
> struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
> unsigned int sample, raw_sample;
> + unsigned int data_reg;
> int ret = 0;
>
> if (iio_buffer_enabled(indio_dev))
> @@ -305,7 +306,12 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
> if (ret < 0)
> goto out;
>
> - ret = ad_sd_read_reg(sigma_delta, AD_SD_REG_DATA,
> + if (sigma_delta->info->data_reg != 0)
> + data_reg = sigma_delta->info->data_reg;
> + else
> + data_reg = AD_SD_REG_DATA;
> +
> + ret = ad_sd_read_reg(sigma_delta, data_reg,
> DIV_ROUND_UP(chan->scan_type.realbits + chan->scan_type.shift, 8),
> &raw_sample);
>
> @@ -392,6 +398,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
> struct iio_dev *indio_dev = pf->indio_dev;
> struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
> unsigned int reg_size;
> + unsigned int data_reg;
> uint8_t data[16];
> int ret;
>
> @@ -401,18 +408,23 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
> indio_dev->channels[0].scan_type.shift;
> reg_size = DIV_ROUND_UP(reg_size, 8);
>
> + if (sigma_delta->info->data_reg != 0)
> + data_reg = sigma_delta->info->data_reg;
> + else
> + data_reg = AD_SD_REG_DATA;
> +
> switch (reg_size) {
> case 4:
> case 2:
> case 1:
> - ret = ad_sd_read_reg_raw(sigma_delta, AD_SD_REG_DATA,
> - reg_size, &data[0]);
> + ret = ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size,
> + &data[0]);
> break;
> case 3:
> /* We store 24 bit samples in a 32 bit word. Keep the upper
> * byte set to zero. */
> - ret = ad_sd_read_reg_raw(sigma_delta, AD_SD_REG_DATA,
> - reg_size, &data[1]);
> + ret = ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size,
> + &data[1]);
> break;
> }
>
> diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
> index 730ead1..7e84351 100644
> --- a/include/linux/iio/adc/ad_sigma_delta.h
> +++ b/include/linux/iio/adc/ad_sigma_delta.h
> @@ -39,6 +39,8 @@ struct iio_dev;
> * if there is just one read-only sample data shift register.
> * @addr_shift: Shift of the register address in the communications register.
> * @read_mask: Mask for the communications register having the read bit set.
> + * @data_reg: Address of the data register, if 0 the default address of 0x3 will
> + * be used.
> */
> struct ad_sigma_delta_info {
> int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);
> @@ -47,6 +49,7 @@ struct ad_sigma_delta_info {
> bool has_registers;
> unsigned int addr_shift;
> unsigned int read_mask;
> + unsigned int data_reg;
> };
>
> /**
prev parent reply other threads:[~2018-11-18 2:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 11:20 [PATCH v5 1/4] iio: ad_sigma_delta: Allow to provide custom data register address Stefan Popa
2018-11-17 16:30 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181117163054.11a1d829@archlinux \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=gregkh@linuxfoundation.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=stefan.popa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).