linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: fixed mixed up ADC single channel readout
@ 2011-11-24 10:58 Robin van der Gracht
  2011-11-24 14:40 ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: Robin van der Gracht @ 2011-11-24 10:58 UTC (permalink / raw)
  To: linux-arm-kernel

In single channel mode, when reading the ADC result, the index value
is still set to the channel selected for this reading.
This mixes up the order of the values returned. This causes problems when
the converted results are made available in pairs (i.e. battery current reading)
To straighten this up, the index value needs to be reset, so that the
converted values are read at the assigned channel.

Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
 drivers/mfd/mc13xxx-core.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index e6bb4b3..3582f15 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -650,6 +650,10 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 
 	mc13xxx_lock(mc13xxx);
 
+	mc13xxx_reg_read(mc13xxx, MC13XXX_ADC1, &adc1);
+	adc1 &= ~(0x7 << MC13XXX_ADC1_CHAN0_SHIFT);
+	mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
+
 	mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_ADCDONE, &adcdone_data);
 
 	if (ret > 0)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] mfd: fixed mixed up ADC single channel readout
  2011-11-24 10:58 [PATCH] mfd: fixed mixed up ADC single channel readout Robin van der Gracht
@ 2011-11-24 14:40 ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2011-11-24 14:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 24, 2011 at 11:58:15AM +0100, Robin van der Gracht wrote:
> In single channel mode, when reading the ADC result, the index value
> is still set to the channel selected for this reading.
> This mixes up the order of the values returned. This causes problems when
> the converted results are made available in pairs (i.e. battery current reading)
> To straighten this up, the index value needs to be reset, so that the
> converted values are read at the assigned channel.
> 
> Signed-off-by: Robin van der Gracht <robin@protonic.nl>
> ---
>  drivers/mfd/mc13xxx-core.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
> index e6bb4b3..3582f15 100644
> --- a/drivers/mfd/mc13xxx-core.c
> +++ b/drivers/mfd/mc13xxx-core.c
> @@ -650,6 +650,10 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
>  
>  	mc13xxx_lock(mc13xxx);
>  
> +	mc13xxx_reg_read(mc13xxx, MC13XXX_ADC1, &adc1);
> +	adc1 &= ~(0x7 << MC13XXX_ADC1_CHAN0_SHIFT);
> +	mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
> +
I didn't completely understood what is exact the problem, but I wonder
if you don't also need 0x7 << MC13XXX_ADC1_CHAN1_SHIFT.

Best regards
Uwe

>  	mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_ADCDONE, &adcdone_data);
>  
>  	if (ret > 0)
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-24 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 10:58 [PATCH] mfd: fixed mixed up ADC single channel readout Robin van der Gracht
2011-11-24 14:40 ` Uwe Kleine-König

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).