aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/serio/i8042.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index a31578170cc..1df02d25aca 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -836,17 +836,32 @@ static int i8042_controller_selftest(void)
836static int i8042_controller_init(void) 836static int i8042_controller_init(void)
837{ 837{
838 unsigned long flags; 838 unsigned long flags;
839 int n = 0;
840 unsigned char ctr[2];
839 841
840/* 842/*
841 * Save the CTR for restoral on unload / reboot. 843 * Save the CTR for restore on unload / reboot.
842 */ 844 */
843 845
844 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) { 846 do {
845 printk(KERN_ERR "i8042.c: Can't read CTR while initializing i8042.\n"); 847 if (n >= 10) {
846 return -EIO; 848 printk(KERN_ERR
847 } 849 "i8042.c: Unable to get stable CTR read.\n");
850 return -EIO;
851 }
852
853 if (n != 0)
854 udelay(50);
855
856 if (i8042_command(&ctr[n++ % 2], I8042_CMD_CTL_RCTR)) {
857 printk(KERN_ERR
858 "i8042.c: Can't read CTR while initializing i8042.\n");
859 return -EIO;
860 }
848 861
849 i8042_initial_ctr = i8042_ctr; 862 } while (n < 2 || ctr[0] != ctr[1]);
863
864 i8042_initial_ctr = i8042_ctr = ctr[0];
850 865
851/* 866/*
852 * Disable the keyboard interface and interrupt. 867 * Disable the keyboard interface and interrupt.
@@ -895,6 +910,12 @@ static int i8042_controller_init(void)
895 return -EIO; 910 return -EIO;
896 } 911 }
897 912
913/*
914 * Flush whatever accumulated while we were disabling keyboard port.
915 */
916
917 i8042_flush();
918
898 return 0; 919 return 0;
899} 920}
900 921
@@ -914,7 +935,7 @@ static void i8042_controller_reset(void)
914 i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS; 935 i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS;
915 i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT); 936 i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT);
916 937
917 if (i8042_command(&i8042_initial_ctr, I8042_CMD_CTL_WCTR)) 938 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
918 printk(KERN_WARNING "i8042.c: Can't write CTR while resetting.\n"); 939 printk(KERN_WARNING "i8042.c: Can't write CTR while resetting.\n");
919 940
920/* 941/*