Home | History | Annotate | Line # | Download | only in mca
ioplanar.c revision 1.1
      1 /*-
      2  * Copyright (c) 2007 The NetBSD Foundation, Inc.
      3  * All rights reserved.
      4  *
      5  * This code is derived from software contributed to The NetBSD Foundation
      6  * by Tim Rightnour
      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  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *        This product includes software developed by the NetBSD
     19  *        Foundation, Inc. and its contributors.
     20  * 4. Neither the name of The NetBSD Foundation nor the names of its
     21  *    contributors may be used to endorse or promote products derived
     22  *    from this software without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34  * POSSIBILITY OF SUCH DAMAGE.
     35  */
     36 
     37 #include <sys/cdefs.h>
     38 __KERNEL_RCSID(0, "$NetBSD: ioplanar.c,v 1.1 2007/12/17 19:09:40 garbled Exp $");
     39 
     40 #include <sys/param.h>
     41 #include <sys/device.h>
     42 
     43 #include <machine/intr.h>
     44 #include <machine/bus.h>
     45 
     46 #include <dev/mca/mcavar.h>
     47 #include <dev/mca/mcadevs.h>
     48 
     49 #include <rs6000/ioplanar/ioplanarvar.h>
     50 
     51 static int	ioplanar_match(struct device *, struct cfdata *, void *);
     52 static void	ioplanar_attach(struct device *, struct device *, void *);
     53 static int	ioplanar_print(void *, const char *);
     54 static int	ioplanar_search(struct device *, struct cfdata *,
     55 				const int *, void *);
     56 
     57 CFATTACH_DECL(ioplanar, sizeof(struct ioplanar_softc),
     58     ioplanar_match, ioplanar_attach, NULL, NULL);
     59 
     60 struct ioplanar_softc *ioplanar_softc;
     61 extern struct cfdriver ioplanar_cd;
     62 
     63 #define RAINBOW_DEVS	7
     64 int rainbow_map[RAINBOW_DEVS] =
     65 	{ IOP_COM0, IOP_COM1, IOP_LPD, IOP_KBD_2,
     66 	  IOP_TABLET_2, IOP_MOUSE, IOP_FDC_2 };
     67 
     68 static int
     69 ioplanar_match(struct device *parent, struct cfdata *cf, void *aux)
     70 {
     71 	struct mca_attach_args *ma = aux;
     72 
     73 	switch (ma->ma_id) {
     74 	case MCA_PRODUCT_IBM_SIO_RAINBOW:
     75 		return 1;
     76 	}
     77 
     78 	return 0;
     79 }
     80 
     81 static void
     82 ioplanar_attach(struct device *parent, struct device *self, void *aux)
     83 {
     84 	struct ioplanar_softc *sc = (struct ioplanar_softc *)self;
     85 	struct mca_attach_args *ma = aux;
     86 
     87 	printf("\n");
     88 
     89 	ioplanar_softc = sc;
     90 	sc->sc_ic = ma->ma_mc;
     91 	sc->sc_iot = ma->ma_iot;
     92 	sc->sc_memt = ma->ma_memt;
     93 	sc->sc_dmat = ma->ma_dmat;
     94 	sc->sc_devid = ma->ma_id;
     95 
     96 	(void)config_search_ia(ioplanar_search, self, "ioplanar", aux);
     97 }
     98 
     99 static int
    100 ioplanar_search(struct device *parent, struct cfdata *cf,
    101     const int *ldesc, void *aux)
    102 {
    103 	struct ioplanar_dev_attach_args idaa;
    104 	struct mca_attach_args *ma = aux;
    105 	int i;
    106 
    107 	idaa.idaa_mc = ma->ma_mc;
    108 	idaa.idaa_iot = ma->ma_iot;
    109 	idaa.idaa_memt = ma->ma_memt;
    110 	idaa.idaa_dmat = ma->ma_dmat;
    111 	idaa.idaa_devid = ma->ma_id;
    112 
    113 	switch (ma->ma_id) {
    114 	case MCA_PRODUCT_IBM_SIO_RAINBOW:
    115 		for (i=0; i < RAINBOW_DEVS; i++) {
    116 			idaa.idaa_device = rainbow_map[i];
    117 			if (config_match(parent, cf, &idaa) > 0)
    118 				config_attach(parent, cf, &idaa,
    119 				    ioplanar_print);
    120 		}
    121 		break;
    122 	default:
    123 		return 0;
    124 	}
    125 	return 0;
    126 }
    127 
    128 static int
    129 ioplanar_print(void *args, const char *name)
    130 {
    131 	/*struct ioplanar_dev_attach_args *idaa = args;*/
    132 
    133 	aprint_normal(": ");
    134 	return (UNCONF);
    135 }
    136