aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2010-10-15 12:48:10 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-10-18 00:12:11 -0400
commite92c27fb5319d8b12f0c291c827e252f0e17afc4 (patch)
treec01bf3f9bfe9b2dee980e2848987ab4b494ceda9 /drivers/input
parent790d5c8dac35cf10cf6c52cc9b90ad20603ac2c1 (diff)
Input: ad7877 - implement specified chip select behavior
According to the AD7877 datasheet: Each transfer operation is 16-bit. If multiple read/write operations are to be performed, CS must be taken high after the end of each read/write operation before another read/write operation can be performed by taking CS low again. Make sure CS toggles after each transfer in the message. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/ad7877.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index 5f0221cffef9..53f4d79ee530 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -230,6 +230,7 @@ static int ad7877_read(struct spi_device *spi, u16 reg)
230 AD7877_READADD(reg)); 230 AD7877_READADD(reg));
231 req->xfer[0].tx_buf = &req->command; 231 req->xfer[0].tx_buf = &req->command;
232 req->xfer[0].len = 2; 232 req->xfer[0].len = 2;
233 req->xfer[0].cs_change = 1;
233 234
234 req->xfer[1].rx_buf = &req->sample; 235 req->xfer[1].rx_buf = &req->sample;
235 req->xfer[1].len = 2; 236 req->xfer[1].len = 2;
@@ -295,20 +296,25 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command)
295 296
296 req->xfer[0].tx_buf = &req->reset; 297 req->xfer[0].tx_buf = &req->reset;
297 req->xfer[0].len = 2; 298 req->xfer[0].len = 2;
299 req->xfer[0].cs_change = 1;
298 300
299 req->xfer[1].tx_buf = &req->ref_on; 301 req->xfer[1].tx_buf = &req->ref_on;
300 req->xfer[1].len = 2; 302 req->xfer[1].len = 2;
301 req->xfer[1].delay_usecs = ts->vref_delay_usecs; 303 req->xfer[1].delay_usecs = ts->vref_delay_usecs;
304 req->xfer[1].cs_change = 1;
302 305
303 req->xfer[2].tx_buf = &req->command; 306 req->xfer[2].tx_buf = &req->command;
304 req->xfer[2].len = 2; 307 req->xfer[2].len = 2;
305 req->xfer[2].delay_usecs = ts->vref_delay_usecs; 308 req->xfer[2].delay_usecs = ts->vref_delay_usecs;
309 req->xfer[2].cs_change = 1;
306 310
307 req->xfer[3].rx_buf = &req->sample; 311 req->xfer[3].rx_buf = &req->sample;
308 req->xfer[3].len = 2; 312 req->xfer[3].len = 2;
313 req->xfer[3].cs_change = 1;
309 314
310 req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/ 315 req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/
311 req->xfer[4].len = 2; 316 req->xfer[4].len = 2;
317 req->xfer[4].cs_change = 1;
312 318
313 req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/ 319 req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/
314 req->xfer[5].len = 2; 320 req->xfer[5].len = 2;
@@ -640,17 +646,21 @@ static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
640 646
641 ts->xfer[0].tx_buf = &ts->cmd_crtl1; 647 ts->xfer[0].tx_buf = &ts->cmd_crtl1;
642 ts->xfer[0].len = 2; 648 ts->xfer[0].len = 2;
649 ts->xfer[0].cs_change = 1;
643 650
644 spi_message_add_tail(&ts->xfer[0], m); 651 spi_message_add_tail(&ts->xfer[0], m);
645 652
646 ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */ 653 ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */
647 ts->xfer[1].len = 2; 654 ts->xfer[1].len = 2;
655 ts->xfer[1].cs_change = 1;
648 656
649 spi_message_add_tail(&ts->xfer[1], m); 657 spi_message_add_tail(&ts->xfer[1], m);
650 658
651 for (i = 0; i < 11; i++) { 659 for (i = 0; i < AD7877_NR_SENSE; i++) {
652 ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i]; 660 ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i];
653 ts->xfer[i + 2].len = 2; 661 ts->xfer[i + 2].len = 2;
662 if (i < (AD7877_NR_SENSE - 1))
663 ts->xfer[i + 2].cs_change = 1;
654 spi_message_add_tail(&ts->xfer[i + 2], m); 664 spi_message_add_tail(&ts->xfer[i + 2], m);
655 } 665 }
656} 666}