aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-09-01 01:57:31 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-09-01 22:43:22 -0400
commit409d568dc5f0dd179b5343630b65fdf082c14069 (patch)
tree65b99cad2ee4e4fb6cb96e0e689a3d4c2f69d779 /drivers
parent36466a1b4585f9a24d5920ff90aa73e3803745cd (diff)
Staging: mrst-touchscreen - fix channel allocation
The touch screen driver tries to find a range of free channels (which are an array of bytes), by scanning for the "end of used channel" marker. However it tries to be WAAAAY too smart and does 32 bit logic on 8 bit quantities, and in the process completely gets it wrong (repeatedly read the same register instead of incrementing in the loop, assuming that if any of the 4 bytes in the 32 byte quantity is free, all four are free, returning the channel number divided by 4 rather than the actual first free channel number) On the setting side, the same mistakes are made by and large; changed this to just use the byte SCU write functions.... With these fixes we go from a completely non detected touchscreen to something that appears to completely get detected. (after also fixing the ordering issue that Jacobs patch should solve) Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/mrst-touchscreen/intel-mid-touch.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/staging/mrst-touchscreen/intel-mid-touch.c b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
index 9333b9e0959..2b9a7864ee7 100644
--- a/drivers/staging/mrst-touchscreen/intel-mid-touch.c
+++ b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
@@ -498,8 +498,8 @@ static int __devinit mrstouch_read_pmic_id(uint *vendor, uint *rev)
498 */ 498 */
499static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev) 499static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev)
500{ 500{
501 int err, i, j, found; 501 int err, i, found;
502 u32 r32; 502 u8 r8;
503 503
504 found = -1; 504 found = -1;
505 505
@@ -507,15 +507,13 @@ static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev)
507 if (found >= 0) 507 if (found >= 0)
508 break; 508 break;
509 509
510 err = intel_scu_ipc_ioread32(PMICADDR0, &r32); 510 err = intel_scu_ipc_ioread8(PMICADDR0 + i, &r8);
511 if (err) 511 if (err)
512 return err; 512 return err;
513 513
514 for (j = 0; j < 32; j+= 8) { 514 if (r8 == END_OF_CHANNEL) {
515 if (((r32 >> j) & 0xFF) == END_OF_CHANNEL) { 515 found = i;
516 found = i; 516 break;
517 break;
518 }
519 } 517 }
520 } 518 }
521 if (found < 0) 519 if (found < 0)
@@ -537,20 +535,17 @@ static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev)
537 */ 535 */
538static int __devinit mrstouch_ts_chan_set(uint offset) 536static int __devinit mrstouch_ts_chan_set(uint offset)
539{ 537{
540 int count;
541 u16 chan; 538 u16 chan;
542 u16 reg[5]; 539
543 u8 data[5]; 540 int ret, count;
544 541
545 chan = PMICADDR0 + offset; 542 chan = PMICADDR0 + offset;
546 for (count = 0; count <= 3; count++) { 543 for (count = 0; count <= 3; count++) {
547 reg[count] = chan++; 544 ret = intel_scu_ipc_iowrite8(chan++, MRST_TS_CHAN10 + count);
548 data[count] = MRST_TS_CHAN10 + count; 545 if (ret)
546 return ret;
549 } 547 }
550 reg[count] = chan; 548 return intel_scu_ipc_iowrite8(chan++, END_OF_CHANNEL);
551 data[count] = END_OF_CHANNEL;
552
553 return intel_scu_ipc_writev(reg, data, 5);
554} 549}
555 550
556/* Initialize ADC */ 551/* Initialize ADC */