| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pckbc.c,v 1.50 2010/04/19 18:24:26 dyoung Exp $ */ | | 1 | /* $NetBSD: pckbc.c,v 1.51 2010/08/08 09:33:05 isaki Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2004 Ben Harris. | | 4 | * Copyright (c) 2004 Ben Harris. |
5 | * Copyright (c) 1998 | | 5 | * Copyright (c) 1998 |
6 | * Matthias Drochner. All rights reserved. | | 6 | * Matthias Drochner. All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.50 2010/04/19 18:24:26 dyoung Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.51 2010/08/08 09:33:05 isaki Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/callout.h> | | 34 | #include <sys/callout.h> |
35 | #include <sys/kernel.h> | | 35 | #include <sys/kernel.h> |
36 | #include <sys/proc.h> | | 36 | #include <sys/proc.h> |
37 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
38 | #include <sys/malloc.h> | | 38 | #include <sys/malloc.h> |
39 | #include <sys/errno.h> | | 39 | #include <sys/errno.h> |
40 | #include <sys/queue.h> | | 40 | #include <sys/queue.h> |
41 | | | 41 | |
42 | #include <sys/bus.h> | | 42 | #include <sys/bus.h> |
43 | | | 43 | |
| @@ -451,34 +451,34 @@ pckbc_slot_enable(void *self, pckbc_slot | | | @@ -451,34 +451,34 @@ pckbc_slot_enable(void *self, pckbc_slot |
451 | } | | 451 | } |
452 | | | 452 | |
453 | static void | | 453 | static void |
454 | pckbc_set_poll(void *self, pckbc_slot_t slot, int on) | | 454 | pckbc_set_poll(void *self, pckbc_slot_t slot, int on) |
455 | { | | 455 | { |
456 | struct pckbc_internal *t = (struct pckbc_internal *)self; | | 456 | struct pckbc_internal *t = (struct pckbc_internal *)self; |
457 | | | 457 | |
458 | t->t_slotdata[slot]->polling = on; | | 458 | t->t_slotdata[slot]->polling = on; |
459 | | | 459 | |
460 | if (on) { | | 460 | if (on) { |
461 | t->t_slotdata[slot]->poll_data = -1; | | 461 | t->t_slotdata[slot]->poll_data = -1; |
462 | t->t_slotdata[slot]->poll_stat = -1; | | 462 | t->t_slotdata[slot]->poll_stat = -1; |
463 | } else { | | 463 | } else { |
464 | int s; | | 464 | int s; |
465 | | | 465 | |
466 | /* | | 466 | /* |
467 | * If disabling polling on a device that's been configured, | | 467 | * If disabling polling on a device that's been configured, |
468 | * make sure there are no bytes left in the FIFO, holding up | | 468 | * make sure there are no bytes left in the FIFO, holding up |
469 | * the interrupt line. Otherwise we won't get any further | | 469 | * the interrupt line. Otherwise we won't get any further |
470 | * interrupts. | | 470 | * interrupts. |
471 | */ | | 471 | */ |
472 | if (t->t_sc) { | | 472 | if (t->t_sc) { |
473 | s = spltty(); | | 473 | s = spltty(); |
474 | pckbcintr(t->t_sc); | | 474 | pckbcintr(t->t_sc); |
475 | splx(s); | | 475 | splx(s); |
476 | } | | 476 | } |
477 | } | | 477 | } |
478 | } | | 478 | } |
479 | | | 479 | |
480 | static void | | 480 | static void |
481 | pckbc_intr_establish(void *pt, pckbport_slot_t slot) | | 481 | pckbc_intr_establish(void *pt, pckbport_slot_t slot) |
482 | { | | 482 | { |
483 | struct pckbc_internal *t = pt; | | 483 | struct pckbc_internal *t = pt; |
484 | | | 484 | |
| @@ -611,30 +611,30 @@ pckbcintr(void *vsc) | | | @@ -611,30 +611,30 @@ pckbcintr(void *vsc) |
611 | } | | 611 | } |
612 | | | 612 | |
613 | int | | 613 | int |
614 | pckbc_cnattach(bus_space_tag_t iot, bus_addr_t addr, | | 614 | pckbc_cnattach(bus_space_tag_t iot, bus_addr_t addr, |
615 | bus_size_t cmd_offset, pckbc_slot_t slot) | | 615 | bus_size_t cmd_offset, pckbc_slot_t slot) |
616 | { | | 616 | { |
617 | bus_space_handle_t ioh_d, ioh_c; | | 617 | bus_space_handle_t ioh_d, ioh_c; |
618 | #ifdef PCKBC_CNATTACH_SELFTEST | | 618 | #ifdef PCKBC_CNATTACH_SELFTEST |
619 | int reply; | | 619 | int reply; |
620 | #endif | | 620 | #endif |
621 | int res = 0; | | 621 | int res = 0; |
622 | | | 622 | |
623 | if (bus_space_map(iot, addr + KBDATAP, 1, 0, &ioh_d)) | | 623 | if (bus_space_map(iot, addr + KBDATAP, 1, 0, &ioh_d)) |
624 | return (ENXIO); | | 624 | return (ENXIO); |
625 | if (bus_space_map(iot, addr + cmd_offset, 1, 0, &ioh_c)) { | | 625 | if (bus_space_map(iot, addr + cmd_offset, 1, 0, &ioh_c)) { |
626 | bus_space_unmap(iot, ioh_d, 1); | | 626 | bus_space_unmap(iot, ioh_d, 1); |
627 | return (ENXIO); | | 627 | return (ENXIO); |
628 | } | | 628 | } |
629 | | | 629 | |
630 | memset(&pckbc_consdata, 0, sizeof(pckbc_consdata)); | | 630 | memset(&pckbc_consdata, 0, sizeof(pckbc_consdata)); |
631 | pckbc_consdata.t_iot = iot; | | 631 | pckbc_consdata.t_iot = iot; |
632 | pckbc_consdata.t_ioh_d = ioh_d; | | 632 | pckbc_consdata.t_ioh_d = ioh_d; |
633 | pckbc_consdata.t_ioh_c = ioh_c; | | 633 | pckbc_consdata.t_ioh_c = ioh_c; |
634 | pckbc_consdata.t_addr = addr; | | 634 | pckbc_consdata.t_addr = addr; |
635 | callout_init(&pckbc_consdata.t_cleanup, 0); | | 635 | callout_init(&pckbc_consdata.t_cleanup, 0); |
636 | | | 636 | |
637 | /* flush */ | | 637 | /* flush */ |
638 | (void) pckbc_poll_data1(&pckbc_consdata, PCKBC_KBD_SLOT); | | 638 | (void) pckbc_poll_data1(&pckbc_consdata, PCKBC_KBD_SLOT); |
639 | | | 639 | |
640 | #ifdef PCKBC_CNATTACH_SELFTEST | | 640 | #ifdef PCKBC_CNATTACH_SELFTEST |