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