i80321_aau.c revision 1.9.18.2 1 /* $NetBSD: i80321_aau.c,v 1.9.18.2 2008/01/21 09:35:51 yamt Exp $ */
2
3 /*
4 * Copyright (c) 2002 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
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 for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * 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 WASABI SYSTEMS, INC
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 /*
39 * Intel i80321 I/O Processor application accelerator unit support.
40 */
41
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.9.18.2 2008/01/21 09:35:51 yamt Exp $");
44
45 #include <sys/param.h>
46 #include <sys/pool.h>
47 #include <sys/systm.h>
48 #include <sys/device.h>
49 #include <sys/uio.h>
50 #include <sys/bus.h>
51 #include <sys/intr.h>
52
53 #include <uvm/uvm.h>
54
55 #include <arm/xscale/i80321reg.h>
56 #include <arm/xscale/i80321var.h>
57
58 #include <arm/xscale/iopaaureg.h>
59 #include <arm/xscale/iopaauvar.h>
60
61 struct aau321_softc {
62 /* Shared AAU definitions. */
63 struct iopaau_softc sc_iopaau;
64
65 /* i80321-specific stuff. */
66 void *sc_error_ih;
67 void *sc_eoc_ih;
68 void *sc_eot_ih;
69 };
70
71 static struct iopaau_function aau321_func_zero = {
72 iopaau_func_zero_setup,
73 NULL,
74 };
75
76 static struct iopaau_function aau321_func_fill8 = {
77 iopaau_func_fill8_setup,
78 NULL,
79 };
80
81 static struct iopaau_function aau321_func_xor_1_4 = {
82 iopaau_func_xor_setup,
83 NULL,
84 };
85
86 static struct iopaau_function aau321_func_xor_5_8 = {
87 iopaau_func_xor_setup,
88 NULL,
89 };
90
91 static const struct dmover_algdesc aau321_algdescs[] = {
92 {
93 DMOVER_FUNC_ZERO,
94 &aau321_func_zero,
95 0
96 },
97 {
98 DMOVER_FUNC_FILL8,
99 &aau321_func_fill8,
100 0
101 },
102 {
103 DMOVER_FUNC_COPY,
104 &aau321_func_xor_1_4,
105 1
106 },
107 {
108 DMOVER_FUNC_XOR2,
109 &aau321_func_xor_1_4,
110 2
111 },
112 {
113 DMOVER_FUNC_XOR3,
114 &aau321_func_xor_1_4,
115 3
116 },
117 {
118 DMOVER_FUNC_XOR4,
119 &aau321_func_xor_1_4,
120 4
121 },
122 {
123 DMOVER_FUNC_XOR5,
124 &aau321_func_xor_5_8,
125 5
126 },
127 {
128 DMOVER_FUNC_XOR6,
129 &aau321_func_xor_5_8,
130 6
131 },
132 {
133 DMOVER_FUNC_XOR7,
134 &aau321_func_xor_5_8,
135 7
136 },
137 {
138 DMOVER_FUNC_XOR8,
139 &aau321_func_xor_5_8,
140 8
141 },
142 };
143 #define AAU321_ALGDESC_COUNT \
144 (sizeof(aau321_algdescs) / sizeof(aau321_algdescs[0]))
145
146 static int
147 aau321_match(struct device *parent, struct cfdata *match, void *aux)
148 {
149 struct iopxs_attach_args *ia = aux;
150
151 if (strcmp(match->cf_name, ia->ia_name) == 0)
152 return (1);
153
154 return (0);
155 }
156
157 static void
158 aau321_attach(struct device *parent, struct device *self, void *aux)
159 {
160 struct aau321_softc *sc321 = (void *) self;
161 struct iopaau_softc *sc = &sc321->sc_iopaau;
162 struct iopxs_attach_args *ia = aux;
163 int error;
164
165 aprint_naive("\n");
166 aprint_normal("\n");
167
168 sc->sc_st = ia->ia_st;
169 error = bus_space_subregion(sc->sc_st, ia->ia_sh,
170 ia->ia_offset, ia->ia_size, &sc->sc_sh);
171 if (error) {
172 aprint_error("%s: unable to subregion registers, error = %d\n",
173 sc->sc_dev.dv_xname, error);
174 return;
175 }
176
177 sc->sc_dmat = ia->ia_dmat;
178
179 sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
180 iopaau_intr, sc);
181 if (sc321->sc_error_ih == NULL) {
182 aprint_error("%s: unable to register error interrupt handler\n",
183 sc->sc_dev.dv_xname);
184 return;
185 }
186
187 sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
188 iopaau_intr, sc);
189 if (sc321->sc_eoc_ih == NULL) {
190 aprint_error("%s: unable to register EOC interrupt handler\n",
191 sc->sc_dev.dv_xname);
192 return;
193 }
194
195 sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
196 iopaau_intr, sc);
197 if (sc321->sc_eoc_ih == NULL) {
198 aprint_error("%s: unable to register EOT interrupt handler\n",
199 sc->sc_dev.dv_xname);
200 return;
201 }
202
203 sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
204 sc->sc_dmb.dmb_speed = 1638400; /* XXX */
205 sc->sc_dmb.dmb_cookie = sc;
206 sc->sc_dmb.dmb_algdescs = aau321_algdescs;
207 sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
208 sc->sc_dmb.dmb_process = iopaau_process;
209
210 iopaau_attach(sc);
211
212 aau321_func_zero.af_desc_cache = iopaau_desc_4_cache;
213 aau321_func_fill8.af_desc_cache = iopaau_desc_4_cache;
214 aau321_func_xor_1_4.af_desc_cache = iopaau_desc_4_cache;
215 aau321_func_xor_5_8.af_desc_cache = iopaau_desc_8_cache;
216 }
217
218 CFATTACH_DECL(iopaau, sizeof(struct aau321_softc),
219 aau321_match, aau321_attach, NULL, NULL);
220