ipaq_saip.c revision 1.22 1 /* $NetBSD: ipaq_saip.c,v 1.22 2009/05/29 14:15:45 rjs 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.22 2009/05/29 14:15:45 rjs 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(device_t, cfdata_t, void *);
58 static void ipaq_attach(device_t, device_t, void *);
59 static int ipaq_search(device_t, cfdata_t, const int *, void *);
60 static int ipaq_print(void *, const char *);
61
62 /* attach structures */
63 CFATTACH_DECL_NEW(ipaqbus, sizeof(struct ipaq_softc),
64 ipaq_match, ipaq_attach, NULL, NULL);
65
66 static int
67 ipaq_print(void *aux, const char *name)
68 {
69 return (UNCONF);
70 }
71
72 int
73 ipaq_match(device_t parent, cfdata_t match, void *aux)
74 {
75 return (1);
76 }
77
78 void
79 ipaq_attach(device_t parent, device_t self, void *aux)
80 {
81 struct ipaq_softc *sc = device_private(self);
82 struct sa11x0_softc *psc = device_private(parent);
83
84 aprint_normal("\n");
85
86 sc->sc_dev = self;
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 device_xname(self));
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 device_xname(self));
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(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
115 {
116 if (config_match(parent, cf, NULL) > 0)
117 config_attach(parent, cf, NULL, ipaq_print);
118
119 return 0;
120 }
121