Home | History | Annotate | Line # | Download | only in dev
ipaq_saip.c revision 1.20.24.1
      1 /*	$NetBSD: ipaq_saip.c,v 1.20.24.1 2007/10/07 15:56:16 rjs 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 (at) 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.20.24.1 2007/10/07 15:56:16 rjs 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(void *aux, const char *name)
     76 {
     77         return (UNCONF);
     78 }
     79 
     80 int
     81 ipaq_match(struct device *parent, struct cfdata *match, void *aux)
     82 {
     83 	return (1);
     84 }
     85 
     86 void
     87 ipaq_attach(struct device *parent, struct device *self, void *aux)
     88 {
     89 	struct ipaq_softc *sc = (struct ipaq_softc*)self;
     90 	struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
     91 	struct sa11x0_attach_args *sa = aux;
     92 
     93 	printf("\n");
     94 
     95 	sc->sc_iot = psc->sc_iot;
     96 	sc->sc_ioh = psc->sc_ioh;
     97 	sc->sc_gpioh = psc->sc_gpioh;
     98 
     99 	/* Map the Extended GPIO registers */
    100 	if (bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0,
    101 			  &sc->sc_egpioh))
    102 		panic("%s: unable to map Extended GPIO registers",
    103 			self->dv_xname);
    104 
    105 	sc->ipaq_egpio = EGPIO_INIT;
    106         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
    107 
    108 	/* Map the SSP registers */
    109 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
    110 		panic("%s: unable to map SSP registers",
    111 			self->dv_xname);
    112 
    113 	sc->sc_ppch = psc->sc_ppch;
    114 	sc->sc_dmach = psc->sc_dmach;
    115 
    116 	/*
    117 	 *  Attach each devices
    118 	 */
    119 	config_search_ia(ipaq_search, self, "ipaqbus", NULL);
    120 }
    121 
    122 int
    123 ipaq_search(struct device *parent, struct cfdata *cf, const int *ldesc,
    124 	    void *aux)
    125 {
    126 	if (config_match(parent, cf, NULL) > 0)
    127 		config_attach(parent, cf, NULL, ipaq_print);
    128 
    129         return 0;
    130 }
    131