i80321_aau.c revision 1.9.88.3 1 1.9.88.3 mjf /* $NetBSD: i80321_aau.c,v 1.9.88.3 2008/02/18 21:04:24 mjf Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 2002 Wasabi Systems, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.1 thorpej *
9 1.1 thorpej * Redistribution and use in source and binary forms, with or without
10 1.1 thorpej * modification, are permitted provided that the following conditions
11 1.1 thorpej * are met:
12 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.1 thorpej * notice, this list of conditions and the following disclaimer.
14 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.1 thorpej * documentation and/or other materials provided with the distribution.
17 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.1 thorpej * must display the following acknowledgement:
19 1.1 thorpej * This product includes software developed for the NetBSD Project by
20 1.1 thorpej * Wasabi Systems, Inc.
21 1.1 thorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1 thorpej * or promote products derived from this software without specific prior
23 1.1 thorpej * written permission.
24 1.1 thorpej *
25 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
36 1.1 thorpej */
37 1.1 thorpej
38 1.1 thorpej /*
39 1.1 thorpej * Intel i80321 I/O Processor application accelerator unit support.
40 1.1 thorpej */
41 1.1 thorpej
42 1.1 thorpej #include <sys/cdefs.h>
43 1.9.88.3 mjf __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.9.88.3 2008/02/18 21:04:24 mjf Exp $");
44 1.1 thorpej
45 1.1 thorpej #include <sys/param.h>
46 1.1 thorpej #include <sys/pool.h>
47 1.1 thorpej #include <sys/systm.h>
48 1.1 thorpej #include <sys/device.h>
49 1.1 thorpej #include <sys/uio.h>
50 1.9.88.3 mjf #include <sys/bus.h>
51 1.9.88.3 mjf #include <sys/intr.h>
52 1.1 thorpej
53 1.1 thorpej #include <uvm/uvm.h>
54 1.1 thorpej
55 1.1 thorpej #include <arm/xscale/i80321reg.h>
56 1.1 thorpej #include <arm/xscale/i80321var.h>
57 1.1 thorpej
58 1.1 thorpej #include <arm/xscale/iopaaureg.h>
59 1.1 thorpej #include <arm/xscale/iopaauvar.h>
60 1.1 thorpej
61 1.1 thorpej struct aau321_softc {
62 1.1 thorpej /* Shared AAU definitions. */
63 1.1 thorpej struct iopaau_softc sc_iopaau;
64 1.1 thorpej
65 1.1 thorpej /* i80321-specific stuff. */
66 1.1 thorpej void *sc_error_ih;
67 1.1 thorpej void *sc_eoc_ih;
68 1.1 thorpej void *sc_eot_ih;
69 1.1 thorpej };
70 1.1 thorpej
71 1.1 thorpej static struct iopaau_function aau321_func_zero = {
72 1.1 thorpej iopaau_func_zero_setup,
73 1.9.88.2 mjf NULL,
74 1.1 thorpej };
75 1.1 thorpej
76 1.1 thorpej static struct iopaau_function aau321_func_fill8 = {
77 1.1 thorpej iopaau_func_fill8_setup,
78 1.9.88.2 mjf NULL,
79 1.1 thorpej };
80 1.1 thorpej
81 1.3 thorpej static struct iopaau_function aau321_func_xor_1_4 = {
82 1.5 thorpej iopaau_func_xor_setup,
83 1.9.88.2 mjf NULL,
84 1.1 thorpej };
85 1.1 thorpej
86 1.5 thorpej static struct iopaau_function aau321_func_xor_5_8 = {
87 1.5 thorpej iopaau_func_xor_setup,
88 1.9.88.2 mjf NULL,
89 1.5 thorpej };
90 1.5 thorpej
91 1.1 thorpej static const struct dmover_algdesc aau321_algdescs[] = {
92 1.1 thorpej {
93 1.1 thorpej DMOVER_FUNC_ZERO,
94 1.1 thorpej &aau321_func_zero,
95 1.1 thorpej 0
96 1.1 thorpej },
97 1.1 thorpej {
98 1.1 thorpej DMOVER_FUNC_FILL8,
99 1.1 thorpej &aau321_func_fill8,
100 1.1 thorpej 0
101 1.1 thorpej },
102 1.1 thorpej {
103 1.1 thorpej DMOVER_FUNC_COPY,
104 1.3 thorpej &aau321_func_xor_1_4,
105 1.1 thorpej 1
106 1.3 thorpej },
107 1.3 thorpej {
108 1.3 thorpej DMOVER_FUNC_XOR2,
109 1.3 thorpej &aau321_func_xor_1_4,
110 1.3 thorpej 2
111 1.3 thorpej },
112 1.3 thorpej {
113 1.3 thorpej DMOVER_FUNC_XOR3,
114 1.3 thorpej &aau321_func_xor_1_4,
115 1.3 thorpej 3
116 1.3 thorpej },
117 1.3 thorpej {
118 1.3 thorpej DMOVER_FUNC_XOR4,
119 1.3 thorpej &aau321_func_xor_1_4,
120 1.3 thorpej 4
121 1.5 thorpej },
122 1.5 thorpej {
123 1.5 thorpej DMOVER_FUNC_XOR5,
124 1.5 thorpej &aau321_func_xor_5_8,
125 1.5 thorpej 5
126 1.5 thorpej },
127 1.5 thorpej {
128 1.5 thorpej DMOVER_FUNC_XOR6,
129 1.5 thorpej &aau321_func_xor_5_8,
130 1.5 thorpej 6
131 1.5 thorpej },
132 1.5 thorpej {
133 1.5 thorpej DMOVER_FUNC_XOR7,
134 1.5 thorpej &aau321_func_xor_5_8,
135 1.5 thorpej 7
136 1.5 thorpej },
137 1.5 thorpej {
138 1.5 thorpej DMOVER_FUNC_XOR8,
139 1.5 thorpej &aau321_func_xor_5_8,
140 1.5 thorpej 8
141 1.1 thorpej },
142 1.1 thorpej };
143 1.1 thorpej #define AAU321_ALGDESC_COUNT \
144 1.1 thorpej (sizeof(aau321_algdescs) / sizeof(aau321_algdescs[0]))
145 1.1 thorpej
146 1.1 thorpej static int
147 1.1 thorpej aau321_match(struct device *parent, struct cfdata *match, void *aux)
148 1.1 thorpej {
149 1.1 thorpej struct iopxs_attach_args *ia = aux;
150 1.1 thorpej
151 1.6 thorpej if (strcmp(match->cf_name, ia->ia_name) == 0)
152 1.1 thorpej return (1);
153 1.1 thorpej
154 1.1 thorpej return (0);
155 1.1 thorpej }
156 1.1 thorpej
157 1.1 thorpej static void
158 1.1 thorpej aau321_attach(struct device *parent, struct device *self, void *aux)
159 1.1 thorpej {
160 1.1 thorpej struct aau321_softc *sc321 = (void *) self;
161 1.1 thorpej struct iopaau_softc *sc = &sc321->sc_iopaau;
162 1.1 thorpej struct iopxs_attach_args *ia = aux;
163 1.1 thorpej int error;
164 1.1 thorpej
165 1.9 thorpej aprint_naive("\n");
166 1.9 thorpej aprint_normal("\n");
167 1.1 thorpej
168 1.1 thorpej sc->sc_st = ia->ia_st;
169 1.1 thorpej error = bus_space_subregion(sc->sc_st, ia->ia_sh,
170 1.1 thorpej ia->ia_offset, ia->ia_size, &sc->sc_sh);
171 1.1 thorpej if (error) {
172 1.9 thorpej aprint_error("%s: unable to subregion registers, error = %d\n",
173 1.1 thorpej sc->sc_dev.dv_xname, error);
174 1.1 thorpej return;
175 1.1 thorpej }
176 1.1 thorpej
177 1.1 thorpej sc->sc_dmat = ia->ia_dmat;
178 1.1 thorpej
179 1.1 thorpej sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
180 1.1 thorpej iopaau_intr, sc);
181 1.1 thorpej if (sc321->sc_error_ih == NULL) {
182 1.9 thorpej aprint_error("%s: unable to register error interrupt handler\n",
183 1.1 thorpej sc->sc_dev.dv_xname);
184 1.1 thorpej return;
185 1.1 thorpej }
186 1.1 thorpej
187 1.1 thorpej sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
188 1.1 thorpej iopaau_intr, sc);
189 1.1 thorpej if (sc321->sc_eoc_ih == NULL) {
190 1.9 thorpej aprint_error("%s: unable to register EOC interrupt handler\n",
191 1.1 thorpej sc->sc_dev.dv_xname);
192 1.1 thorpej return;
193 1.1 thorpej }
194 1.1 thorpej
195 1.1 thorpej sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
196 1.1 thorpej iopaau_intr, sc);
197 1.1 thorpej if (sc321->sc_eoc_ih == NULL) {
198 1.9 thorpej aprint_error("%s: unable to register EOT interrupt handler\n",
199 1.1 thorpej sc->sc_dev.dv_xname);
200 1.1 thorpej return;
201 1.1 thorpej }
202 1.1 thorpej
203 1.1 thorpej sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
204 1.1 thorpej sc->sc_dmb.dmb_speed = 1638400; /* XXX */
205 1.1 thorpej sc->sc_dmb.dmb_cookie = sc;
206 1.1 thorpej sc->sc_dmb.dmb_algdescs = aau321_algdescs;
207 1.1 thorpej sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
208 1.1 thorpej sc->sc_dmb.dmb_process = iopaau_process;
209 1.1 thorpej
210 1.1 thorpej iopaau_attach(sc);
211 1.9.88.2 mjf
212 1.9.88.2 mjf aau321_func_zero.af_desc_cache = iopaau_desc_4_cache;
213 1.9.88.2 mjf aau321_func_fill8.af_desc_cache = iopaau_desc_4_cache;
214 1.9.88.2 mjf aau321_func_xor_1_4.af_desc_cache = iopaau_desc_4_cache;
215 1.9.88.2 mjf aau321_func_xor_5_8.af_desc_cache = iopaau_desc_8_cache;
216 1.1 thorpej }
217 1.1 thorpej
218 1.8 thorpej CFATTACH_DECL(iopaau, sizeof(struct aau321_softc),
219 1.8 thorpej aau321_match, aau321_attach, NULL, NULL);
220