1 /* $OpenBSD: lpt_ebus.c,v 1.10 2019/12/05 12:46:54 mpi Exp $ */ 2 /* $NetBSD: lpt_ebus.c,v 1.8 2002/03/01 11:51:00 martin Exp $ */ 3 4 /* 5 * Copyright (c) 1999, 2000 Matthew R. Green 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 /* 31 * NS Super I/O PC87332VLJ "lpt" to ebus attachment 32 */ 33 34 #include <sys/param.h> 35 #include <sys/systm.h> 36 #include <sys/device.h> 37 #include <sys/tty.h> 38 39 #include <machine/bus.h> 40 41 #include <sparc64/dev/ebusreg.h> 42 #include <sparc64/dev/ebusvar.h> 43 44 #include <dev/ic/lptvar.h> 45 46 struct lpt_ebus_softc { 47 struct lpt_softc sc_lpt; 48 bus_space_handle_t sc_ctrl; 49 }; 50 51 int lpt_ebus_match(struct device *, void *, void *); 52 void lpt_ebus_attach(struct device *, struct device *, void *); 53 54 struct cfattach lpt_ebus_ca = { 55 sizeof(struct lpt_ebus_softc), lpt_ebus_match, lpt_ebus_attach 56 }; 57 58 int 59 lpt_ebus_match(parent, match, aux) 60 struct device *parent; 61 void *match; 62 void *aux; 63 { 64 struct ebus_attach_args *ea = aux; 65 66 if (!strcmp(ea->ea_name, "ecpp") || 67 !strcmp(ea->ea_name, "parallel")) 68 return (1); 69 return (0); 70 } 71 72 void 73 lpt_ebus_attach(parent, self, aux) 74 struct device *parent, *self; 75 void *aux; 76 { 77 struct lpt_ebus_softc *sc = (void *)self; 78 struct ebus_attach_args *ea = aux; 79 80 81 if (ebus_bus_map(ea->ea_memtag, 0, 82 EBUS_PADDR_FROM_REG(&ea->ea_regs[0]), ea->ea_regs[0].size, 83 0, 0, &sc->sc_lpt.sc_ioh) == 0) { 84 sc->sc_lpt.sc_iot = ea->ea_memtag; 85 } else if (ebus_bus_map(ea->ea_iotag, 0, 86 EBUS_PADDR_FROM_REG(&ea->ea_regs[0]), ea->ea_regs[0].size, 87 0, 0, &sc->sc_lpt.sc_ioh) == 0) { 88 sc->sc_lpt.sc_iot = ea->ea_iotag; 89 } else { 90 printf(": can't map register space\n"); 91 return; 92 } 93 94 if (ebus_bus_map(sc->sc_lpt.sc_iot, 0, 95 EBUS_PADDR_FROM_REG(&ea->ea_regs[1]), ea->ea_regs[1].size, 0, 0, 96 &sc->sc_ctrl) != 0) { 97 printf(": can't map control space\n"); 98 bus_space_unmap(sc->sc_lpt.sc_iot, sc->sc_lpt.sc_ioh, 99 ea->ea_regs[0].size); 100 return; 101 } 102 103 sc->sc_lpt.sc_flags |= LPT_POLLED; 104 printf(": polled"); 105 106 lpt_attach_common(&sc->sc_lpt); 107 } 108