No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arm / xscale / i80321_aau.c
blobbe9fe00978ae88db73c79f42d4e24b8e0cfd5381
1 /* $NetBSD: i80321_aau.c,v 1.13 2008/04/27 18:58:45 matt Exp $ */
3 /*
4 * Copyright (c) 2002 Wasabi Systems, Inc.
5 * All rights reserved.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
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.
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.
39 * Intel i80321 I/O Processor application accelerator unit support.
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.13 2008/04/27 18:58:45 matt Exp $");
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>
53 #include <uvm/uvm.h>
55 #include <arm/xscale/i80321reg.h>
56 #include <arm/xscale/i80321var.h>
58 #include <arm/xscale/iopaaureg.h>
59 #include <arm/xscale/iopaauvar.h>
61 struct aau321_softc {
62 /* Shared AAU definitions. */
63 struct iopaau_softc sc_iopaau;
65 /* i80321-specific stuff. */
66 void *sc_error_ih;
67 void *sc_eoc_ih;
68 void *sc_eot_ih;
71 static struct iopaau_function aau321_func_zero = {
72 .af_setup = iopaau_func_zero_setup,
75 static struct iopaau_function aau321_func_fill8 = {
76 .af_setup = iopaau_func_fill8_setup,
79 static struct iopaau_function aau321_func_xor_1_4 = {
80 .af_setup = iopaau_func_xor_setup,
83 static struct iopaau_function aau321_func_xor_5_8 = {
84 .af_setup = iopaau_func_xor_setup,
87 static const struct dmover_algdesc aau321_algdescs[] = {
89 .dad_name = DMOVER_FUNC_ZERO,
90 .dad_data = &aau321_func_zero,
91 .dad_ninputs = 0
94 .dad_name = DMOVER_FUNC_FILL8,
95 .dad_data = &aau321_func_fill8,
96 .dad_ninputs = 0
99 .dad_name = DMOVER_FUNC_COPY,
100 .dad_data = &aau321_func_xor_1_4,
101 .dad_ninputs = 1
104 .dad_name = DMOVER_FUNC_XOR2,
105 .dad_data = &aau321_func_xor_1_4,
106 .dad_ninputs = 2
109 .dad_name = DMOVER_FUNC_XOR3,
110 .dad_data = &aau321_func_xor_1_4,
111 .dad_ninputs = 3
114 .dad_name = DMOVER_FUNC_XOR4,
115 .dad_data = &aau321_func_xor_1_4,
116 .dad_ninputs = 4
119 .dad_name = DMOVER_FUNC_XOR5,
120 .dad_data = &aau321_func_xor_5_8,
124 .dad_name = DMOVER_FUNC_XOR6,
125 .dad_data = &aau321_func_xor_5_8,
126 .dad_ninputs = 6
129 .dad_name = DMOVER_FUNC_XOR7,
130 .dad_data = &aau321_func_xor_5_8,
131 .dad_ninputs = 7
134 .dad_name = DMOVER_FUNC_XOR8,
135 .dad_data = &aau321_func_xor_5_8,
136 .dad_ninputs = 8
139 #define AAU321_ALGDESC_COUNT __arraycount(aau321_algdescs)
141 static int
142 aau321_match(struct device *parent, struct cfdata *match, void *aux)
144 struct iopxs_attach_args *ia = aux;
146 if (strcmp(match->cf_name, ia->ia_name) == 0)
147 return (1);
149 return (0);
152 static void
153 aau321_attach(struct device *parent, struct device *self, void *aux)
155 struct aau321_softc *sc321 = (void *) self;
156 struct iopaau_softc *sc = &sc321->sc_iopaau;
157 struct iopxs_attach_args *ia = aux;
158 int error;
160 aprint_naive("\n");
161 aprint_normal("\n");
163 sc->sc_st = ia->ia_st;
164 error = bus_space_subregion(sc->sc_st, ia->ia_sh,
165 ia->ia_offset, ia->ia_size, &sc->sc_sh);
166 if (error) {
167 aprint_error("%s: unable to subregion registers, error = %d\n",
168 sc->sc_dev.dv_xname, error);
169 return;
172 sc->sc_dmat = ia->ia_dmat;
174 sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
175 iopaau_intr, sc);
176 if (sc321->sc_error_ih == NULL) {
177 aprint_error("%s: unable to register error interrupt handler\n",
178 sc->sc_dev.dv_xname);
179 return;
182 sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
183 iopaau_intr, sc);
184 if (sc321->sc_eoc_ih == NULL) {
185 aprint_error("%s: unable to register EOC interrupt handler\n",
186 sc->sc_dev.dv_xname);
187 return;
190 sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
191 iopaau_intr, sc);
192 if (sc321->sc_eoc_ih == NULL) {
193 aprint_error("%s: unable to register EOT interrupt handler\n",
194 sc->sc_dev.dv_xname);
195 return;
198 sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
199 sc->sc_dmb.dmb_speed = 1638400; /* XXX */
200 sc->sc_dmb.dmb_cookie = sc;
201 sc->sc_dmb.dmb_algdescs = aau321_algdescs;
202 sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
203 sc->sc_dmb.dmb_process = iopaau_process;
205 iopaau_attach(sc);
208 * These must be initialized after iopaau_attach()
209 * because iopaau_desc_[48]_cache is set up there.
211 KASSERT(iopaau_desc_4_cache != NULL);
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;
216 KASSERT(iopaau_desc_8_cache != NULL);
217 aau321_func_xor_5_8.af_desc_cache = iopaau_desc_8_cache;
220 CFATTACH_DECL(iopaau, sizeof(struct aau321_softc),
221 aau321_match, aau321_attach, NULL, NULL);