xref: /netbsd-src/sys/arch/arm/xscale/i80321_aau.c (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: i80321_aau.c,v 1.9 2003/04/29 01:07:31 thorpej 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 2003/04/29 01:07:31 thorpej Exp $");
44 
45 #include <sys/param.h>
46 #include <sys/pool.h>
47 #include <sys/lock.h>
48 #include <sys/systm.h>
49 #include <sys/device.h>
50 #include <sys/uio.h>
51 
52 #include <uvm/uvm.h>
53 
54 #include <machine/bus.h>
55 #include <machine/intr.h>
56 
57 #include <arm/xscale/i80321reg.h>
58 #include <arm/xscale/i80321var.h>
59 
60 #include <arm/xscale/iopaaureg.h>
61 #include <arm/xscale/iopaauvar.h>
62 
63 struct aau321_softc {
64 	/* Shared AAU definitions. */
65 	struct iopaau_softc sc_iopaau;
66 
67 	/* i80321-specific stuff. */
68 	void *sc_error_ih;
69 	void *sc_eoc_ih;
70 	void *sc_eot_ih;
71 };
72 
73 static struct iopaau_function aau321_func_zero = {
74 	iopaau_func_zero_setup,
75 	&iopaau_desc_4_cache,
76 };
77 
78 static struct iopaau_function aau321_func_fill8 = {
79 	iopaau_func_fill8_setup,
80 	&iopaau_desc_4_cache,
81 };
82 
83 static struct iopaau_function aau321_func_xor_1_4 = {
84 	iopaau_func_xor_setup,
85 	&iopaau_desc_4_cache,
86 };
87 
88 static struct iopaau_function aau321_func_xor_5_8 = {
89 	iopaau_func_xor_setup,
90 	&iopaau_desc_8_cache,
91 };
92 
93 static const struct dmover_algdesc aau321_algdescs[] = {
94 	{
95 	  DMOVER_FUNC_ZERO,
96 	  &aau321_func_zero,
97 	  0
98 	},
99 	{
100 	  DMOVER_FUNC_FILL8,
101 	  &aau321_func_fill8,
102 	  0
103 	},
104 	{
105 	  DMOVER_FUNC_COPY,
106 	  &aau321_func_xor_1_4,
107 	  1
108 	},
109 	{
110 	  DMOVER_FUNC_XOR2,
111 	  &aau321_func_xor_1_4,
112 	  2
113 	},
114 	{
115 	  DMOVER_FUNC_XOR3,
116 	  &aau321_func_xor_1_4,
117 	  3
118 	},
119 	{
120 	  DMOVER_FUNC_XOR4,
121 	  &aau321_func_xor_1_4,
122 	  4
123 	},
124 	{
125 	  DMOVER_FUNC_XOR5,
126 	  &aau321_func_xor_5_8,
127 	  5
128 	},
129 	{
130 	  DMOVER_FUNC_XOR6,
131 	  &aau321_func_xor_5_8,
132 	  6
133 	},
134 	{
135 	  DMOVER_FUNC_XOR7,
136 	  &aau321_func_xor_5_8,
137 	  7
138 	},
139 	{
140 	  DMOVER_FUNC_XOR8,
141 	  &aau321_func_xor_5_8,
142 	  8
143 	},
144 };
145 #define	AAU321_ALGDESC_COUNT \
146 	(sizeof(aau321_algdescs) / sizeof(aau321_algdescs[0]))
147 
148 static int
149 aau321_match(struct device *parent, struct cfdata *match, void *aux)
150 {
151 	struct iopxs_attach_args *ia = aux;
152 
153 	if (strcmp(match->cf_name, ia->ia_name) == 0)
154 		return (1);
155 
156 	return (0);
157 }
158 
159 static void
160 aau321_attach(struct device *parent, struct device *self, void *aux)
161 {
162 	struct aau321_softc *sc321 = (void *) self;
163 	struct iopaau_softc *sc = &sc321->sc_iopaau;
164 	struct iopxs_attach_args *ia = aux;
165 	int error;
166 
167 	aprint_naive("\n");
168 	aprint_normal("\n");
169 
170 	sc->sc_st = ia->ia_st;
171 	error = bus_space_subregion(sc->sc_st, ia->ia_sh,
172 	    ia->ia_offset, ia->ia_size, &sc->sc_sh);
173 	if (error) {
174 		aprint_error("%s: unable to subregion registers, error = %d\n",
175 		    sc->sc_dev.dv_xname, error);
176 		return;
177 	}
178 
179 	sc->sc_dmat = ia->ia_dmat;
180 
181 	sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
182 	    iopaau_intr, sc);
183 	if (sc321->sc_error_ih == NULL) {
184 		aprint_error("%s: unable to register error interrupt handler\n",
185 		    sc->sc_dev.dv_xname);
186 		return;
187 	}
188 
189 	sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
190 	    iopaau_intr, sc);
191 	if (sc321->sc_eoc_ih == NULL) {
192 		aprint_error("%s: unable to register EOC interrupt handler\n",
193 		    sc->sc_dev.dv_xname);
194 		return;
195 	}
196 
197 	sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
198 	    iopaau_intr, sc);
199 	if (sc321->sc_eoc_ih == NULL) {
200 		aprint_error("%s: unable to register EOT interrupt handler\n",
201 		    sc->sc_dev.dv_xname);
202 		return;
203 	}
204 
205 	sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
206 	sc->sc_dmb.dmb_speed = 1638400;			/* XXX */
207 	sc->sc_dmb.dmb_cookie = sc;
208 	sc->sc_dmb.dmb_algdescs = aau321_algdescs;
209 	sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
210 	sc->sc_dmb.dmb_process = iopaau_process;
211 
212 	iopaau_attach(sc);
213 }
214 
215 CFATTACH_DECL(iopaau, sizeof(struct aau321_softc),
216     aau321_match, aau321_attach, NULL, NULL);
217