From 9e9590f441bc6f6b14c757860b0b339148aa49f3 Mon Sep 17 00:00:00 2001 From: drochner Date: Mon, 9 Apr 2001 15:45:50 +0000 Subject: [PATCH] Change the way the aux port is probed for. Some older chipsets w/o mouse port seem to interpret the "test aux port" (0xa9) command differently, leading to a non-working keyboard. Now we try to echo a byte through the aux port by means of the "echo aux" (0xd3) command, which is what Linux does. Thanks to Christoph Badura for detailed reports and testing. --- sys/dev/ic/pckbc.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sys/dev/ic/pckbc.c b/sys/dev/ic/pckbc.c index 385c8d91b6a0..eef8768206cd 100644 --- a/sys/dev/ic/pckbc.c +++ b/sys/dev/ic/pckbc.c @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc.c,v 1.5 2000/06/09 04:58:35 soda Exp $ */ +/* $NetBSD: pckbc.c,v 1.6 2001/04/09 15:45:50 drochner Exp $ */ /* * Copyright (c) 1998 @@ -357,26 +357,31 @@ pckbc_attach(sc) #endif /* 0 */ /* - * check aux port ok + * Check aux port ok. + * Avoid KBC_AUXTEST because it hangs some older controllers + * (eg UMC880?). */ - if (!pckbc_send_cmd(iot, ioh_c, KBC_AUXTEST)) - return; - res = pckbc_poll_data1(iot, ioh_d, ioh_c, PCKBC_KBD_SLOT, 0); - - if (res == 0 || res == 0xfa || res == 0x01) { -#ifdef PCKBCDEBUG - if (res != 0) - printf("kbc: returned %x on aux slot test\n", res); -#endif + if (!pckbc_send_cmd(iot, ioh_c, KBC_AUXECHO)) { + printf("kbc: aux echo error 1\n"); + goto nomouse; + } + if (!pckbc_wait_output(iot, ioh_c)) { + printf("kbc: aux echo error 2\n"); + goto nomouse; + } + bus_space_write_1(iot, ioh_d, 0, 0x5a); /* a random value */ + res = pckbc_poll_data1(iot, ioh_d, ioh_c, PCKBC_AUX_SLOT, 1); + if (res == 0x5a) { t->t_haveaux = 1; if (pckbc_attach_slot(sc, PCKBC_AUX_SLOT)) cmdbits |= KC8_MENABLE; } #ifdef PCKBCDEBUG else - printf("kbc: aux port test: %x\n", res); + printf("kbc: aux echo: %x\n", res); #endif +nomouse: /* enable needed interrupts */ t->t_cmdbyte |= cmdbits; if (!pckbc_put8042cmd(t)) @@ -403,7 +408,7 @@ pckbc_init_slotdata(q) TAILQ_INIT(&q->cmdqueue); TAILQ_INIT(&q->freequeue); - for (i=0; ifreequeue, &(q->cmds[i]), next); } q->polling = 0;