ipaq_saip.c revision 1.13.6.2 1 /* $NetBSD: ipaq_saip.c,v 1.13.6.2 2004/09/18 14:34:51 skrll 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.13.6.2 2004/09/18 14:34:51 skrll 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 *, void *);
55 static int ipaq_print(void *, const char *);
56
57 /* attach structures */
58 CFATTACH_DECL(ipaqbus, sizeof(struct ipaq_softc),
59 ipaq_match, ipaq_attach, NULL, NULL);
60
61 static int
62 ipaq_print(aux, name)
63 void *aux;
64 const char *name;
65 {
66 return (UNCONF);
67 }
68
69 int
70 ipaq_match(parent, match, aux)
71 struct device *parent;
72 struct cfdata *match;
73 void *aux;
74 {
75 return (1);
76 }
77
78 void
79 ipaq_attach(parent, self, aux)
80 struct device *parent;
81 struct device *self;
82 void *aux;
83 {
84 struct ipaq_softc *sc = (struct ipaq_softc*)self;
85 struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
86
87 printf("\n");
88
89 sc->sc_iot = psc->sc_iot;
90 sc->sc_ioh = psc->sc_ioh;
91 sc->sc_gpioh = psc->sc_gpioh;
92
93 /* Map the Extended GPIO registers */
94 if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
95 panic("%s: unable to map Extended GPIO registers",
96 self->dv_xname);
97
98 sc->ipaq_egpio = EGPIO_INIT;
99 bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
100
101 /* Map the SSP registers */
102 if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
103 panic("%s: unable to map SSP registers",
104 self->dv_xname);
105
106 sc->sc_ppch = psc->sc_ppch;
107 sc->sc_dmach = psc->sc_dmach;
108
109 /*
110 * Attach each devices
111 */
112 config_search(ipaq_search, self, NULL);
113 }
114
115 int
116 ipaq_search(parent, cf, aux)
117 struct device *parent;
118 struct cfdata *cf;
119 void *aux;
120 {
121 if (config_match(parent, cf, NULL) > 0)
122 config_attach(parent, cf, NULL, ipaq_print);
123
124 return 0;
125 }
126