Deleted Added
full compact
34c34
< __FBSDID("$FreeBSD: head/sys/dev/atkbdc/atkbdc.c 161969 2006-09-04 00:19:31Z dwhite $");
---
> __FBSDID("$FreeBSD: head/sys/dev/atkbdc/atkbdc.c 207354 2010-04-29 06:16:00Z sobomax $");
46a47,50
> #if defined(__amd64__)
> #include <machine/clock.h>
> #endif
>
156c160
< #if defined(__i386__)
---
> #if defined(__i386__) || defined(__amd64__)
225c229
< #if defined(__i386__)
---
> #if defined(__i386__) || defined(__amd64__)
250a255,259
> #if defined(__amd64__)
> u_int64_t tscval[3], read_delay;
> register_t flags;
> #endif
>
266a276,302
>
> #if defined(__amd64__)
> /*
> * On certain chipsets AT keyboard controller isn't present and is
> * emulated by BIOS using SMI interrupt. On those chipsets reading
> * from the status port may be thousand times slower than usually.
> * Sometimes this emilation is not working properly resulting in
> * commands timing our and since we assume that inb() operation
> * takes very little time to complete we need to adjust number of
> * retries to keep waiting time within a designed limits (100ms).
> * Measure time it takes to make read_status() call and adjust
> * number of retries accordingly.
> */
> flags = intr_disable();
> tscval[0] = rdtsc();
> read_status(sc);
> tscval[1] = rdtsc();
> DELAY(1000);
> tscval[2] = rdtsc();
> intr_restore(flags);
> read_delay = tscval[1] - tscval[0];
> read_delay /= (tscval[2] - tscval[1]) / 1000;
> sc->retry = 100000 / ((KBDD_DELAYTIME * 2) + read_delay);
> #else
> sc->retry = 5000;
> #endif
>
383,384c419
< /* CPU will stay inside the loop for 100msec at most */
< int retry = 5000;
---
> int retry;
386a422,424
> /* CPU will stay inside the loop for 100msec at most */
> retry = kbdc->retry;
>
409,410c447
< /* CPU will stay inside the loop for 200msec at most */
< int retry = 10000;
---
> int retry;
412a450,452
> /* CPU will stay inside the loop for 200msec at most */
> retry = kbdc->retry * 2;
>
426,427c466
< /* CPU will stay inside the loop for 200msec at most */
< int retry = 10000;
---
> int retry;
429a469,471
> /* CPU will stay inside the loop for 200msec at most */
> retry = kbdc->retry * 2;
>
451,452c493
< /* CPU will stay inside the loop for 200msec at most */
< int retry = 10000;
---
> int retry;
455a497,499
> /* CPU will stay inside the loop for 200msec at most */
> retry = kbdc->retry * 2;
>
478,479c522
< /* CPU will stay inside the loop for 200msec at most */
< int retry = 10000;
---
> int retry;
481a525,527
> /* CPU will stay inside the loop for 200msec at most */
> retry = kbdc->retry * 2;
>
503,504c549
< /* CPU will stay inside the loop for 200msec at most */
< int retry = 10000;
---
> int retry;
507a553,555
> /* CPU will stay inside the loop for 200msec at most */
> retry = kbdc->retry * 2;
>