Home | History | Annotate | Line # | Download | only in dev
ipaq_saip.c revision 1.8.8.3
      1  1.8.8.3  nathanw /*	$NetBSD: ipaq_saip.c,v 1.8.8.3 2002/10/18 02:37:00 nathanw Exp $	*/
      2  1.8.8.2  nathanw 
      3  1.8.8.2  nathanw /*-
      4  1.8.8.2  nathanw  * Copyright (c) 2001, The NetBSD Foundation, Inc.  All rights reserved.
      5  1.8.8.2  nathanw  *
      6  1.8.8.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      7  1.8.8.2  nathanw  * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
      8  1.8.8.2  nathanw  *
      9  1.8.8.2  nathanw  * Redistribution and use in source and binary forms, with or without
     10  1.8.8.2  nathanw  * modification, are permitted provided that the following conditions
     11  1.8.8.2  nathanw  * are met:
     12  1.8.8.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     13  1.8.8.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     14  1.8.8.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.8.8.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     16  1.8.8.2  nathanw  *    documentation and/or other materials provided with the distribution.
     17  1.8.8.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     18  1.8.8.2  nathanw  *    must display the following acknowledgement:
     19  1.8.8.2  nathanw  *      This product includes software developed by the NetBSD
     20  1.8.8.2  nathanw  *      Foundation, Inc. and its contributors.
     21  1.8.8.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  1.8.8.2  nathanw  *    contributors may be used to endorse or promote products derived
     23  1.8.8.2  nathanw  *    from this software without specific prior written permission.
     24  1.8.8.2  nathanw  */
     25  1.8.8.2  nathanw #include <sys/param.h>
     26  1.8.8.2  nathanw #include <sys/systm.h>
     27  1.8.8.2  nathanw #include <sys/types.h>
     28  1.8.8.2  nathanw #include <sys/conf.h>
     29  1.8.8.2  nathanw #include <sys/device.h>
     30  1.8.8.2  nathanw #include <sys/kernel.h>
     31  1.8.8.2  nathanw #include <sys/malloc.h>
     32  1.8.8.2  nathanw #include <sys/uio.h>
     33  1.8.8.2  nathanw 
     34  1.8.8.2  nathanw #include <machine/cpu.h>
     35  1.8.8.2  nathanw #include <machine/bus.h>
     36  1.8.8.2  nathanw 
     37  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_var.h>
     38  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_reg.h>
     39  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_dmacreg.h>
     40  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_ppcreg.h>
     41  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_gpioreg.h>
     42  1.8.8.2  nathanw #include <arm/sa11x0/sa11x0_sspreg.h>
     43  1.8.8.2  nathanw 
     44  1.8.8.2  nathanw #include <hpcarm/dev/ipaq_saipvar.h>
     45  1.8.8.2  nathanw #include <hpcarm/dev/ipaq_gpioreg.h>
     46  1.8.8.2  nathanw 
     47  1.8.8.2  nathanw /* prototypes */
     48  1.8.8.2  nathanw static int	ipaq_match(struct device *, struct cfdata *, void *);
     49  1.8.8.2  nathanw static void	ipaq_attach(struct device *, struct device *, void *);
     50  1.8.8.2  nathanw static int 	ipaq_search(struct device *, struct cfdata *, void *);
     51  1.8.8.2  nathanw static int	ipaq_print(void *, const char *);
     52  1.8.8.2  nathanw 
     53  1.8.8.2  nathanw /* attach structures */
     54  1.8.8.3  nathanw CFATTACH_DECL(ipaqbus, sizeof(struct ipaq_softc),
     55  1.8.8.3  nathanw     ipaq_match, ipaq_attach, NULL, NULL);
     56  1.8.8.2  nathanw 
     57  1.8.8.2  nathanw static int
     58  1.8.8.2  nathanw ipaq_print(aux, name)
     59  1.8.8.2  nathanw 	void *aux;
     60  1.8.8.2  nathanw 	const char *name;
     61  1.8.8.2  nathanw {
     62  1.8.8.2  nathanw         return (UNCONF);
     63  1.8.8.2  nathanw }
     64  1.8.8.2  nathanw 
     65  1.8.8.2  nathanw int
     66  1.8.8.2  nathanw ipaq_match(parent, match, aux)
     67  1.8.8.2  nathanw 	struct device *parent;
     68  1.8.8.2  nathanw 	struct cfdata *match;
     69  1.8.8.2  nathanw 	void *aux;
     70  1.8.8.2  nathanw {
     71  1.8.8.2  nathanw 	return (1);
     72  1.8.8.2  nathanw }
     73  1.8.8.2  nathanw 
     74  1.8.8.2  nathanw void
     75  1.8.8.2  nathanw ipaq_attach(parent, self, aux)
     76  1.8.8.2  nathanw 	struct device *parent;
     77  1.8.8.2  nathanw 	struct device *self;
     78  1.8.8.2  nathanw 	void *aux;
     79  1.8.8.2  nathanw {
     80  1.8.8.2  nathanw 	struct ipaq_softc *sc = (struct ipaq_softc*)self;
     81  1.8.8.2  nathanw 	struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
     82  1.8.8.2  nathanw 
     83  1.8.8.2  nathanw 	printf("\n");
     84  1.8.8.2  nathanw 
     85  1.8.8.2  nathanw 	sc->sc_iot = psc->sc_iot;
     86  1.8.8.2  nathanw 	sc->sc_ioh = psc->sc_ioh;
     87  1.8.8.2  nathanw 	sc->sc_gpioh = psc->sc_gpioh;
     88  1.8.8.2  nathanw 
     89  1.8.8.2  nathanw 	/* Map the Extended GPIO registers */
     90  1.8.8.2  nathanw 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
     91  1.8.8.3  nathanw 		panic("%s: unable to map Extended GPIO registers",
     92  1.8.8.2  nathanw 			self->dv_xname);
     93  1.8.8.2  nathanw 
     94  1.8.8.2  nathanw 	sc->ipaq_egpio = EGPIO_INIT;
     95  1.8.8.2  nathanw         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
     96  1.8.8.2  nathanw 
     97  1.8.8.2  nathanw 	/* Map the SSP registers */
     98  1.8.8.2  nathanw 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
     99  1.8.8.3  nathanw 		panic("%s: unable to map SSP registers",
    100  1.8.8.2  nathanw 			self->dv_xname);
    101  1.8.8.2  nathanw 
    102  1.8.8.2  nathanw 	sc->sc_ppch = psc->sc_ppch;
    103  1.8.8.2  nathanw 	sc->sc_dmach = psc->sc_dmach;
    104  1.8.8.2  nathanw 
    105  1.8.8.2  nathanw 	/*
    106  1.8.8.2  nathanw 	 *  Attach each devices
    107  1.8.8.2  nathanw 	 */
    108  1.8.8.2  nathanw 	config_search(ipaq_search, self, NULL);
    109  1.8.8.2  nathanw }
    110  1.8.8.2  nathanw 
    111  1.8.8.2  nathanw int
    112  1.8.8.2  nathanw ipaq_search(parent, cf, aux)
    113  1.8.8.2  nathanw 	struct device *parent;
    114  1.8.8.2  nathanw 	struct cfdata *cf;
    115  1.8.8.2  nathanw 	void *aux;
    116  1.8.8.2  nathanw {
    117  1.8.8.3  nathanw 	if (config_match(parent, cf, NULL) > 0)
    118  1.8.8.2  nathanw 		config_attach(parent, cf, NULL, ipaq_print);
    119  1.8.8.2  nathanw 
    120  1.8.8.2  nathanw         return 0;
    121  1.8.8.2  nathanw }
    122