All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix possibly incorrect offset in wm97xx-core
@ 2009-06-03 21:44 Marek Vasut
  2009-06-04  8:46 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2009-06-03 21:44 UTC (permalink / raw)
  To: alsa-devel; +Cc: Eric Miao, Mark Brown, Russell King - ARM Linux

Hi,

I just hit a problem with the accelerated (interrupt driven) ts driver. It 
stop responding after a while (sometimes right after you release a stylus off 
the touchscreen, it doesn't generate any more interrupts). I made the 
following patch that fixes the problem for me (and if I read the 9712 and 
9713 manuals correctly, the patch should be OK)

Thanks for reply.

diff --git a/drivers/input/touchscreen/wm97xx-core.c 
b/drivers/input/touchscreen/wm97xx-core.c
index 69af838..4f13a7f 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -307,11 +307,7 @@ static void wm97xx_pen_irq_worker(struct work_struct 
*work)
                                         WM97XX_GPIO_13);
                }

-               if (wm->id == WM9712_ID2)
-                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status &
-                                               ~WM97XX_GPIO_13) << 1);
-               else
-                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
+               wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
                                                ~WM97XX_GPIO_13);
                mutex_unlock(&wm->codec_mutex);
        }

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

* Re: [PATCH] Fix possibly incorrect offset in wm97xx-core
  2009-06-03 21:44 [PATCH] Fix possibly incorrect offset in wm97xx-core Marek Vasut
@ 2009-06-04  8:46 ` Mark Brown
  2009-06-04  9:59   ` Marek Vasut
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-06-04  8:46 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Eric Miao, alsa-devel, Russell King - ARM Linux

On Wed, Jun 03, 2009 at 11:44:37PM +0200, Marek Vasut wrote:

> -               if (wm->id == WM9712_ID2)
> -                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status &
> -                                               ~WM97XX_GPIO_13) << 1);
> -               else
> -                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
> +               wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
>                                                 ~WM97XX_GPIO_13);

Nack, the existing code reflects the behaviour of the silicon.

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

* Re: [PATCH] Fix possibly incorrect offset in wm97xx-core
  2009-06-04  8:46 ` Mark Brown
@ 2009-06-04  9:59   ` Marek Vasut
  2009-06-04 11:06     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2009-06-04  9:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Eric Miao, alsa-devel, Russell King - ARM Linux

On Thursday 04 of June 2009 10:46:03 Mark Brown wrote:
> On Wed, Jun 03, 2009 at 11:44:37PM +0200, Marek Vasut wrote:
> > -               if (wm->id == WM9712_ID2)
> > -                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status &
> > -                                               ~WM97XX_GPIO_13) << 1);
> > -               else
> > -                       wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
> > +               wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
> >                                                 ~WM97XX_GPIO_13);
>
> Nack, the existing code reflects the behaviour of the silicon.

The patch above reflects the behavior of my silicon (WM9712G) :-/

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

* Re: [PATCH] Fix possibly incorrect offset in wm97xx-core
  2009-06-04  9:59   ` Marek Vasut
@ 2009-06-04 11:06     ` Mark Brown
  2009-06-04 20:05       ` Marek Vasut
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-06-04 11:06 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Eric Miao, alsa-devel, Russell King - ARM Linux

On Thu, Jun 04, 2009 at 11:59:02AM +0200, Marek Vasut wrote:
> On Thursday 04 of June 2009 10:46:03 Mark Brown wrote:

> > Nack, the existing code reflects the behaviour of the silicon.

> The patch above reflects the behavior of my silicon (WM9712G) :-/

Could you expand on the behaviour you're seeing, please?  Also, what are
the full markings on the chip?

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

* Re: [PATCH] Fix possibly incorrect offset in wm97xx-core
  2009-06-04 11:06     ` Mark Brown
@ 2009-06-04 20:05       ` Marek Vasut
  2009-06-05  8:51         ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2009-06-04 20:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Eric Miao, alsa-devel, Russell King - ARM Linux

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

On Thursday 04 of June 2009 13:06:09 Mark Brown wrote:
> On Thu, Jun 04, 2009 at 11:59:02AM +0200, Marek Vasut wrote:
> > On Thursday 04 of June 2009 10:46:03 Mark Brown wrote:
> > > Nack, the existing code reflects the behaviour of the silicon.
> >
> > The patch above reflects the behavior of my silicon (WM9712G) :-/
>
> Could you expand on the behaviour you're seeing, please?  Also, what are
> the full markings on the chip?

Actually, after discussing this on IRC with you, I come with the following 
patch (it should be applied on top of the mainstone accelerated touch patch 
which follows).

[-- Attachment #2: 0002-Add-possibility-to-control-the-GPIO_STATUS-shift.patch --]
[-- Type: text/x-diff, Size: 3449 bytes --]

From cb511c67296ed0cbb7b82a690cd4a027511b149b Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Thu, 4 Jun 2009 21:56:59 +0200
Subject: [PATCH 2/2] Add possibility to control the GPIO_STATUS shift

This patch allows tweaking the behaviour of GPIO_STATUS register
shift quirk that's in wm97xx-core. The problem with GPIO_STATUS
register being shifted by one doesn't appear on all hardware it
seems and causes problems with accelerated touchscreen drivers on
Palm hardware. Therefore an accelerated touchscreen driver can select
if the shift is/isn't happening on the hardware.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/mainstone-wm97xx.c |    2 ++
 drivers/input/touchscreen/wm97xx-core.c      |   19 +++++++++----------
 include/linux/wm97xx.h                       |    1 +
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 60bda9a..7ed54f5 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -200,6 +200,8 @@ static int wm97xx_acc_startup(struct wm97xx *wm)
 	if (machine_is_palmt5() || machine_is_palmtx() || machine_is_palmld()) {
 		pen_int = 1;
 		irq = 27;
+		wm->gpio_offset = 0;	/* interestingly, on Palm hardware, the
+					 * GPIO_STATUS shift doesn't occur */
 	} else if (machine_is_mainstone() && pen_int)
 		irq = 4;
 
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 69af838..cada765 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -204,10 +204,7 @@ void wm97xx_set_gpio(struct wm97xx *wm, u32 gpio,
 	else
 		reg &= ~gpio;
 
-	if (wm->id == WM9712_ID2)
-		wm97xx_reg_write(wm, AC97_GPIO_STATUS, reg << 1);
-	else
-		wm97xx_reg_write(wm, AC97_GPIO_STATUS, reg);
+	wm97xx_reg_write(wm, AC97_GPIO_STATUS, reg << wm->gpio_offset);
 	mutex_unlock(&wm->codec_mutex);
 }
 EXPORT_SYMBOL_GPL(wm97xx_set_gpio);
@@ -307,12 +304,8 @@ static void wm97xx_pen_irq_worker(struct work_struct *work)
 					 WM97XX_GPIO_13);
 		}
 
-		if (wm->id == WM9712_ID2)
-			wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status &
-						~WM97XX_GPIO_13) << 1);
-		else
-			wm97xx_reg_write(wm, AC97_GPIO_STATUS, status &
-						~WM97XX_GPIO_13);
+		wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status &
+				~WM97XX_GPIO_13) << wm->gpio_offset);
 		mutex_unlock(&wm->codec_mutex);
 	}
 
@@ -582,6 +575,12 @@ static int wm97xx_probe(struct device *dev)
 
 	wm->id = wm97xx_reg_read(wm, AC97_VENDOR_ID2);
 
+	/* On some versions of WM9712, the GPIO_STATUS register is shifted */
+	if (wm->id == WM9712_ID2)
+		wm->gpio_offset	= 1;
+	else
+		wm->gpio_offset	= 0;
+
 	dev_info(wm->dev, "detected a wm97%02x codec\n", wm->id & 0xff);
 
 	switch (wm->id & 0xff) {
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 6f69968..c6dc15b 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -283,6 +283,7 @@ struct wm97xx {
 	unsigned pen_is_down:1;		/* Pen is down */
 	unsigned aux_waiting:1;		/* aux measurement waiting */
 	unsigned pen_probably_down:1;	/* used in polling mode */
+	unsigned gpio_offset:1;		/* gpio register offset */
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
-- 
1.6.2.1


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH] Fix possibly incorrect offset in wm97xx-core
  2009-06-04 20:05       ` Marek Vasut
@ 2009-06-05  8:51         ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2009-06-05  8:51 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Eric Miao, alsa-devel, Russell King - ARM Linux

On Thu, Jun 04, 2009 at 10:05:48PM +0200, Marek Vasut wrote:

> Actually, after discussing this on IRC with you, I come with the following 
> patch (it should be applied on top of the mainstone accelerated touch patch 
> which follows).

Yes, something along these lines would be a good fix.  As discussed let
me get my test system up and running to have a look at what's going on
here before we do anything - should be sometime next week.

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

end of thread, other threads:[~2009-06-05  8:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-03 21:44 [PATCH] Fix possibly incorrect offset in wm97xx-core Marek Vasut
2009-06-04  8:46 ` Mark Brown
2009-06-04  9:59   ` Marek Vasut
2009-06-04 11:06     ` Mark Brown
2009-06-04 20:05       ` Marek Vasut
2009-06-05  8:51         ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.