Home | History | Annotate | Line # | Download | only in dev
ipaq_saip.c revision 1.1
      1  1.1  ichiro /*	$NetBSD: ipaq_saip.c,v 1.1 2001/07/10 16:31:53 ichiro 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.1  ichiro  */
     25  1.1  ichiro #include <sys/param.h>
     26  1.1  ichiro #include <sys/systm.h>
     27  1.1  ichiro #include <sys/types.h>
     28  1.1  ichiro #include <sys/conf.h>
     29  1.1  ichiro #include <sys/device.h>
     30  1.1  ichiro #include <sys/kernel.h>
     31  1.1  ichiro #include <sys/malloc.h>
     32  1.1  ichiro #include <sys/uio.h>
     33  1.1  ichiro 
     34  1.1  ichiro #include <machine/cpu.h>
     35  1.1  ichiro #include <machine/bus.h>
     36  1.1  ichiro 
     37  1.1  ichiro #include <hpcarm/sa11x0/sa11x0_reg.h>
     38  1.1  ichiro #include <hpcarm/sa11x0/sa11x0_var.h>
     39  1.1  ichiro #include <hpcarm/sa11x0/sa11x0_dmacreg.h>
     40  1.1  ichiro #include <hpcarm/sa11x0/sa11x0_ppcreg.h>
     41  1.1  ichiro #include <hpcarm/sa11x0/sa11x0_gpioreg.h>
     42  1.1  ichiro 
     43  1.1  ichiro #include <hpcarm/dev/ipaq_gpioreg.h>
     44  1.1  ichiro 
     45  1.1  ichiro /* ipaq softc */
     46  1.1  ichiro struct ipaq_softc {
     47  1.1  ichiro 	struct device sc_dev;
     48  1.1  ichiro 	bus_space_tag_t sc_iot;
     49  1.1  ichiro 	bus_space_handle_t sc_ioh;
     50  1.1  ichiro 	bus_space_handle_t sc_gpioh;
     51  1.1  ichiro 	bus_space_handle_t sc_egpioh;
     52  1.1  ichiro 	bus_space_handle_t sc_ppch;
     53  1.1  ichiro 	bus_space_handle_t sc_dmach;
     54  1.1  ichiro 	u_int32_t sc_intrmask;
     55  1.1  ichiro };
     56  1.1  ichiro 
     57  1.1  ichiro /* prototypes */
     58  1.1  ichiro static int	ipaq_match(struct device *, struct cfdata *, void *);
     59  1.1  ichiro static void	ipaq_attach(struct device *, struct device *, void *);
     60  1.1  ichiro static int 	ipaq_search(struct device *, struct cfdata *, void *);
     61  1.1  ichiro static int	ipaq_print(void *, const char *);
     62  1.1  ichiro 
     63  1.1  ichiro /* attach structures */
     64  1.1  ichiro struct cfattach ipaqbus_ca = {
     65  1.1  ichiro 	sizeof(struct ipaq_softc), ipaq_match, ipaq_attach
     66  1.1  ichiro };
     67  1.1  ichiro 
     68  1.1  ichiro static int
     69  1.1  ichiro ipaq_print(aux, name)
     70  1.1  ichiro 	void *aux;
     71  1.1  ichiro 	const char *name;
     72  1.1  ichiro {
     73  1.1  ichiro         return (UNCONF);
     74  1.1  ichiro }
     75  1.1  ichiro 
     76  1.1  ichiro int
     77  1.1  ichiro ipaq_match(parent, match, aux)
     78  1.1  ichiro 	struct device *parent;
     79  1.1  ichiro 	struct cfdata *match;
     80  1.1  ichiro 	void *aux;
     81  1.1  ichiro {
     82  1.1  ichiro 	return 1;
     83  1.1  ichiro }
     84  1.1  ichiro 
     85  1.1  ichiro void
     86  1.1  ichiro ipaq_attach(parent, self, aux)
     87  1.1  ichiro 	struct device *parent;
     88  1.1  ichiro 	struct device *self;
     89  1.1  ichiro 	void *aux;
     90  1.1  ichiro {
     91  1.1  ichiro 	struct ipaq_softc *sc = (struct ipaq_softc*)self;
     92  1.1  ichiro 	struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
     93  1.1  ichiro 
     94  1.1  ichiro 	printf("\n");
     95  1.1  ichiro 
     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.1  ichiro 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
    100  1.1  ichiro 		panic("%s: unable to map Extended GPIO registers\n",
    101  1.1  ichiro 			self->dv_xname);
    102  1.1  ichiro # if 0
    103  1.1  ichiro         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, EGPIO_INIT);
    104  1.1  ichiro # endif
    105  1.1  ichiro 
    106  1.1  ichiro 	sc->sc_ppch = psc->sc_ppch;
    107  1.1  ichiro 	sc->sc_dmach = psc->sc_dmach;
    108  1.1  ichiro 
    109  1.1  ichiro 	/*
    110  1.1  ichiro 	 *  Attach each devices
    111  1.1  ichiro 	 */
    112  1.1  ichiro 	config_search(ipaq_search, self, NULL);
    113  1.1  ichiro }
    114  1.1  ichiro 
    115  1.1  ichiro int
    116  1.1  ichiro ipaq_search(parent, cf, aux)
    117  1.1  ichiro 	struct device *parent;
    118  1.1  ichiro 	struct cfdata *cf;
    119  1.1  ichiro 	void *aux;
    120  1.1  ichiro {
    121  1.1  ichiro 	if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0)
    122  1.1  ichiro 		config_attach(parent, cf, NULL, ipaq_print);
    123  1.1  ichiro 
    124  1.1  ichiro         return 0;
    125  1.1  ichiro }
    126