/*
* Copyright (c) 1998
* Matthias Drochner. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int
pckbc_isa_match(device_t parent, cfdata_t match, void *aux)
{
struct isa_attach_args *ia = aux;
bus_space_tag_t iot = ia->ia_iot;
bus_space_handle_t ioh_d, ioh_c;
int res, ok = 1;
if (ISA_DIRECT_CONFIG(ia))
return (0);
/* If values are hardwired to something that they can't be, punt. */
if (ia->ia_nio < 1 ||
(ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT &&
ia->ia_io[0].ir_addr != IO_KBD))
return (0);
if (ia->ia_niomem > 0 &&
(ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM))
return (0);
switch (ia->ia_nirq) {
case 1:
/* Both channels use the same IRQ. */
isc->sc_irq[PCKBC_KBD_SLOT] =
isc->sc_irq[PCKBC_AUX_SLOT] = ia->ia_irq[0].ir_irq;
break;
case 2:
/* First IRQ is kbd, second IRQ is aux port. */
isc->sc_irq[PCKBC_KBD_SLOT] = ia->ia_irq[0].ir_irq;
isc->sc_irq[PCKBC_AUX_SLOT] = ia->ia_irq[1].ir_irq;
break;
default:
/* Set up IRQs for "normal" ISA. */
isc->sc_irq[PCKBC_KBD_SLOT] = 1;
isc->sc_irq[PCKBC_AUX_SLOT] = 12;
break;
}
sc->intr_establish = pckbc_isa_intr_establish;
if (pckbc_is_console(iot, IO_KBD)) {
t = &pckbc_consdata;
ioh_d = t->t_ioh_d;
ioh_c = t->t_ioh_c;
pckbc_console_attached = 1;
/* t->t_cmdbyte was initialized by cnattach */
} else {
if (bus_space_map(iot, IO_KBD + KBDATAP, 1, 0, &ioh_d) ||
bus_space_map(iot, IO_KBD + KBCMDP, 1, 0, &ioh_c))
panic("pckbc_attach: couldn't map");