1 /* $NetBSD: ipaq_saip.c,v 1.18 2006/04/11 15:21:26 peter Exp $ */ 2 3 /*- 4 * Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Ichiro FUKUHARA (ichiro@ichiro.org). 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the NetBSD 20 * Foundation, Inc. and its contributors. 21 * 4. Neither the name of The NetBSD Foundation nor the names of its 22 * contributors may be used to endorse or promote products derived 23 * from this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 #include <sys/cdefs.h> 39 __KERNEL_RCSID(0, "$NetBSD: ipaq_saip.c,v 1.18 2006/04/11 15:21:26 peter Exp $"); 40 41 #include <sys/param.h> 42 #include <sys/systm.h> 43 #include <sys/types.h> 44 #include <sys/conf.h> 45 #include <sys/device.h> 46 #include <sys/kernel.h> 47 #include <sys/malloc.h> 48 #include <sys/uio.h> 49 50 #include <machine/cpu.h> 51 #include <machine/bus.h> 52 53 #include <arm/sa11x0/sa11x0_var.h> 54 #include <arm/sa11x0/sa11x0_reg.h> 55 #include <arm/sa11x0/sa11x0_dmacreg.h> 56 #include <arm/sa11x0/sa11x0_ppcreg.h> 57 #include <arm/sa11x0/sa11x0_gpioreg.h> 58 #include <arm/sa11x0/sa11x0_sspreg.h> 59 60 #include <hpcarm/dev/ipaq_saipvar.h> 61 #include <hpcarm/dev/ipaq_gpioreg.h> 62 63 /* prototypes */ 64 static int ipaq_match(struct device *, struct cfdata *, void *); 65 static void ipaq_attach(struct device *, struct device *, void *); 66 static int ipaq_search(struct device *, struct cfdata *, 67 const int *, void *); 68 static int ipaq_print(void *, const char *); 69 70 /* attach structures */ 71 CFATTACH_DECL(ipaqbus, sizeof(struct ipaq_softc), 72 ipaq_match, ipaq_attach, NULL, NULL); 73 74 static int 75 ipaq_print(aux, name) 76 void *aux; 77 const char *name; 78 { 79 return (UNCONF); 80 } 81 82 int 83 ipaq_match(parent, match, aux) 84 struct device *parent; 85 struct cfdata *match; 86 void *aux; 87 { 88 return (1); 89 } 90 91 void 92 ipaq_attach(parent, self, aux) 93 struct device *parent; 94 struct device *self; 95 void *aux; 96 { 97 struct ipaq_softc *sc = (struct ipaq_softc*)self; 98 struct sa11x0_softc *psc = (struct sa11x0_softc *)parent; 99 100 printf("\n"); 101 102 sc->sc_iot = psc->sc_iot; 103 sc->sc_ioh = psc->sc_ioh; 104 sc->sc_gpioh = psc->sc_gpioh; 105 106 /* Map the Extended GPIO registers */ 107 if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh)) 108 panic("%s: unable to map Extended GPIO registers", 109 self->dv_xname); 110 111 sc->ipaq_egpio = EGPIO_INIT; 112 bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio); 113 114 /* Map the SSP registers */ 115 if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph)) 116 panic("%s: unable to map SSP registers", 117 self->dv_xname); 118 119 sc->sc_ppch = psc->sc_ppch; 120 sc->sc_dmach = psc->sc_dmach; 121 122 /* 123 * Attach each devices 124 */ 125 config_search_ia(ipaq_search, self, "ipaqbus", NULL); 126 } 127 128 int 129 ipaq_search(parent, cf, ldesc, aux) 130 struct device *parent; 131 struct cfdata *cf; 132 const int *ldesc; 133 void *aux; 134 { 135 if (config_match(parent, cf, NULL) > 0) 136 config_attach(parent, cf, NULL, ipaq_print); 137 138 return 0; 139 } 140