i80321_aau.c revision 1.14.18.1 1 1.14.18.1 mrg /* $NetBSD: i80321_aau.c,v 1.14.18.1 2012/02/18 07:31:33 mrg 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.14.18.1 mrg __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.14.18.1 2012/02/18 07:31:33 mrg 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.12 ad #include <sys/bus.h>
51 1.12 ad #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.13 matt .af_setup = iopaau_func_zero_setup,
73 1.1 thorpej };
74 1.1 thorpej
75 1.1 thorpej static struct iopaau_function aau321_func_fill8 = {
76 1.13 matt .af_setup = iopaau_func_fill8_setup,
77 1.1 thorpej };
78 1.1 thorpej
79 1.3 thorpej static struct iopaau_function aau321_func_xor_1_4 = {
80 1.13 matt .af_setup = iopaau_func_xor_setup,
81 1.1 thorpej };
82 1.1 thorpej
83 1.5 thorpej static struct iopaau_function aau321_func_xor_5_8 = {
84 1.13 matt .af_setup = iopaau_func_xor_setup,
85 1.5 thorpej };
86 1.5 thorpej
87 1.1 thorpej static const struct dmover_algdesc aau321_algdescs[] = {
88 1.1 thorpej {
89 1.13 matt .dad_name = DMOVER_FUNC_ZERO,
90 1.13 matt .dad_data = &aau321_func_zero,
91 1.13 matt .dad_ninputs = 0
92 1.1 thorpej },
93 1.1 thorpej {
94 1.13 matt .dad_name = DMOVER_FUNC_FILL8,
95 1.13 matt .dad_data = &aau321_func_fill8,
96 1.13 matt .dad_ninputs = 0
97 1.1 thorpej },
98 1.1 thorpej {
99 1.13 matt .dad_name = DMOVER_FUNC_COPY,
100 1.13 matt .dad_data = &aau321_func_xor_1_4,
101 1.13 matt .dad_ninputs = 1
102 1.3 thorpej },
103 1.3 thorpej {
104 1.13 matt .dad_name = DMOVER_FUNC_XOR2,
105 1.13 matt .dad_data = &aau321_func_xor_1_4,
106 1.13 matt .dad_ninputs = 2
107 1.3 thorpej },
108 1.3 thorpej {
109 1.13 matt .dad_name = DMOVER_FUNC_XOR3,
110 1.13 matt .dad_data = &aau321_func_xor_1_4,
111 1.13 matt .dad_ninputs = 3
112 1.3 thorpej },
113 1.3 thorpej {
114 1.13 matt .dad_name = DMOVER_FUNC_XOR4,
115 1.13 matt .dad_data = &aau321_func_xor_1_4,
116 1.13 matt .dad_ninputs = 4
117 1.5 thorpej },
118 1.5 thorpej {
119 1.13 matt .dad_name = DMOVER_FUNC_XOR5,
120 1.13 matt .dad_data = &aau321_func_xor_5_8,
121 1.5 thorpej 5
122 1.5 thorpej },
123 1.5 thorpej {
124 1.13 matt .dad_name = DMOVER_FUNC_XOR6,
125 1.13 matt .dad_data = &aau321_func_xor_5_8,
126 1.13 matt .dad_ninputs = 6
127 1.5 thorpej },
128 1.5 thorpej {
129 1.13 matt .dad_name = DMOVER_FUNC_XOR7,
130 1.13 matt .dad_data = &aau321_func_xor_5_8,
131 1.13 matt .dad_ninputs = 7
132 1.5 thorpej },
133 1.5 thorpej {
134 1.13 matt .dad_name = DMOVER_FUNC_XOR8,
135 1.13 matt .dad_data = &aau321_func_xor_5_8,
136 1.13 matt .dad_ninputs = 8
137 1.1 thorpej },
138 1.1 thorpej };
139 1.13 matt #define AAU321_ALGDESC_COUNT __arraycount(aau321_algdescs)
140 1.1 thorpej
141 1.1 thorpej static int
142 1.14.18.1 mrg aau321_match(device_t parent, cfdata_t match, void *aux)
143 1.1 thorpej {
144 1.1 thorpej struct iopxs_attach_args *ia = aux;
145 1.1 thorpej
146 1.6 thorpej if (strcmp(match->cf_name, ia->ia_name) == 0)
147 1.1 thorpej return (1);
148 1.1 thorpej
149 1.1 thorpej return (0);
150 1.1 thorpej }
151 1.1 thorpej
152 1.1 thorpej static void
153 1.14.18.1 mrg aau321_attach(device_t parent, device_t self, void *aux)
154 1.1 thorpej {
155 1.14.18.1 mrg struct aau321_softc *sc321 = device_private(self);
156 1.1 thorpej struct iopaau_softc *sc = &sc321->sc_iopaau;
157 1.1 thorpej struct iopxs_attach_args *ia = aux;
158 1.14.18.1 mrg const char *xname = device_xname(self);
159 1.1 thorpej int error;
160 1.1 thorpej
161 1.9 thorpej aprint_naive("\n");
162 1.9 thorpej aprint_normal("\n");
163 1.1 thorpej
164 1.14.18.1 mrg sc->sc_dev = self;
165 1.1 thorpej sc->sc_st = ia->ia_st;
166 1.1 thorpej error = bus_space_subregion(sc->sc_st, ia->ia_sh,
167 1.1 thorpej ia->ia_offset, ia->ia_size, &sc->sc_sh);
168 1.1 thorpej if (error) {
169 1.9 thorpej aprint_error("%s: unable to subregion registers, error = %d\n",
170 1.14.18.1 mrg xname, error);
171 1.1 thorpej return;
172 1.1 thorpej }
173 1.1 thorpej
174 1.1 thorpej sc->sc_dmat = ia->ia_dmat;
175 1.1 thorpej
176 1.1 thorpej sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
177 1.1 thorpej iopaau_intr, sc);
178 1.1 thorpej if (sc321->sc_error_ih == NULL) {
179 1.9 thorpej aprint_error("%s: unable to register error interrupt handler\n",
180 1.14.18.1 mrg xname);
181 1.1 thorpej return;
182 1.1 thorpej }
183 1.1 thorpej
184 1.1 thorpej sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
185 1.1 thorpej iopaau_intr, sc);
186 1.1 thorpej if (sc321->sc_eoc_ih == NULL) {
187 1.9 thorpej aprint_error("%s: unable to register EOC interrupt handler\n",
188 1.14.18.1 mrg xname);
189 1.1 thorpej return;
190 1.1 thorpej }
191 1.1 thorpej
192 1.1 thorpej sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
193 1.1 thorpej iopaau_intr, sc);
194 1.1 thorpej if (sc321->sc_eoc_ih == NULL) {
195 1.9 thorpej aprint_error("%s: unable to register EOT interrupt handler\n",
196 1.14.18.1 mrg xname);
197 1.1 thorpej return;
198 1.1 thorpej }
199 1.1 thorpej
200 1.14.18.1 mrg sc->sc_dmb.dmb_name = xname;
201 1.1 thorpej sc->sc_dmb.dmb_speed = 1638400; /* XXX */
202 1.1 thorpej sc->sc_dmb.dmb_cookie = sc;
203 1.1 thorpej sc->sc_dmb.dmb_algdescs = aau321_algdescs;
204 1.1 thorpej sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
205 1.1 thorpej sc->sc_dmb.dmb_process = iopaau_process;
206 1.1 thorpej
207 1.1 thorpej iopaau_attach(sc);
208 1.11 ad
209 1.14 briggs /*
210 1.14 briggs * These must be initialized after iopaau_attach()
211 1.14 briggs * because iopaau_desc_[48]_cache is set up there.
212 1.14 briggs */
213 1.14 briggs KASSERT(iopaau_desc_4_cache != NULL);
214 1.11 ad aau321_func_zero.af_desc_cache = iopaau_desc_4_cache;
215 1.11 ad aau321_func_fill8.af_desc_cache = iopaau_desc_4_cache;
216 1.11 ad aau321_func_xor_1_4.af_desc_cache = iopaau_desc_4_cache;
217 1.14 briggs
218 1.14 briggs KASSERT(iopaau_desc_8_cache != NULL);
219 1.11 ad aau321_func_xor_5_8.af_desc_cache = iopaau_desc_8_cache;
220 1.1 thorpej }
221 1.1 thorpej
222 1.14.18.1 mrg CFATTACH_DECL_NEW(iopaau, sizeof(struct aau321_softc),
223 1.8 thorpej aau321_match, aau321_attach, NULL, NULL);
224