1 /* $NetBSD: lpt_supio.c,v 1.10 2002/10/02 04:55:52 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Ignatios Souvatzis. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 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. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: lpt_supio.c,v 1.10 2002/10/02 04:55:52 thorpej Exp $"); 41 42 #include <sys/param.h> 43 #include <sys/systm.h> 44 #include <sys/ioctl.h> 45 #include <sys/select.h> 46 #include <sys/tty.h> 47 #include <sys/proc.h> 48 #include <sys/user.h> 49 #include <sys/conf.h> 50 #include <sys/file.h> 51 #include <sys/uio.h> 52 #include <sys/kernel.h> 53 #include <sys/syslog.h> 54 #include <sys/types.h> 55 #include <sys/device.h> 56 57 #include <machine/intr.h> 58 #include <machine/bus.h> 59 60 #include <dev/ic/lptreg.h> 61 #include <dev/ic/lptvar.h> 62 63 #include <amiga/dev/supio.h> 64 65 struct lptsupio_softc { 66 struct lpt_softc sc_lpt; 67 struct isr sc_isr; 68 void (*sc_intack)(void *); 69 }; 70 71 int lpt_supio_match(struct device *, struct cfdata *, void *); 72 void lpt_supio_attach(struct device *, struct device *, void *); 73 int lpt_supio_intr(void *p); 74 75 CFATTACH_DECL(lpt_supio, sizeof(struct lptsupio_softc), 76 lpt_supio_match, lpt_supio_attach, NULL, NULL); 77 78 int 79 lpt_supio_match(struct device *parent, struct cfdata *match, void *aux) 80 { 81 struct supio_attach_args *supa = aux; 82 83 if (strcmp(supa->supio_name,"lpt")) 84 return 0; 85 86 return (1); 87 } 88 89 int 90 lpt_supio_intr(void *p) 91 { 92 struct lptsupio_softc *sc = (void *)p; 93 int rc; 94 95 rc = lptintr(&sc->sc_lpt); 96 if (sc->sc_intack) 97 (*sc->sc_intack)(p); 98 return (rc); 99 } 100 101 void 102 lpt_supio_attach(struct device *parent, struct device *self, void *aux) 103 { 104 struct lptsupio_softc *sc = (void *)self; 105 struct lpt_softc *lsc = &sc->sc_lpt; 106 int iobase; 107 bus_space_tag_t iot; 108 struct supio_attach_args *supa = aux; 109 110 /* 111 * We're living on a superio chip. 112 */ 113 iobase = supa->supio_iobase; 114 iot = lsc->sc_iot = supa->supio_iot; 115 sc->sc_intack = (void *)supa->supio_arg; 116 117 if (bus_space_map(iot, iobase, LPT_NPORTS, 0, &lsc->sc_ioh)) 118 panic("lpt_supio_attach: io mapping failed"); 119 120 printf(" port 0x%04x ipl %d\n", iobase, supa->supio_ipl); 121 lpt_attach_subr(lsc); 122 123 sc->sc_isr.isr_intr = lpt_supio_intr; 124 sc->sc_isr.isr_arg = sc; 125 sc->sc_isr.isr_ipl = supa->supio_ipl; 126 add_isr(&sc->sc_isr); 127 } 128