From: Juha Yrjola Date: Fri, 10 Feb 2006 15:02:09 +0000 (+0200) Subject: ads7846: fix ADC power down bug X-Git-Tag: v2.6.16-omap1~70 X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=bce5b8ee122458e5aeded04e50df555675cc04ac;p=linux-2.6-omap-h63xx.git ads7846: fix ADC power down bug Submit a seperate read request for powering down the ADC in ads7846, instead of doing it in the last read request. Otherwise some of the read values are incorrect. Signed-off-by: Imre Deak Signed-off-by: Juha Yrjölä --- diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index f157be23611..c3357670156 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -71,10 +71,11 @@ struct ads7846 { u16 vref_delay_usecs; u16 x_plate_ohms; - u8 read_x, read_y, read_z1, read_z2; + u8 read_x, read_y, read_z1, read_z2, pwrdown; + u16 dummy; /* for the pwrdown read */ struct ts_event tc; - struct spi_transfer xfer[8]; + struct spi_transfer xfer[10]; struct spi_message msg; spinlock_t lock; @@ -124,7 +125,9 @@ struct ads7846 { #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) -#define READ_X (READ_12BIT_DFR(x) | ADS_PD10_PDOWN) /* LAST */ + +#define READ_X (READ_12BIT_DFR(x) | ADS_PD10_ADC_ON) +#define PWRDOWN (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /* LAST */ /* single-ended samples need to first power up reference voltage; * we leave both ADC and VREF powered @@ -525,6 +528,18 @@ static int __devinit ads7846_probe(struct spi_device *spi) x++; x->rx_buf = &ts->tc.x; x->len = 2; + spi_message_add_tail(x, &ts->msg); + + /* power down */ + x++; + ts->pwrdown = PWRDOWN; + x->tx_buf = &ts->pwrdown; + x->len = 1; + spi_message_add_tail(x, &ts->msg); + + x++; + x->rx_buf = &ts->dummy; + x->len = 2; CS_CHANGE(*x); spi_message_add_tail(x, &ts->msg);