Home | History | Annotate | Line # | Download | only in dev
lpt_ebus.c revision 1.2
      1 /*	$NetBSD: lpt_ebus.c,v 1.2 1999/06/05 14:19:44 mrg Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999 Matthew R. Green
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 /*
     32  * NS Super I/O PC87332VLJ "lpt" to ebus attachment
     33  */
     34 
     35 #include <sys/types.h>
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 #include <sys/device.h>
     39 #include <sys/tty.h>
     40 
     41 #include <machine/bus.h>
     42 
     43 #include <sparc64/dev/ebusreg.h>
     44 #include <sparc64/dev/ebusvar.h>
     45 
     46 #include <dev/ic/lptvar.h>
     47 
     48 int	lpt_ebus_match __P((struct device *, struct cfdata *, void *));
     49 void	lpt_ebus_attach __P((struct device *, struct device *, void *));
     50 
     51 struct cfattach lpt_ebus_ca = {
     52 	sizeof(struct lpt_softc), lpt_ebus_match, lpt_ebus_attach
     53 };
     54 
     55 #define	ROM_LPT_NAME	"ecpp"
     56 
     57 int
     58 lpt_ebus_match(parent, match, aux)
     59 	struct device *parent;
     60 	struct cfdata *match;
     61 	void *aux;
     62 {
     63 	struct ebus_attach_args *ea = aux;
     64 
     65 	if (strcmp(ea->ea_name, ROM_LPT_NAME) == 0)
     66 		return (1);
     67 
     68 	return (0);
     69 }
     70 
     71 void
     72 lpt_ebus_attach(parent, self, aux)
     73 	struct device *parent, *self;
     74 	void *aux;
     75 {
     76 	struct lpt_softc *sc = (void *)self;
     77 	struct ebus_attach_args *ea = aux;
     78 	int i;
     79 
     80 	sc->sc_iot = ea->ea_bustag;
     81 	/*
     82 	 * Use the prom address if there.
     83 	 */
     84 	if (ea->ea_naddrs)
     85 		sc->sc_ioh = (bus_space_handle_t)ea->ea_vaddrs[0];
     86 	else if (ebus_bus_map(sc->sc_iot, 0,
     87 			      EBUS_PADDR_FROM_REG(&ea->ea_regs[0]),
     88 			      ea->ea_regs[0].size,
     89 			      BUS_SPACE_MAP_LINEAR,
     90 			      0, &sc->sc_ioh) != 0) {
     91 		printf(": can't map register space\n");
     92                 return;
     93 	}
     94 	printf(" addr %p");
     95 
     96 	for (i = 0; i < ea->ea_nintrs; i++) {
     97 		bus_intr_establish(ea->ea_bustag, ea->ea_intrs[i], 0,
     98 		    lptintr, sc);
     99 		printf(" vector %d", ea->ea_intrs[i]);
    100 	}
    101 	printf("\n");
    102 
    103 	lpt_attach_subr(sc);
    104 }
    105