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