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 * 17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #include <sys/cdefs.h> 31 __KERNEL_RCSID(0, "$NetBSD: ioplanar.c,v 1.2 2008/04/28 20:23:34 martin Exp $"); 32 33 #include <sys/param.h> 34 #include <sys/device.h> 35 36 #include <machine/intr.h> 37 #include <machine/bus.h> 38 39 #include <dev/mca/mcavar.h> 40 #include <dev/mca/mcadevs.h> 41 42 #include <rs6000/ioplanar/ioplanarvar.h> 43 44 static int ioplanar_match(struct device *, struct cfdata *, void *); 45 static void ioplanar_attach(struct device *, struct device *, void *); 46 static int ioplanar_print(void *, const char *); 47 static int ioplanar_search(struct device *, struct cfdata *, 48 const int *, void *); 49 50 CFATTACH_DECL(ioplanar, sizeof(struct ioplanar_softc), 51 ioplanar_match, ioplanar_attach, NULL, NULL); 52 53 struct ioplanar_softc *ioplanar_softc; 54 extern struct cfdriver ioplanar_cd; 55 56 #define RAINBOW_DEVS 7 57 int rainbow_map[RAINBOW_DEVS] = 58 { IOP_COM0, IOP_COM1, IOP_LPD, IOP_KBD_2, 59 IOP_TABLET_2, IOP_MOUSE, IOP_FDC_2 }; 60 61 static int 62 ioplanar_match(struct device *parent, struct cfdata *cf, void *aux) 63 { 64 struct mca_attach_args *ma = aux; 65 66 switch (ma->ma_id) { 67 case MCA_PRODUCT_IBM_SIO_RAINBOW: 68 return 1; 69 } 70 71 return 0; 72 } 73 74 static void 75 ioplanar_attach(struct device *parent, struct device *self, void *aux) 76 { 77 struct ioplanar_softc *sc = (struct ioplanar_softc *)self; 78 struct mca_attach_args *ma = aux; 79 80 printf("\n"); 81 82 ioplanar_softc = sc; 83 sc->sc_ic = ma->ma_mc; 84 sc->sc_iot = ma->ma_iot; 85 sc->sc_memt = ma->ma_memt; 86 sc->sc_dmat = ma->ma_dmat; 87 sc->sc_devid = ma->ma_id; 88 89 (void)config_search_ia(ioplanar_search, self, "ioplanar", aux); 90 } 91 92 static int 93 ioplanar_search(struct device *parent, struct cfdata *cf, 94 const int *ldesc, void *aux) 95 { 96 struct ioplanar_dev_attach_args idaa; 97 struct mca_attach_args *ma = aux; 98 int i; 99 100 idaa.idaa_mc = ma->ma_mc; 101 idaa.idaa_iot = ma->ma_iot; 102 idaa.idaa_memt = ma->ma_memt; 103 idaa.idaa_dmat = ma->ma_dmat; 104 idaa.idaa_devid = ma->ma_id; 105 106 switch (ma->ma_id) { 107 case MCA_PRODUCT_IBM_SIO_RAINBOW: 108 for (i=0; i < RAINBOW_DEVS; i++) { 109 idaa.idaa_device = rainbow_map[i]; 110 if (config_match(parent, cf, &idaa) > 0) 111 config_attach(parent, cf, &idaa, 112 ioplanar_print); 113 } 114 break; 115 default: 116 return 0; 117 } 118 return 0; 119 } 120 121 static int 122 ioplanar_print(void *args, const char *name) 123 { 124 /*struct ioplanar_dev_attach_args *idaa = args;*/ 125 126 aprint_normal(": "); 127 return (UNCONF); 128 } 129