1 /* $NetBSD: pckbc_jensenio.c,v 1.9 2008/03/15 13:23:24 cube Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(0, "$NetBSD: pckbc_jensenio.c,v 1.9 2008/03/15 13:23:24 cube Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
40 #include <sys/device.h>
41 #include <sys/malloc.h>
42 #include <sys/errno.h>
43 #include <sys/queue.h>
47 #include <dev/ic/i8042reg.h>
48 #include <dev/ic/pckbcvar.h>
50 #include <dev/eisa/eisavar.h>
52 #include <dev/isa/isavar.h>
54 #include <alpha/jensenio/jenseniovar.h>
56 struct pckbc_jensenio_intrcookie
{
57 struct pckbc_softc
*ic_sc
;
63 struct pckbc_jensenio_softc
{
64 struct pckbc_softc sc_pckbc
; /* real "pckbc" softc */
66 /* Jensen-specific goo. */
67 struct pckbc_jensenio_intrcookie sc_ic
[PCKBC_NSLOTS
];
70 int pckbc_jensenio_match(device_t
, cfdata_t
, void *);
71 void pckbc_jensenio_attach(device_t
, device_t
, void *);
73 CFATTACH_DECL_NEW(pckbc_jensenio
, sizeof(struct pckbc_jensenio_softc
),
74 pckbc_jensenio_match
, pckbc_jensenio_attach
, NULL
, NULL
);
76 void pckbc_jensenio_intr_establish(struct pckbc_softc
*, pckbc_slot_t
);
77 void pckbc_jensenio_intr(void *, u_long
);
80 pckbc_jensenio_match(device_t parent
, cfdata_t match
, void *aux
)
82 struct jensenio_attach_args
*ja
= aux
;
85 if (strcmp(ja
->ja_name
, match
->cf_name
) == 0)
92 pckbc_jensenio_attach(device_t parent
, device_t self
, void *aux
)
94 struct pckbc_jensenio_softc
*jsc
= device_private(self
);
95 struct pckbc_softc
*sc
= &jsc
->sc_pckbc
;
96 struct jensenio_attach_args
*ja
= aux
;
97 struct pckbc_internal
*t
;
98 bus_space_handle_t ioh_d
, ioh_c
;
105 jsc
->sc_ic
[PCKBC_KBD_SLOT
].ic_vector
= ja
->ja_irq
[0];
106 jsc
->sc_ic
[PCKBC_AUX_SLOT
].ic_vector
= ja
->ja_irq
[1];
108 sc
->intr_establish
= pckbc_jensenio_intr_establish
;
110 if (pckbc_is_console(ja
->ja_iot
, ja
->ja_ioaddr
)) {
112 pckbc_console_attached
= 1;
113 /* t->t_cmdbyte was initialized by cnattach */
115 if (bus_space_map(ja
->ja_iot
, ja
->ja_ioaddr
+ KBDATAP
,
116 1, 0, &ioh_d
) != 0 ||
117 bus_space_map(ja
->ja_iot
, ja
->ja_ioaddr
+ KBCMDP
,
119 panic("pckbc_jensenio_attach: couldn't map");
121 t
= malloc(sizeof(struct pckbc_internal
), M_DEVBUF
, M_WAITOK
);
122 memset(t
, 0, sizeof(struct pckbc_internal
));
123 t
->t_iot
= ja
->ja_iot
;
126 t
->t_addr
= ja
->ja_ioaddr
;
127 t
->t_cmdbyte
= KC8_CPU
; /* Enable ports */
135 /* Finish off the attach. */
140 pckbc_jensenio_intr_establish(struct pckbc_softc
*sc
, pckbc_slot_t slot
)
142 struct pckbc_jensenio_softc
*jsc
= (void *) sc
;
144 jsc
->sc_ic
[slot
].ic_sc
= sc
;
146 scb_set(jsc
->sc_ic
[slot
].ic_vector
, pckbc_jensenio_intr
,
147 &jsc
->sc_ic
[slot
], IPL_VM
);
148 aprint_normal_dev(sc
->sc_dv
, "%s slot interrupting at vector 0x%lx\n",
149 pckbc_slot_names
[slot
], jsc
->sc_ic
[slot
].ic_vector
);
151 sprintf(jsc
->sc_ic
[slot
].ic_vecstr
, "0x%lx",
152 jsc
->sc_ic
[slot
].ic_vector
);
153 evcnt_attach_dynamic(&jsc
->sc_ic
[slot
].ic_ev
, EVCNT_TYPE_INTR
,
154 NULL
, "vector", jsc
->sc_ic
[slot
].ic_vecstr
);
158 pckbc_jensenio_intr(void *arg
, u_long vec
)
160 struct pckbc_jensenio_intrcookie
*ic
= arg
;
162 ic
->ic_ev
.ev_count
++;
163 (void) pckbcintr(ic
->ic_sc
);