1 /* $NetBSD: opms_isa.c,v 1.2 2002/01/07 21:46:57 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/tty.h> 33 #include <sys/device.h> 34 35 #include <machine/bus.h> 36 37 #include <dev/isa/isareg.h> 38 #include <dev/isa/isavar.h> 39 40 #include <arc/dev/pcconsvar.h> 41 #include <arc/dev/opmsvar.h> 42 43 int opms_isa_match __P((struct device *, struct cfdata *, void *)); 44 void opms_isa_attach __P((struct device *, struct device *, void *)); 45 46 struct cfattach opms_isa_ca = { 47 sizeof(struct opms_softc), opms_isa_match, opms_isa_attach, 48 }; 49 50 struct pccons_config *pccons_isa_conf; /* share stroage with pccons_isa.c */ 51 52 int 53 opms_isa_match(parent, match, aux) 54 struct device *parent; 55 struct cfdata *match; 56 void *aux; 57 { 58 struct isa_attach_args *ia = aux; 59 bus_addr_t iobase = IO_KBD; 60 bus_size_t iosize = IO_KBDSIZE; 61 int irq = 12; 62 63 if (ia->ia_nio < 1) 64 return (0); 65 if (ia->ia_io[0].ir_addr != ISACF_PORT_DEFAULT) 66 iobase = ia->ia_io[0].ir_addr; 67 #if 0 /* XXX isa.c */ 68 if (ia->ia_iosize != 0) 69 iosize = ia->ia_iosize; 70 #endif 71 if (ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT) 72 irq = ia->ia_irq[0].ir_irq; 73 74 #if 0 75 /* If values are hardwired to something that they can't be, punt. */ 76 if (iobase != IO_KBD || iosize != IO_KBDSIZE || 77 ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 || 78 ia->ia_irq != 1 || ia->ia_drq != DRQUNK) 79 return (0); 80 #endif 81 82 if (pccons_isa_conf == NULL) 83 return (0); 84 85 if (!opms_common_match(ia->ia_iot, pccons_isa_conf)) 86 return (0); 87 88 ia->ia_nio = 1; 89 ia->ia_io[0].ir_addr = iobase; 90 ia->ia_io[0].ir_size = iosize; 91 92 ia->ia_nirq = 1; 93 ia->ia_irq[0].ir_irq = irq; 94 95 ia->ia_niomem = 0; 96 ia->ia_ndrq = 0; 97 98 return (1); 99 } 100 101 void 102 opms_isa_attach(parent, self, aux) 103 struct device *parent, *self; 104 void *aux; 105 { 106 struct opms_softc *sc = (struct opms_softc *)self; 107 struct isa_attach_args *ia = aux; 108 109 printf("\n"); 110 111 isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY, 112 pcintr, self); 113 opms_common_attach(sc, ia->ia_iot, pccons_isa_conf); 114 } 115