public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: plagnioj@jcrosoft•com (Jean-Christophe PLAGNIOL-VILLARD)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 3/3] ARM: AT91: IIO: fix missing Sample and Hold time
Date: Thu, 20 Dec 2012 13:49:09 +0100	[thread overview]
Message-ID: <20121220124909.GR23971@game.jcrosoft.org> (raw)
In-Reply-To: <50D2EEA0.8040807@free-electrons.com>

On 11:55 Thu 20 Dec     , Maxime Ripard wrote:
> Hi,
> 
> Le 19/12/2012 19:37, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
> > On the at91_adc a minimal Sample and Hold Time is necessary for the ADC to
> > guarantee the best converted final value between two channels selection.
> > This time has to be programmed through the bitfield SHTIM in the
> > Mode Register ADC_MR.
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft•com>
> > Cc: linux-iio at vger.kernel.org
> > Cc: Nicolas Ferre <nicolas.ferre@atmel•com>
> > Cc: Ludovic Desroches <ludovic.desroches@atmel•com>
> > ---
> >  Documentation/devicetree/bindings/arm/atmel-adc.txt |    1 +
> >  drivers/iio/adc/at91_adc.c                          |   15 ++++++++++++++-
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/atmel-adc.txt b/Documentation/devicetree/bindings/arm/atmel-adc.txt
> > index efb6f02..dd2ca90 100644
> > --- a/Documentation/devicetree/bindings/arm/atmel-adc.txt
> > +++ b/Documentation/devicetree/bindings/arm/atmel-adc.txt
> > @@ -26,6 +26,7 @@ Optional properties:
> >  		       atmel,adc-res-names property. If not specified, the highest
> >  		       resolution will be used.
> >    - atmel,atmel,adc-sleep-mode: Boolean to enable of sleep mode when no conversion
> > +  - atmel,adc-sample-hold-time: Sample and Hold Time
> 
> In which unit? nanoseconds? number of clock ticks?
> 
> >   
> >  Optional trigger Nodes:
> >    - Required properties:
> > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> > index c563488..9481375 100644
> > --- a/drivers/iio/adc/at91_adc.c
> > +++ b/drivers/iio/adc/at91_adc.c
> > @@ -52,6 +52,7 @@ struct at91_adc_state {
> >  	void __iomem		*reg_base;
> >  	struct at91_adc_reg_desc *registers;
> >  	u8			startup_time;
> > +	u8			sample_hold_time;
> >  	bool			sleep_mode;
> >  	struct iio_trigger	**trig;
> >  	struct at91_adc_trigger	*trigger_list;
> > @@ -465,6 +466,9 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
> >  	}
> >  	st->startup_time = prop;
> >  
> > +	prop = 0;
> > +	of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
> > +	st->sample_hold_time = prop;
> >  
> >  	if (of_property_read_u32(node, "atmel,adc-vref", &prop)) {
> >  		dev_err(&idev->dev, "Missing adc-vref property in the DT.\n");
> > @@ -578,7 +582,7 @@ static const struct iio_info at91_adc_info = {
> >  
> >  static int __devinit at91_adc_probe(struct platform_device *pdev)
> >  {
> > -	unsigned int prsc, mstrclk, ticks, adc_clk;
> > +	unsigned int prsc, mstrclk, ticks, adc_clk, shtim;
> >  	int ret;
> >  	struct iio_dev *idev;
> >  	struct at91_adc_state *st;
> > @@ -691,12 +695,21 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
> >  	 */
> >  	ticks = round_up((st->startup_time * adc_clk /
> >  			  1000000) - 1, 8) / 8;
> > +	/*
> > +	 * a minimal Sample and Hold Time is necessary for the ADC to guarantee
> > +	 * the best converted final value between two channels selection
> > +	 * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
> > +	 */
> > +	shtim = round_up((st->sample_hold_time * adc_clk /
> > +			  1000000) - 1, 1);
> > +
> 
> Since, from all the datasheet I have (G20, G45 and X5), the minimum time
> is always 500ns, do we really need to add a dt property for that?
you must this is hardware specific it depend on the line capacity

Best Regards,
J.

  reply	other threads:[~2012-12-20 12:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19 18:32 [PATCH 0/3] IIO: AT91: add lowres, sleep and sample&hold time missing support Jean-Christophe PLAGNIOL-VILLARD
2012-12-19 18:37 ` [PATCH 1/3] ARM: AT91: IIO: add low and high res support for adc Jean-Christophe PLAGNIOL-VILLARD
2012-12-19 18:37   ` [PATCH 2/3] ARM: AT91: IIO: add sleep mode support Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 10:46     ` Maxime Ripard
2012-12-27 12:09       ` Jonathan Cameron
2012-12-27 17:54     ` Maxime Ripard
2012-12-19 18:37   ` [PATCH 3/3] ARM: AT91: IIO: fix missing Sample and Hold time Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 10:55     ` Maxime Ripard
2012-12-20 12:49       ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-12-21  9:08         ` Maxime Ripard
2012-12-20 10:42   ` [PATCH 1/3] ARM: AT91: IIO: add low and high res support for adc Maxime Ripard
2012-12-20 10:52     ` ludovic.desroches
2012-12-20 15:51       ` Maxime Ripard
2012-12-20 16:13         ` ludovic.desroches
2012-12-21  9:07           ` Maxime Ripard
2012-12-22 17:21             ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-07  9:20               ` Maxime Ripard
2012-12-20 10:40 ` [PATCH 0/3] IIO: AT91: add lowres, sleep and sample&hold time missing support Maxime Ripard
2012-12-20 10:51 ` Nicolas Ferre
2012-12-27 12:14   ` Jonathan Cameron

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=20121220124909.GR23971@game.jcrosoft.org \
    --to=plagnioj@jcrosoft$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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