[PATCH] fix ps/2 mouse problem for SiS chipset and others

Phillip Lougher phillip at lougher.demon.co.uk
Mon May 21 17:18:16 UTC 2007


The following patches fix the ps/2 mouse problem for the SiS
chipset, and for HP500/HP510 notebooks (and probably others).
This has been confirmed by two Ubuntu users so far.

Unfortunately, they don't fix ps2 mice for Virtual PC, but this
is an ongoing upstream kernel issue, and there are no patches
(or analysis of why it breaks) for this yet.

Please ACK.

Phillip


>From d930b628239a2556cfcfd021c628b55d153ba32f Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <dtor at insightbb.com>
Date: Sat, 10 Feb 2007 01:29:53 -0500
Subject: [PATCH] Input: i8042 - fix AUX IRQ delivery check

On boxes that do not implement AUX LOOP command we can not
verify AUX IRQ delivery and must assume that it is wired
properly.

Signed-off-by: Dmitry Torokhov <dtor at mail.ru>
(cherry picked from commit 1e4865f8d469b1795e77877410951e5b808a2c4e)
---
 drivers/input/serio/i8042.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 2cf61ee..7c54827 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -544,6 +544,7 @@ static int __devinit i8042_check_aux(void)
 {
 	int retval = -1;
 	int irq_registered = 0;
+	int aux_loop_broken = 0;
 	unsigned long flags;
 	unsigned char param;
 
@@ -573,6 +574,8 @@ static int __devinit i8042_check_aux(void)
 		if (i8042_command(&param, I8042_CMD_AUX_TEST) ||
 		    (param && param != 0xfa && param != 0xff))
 			return -1;
+
+		aux_loop_broken = 1;
 	}
 
 /*
@@ -596,7 +599,7 @@ static int __devinit i8042_check_aux(void)
  * used it for a PCI card or somethig else.
  */
 
-	if (i8042_noloop) {
+	if (i8042_noloop || aux_loop_broken) {
 /*
  * Without LOOP command we can't test AUX IRQ delivery. Assume the port
  * is working and hope we are right.
-- 
1.4.4.2

>From f283cf52c4c8818e18c6e41275ff3e72ab412755 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <dtor at insightbb.com>
Date: Wed, 7 Mar 2007 23:20:55 -0500
Subject: [PATCH] Input: i8042 - another attempt to fix AUX delivery checks

Do not assume that AUX_LOOP command is broken unless it
completes successfully but returns wrong (unexpected) data.

Signed-off-by: Dmitry Torokhov <dtor at mail.ru>
(cherry picked from commit 3ca5de6dd4ec5a139b2b8f00dce3e4726ca91af1)
---
 drivers/input/serio/i8042.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 7c54827..05bac76 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -561,7 +561,8 @@ static int __devinit i8042_check_aux(void)
  */
 
 	param = 0x5a;
-	if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0x5a) {
+	retval = i8042_command(&param, I8042_CMD_AUX_LOOP);
+	if (retval || param != 0x5a) {
 
 /*
  * External connection test - filters out AT-soldered PS/2 i8042's
@@ -575,7 +576,12 @@ static int __devinit i8042_check_aux(void)
 		    (param && param != 0xfa && param != 0xff))
 			return -1;
 
-		aux_loop_broken = 1;
+/*
+ * If AUX_LOOP completed without error but returned unexpected data
+ * mark it as broken
+ */
+		if (!retval)
+			aux_loop_broken = 1;
 	}
 
 /*
-- 
1.4.4.2

>From 5e8f1c7fee43fcf2b1a7710776880f9ee245345a Mon Sep 17 00:00:00 2001
From: Roland Scheidegger <sroland at tungstengraphics.com>
Date: Tue, 8 May 2007 01:31:40 -0400
Subject: [PATCH] Input: i8042 - fix AUX port detection with some chips

The i8042 driver fails detection of the AUX port with some chips,
because they apparently do not change the I8042_CTR_AUXDIS bit
immediately. This is known to affect at least HP500/HP510 notebooks,
consequently the built-in touchpad will not work. The patch will simply
reread the value until it gets the expected value or a retry limit is
hit, without touching other workaround code in the same area.

Signed-off-by: Roland Scheidegger <sroland at tungstengraphics.com>
Signed-off-by: Dmitry Torokhov <dtor at mail.ru>
(cherry picked from commit d2ada5597d33a9108acb2caf912f85cbc9caab1e)
---
 drivers/input/serio/i8042.c |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 05bac76..81c099c 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -534,6 +534,33 @@ static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+/*
+ * i8042_toggle_aux - enables or disables AUX port on i8042 via command and
+ * verifies success by readinng CTR. Used when testing for presence of AUX
+ * port.
+ */
+static int __devinit i8042_toggle_aux(int on)
+{
+	unsigned char param;
+	int i;
+
+	if (i8042_command(&param,
+			on ? I8042_CMD_AUX_ENABLE : I8042_CMD_AUX_DISABLE))
+		return -1;
+
+	/* some chips need some time to set the I8042_CTR_AUXDIS bit */
+	for (i = 0; i < 100; i++) {
+		udelay(50);
+
+		if (i8042_command(&param, I8042_CMD_CTL_RCTR))
+			return -1;
+
+		if (!(param & I8042_CTR_AUXDIS) == on)
+			return 0;
+	}
+
+	return -1;
+}
 
 /*
  * i8042_check_aux() applies as much paranoia as it can at detecting
@@ -588,16 +615,12 @@ static int __devinit i8042_check_aux(void)
  * Bit assignment test - filters out PS/2 i8042's in AT mode
  */
 
-	if (i8042_command(&param, I8042_CMD_AUX_DISABLE))
-		return -1;
-	if (i8042_command(&param, I8042_CMD_CTL_RCTR) || (~param & I8042_CTR_AUXDIS)) {
+	if (i8042_toggle_aux(0)) {
 		printk(KERN_WARNING "Failed to disable AUX port, but continuing anyway... Is this a SiS?\n");
 		printk(KERN_WARNING "If AUX port is really absent please use the 'i8042.noaux' option.\n");
 	}
 
-	if (i8042_command(&param, I8042_CMD_AUX_ENABLE))
-		return -1;
-	if (i8042_command(&param, I8042_CMD_CTL_RCTR) || (param & I8042_CTR_AUXDIS))
+	if (i8042_toggle_aux(1))
 		return -1;
 
 /*
-- 
1.4.4.2





More information about the kernel-team mailing list