diff mbox series

[2/2] iio: light: vcnl4000: update sampling rates for vcnl4040

Message ID 20200108155852.32702-3-tomas@novotny.cz (mailing list archive)
State New, archived
Headers show
Series iio: light: vcnl4000: update sampling rates | expand

Commit Message

Tomas Novotny Jan. 8, 2020, 3:58 p.m. UTC
Vishay has published a new version of "Designing the VCNL4200 Into an
Application" application note in October 2019. The new version specifies
that there is +-20% of part to part tolerance. Although the application
note is related to vcnl4200, according to support the vcnl4040's "ASIC
is quite similar to that one for the VCNL4200".

So update the sampling rates (and comment), including the correct
sampling rate for proximity. Both sampling rates are lower. Users
relying on the blocking behaviour of reading will get proximity
measurements much earlier.

Fixes: 5a441aade5b3 ("iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor")
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
---
 drivers/iio/light/vcnl4000.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Guido Günther Jan. 11, 2020, 11:21 a.m. UTC | #1
Hi,
On Wed, Jan 08, 2020 at 04:58:52PM +0100, Tomas Novotny wrote:
> Vishay has published a new version of "Designing the VCNL4200 Into an
> Application" application note in October 2019. The new version specifies
> that there is +-20% of part to part tolerance. Although the application
> note is related to vcnl4200, according to support the vcnl4040's "ASIC
> is quite similar to that one for the VCNL4200".
> 
> So update the sampling rates (and comment), including the correct
> sampling rate for proximity. Both sampling rates are lower. Users
> relying on the blocking behaviour of reading will get proximity
> measurements much earlier.
> 
> Fixes: 5a441aade5b3 ("iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor")
> Signed-off-by: Tomas Novotny <tomas@novotny.cz>
> ---
>  drivers/iio/light/vcnl4000.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 98428bf430bd..e5b00a6611ac 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -174,9 +174,10 @@ static int vcnl4200_init(struct vcnl4000_data *data)
>  		data->al_scale = 24000;
>  		break;
>  	case VCNL4040_PROD_ID:
> -		/* Integration time is 80ms, add 10ms. */
> -		data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
> -		data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
> +		/* Default wait time is 80ms, add 20% tolerance. */
> +		data->vcnl4200_al.sampling_rate = ktime_set(0, 96000 * 1000);
> +		/* Default wait time is 5ms, add 20% tolerance. */
> +		data->vcnl4200_ps.sampling_rate = ktime_set(0, 6000 * 1000);

I'm seeing the 80ms in VCNL4040 Application guide (Revision:
12-Nov-2019) but that one also says 6400us for the proximity so 8000
might be more on the safe side which (which i just tested, it's still
way better than the current 100000).

with that fixed

Reviewed-by: Guido Günther <agx@sigxcpu.org>

Cheers,
 -- Guido

>  		data->al_scale = 120000;
>  		break;
>  	}
> -- 
> 2.16.4
>
Guido Günther Jan. 11, 2020, 11:39 a.m. UTC | #2
Hi,
On Sat, Jan 11, 2020 at 12:21:45PM +0100, Guido Günther wrote:
> Hi,
> On Wed, Jan 08, 2020 at 04:58:52PM +0100, Tomas Novotny wrote:
> > Vishay has published a new version of "Designing the VCNL4200 Into an
> > Application" application note in October 2019. The new version specifies
> > that there is +-20% of part to part tolerance. Although the application
> > note is related to vcnl4200, according to support the vcnl4040's "ASIC
> > is quite similar to that one for the VCNL4200".
> > 
> > So update the sampling rates (and comment), including the correct
> > sampling rate for proximity. Both sampling rates are lower. Users
> > relying on the blocking behaviour of reading will get proximity
> > measurements much earlier.
> > 
> > Fixes: 5a441aade5b3 ("iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor")
> > Signed-off-by: Tomas Novotny <tomas@novotny.cz>
> > ---
> >  drivers/iio/light/vcnl4000.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> > index 98428bf430bd..e5b00a6611ac 100644
> > --- a/drivers/iio/light/vcnl4000.c
> > +++ b/drivers/iio/light/vcnl4000.c
> > @@ -174,9 +174,10 @@ static int vcnl4200_init(struct vcnl4000_data *data)
> >  		data->al_scale = 24000;
> >  		break;
> >  	case VCNL4040_PROD_ID:
> > -		/* Integration time is 80ms, add 10ms. */
> > -		data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
> > -		data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
> > +		/* Default wait time is 80ms, add 20% tolerance. */
> > +		data->vcnl4200_al.sampling_rate = ktime_set(0, 96000 * 1000);
> > +		/* Default wait time is 5ms, add 20% tolerance. */
> > +		data->vcnl4200_ps.sampling_rate = ktime_set(0, 6000 * 1000);
> 
> I'm seeing the 80ms in VCNL4040 Application guide (Revision:
> 12-Nov-2019) but that one also says 6400us for the proximity so 8000
> might be more on the safe side which (which i just tested, it's still
> way better than the current 100000).

In fact i was looking at the wrong value so no changes required:

Reviewed-by: Guido Günther <agx@sigxcpu.org>
Tested-by: Guido Günther <agx@sigxcpu.org>

 -- Guido

> 
> with that fixed
> 
> Reviewed-by: Guido Günther <agx@sigxcpu.org>
> 
> Cheers,
>  -- Guido
> 
> >  		data->al_scale = 120000;
> >  		break;
> >  	}
> > -- 
> > 2.16.4
> >
diff mbox series

Patch

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 98428bf430bd..e5b00a6611ac 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -174,9 +174,10 @@  static int vcnl4200_init(struct vcnl4000_data *data)
 		data->al_scale = 24000;
 		break;
 	case VCNL4040_PROD_ID:
-		/* Integration time is 80ms, add 10ms. */
-		data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
-		data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
+		/* Default wait time is 80ms, add 20% tolerance. */
+		data->vcnl4200_al.sampling_rate = ktime_set(0, 96000 * 1000);
+		/* Default wait time is 5ms, add 20% tolerance. */
+		data->vcnl4200_ps.sampling_rate = ktime_set(0, 6000 * 1000);
 		data->al_scale = 120000;
 		break;
 	}