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