Home | History | Annotate | Line # | Download | only in ibus
ibus.c revision 1.3
      1 /* $NetBSD: ibus.c,v 1.3 1999/11/23 20:07:40 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1998 Jonathan Stone.  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 Jonathan Stone for
     17  *      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 THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 
     35 __KERNEL_RCSID(0, "$NetBSD: ibus.c,v 1.3 1999/11/23 20:07:40 thorpej Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 
     41 #include <pmax/ibus/ibusvar.h>
     42 
     43 #include "locators.h"
     44 
     45 extern struct cfdriver ibus_cd;
     46 
     47 int	ibussubmatch __P((struct device *, struct cfdata *, void *));
     48 
     49 void
     50 ibusattach(parent, self, aux)
     51         struct device *parent, *self;
     52         void *aux;
     53 {
     54         struct ibus_softc *sc = (struct ibus_softc *)self;
     55 	struct ibus_dev_attach_args *ida = aux;
     56         int i;
     57 
     58         printf("\n");
     59 
     60         sc->sc_intr_establish = ida->ida_establish;
     61         sc->sc_intr_disestablish = ida->ida_disestablish;
     62 
     63 	for (i = 0; i < ida->ida_ndevs; i++)
     64 		(void) config_found_sm(self, &ida->ida_devs[i], ibusprint,
     65 		    ibussubmatch);
     66 }
     67 
     68 int
     69 ibussubmatch(parent, cf, aux)
     70 	struct device *parent;
     71 	struct cfdata *cf;
     72 	void *aux;
     73 {
     74 	struct ibus_attach_args *ia = aux;
     75 	paddr_t pa;
     76 
     77 	pa = MIPS_KSEG1_TO_PHYS(ia->ia_addr);
     78 
     79 	if (cf->cf_loc[IBUSCF_ADDR] != IBUSCF_ADDR_DEFAULT &&
     80 	    cf->cf_loc[IBUSCF_ADDR] != pa)
     81 		return (0);
     82 
     83 	return ((*cf->cf_attach->ca_match)(parent, cf, aux));
     84 }
     85 
     86 int
     87 ibusprint(aux, pnp)
     88 	void *aux;
     89 	const char *pnp;
     90 {
     91 	struct ibus_attach_args *ia = aux;
     92 
     93 	if (pnp)
     94 		printf("%s at %s", ia->ia_name, pnp);
     95 
     96 	printf(" addr 0x%x", MIPS_KSEG1_TO_PHYS(ia->ia_addr));
     97 
     98 	return (UNCONF);
     99 }
    100 
    101 void
    102 ibus_intr_establish(dev, cookie, level, handler, arg)
    103 	struct device *dev;
    104 	void *cookie;
    105 	int level;
    106 	int (*handler) __P((void *));
    107 	void *arg;
    108 {
    109 	struct ibus_softc *sc = ibus_cd.cd_devs[0];
    110 
    111 	(*sc->sc_intr_establish)(dev, cookie, level, handler, arg);
    112 }
    113 
    114 
    115 void
    116 ibus_intr_disestablish(dev, arg)
    117 	struct device *dev;
    118 	void *arg;
    119 {
    120 	struct ibus_softc *sc = ibus_cd.cd_devs[0];
    121 
    122 	(*sc->sc_intr_disestablish)(dev, arg);
    123 }
    124