Patchwork Keyboard not working on Thinkpad X60/T60

login
register
about
Submitter Sven Schnelle
Date 2011-05-28 14:23:35
Message ID <87aae6dhug.fsf@begreifnix.stackframe.org>
Download mbox | patch
Permalink /patch/3009/
State Not Applicable
Headers show

Comments

Sven Schnelle - 2011-05-28 14:23:35
Hi Kevin,

Kevin O'Connor <kevin@koconnor.net> writes:

> On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
>> Kevin O'Connor <kevin@koconnor.net> writes:
>> > Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in.
>> > The detection for NAK was added so that it doesn't take a full second
>> > to recognize that no keyboard is present.  The patch you sent would
>> > loop infinitely in this situation.
>> 
>> Yes, the patch was only for testing purposes. :)
>> 
>> I feared that are controllers out there that behave like this, so i have
>> to find another solution.
>
> How about something like (untested):
>
> --- a/src/ps2port.c
> +++ b/src/ps2port.c
> @@ -438,9 +438,14 @@ keyboard_init(void *data)
>  
>      /* ------------------- keyboard side ------------------------*/
>      /* reset keyboard and self test  (keyboard side) */
> -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> -    if (ret)
> -        return;
> +    u64 end = calc_future_tsc(4000);
> +    for (;;) {
> +        ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> +        if (!ret)
> +            break;
> +        if (check_tsc(end))
> +            return;
> +    }
>      if (param[0] != 0xaa) {
>          dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]);
>          return;
>
> If it works, the 4000 could be turned into a config option.

Yes, that fixes it. I'm using the patch below right now.

Not sure about the default value, but 0 seems to be safe to not
introduce an additional delay for other users ;)

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Kevin O'Connor - 2011-05-28 15:04:41
On Sat, May 28, 2011 at 04:23:35PM +0200, Sven Schnelle wrote:
> Kevin O'Connor <kevin@koconnor.net> writes:
> > On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
> >> Kevin O'Connor <kevin@koconnor.net> writes:
> >> > Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in.
> >> > The detection for NAK was added so that it doesn't take a full second
> >> > to recognize that no keyboard is present.  The patch you sent would
> >> > loop infinitely in this situation.
> >> 
> >> Yes, the patch was only for testing purposes. :)
> >> 
> >> I feared that are controllers out there that behave like this, so i have
> >> to find another solution.
> >
> > How about something like (untested):
[...]
> > If it works, the 4000 could be turned into a config option.
> 
> Yes, that fixes it. I'm using the patch below right now.

Thanks.  I committed a similar patch.

> Not sure about the default value, but 0 seems to be safe to not
> introduce an additional delay for other users ;)

Yeah - using zero as the default should make this a nop for other
users.

-Kevin
Josh Stump - 2011-05-31 17:24:40
I know this is off topic, but how did you get corebios flashed to the T60?
 Is there a software based way or must I get hardware in order to do it?


On Sat, May 28, 2011 at 7:23 AM, Sven Schnelle <svens@stackframe.org> wrote:

> Hi Kevin,
>
> Kevin O'Connor <kevin@koconnor.net> writes:
>
> > On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
> >> Kevin O'Connor <kevin@koconnor.net> writes:
> >> > Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in.
> >> > The detection for NAK was added so that it doesn't take a full second
> >> > to recognize that no keyboard is present.  The patch you sent would
> >> > loop infinitely in this situation.
> >>
> >> Yes, the patch was only for testing purposes. :)
> >>
> >> I feared that are controllers out there that behave like this, so i have
> >> to find another solution.
> >
> > How about something like (untested):
> >
> > --- a/src/ps2port.c
> > +++ b/src/ps2port.c
> > @@ -438,9 +438,14 @@ keyboard_init(void *data)
> >
> >      /* ------------------- keyboard side ------------------------*/
> >      /* reset keyboard and self test  (keyboard side) */
> > -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> > -    if (ret)
> > -        return;
> > +    u64 end = calc_future_tsc(4000);
> > +    for (;;) {
> > +        ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> > +        if (!ret)
> > +            break;
> > +        if (check_tsc(end))
> > +            return;
> > +    }
> >      if (param[0] != 0xaa) {
> >          dprintf(1, "keyboard self test failed (got %x not 0xaa)\n",
> param[0]);
> >          return;
> >
> > If it works, the 4000 could be turned into a config option.
>
> Yes, that fixes it. I'm using the patch below right now.
>
> Not sure about the default value, but 0 seems to be safe to not
> introduce an additional delay for other users ;)
>
> Signed-off-by: Sven Schnelle <svens@stackframe.org>
>
> diff --git a/src/Kconfig b/src/Kconfig
> index 123db01..21cef19 100644
> --- a/src/Kconfig
> +++ b/src/Kconfig
> @@ -126,6 +126,14 @@ menu "Hardware support"
>         help
>             Support PS2 ports (keyboard and mouse).
>
> +    config PS2_RESET_TIMEOUT
> +        depends on PS2PORT
> +        int "Reset timeout (in ms)"
> +        default 0
> +        help
> +            This option specifies how long we should wait for the
> Keyboard.
> +            Some keyboards are requiring a delay after POR for
> initialization.
> +
>     config USB
>         bool "USB"
>         default y
> diff --git a/src/ps2port.c b/src/ps2port.c
> index 81d47c9..3df8a8a 100644
> --- a/src/ps2port.c
> +++ b/src/ps2port.c
> @@ -438,7 +438,9 @@ keyboard_init(void *data)
>
>     /* ------------------- keyboard side ------------------------*/
>     /* reset keyboard and self test  (keyboard side) */
> -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> +    u64 end = calc_future_tsc(CONFIG_PS2_RESET_TIMEOUT);
> +    while ((ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param)) &&
> !check_tsc(end));
> +
>     if (ret)
>         return;
>     if (param[0] != 0xaa) {
>
> --
> coreboot mailing list: coreboot@coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot
>
Josh Stump - 2011-05-31 19:05:03
I know this is off topic, but how did you get corebios flashed to the T60?
 Is there a software based way or must I get hardware in order to do it?

On Sat, May 28, 2011 at 7:23 AM, Sven Schnelle <svens@stackframe.org> wrote:

> Hi Kevin,
>
> Kevin O'Connor <kevin@koconnor.net> writes:
>
> > On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
> >> Kevin O'Connor <kevin@koconnor.net> writes:
> >> > Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in.
> >> > The detection for NAK was added so that it doesn't take a full second
> >> > to recognize that no keyboard is present.  The patch you sent would
> >> > loop infinitely in this situation.
> >>
> >> Yes, the patch was only for testing purposes. :)
> >>
> >> I feared that are controllers out there that behave like this, so i have
> >> to find another solution.
> >
> > How about something like (untested):
> >
> > --- a/src/ps2port.c
> > +++ b/src/ps2port.c
> > @@ -438,9 +438,14 @@ keyboard_init(void *data)
> >
> >      /* ------------------- keyboard side ------------------------*/
> >      /* reset keyboard and self test  (keyboard side) */
> > -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> > -    if (ret)
> > -        return;
> > +    u64 end = calc_future_tsc(4000);
> > +    for (;;) {
> > +        ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> > +        if (!ret)
> > +            break;
> > +        if (check_tsc(end))
> > +            return;
> > +    }
> >      if (param[0] != 0xaa) {
> >          dprintf(1, "keyboard self test failed (got %x not 0xaa)\n",
> param[0]);
> >          return;
> >
> > If it works, the 4000 could be turned into a config option.
>
> Yes, that fixes it. I'm using the patch below right now.
>
> Not sure about the default value, but 0 seems to be safe to not
> introduce an additional delay for other users ;)
>
> Signed-off-by: Sven Schnelle <svens@stackframe.org>
>
> diff --git a/src/Kconfig b/src/Kconfig
> index 123db01..21cef19 100644
> --- a/src/Kconfig
> +++ b/src/Kconfig
> @@ -126,6 +126,14 @@ menu "Hardware support"
>         help
>             Support PS2 ports (keyboard and mouse).
>
> +    config PS2_RESET_TIMEOUT
> +        depends on PS2PORT
> +        int "Reset timeout (in ms)"
> +        default 0
> +        help
> +            This option specifies how long we should wait for the
> Keyboard.
> +            Some keyboards are requiring a delay after POR for
> initialization.
> +
>     config USB
>         bool "USB"
>         default y
> diff --git a/src/ps2port.c b/src/ps2port.c
> index 81d47c9..3df8a8a 100644
> --- a/src/ps2port.c
> +++ b/src/ps2port.c
> @@ -438,7 +438,9 @@ keyboard_init(void *data)
>
>     /* ------------------- keyboard side ------------------------*/
>     /* reset keyboard and self test  (keyboard side) */
> -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> +    u64 end = calc_future_tsc(CONFIG_PS2_RESET_TIMEOUT);
> +    while ((ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param)) &&
> !check_tsc(end));
> +
>     if (ret)
>         return;
>     if (param[0] != 0xaa) {
>
> --
> coreboot mailing list: coreboot@coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot
>
Paul Menzel - 2011-05-31 19:28:22
Dear Josh,


Am Dienstag, den 31.05.2011, 10:24 -0700 schrieb Josh Stump:
> I know this is off topic,

then start a new thread. ;-)

> but how did you get corebios flashed to the T60?

s/corebios/coreboot/

> Is there a software based way or must I get hardware in order to do it?

If I remember correctly flashrom does not work and Sven had to solder
something to get it flashed.


Thanks,

Paul

Patch

diff --git a/src/Kconfig b/src/Kconfig
index 123db01..21cef19 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -126,6 +126,14 @@  menu "Hardware support"
         help
             Support PS2 ports (keyboard and mouse).
 
+    config PS2_RESET_TIMEOUT
+        depends on PS2PORT
+        int "Reset timeout (in ms)"
+        default 0
+        help
+            This option specifies how long we should wait for the Keyboard.
+            Some keyboards are requiring a delay after POR for initialization.
+
     config USB
         bool "USB"
         default y
diff --git a/src/ps2port.c b/src/ps2port.c
index 81d47c9..3df8a8a 100644
--- a/src/ps2port.c
+++ b/src/ps2port.c
@@ -438,7 +438,9 @@  keyboard_init(void *data)
 
     /* ------------------- keyboard side ------------------------*/
     /* reset keyboard and self test  (keyboard side) */
-    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
+    u64 end = calc_future_tsc(CONFIG_PS2_RESET_TIMEOUT);
+    while ((ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param)) && !check_tsc(end));
+
     if (ret)
         return;
     if (param[0] != 0xaa) {