All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: lars@metafoo.de, Marek Vasut <marex@denx.de>,
	harald@ccbib.org, hector.palacios@digi.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv5 RESEND 1/4] iio: mxs-lradc: add scale attribute to channels
Date: Wed, 01 Jan 2014 14:25:04 +0000	[thread overview]
Message-ID: <52C42540.7080103@kernel.org> (raw)
In-Reply-To: <1387820884-28140-2-git-send-email-alexandre.belloni@free-electrons.com>



On 23/12/13 17:48, Alexandre Belloni wrote:
> From: Hector Palacios <hector.palacios@digi.com>
>
> Some LRADC channels have fixed pre-dividers and all have an optional
> divider by two which allows a maximum input voltage of VDDIO - 50mV.
>
> This patch
>   - adds the scaling info flag to all channels
>   - grabs the max reference voltage per channel
>     (where the fixed pre-dividers apply)
>   - allows to read the scaling attribute (computed from the Vref)
>
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>.
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Marek Vasut <marex@denx.de>
Applied to the togreg branch of iio.git - initially pushed out as 
testing for the autobuilders to do their magic.

Jonathan
>
> ---
>   drivers/staging/iio/adc/mxs-lradc.c | 56 +++++++++++++++++++++++++++++++++++--
>   1 file changed, 54 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index 5a4499c3d22a..22fef0a408db 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -111,16 +111,59 @@ static const char * const mx28_lradc_irq_names[] = {
>   struct mxs_lradc_of_config {
>   	const int		irq_count;
>   	const char * const	*irq_name;
> +	const uint32_t		*vref_mv;
> +};
> +
> +#define VREF_MV_BASE 1850
> +
> +static const uint32_t mx23_vref_mv[LRADC_MAX_TOTAL_CHANS] = {
> +	VREF_MV_BASE,		/* CH0 */
> +	VREF_MV_BASE,		/* CH1 */
> +	VREF_MV_BASE,		/* CH2 */
> +	VREF_MV_BASE,		/* CH3 */
> +	VREF_MV_BASE,		/* CH4 */
> +	VREF_MV_BASE,		/* CH5 */
> +	VREF_MV_BASE * 2,	/* CH6 VDDIO */
> +	VREF_MV_BASE * 4,	/* CH7 VBATT */
> +	VREF_MV_BASE,		/* CH8 Temp sense 0 */
> +	VREF_MV_BASE,		/* CH9 Temp sense 1 */
> +	VREF_MV_BASE,		/* CH10 */
> +	VREF_MV_BASE,		/* CH11 */
> +	VREF_MV_BASE,		/* CH12 USB_DP */
> +	VREF_MV_BASE,		/* CH13 USB_DN */
> +	VREF_MV_BASE,		/* CH14 VBG */
> +	VREF_MV_BASE * 4,	/* CH15 VDD5V */
> +};
> +
> +static const uint32_t mx28_vref_mv[LRADC_MAX_TOTAL_CHANS] = {
> +	VREF_MV_BASE,		/* CH0 */
> +	VREF_MV_BASE,		/* CH1 */
> +	VREF_MV_BASE,		/* CH2 */
> +	VREF_MV_BASE,		/* CH3 */
> +	VREF_MV_BASE,		/* CH4 */
> +	VREF_MV_BASE,		/* CH5 */
> +	VREF_MV_BASE,		/* CH6 */
> +	VREF_MV_BASE * 4,	/* CH7 VBATT */
> +	VREF_MV_BASE,		/* CH8 Temp sense 0 */
> +	VREF_MV_BASE,		/* CH9 Temp sense 1 */
> +	VREF_MV_BASE * 2,	/* CH10 VDDIO */
> +	VREF_MV_BASE,		/* CH11 VTH */
> +	VREF_MV_BASE * 2,	/* CH12 VDDA */
> +	VREF_MV_BASE,		/* CH13 VDDD */
> +	VREF_MV_BASE,		/* CH14 VBG */
> +	VREF_MV_BASE * 4,	/* CH15 VDD5V */
>   };
>
>   static const struct mxs_lradc_of_config mxs_lradc_of_config[] = {
>   	[IMX23_LRADC] = {
>   		.irq_count	= ARRAY_SIZE(mx23_lradc_irq_names),
>   		.irq_name	= mx23_lradc_irq_names,
> +		.vref_mv	= mx23_vref_mv,
>   	},
>   	[IMX28_LRADC] = {
>   		.irq_count	= ARRAY_SIZE(mx28_lradc_irq_names),
>   		.irq_name	= mx28_lradc_irq_names,
> +		.vref_mv	= mx28_vref_mv,
>   	},
>   };
>
> @@ -155,6 +198,8 @@ struct mxs_lradc {
>
>   	struct completion	completion;
>
> +	const uint32_t		*vref_mv;
> +
>   	/*
>   	 * Touchscreen LRADC channels receives a private slot in the CTRL4
>   	 * register, the slot #7. Therefore only 7 slots instead of 8 in the
> @@ -836,6 +881,8 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>   			const struct iio_chan_spec *chan,
>   			int *val, int *val2, long m)
>   {
> +	struct mxs_lradc *lradc = iio_priv(iio_dev);
> +
>   	/* Check for invalid channel */
>   	if (chan->channel > LRADC_MAX_TOTAL_CHANS)
>   		return -EINVAL;
> @@ -857,7 +904,9 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>   			return IIO_VAL_INT_PLUS_MICRO;
>   		}
>
> -		return -EINVAL;
> +		*val = lradc->vref_mv[chan->channel];
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>
>   	case IIO_CHAN_INFO_OFFSET:
>   		if (chan->type == IIO_TEMP) {
> @@ -1189,7 +1238,8 @@ static const struct iio_buffer_setup_ops mxs_lradc_buffer_ops = {
>   	.type = (chan_type),					\
>   	.indexed = 1,						\
>   	.scan_index = (idx),					\
> -	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),		\
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |		\
> +			      BIT(IIO_CHAN_INFO_SCALE),		\
>   	.channel = (idx),					\
>   	.scan_type = {						\
>   		.sign = 'u',					\
> @@ -1381,6 +1431,8 @@ static int mxs_lradc_probe(struct platform_device *pdev)
>   			return ret;
>   	}
>
> +	lradc->vref_mv = of_cfg->vref_mv;
> +
>   	platform_set_drvdata(pdev, iio);
>
>   	init_completion(&lradc->completion);
>

  reply	other threads:[~2014-01-01 14:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 17:48 [PATCHv5 RESEND 0/4] iio: mxs-lradc: add support to optional divider_by_two Alexandre Belloni
2013-12-23 17:48 ` [PATCHv5 RESEND 1/4] iio: mxs-lradc: add scale attribute to channels Alexandre Belloni
2014-01-01 14:25   ` Jonathan Cameron [this message]
2013-12-23 17:48 ` [PATCHv5 RESEND 2/4] iio: mxs-lradc: add scale_available file " Alexandre Belloni
2014-01-01 14:28   ` Jonathan Cameron
2013-12-23 17:48 ` [PATCHv5 RESEND 3/4] iio: mxs-lradc: add write_raw function to modify scale Alexandre Belloni
2014-01-01 14:29   ` Jonathan Cameron
2013-12-23 17:48 ` [PATCHv5 RESEND 4/4] iio: mxs-lradc: convert is_divided to a bitmap Alexandre Belloni
2014-01-01 14:31   ` Jonathan Cameron
2014-01-01 19:31     ` Marek Vasut
2014-01-02  8:38       ` Alexandre Belloni
2014-01-02  9:40         ` Jonathan Cameron
2013-12-23 18:54 ` [PATCHv5 RESEND 0/4] iio: mxs-lradc: add support to optional divider_by_two Marek Vasut
2013-12-23 19:22   ` Alexandre Belloni
2013-12-24  1:50     ` Marek Vasut

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=52C42540.7080103@kernel.org \
    --to=jic23@kernel.org \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=harald@ccbib.org \
    --cc=hector.palacios@digi.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.