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