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