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