Home | History | Annotate | Line # | Download | only in dev
      1  1.26  thorpej /*	$NetBSD: ipaq_saip.c,v 1.26 2023/12/20 14:50:02 thorpej 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.26  thorpej __KERNEL_RCSID(0, "$NetBSD: ipaq_saip.c,v 1.26 2023/12/20 14:50:02 thorpej 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/uio.h>
     41  1.23   dyoung #include <sys/bus.h>
     42   1.1   ichiro 
     43   1.1   ichiro #include <machine/cpu.h>
     44   1.1   ichiro 
     45   1.9   ichiro #include <arm/sa11x0/sa11x0_var.h>
     46   1.9   ichiro #include <arm/sa11x0/sa11x0_reg.h>
     47   1.9   ichiro #include <arm/sa11x0/sa11x0_dmacreg.h>
     48   1.9   ichiro #include <arm/sa11x0/sa11x0_ppcreg.h>
     49   1.9   ichiro #include <arm/sa11x0/sa11x0_gpioreg.h>
     50   1.9   ichiro #include <arm/sa11x0/sa11x0_sspreg.h>
     51   1.9   ichiro 
     52   1.4   ichiro #include <hpcarm/dev/ipaq_saipvar.h>
     53   1.5   ichiro #include <hpcarm/dev/ipaq_gpioreg.h>
     54   1.1   ichiro 
     55   1.1   ichiro /* prototypes */
     56  1.22      rjs static int	ipaq_match(device_t, cfdata_t, void *);
     57  1.22      rjs static void	ipaq_attach(device_t, device_t, void *);
     58  1.22      rjs static int 	ipaq_search(device_t, cfdata_t, const int *, void *);
     59   1.1   ichiro static int	ipaq_print(void *, const char *);
     60   1.1   ichiro 
     61   1.1   ichiro /* attach structures */
     62  1.22      rjs CFATTACH_DECL_NEW(ipaqbus, sizeof(struct ipaq_softc),
     63  1.13  thorpej     ipaq_match, ipaq_attach, NULL, NULL);
     64   1.1   ichiro 
     65   1.1   ichiro static int
     66  1.19      rjs ipaq_print(void *aux, const char *name)
     67   1.1   ichiro {
     68   1.1   ichiro         return (UNCONF);
     69   1.1   ichiro }
     70   1.1   ichiro 
     71   1.1   ichiro int
     72  1.22      rjs ipaq_match(device_t parent, cfdata_t match, void *aux)
     73   1.1   ichiro {
     74   1.3   ichiro 	return (1);
     75   1.1   ichiro }
     76   1.1   ichiro 
     77   1.1   ichiro void
     78  1.22      rjs ipaq_attach(device_t parent, device_t self, void *aux)
     79   1.1   ichiro {
     80  1.22      rjs 	struct ipaq_softc *sc = device_private(self);
     81  1.22      rjs 	struct sa11x0_softc *psc = device_private(parent);
     82   1.1   ichiro 
     83  1.22      rjs 	aprint_normal("\n");
     84   1.1   ichiro 
     85  1.22      rjs 	sc->sc_dev = self;
     86   1.2   ichiro 	sc->sc_iot = psc->sc_iot;
     87   1.1   ichiro 	sc->sc_ioh = psc->sc_ioh;
     88   1.1   ichiro 	sc->sc_gpioh = psc->sc_gpioh;
     89   1.1   ichiro 
     90   1.3   ichiro 	/* Map the Extended GPIO registers */
     91   1.1   ichiro 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
     92  1.11   provos 		panic("%s: unable to map Extended GPIO registers",
     93  1.22      rjs 			device_xname(self));
     94   1.5   ichiro 
     95   1.5   ichiro 	sc->ipaq_egpio = EGPIO_INIT;
     96   1.5   ichiro         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
     97   1.6   ichiro 
     98   1.6   ichiro 	/* Map the SSP registers */
     99   1.6   ichiro 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
    100  1.11   provos 		panic("%s: unable to map SSP registers",
    101  1.22      rjs 			device_xname(self));
    102   1.1   ichiro 
    103   1.1   ichiro 	sc->sc_ppch = psc->sc_ppch;
    104   1.1   ichiro 	sc->sc_dmach = psc->sc_dmach;
    105   1.1   ichiro 
    106   1.1   ichiro 	/*
    107   1.1   ichiro 	 *  Attach each devices
    108   1.1   ichiro 	 */
    109  1.24  thorpej 	config_search(self, NULL,
    110  1.25  thorpej 	    CFARGS(.search = ipaq_search));
    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.24  thorpej 	if (config_probe(parent, cf, NULL))
    117  1.25  thorpej 		config_attach(parent, cf, NULL, ipaq_print, CFARGS_NONE);
    118   1.1   ichiro 
    119   1.1   ichiro         return 0;
    120   1.1   ichiro }
    121