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