Home | History | Annotate | Line # | Download | only in dev
ipaq_saip.c revision 1.23
      1  1.23    dyoung /*	$NetBSD: ipaq_saip.c,v 1.23 2011/07/19 15:37:38 dyoung 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.18     peter  *
     18  1.18     peter  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  1.18     peter  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  1.18     peter  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  1.18     peter  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  1.18     peter  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  1.18     peter  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  1.18     peter  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  1.18     peter  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  1.18     peter  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  1.18     peter  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  1.18     peter  * POSSIBILITY OF SUCH DAMAGE.
     29   1.1    ichiro  */
     30  1.14     lukem 
     31  1.14     lukem #include <sys/cdefs.h>
     32  1.23    dyoung __KERNEL_RCSID(0, "$NetBSD: ipaq_saip.c,v 1.23 2011/07/19 15:37:38 dyoung Exp $");
     33  1.14     lukem 
     34   1.1    ichiro #include <sys/param.h>
     35   1.1    ichiro #include <sys/systm.h>
     36   1.1    ichiro #include <sys/types.h>
     37   1.1    ichiro #include <sys/conf.h>
     38   1.1    ichiro #include <sys/device.h>
     39   1.1    ichiro #include <sys/kernel.h>
     40   1.1    ichiro #include <sys/malloc.h>
     41   1.1    ichiro #include <sys/uio.h>
     42  1.23    dyoung #include <sys/bus.h>
     43   1.1    ichiro 
     44   1.1    ichiro #include <machine/cpu.h>
     45   1.1    ichiro 
     46   1.9    ichiro #include <arm/sa11x0/sa11x0_var.h>
     47   1.9    ichiro #include <arm/sa11x0/sa11x0_reg.h>
     48   1.9    ichiro #include <arm/sa11x0/sa11x0_dmacreg.h>
     49   1.9    ichiro #include <arm/sa11x0/sa11x0_ppcreg.h>
     50   1.9    ichiro #include <arm/sa11x0/sa11x0_gpioreg.h>
     51   1.9    ichiro #include <arm/sa11x0/sa11x0_sspreg.h>
     52   1.9    ichiro 
     53   1.4    ichiro #include <hpcarm/dev/ipaq_saipvar.h>
     54   1.5    ichiro #include <hpcarm/dev/ipaq_gpioreg.h>
     55   1.1    ichiro 
     56   1.1    ichiro /* prototypes */
     57  1.22       rjs static int	ipaq_match(device_t, cfdata_t, void *);
     58  1.22       rjs static void	ipaq_attach(device_t, device_t, void *);
     59  1.22       rjs static int 	ipaq_search(device_t, cfdata_t, const int *, void *);
     60   1.1    ichiro static int	ipaq_print(void *, const char *);
     61   1.1    ichiro 
     62   1.1    ichiro /* attach structures */
     63  1.22       rjs CFATTACH_DECL_NEW(ipaqbus, sizeof(struct ipaq_softc),
     64  1.13   thorpej     ipaq_match, ipaq_attach, NULL, NULL);
     65   1.1    ichiro 
     66   1.1    ichiro static int
     67  1.19       rjs ipaq_print(void *aux, const char *name)
     68   1.1    ichiro {
     69   1.1    ichiro         return (UNCONF);
     70   1.1    ichiro }
     71   1.1    ichiro 
     72   1.1    ichiro int
     73  1.22       rjs ipaq_match(device_t parent, cfdata_t match, void *aux)
     74   1.1    ichiro {
     75   1.3    ichiro 	return (1);
     76   1.1    ichiro }
     77   1.1    ichiro 
     78   1.1    ichiro void
     79  1.22       rjs ipaq_attach(device_t parent, device_t self, void *aux)
     80   1.1    ichiro {
     81  1.22       rjs 	struct ipaq_softc *sc = device_private(self);
     82  1.22       rjs 	struct sa11x0_softc *psc = device_private(parent);
     83   1.1    ichiro 
     84  1.22       rjs 	aprint_normal("\n");
     85   1.1    ichiro 
     86  1.22       rjs 	sc->sc_dev = self;
     87   1.2    ichiro 	sc->sc_iot = psc->sc_iot;
     88   1.1    ichiro 	sc->sc_ioh = psc->sc_ioh;
     89   1.1    ichiro 	sc->sc_gpioh = psc->sc_gpioh;
     90   1.1    ichiro 
     91   1.3    ichiro 	/* Map the Extended GPIO registers */
     92   1.1    ichiro 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
     93  1.11    provos 		panic("%s: unable to map Extended GPIO registers",
     94  1.22       rjs 			device_xname(self));
     95   1.5    ichiro 
     96   1.5    ichiro 	sc->ipaq_egpio = EGPIO_INIT;
     97   1.5    ichiro         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
     98   1.6    ichiro 
     99   1.6    ichiro 	/* Map the SSP registers */
    100   1.6    ichiro 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
    101  1.11    provos 		panic("%s: unable to map SSP registers",
    102  1.22       rjs 			device_xname(self));
    103   1.1    ichiro 
    104   1.1    ichiro 	sc->sc_ppch = psc->sc_ppch;
    105   1.1    ichiro 	sc->sc_dmach = psc->sc_dmach;
    106   1.1    ichiro 
    107   1.1    ichiro 	/*
    108   1.1    ichiro 	 *  Attach each devices
    109   1.1    ichiro 	 */
    110  1.15  drochner 	config_search_ia(ipaq_search, self, "ipaqbus", NULL);
    111   1.1    ichiro }
    112   1.1    ichiro 
    113   1.1    ichiro int
    114  1.22       rjs ipaq_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    115   1.1    ichiro {
    116  1.10   thorpej 	if (config_match(parent, cf, NULL) > 0)
    117   1.1    ichiro 		config_attach(parent, cf, NULL, ipaq_print);
    118   1.1    ichiro 
    119   1.1    ichiro         return 0;
    120   1.1    ichiro }
    121