X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Finput%2Fserio%2Fi8042.c;h=65a74cfc187b12199bb3f291775e9223da504198;hb=c36c804559d3a891a2e655ba8185b4fa7eaee156;hp=db9cca3b65e068f4e22002ebab7d448a510d8eb0;hpb=eb9c4f2ef7150ea2144b53811d1cf555d8e27f69;p=linux-2.6-omap-h63xx.git diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index db9cca3b65e..65a74cfc187 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include @@ -63,6 +63,12 @@ static unsigned int i8042_blink_frequency = 500; module_param_named(panicblink, i8042_blink_frequency, uint, 0600); MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics"); +#ifdef CONFIG_X86 +static unsigned int i8042_dritek; +module_param_named(dritek, i8042_dritek, bool, 0); +MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension"); +#endif + #ifdef CONFIG_PNP static int i8042_nopnp; module_param_named(nopnp, i8042_nopnp, bool, 0); @@ -208,7 +214,7 @@ static int __i8042_command(unsigned char *param, int command) return 0; } -static int i8042_command(unsigned char *param, int command) +int i8042_command(unsigned char *param, int command) { unsigned long flags; int retval; @@ -219,6 +225,7 @@ static int i8042_command(unsigned char *param, int command) return retval; } +EXPORT_SYMBOL(i8042_command); /* * i8042_kbd_write() sends a byte out through the keyboard interface. @@ -278,7 +285,14 @@ static void i8042_stop(struct serio *serio) struct i8042_port *port = serio->port_data; port->exists = 0; - synchronize_sched(); + + /* + * We synchronize with both AUX and KBD IRQs because there is + * a (very unlikely) chance that AUX IRQ is raised for KBD port + * and vice versa. + */ + synchronize_irq(I8042_AUX_IRQ); + synchronize_irq(I8042_KBD_IRQ); port->serio = NULL; } @@ -385,6 +399,8 @@ static int i8042_enable_kbd_port(void) i8042_ctr |= I8042_CTR_KBDINT; if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { + i8042_ctr &= ~I8042_CTR_KBDINT; + i8042_ctr |= I8042_CTR_KBDDIS; printk(KERN_ERR "i8042.c: Failed to enable KBD port.\n"); return -EIO; } @@ -402,6 +418,8 @@ static int i8042_enable_aux_port(void) i8042_ctr |= I8042_CTR_AUXINT; if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { + i8042_ctr &= ~I8042_CTR_AUXINT; + i8042_ctr |= I8042_CTR_AUXDIS; printk(KERN_ERR "i8042.c: Failed to enable AUX port.\n"); return -EIO; } @@ -512,6 +530,7 @@ static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) { unsigned long flags; unsigned char str, data; + int ret = 0; spin_lock_irqsave(&i8042_lock, flags); str = i8042_read_status(); @@ -520,12 +539,40 @@ static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) if (i8042_irq_being_tested && data == 0xa5 && (str & I8042_STR_AUXDATA)) complete(&i8042_aux_irq_delivered); + ret = 1; } spin_unlock_irqrestore(&i8042_lock, flags); - return IRQ_HANDLED; + return IRQ_RETVAL(ret); } +/* + * 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(¶m, + 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(¶m, 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 @@ -580,16 +627,12 @@ static int __devinit i8042_check_aux(void) * Bit assignment test - filters out PS/2 i8042's in AT mode */ - if (i8042_command(¶m, I8042_CMD_AUX_DISABLE)) - return -1; - if (i8042_command(¶m, 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(¶m, I8042_CMD_AUX_ENABLE)) - return -1; - if (i8042_command(¶m, I8042_CMD_CTL_RCTR) || (param & I8042_CTR_AUXDIS)) + if (i8042_toggle_aux(1)) return -1; /* @@ -767,6 +810,13 @@ static void i8042_controller_reset(void) { i8042_flush(); +/* + * Disable both KBD and AUX interfaces so they don't get in the way + */ + + i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS; + i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT); + /* * Disable MUX mode if present. */ @@ -1008,7 +1058,7 @@ static void __devinit i8042_register_ports(void) } } -static void __devinit i8042_unregister_ports(void) +static void __devexit i8042_unregister_ports(void) { int i; @@ -1121,7 +1171,14 @@ static int __devinit i8042_probe(struct platform_device *dev) if (error) goto out_fail; } - +#ifdef CONFIG_X86 + if (i8042_dritek) { + char param = 0x90; + error = i8042_command(¶m, 0x1059); + if (error) + goto out_fail; + } +#endif /* * Ok, everything is ready, let's register all serio ports */