sun4i_spi.c revision 1.5 1 1.5 bouyer /* $NetBSD: sun4i_spi.c,v 1.5 2019/09/11 15:03:52 bouyer Exp $ */
2 1.1 tnn
3 1.1 tnn /*
4 1.1 tnn * Copyright (c) 2019 Tobias Nygren
5 1.1 tnn * Copyright (c) 2018 Jonathan A. Kollasch
6 1.1 tnn * All rights reserved.
7 1.1 tnn *
8 1.1 tnn * Redistribution and use in source and binary forms, with or without
9 1.1 tnn * modification, are permitted provided that the following conditions
10 1.1 tnn * are met:
11 1.1 tnn * 1. Redistributions of source code must retain the above copyright
12 1.1 tnn * notice, this list of conditions and the following disclaimer.
13 1.1 tnn * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 tnn * notice, this list of conditions and the following disclaimer in the
15 1.1 tnn * documentation and/or other materials provided with the distribution.
16 1.1 tnn *
17 1.1 tnn * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 1.1 tnn * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1 tnn * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1 tnn * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21 1.1 tnn * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 1.1 tnn * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 1.1 tnn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 1.1 tnn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 1.1 tnn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 1.1 tnn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 1.1 tnn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 tnn */
29 1.1 tnn
30 1.1 tnn #include <sys/cdefs.h>
31 1.5 bouyer __KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.5 2019/09/11 15:03:52 bouyer Exp $");
32 1.1 tnn
33 1.1 tnn #include <sys/param.h>
34 1.1 tnn #include <sys/device.h>
35 1.1 tnn #include <sys/systm.h>
36 1.1 tnn #include <sys/bus.h>
37 1.1 tnn #include <sys/intr.h>
38 1.1 tnn #include <sys/kernel.h>
39 1.1 tnn #include <sys/bitops.h>
40 1.1 tnn #include <dev/spi/spivar.h>
41 1.1 tnn #include <arm/sunxi/sun4i_spireg.h>
42 1.1 tnn #include <dev/fdt/fdtvar.h>
43 1.1 tnn
44 1.1 tnn static const char * const compatible[] = {
45 1.1 tnn "allwinner,sun4i-a10-spi",
46 1.1 tnn NULL
47 1.1 tnn };
48 1.1 tnn
49 1.1 tnn struct sun4ispi_softc {
50 1.1 tnn device_t sc_dev;
51 1.1 tnn bus_space_tag_t sc_bst;
52 1.1 tnn bus_space_handle_t sc_bsh;
53 1.1 tnn void *sc_intrh;
54 1.1 tnn struct spi_controller sc_spi;
55 1.1 tnn SIMPLEQ_HEAD(,spi_transfer) sc_q;
56 1.1 tnn struct spi_transfer *sc_transfer;
57 1.1 tnn struct spi_chunk *sc_rchunk, *sc_wchunk;
58 1.1 tnn uint32_t sc_CTL;
59 1.1 tnn u_int sc_modclkrate;
60 1.1 tnn volatile bool sc_running;
61 1.1 tnn };
62 1.1 tnn
63 1.1 tnn #define SPIREG_READ(sc, reg) \
64 1.1 tnn bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
65 1.1 tnn #define SPIREG_WRITE(sc, reg, val) \
66 1.1 tnn bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
67 1.1 tnn
68 1.5 bouyer static struct spi_controller * sun4i_spi_get_controller(device_t);
69 1.1 tnn static int sun4ispi_match(device_t, cfdata_t, void *);
70 1.1 tnn static void sun4ispi_attach(device_t, device_t, void *);
71 1.1 tnn
72 1.1 tnn static int sun4ispi_configure(void *, int, int, int);
73 1.1 tnn static int sun4ispi_transfer(void *, struct spi_transfer *);
74 1.1 tnn
75 1.1 tnn static void sun4ispi_txfifo_fill(struct sun4ispi_softc * const, size_t);
76 1.1 tnn static void sun4ispi_rxfifo_drain(struct sun4ispi_softc * const, size_t);
77 1.2 tnn static void sun4ispi_rxtx(struct sun4ispi_softc * const);
78 1.1 tnn static void sun4ispi_set_interrupt_mask(struct sun4ispi_softc * const);
79 1.1 tnn static void sun4ispi_start(struct sun4ispi_softc * const);
80 1.1 tnn static int sun4ispi_intr(void *);
81 1.1 tnn
82 1.1 tnn CFATTACH_DECL_NEW(sun4i_spi, sizeof(struct sun4ispi_softc),
83 1.1 tnn sun4ispi_match, sun4ispi_attach, NULL, NULL);
84 1.1 tnn
85 1.5 bouyer static const struct fdtbus_spi_controller_func sun4i_spi_funcs = {
86 1.5 bouyer .get_controller = sun4i_spi_get_controller
87 1.5 bouyer };
88 1.5 bouyer
89 1.5 bouyer static struct spi_controller *
90 1.5 bouyer sun4i_spi_get_controller(device_t dev)
91 1.5 bouyer {
92 1.5 bouyer struct sun4ispi_softc * const sc = device_private(dev);
93 1.5 bouyer
94 1.5 bouyer return &sc->sc_spi;
95 1.5 bouyer }
96 1.5 bouyer
97 1.1 tnn static int
98 1.1 tnn sun4ispi_match(device_t parent, cfdata_t cf, void *aux)
99 1.1 tnn {
100 1.1 tnn struct fdt_attach_args * const faa = aux;
101 1.1 tnn
102 1.1 tnn return of_match_compatible(faa->faa_phandle, compatible);
103 1.1 tnn }
104 1.1 tnn
105 1.1 tnn static void
106 1.1 tnn sun4ispi_attach(device_t parent, device_t self, void *aux)
107 1.1 tnn {
108 1.1 tnn struct sun4ispi_softc * const sc = device_private(self);
109 1.1 tnn struct fdt_attach_args * const faa = aux;
110 1.1 tnn const int phandle = faa->faa_phandle;
111 1.1 tnn bus_addr_t addr;
112 1.1 tnn bus_size_t size;
113 1.1 tnn struct clk *clk, *modclk;
114 1.1 tnn char intrstr[128];
115 1.1 tnn
116 1.1 tnn sc->sc_dev = self;
117 1.1 tnn sc->sc_bst = faa->faa_bst;
118 1.1 tnn SIMPLEQ_INIT(&sc->sc_q);
119 1.1 tnn
120 1.1 tnn if ((clk = fdtbus_clock_get_index(phandle, 0)) == NULL
121 1.1 tnn || clk_enable(clk) != 0) {
122 1.1 tnn aprint_error(": couldn't enable clock\n");
123 1.1 tnn return;
124 1.1 tnn }
125 1.1 tnn
126 1.1 tnn if ((modclk = fdtbus_clock_get(phandle, "mod")) == NULL
127 1.1 tnn || clk_set_rate(modclk, clk_get_rate(clk)) != 0
128 1.1 tnn || clk_enable(modclk) != 0) {
129 1.1 tnn aprint_error(": couldn't enable module clock\n");
130 1.1 tnn return;
131 1.1 tnn }
132 1.1 tnn sc->sc_modclkrate = clk_get_rate(modclk);
133 1.1 tnn
134 1.1 tnn if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0
135 1.1 tnn || bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) {
136 1.1 tnn aprint_error(": couldn't map registers\n");
137 1.1 tnn return;
138 1.1 tnn }
139 1.1 tnn
140 1.1 tnn SPIREG_WRITE(sc, SPI_CTL, SPI_CTL_SSPOL | SPI_CTL_RF_RST
141 1.1 tnn | SPI_CTL_TF_RST | SPI_CTL_MODE);
142 1.1 tnn SPIREG_WRITE(sc, SPI_DMACTL, 0);
143 1.1 tnn SPIREG_WRITE(sc, SPI_WAIT, 0);
144 1.1 tnn SPIREG_WRITE(sc, SPI_INTCTL, 0);
145 1.1 tnn SPIREG_WRITE(sc, SPI_INT_STA, ~0);
146 1.1 tnn
147 1.1 tnn if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
148 1.1 tnn aprint_error(": failed to decode interrupt\n");
149 1.1 tnn return;
150 1.1 tnn }
151 1.1 tnn
152 1.1 tnn sc->sc_intrh = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, sun4ispi_intr, sc);
153 1.1 tnn if (sc->sc_intrh == NULL) {
154 1.2 tnn aprint_error(": unable to establish interrupt\n");
155 1.1 tnn return;
156 1.1 tnn }
157 1.1 tnn
158 1.1 tnn aprint_naive("\n");
159 1.1 tnn aprint_normal(": SPI\n");
160 1.1 tnn aprint_normal_dev(self, "interrupting on %s\n", intrstr);
161 1.1 tnn
162 1.1 tnn sc->sc_spi.sct_cookie = sc;
163 1.1 tnn sc->sc_spi.sct_configure = sun4ispi_configure;
164 1.1 tnn sc->sc_spi.sct_transfer = sun4ispi_transfer;
165 1.1 tnn (void) of_getprop_uint32(phandle, "num-cs", &sc->sc_spi.sct_nslaves);
166 1.5 bouyer fdtbus_register_spi_controller(self, phandle, &sun4i_spi_funcs);
167 1.5 bouyer (void) fdtbus_attach_spibus(self, phandle, spibus_print);
168 1.1 tnn }
169 1.1 tnn
170 1.1 tnn static int
171 1.1 tnn sun4ispi_configure(void *cookie, int slave, int mode, int speed)
172 1.1 tnn {
173 1.1 tnn struct sun4ispi_softc * const sc = cookie;
174 1.1 tnn uint32_t ctl, cctl;
175 1.1 tnn uint32_t minfreq, maxfreq;
176 1.1 tnn
177 1.1 tnn minfreq = sc->sc_modclkrate >> 16;
178 1.1 tnn maxfreq = sc->sc_modclkrate >> 1;
179 1.1 tnn
180 1.1 tnn if (speed <= 0 || speed < minfreq || speed > maxfreq)
181 1.1 tnn return EINVAL;
182 1.1 tnn
183 1.1 tnn if (slave >= sc->sc_spi.sct_nslaves)
184 1.1 tnn return EINVAL;
185 1.1 tnn
186 1.1 tnn ctl = SPI_CTL_SDM | SPI_CTL_TP_EN | SPI_CTL_SSPOL | SPI_CTL_MODE | SPI_CTL_EN;
187 1.1 tnn
188 1.1 tnn switch (mode) {
189 1.1 tnn case SPI_MODE_0:
190 1.1 tnn ctl |= 0;
191 1.1 tnn break;
192 1.1 tnn case SPI_MODE_1:
193 1.1 tnn ctl |= SPI_CTL_PHA;
194 1.1 tnn break;
195 1.1 tnn case SPI_MODE_2:
196 1.1 tnn ctl |= SPI_CTL_POL;
197 1.1 tnn break;
198 1.1 tnn case SPI_MODE_3:
199 1.1 tnn ctl |= SPI_CTL_PHA | SPI_CTL_POL;
200 1.1 tnn break;
201 1.1 tnn default:
202 1.1 tnn return EINVAL;
203 1.1 tnn }
204 1.1 tnn
205 1.1 tnn if (speed < sc->sc_modclkrate / 512) {
206 1.1 tnn for (cctl = 0; cctl <= __SHIFTOUT_MASK(SPI_CCTL_CDR1); cctl++) {
207 1.1 tnn if ((sc->sc_modclkrate / (1 << cctl)) <= speed)
208 1.1 tnn goto cdr1_found;
209 1.1 tnn }
210 1.1 tnn return EINVAL;
211 1.1 tnn cdr1_found:
212 1.1 tnn cctl = __SHIFTIN(cctl, SPI_CCTL_CDR1);
213 1.1 tnn } else {
214 1.1 tnn cctl = howmany(sc->sc_modclkrate, 2 * speed) - 1;
215 1.1 tnn cctl = SPI_CCTL_DRS|__SHIFTIN(cctl, SPI_CCTL_CDR2);
216 1.1 tnn }
217 1.1 tnn
218 1.1 tnn device_printf(sc->sc_dev, "ctl 0x%x, cctl 0x%x, CLK %uHz, SCLK %uHz\n",
219 1.1 tnn ctl, cctl, sc->sc_modclkrate,
220 1.1 tnn (cctl & SPI_CCTL_DRS)
221 1.1 tnn ? (sc->sc_modclkrate / (u_int)(2 * (__SHIFTOUT(cctl, SPI_CCTL_CDR2) + 1)))
222 1.1 tnn : (sc->sc_modclkrate >> (__SHIFTOUT(cctl, SPI_CCTL_CDR1) + 1))
223 1.1 tnn );
224 1.1 tnn
225 1.1 tnn sc->sc_CTL = ctl;
226 1.1 tnn SPIREG_WRITE(sc, SPI_CTL, (ctl | SPI_CTL_RF_RST | SPI_CTL_TF_RST) & ~SPI_CTL_EN);
227 1.1 tnn SPIREG_WRITE(sc, SPI_CCTL, cctl);
228 1.1 tnn SPIREG_WRITE(sc, SPI_CTL, ctl);
229 1.1 tnn
230 1.1 tnn return 0;
231 1.1 tnn }
232 1.1 tnn
233 1.1 tnn static int
234 1.1 tnn sun4ispi_transfer(void *cookie, struct spi_transfer *st)
235 1.1 tnn {
236 1.1 tnn struct sun4ispi_softc * const sc = cookie;
237 1.1 tnn int s;
238 1.1 tnn
239 1.1 tnn s = splbio();
240 1.1 tnn spi_transq_enqueue(&sc->sc_q, st);
241 1.1 tnn if (sc->sc_running == false) {
242 1.1 tnn sun4ispi_start(sc);
243 1.1 tnn }
244 1.1 tnn splx(s);
245 1.1 tnn
246 1.1 tnn return 0;
247 1.1 tnn }
248 1.1 tnn
249 1.1 tnn static void
250 1.1 tnn sun4ispi_txfifo_fill(struct sun4ispi_softc * const sc, size_t maxlen)
251 1.1 tnn {
252 1.1 tnn struct spi_chunk *chunk = sc->sc_wchunk;
253 1.1 tnn size_t len;
254 1.1 tnn uint8_t b;
255 1.1 tnn
256 1.1 tnn if (chunk == NULL)
257 1.1 tnn return;
258 1.1 tnn
259 1.1 tnn len = MIN(maxlen, chunk->chunk_wresid);
260 1.1 tnn chunk->chunk_wresid -= len;
261 1.1 tnn while (len--) {
262 1.1 tnn if (chunk->chunk_wptr) {
263 1.1 tnn b = *chunk->chunk_wptr++;
264 1.1 tnn } else {
265 1.1 tnn b = 0;
266 1.1 tnn }
267 1.1 tnn bus_space_write_1(sc->sc_bst, sc->sc_bsh, SPI_TXDATA, b);
268 1.1 tnn }
269 1.1 tnn if (sc->sc_wchunk->chunk_wresid == 0) {
270 1.1 tnn sc->sc_wchunk = sc->sc_wchunk->chunk_next;
271 1.1 tnn }
272 1.1 tnn }
273 1.1 tnn
274 1.1 tnn static void
275 1.1 tnn sun4ispi_rxfifo_drain(struct sun4ispi_softc * const sc, size_t maxlen)
276 1.1 tnn {
277 1.1 tnn struct spi_chunk *chunk = sc->sc_rchunk;
278 1.1 tnn size_t len;
279 1.1 tnn uint8_t b;
280 1.1 tnn
281 1.1 tnn if (chunk == NULL)
282 1.1 tnn return;
283 1.1 tnn
284 1.1 tnn len = MIN(maxlen, chunk->chunk_rresid);
285 1.1 tnn chunk->chunk_rresid -= len;
286 1.1 tnn
287 1.1 tnn while (len--) {
288 1.1 tnn b = bus_space_read_1(sc->sc_bst, sc->sc_bsh, SPI_RXDATA);
289 1.1 tnn if (chunk->chunk_rptr) {
290 1.1 tnn *chunk->chunk_rptr++ = b;
291 1.1 tnn }
292 1.1 tnn }
293 1.1 tnn if (sc->sc_rchunk->chunk_rresid == 0) {
294 1.1 tnn sc->sc_rchunk = sc->sc_rchunk->chunk_next;
295 1.1 tnn }
296 1.1 tnn }
297 1.1 tnn
298 1.1 tnn static void
299 1.1 tnn sun4ispi_rxtx(struct sun4ispi_softc * const sc)
300 1.1 tnn {
301 1.1 tnn bool again;
302 1.1 tnn size_t rxavail, txavail;
303 1.1 tnn uint32_t fsr;
304 1.1 tnn
305 1.1 tnn /* service both FIFOs until no more progress can be made */
306 1.1 tnn again = true;
307 1.1 tnn while (again) {
308 1.1 tnn again = false;
309 1.1 tnn fsr = SPIREG_READ(sc, SPI_FIFO_STA);
310 1.1 tnn rxavail = __SHIFTOUT(fsr, SPI_FIFO_STA_RF_CNT);
311 1.1 tnn txavail = 64 - __SHIFTOUT(fsr, SPI_FIFO_STA_TF_CNT);
312 1.1 tnn if (rxavail > 0) {
313 1.1 tnn KASSERT(sc->sc_rchunk != NULL);
314 1.1 tnn sun4ispi_rxfifo_drain(sc, rxavail);
315 1.1 tnn again = true;
316 1.1 tnn }
317 1.1 tnn if (txavail > 0 && sc->sc_wchunk != NULL) {
318 1.1 tnn sun4ispi_txfifo_fill(sc, txavail);
319 1.1 tnn again = true;
320 1.1 tnn }
321 1.1 tnn }
322 1.1 tnn }
323 1.1 tnn
324 1.1 tnn static void
325 1.1 tnn sun4ispi_set_interrupt_mask(struct sun4ispi_softc * const sc)
326 1.1 tnn {
327 1.1 tnn uint32_t intctl;
328 1.1 tnn
329 1.1 tnn intctl = SPI_INTCTL_TX_INT_EN;
330 1.1 tnn intctl |= SPI_INTCTL_RF_OF_INT_EN;
331 1.1 tnn intctl |= SPI_INTCTL_TF_UR_INT_EN;
332 1.1 tnn
333 1.1 tnn if (sc->sc_rchunk) {
334 1.1 tnn if (sc->sc_rchunk->chunk_rresid >= 32) {
335 1.1 tnn intctl |= SPI_INTCTL_RF_HALF_FU_INT_EN;
336 1.1 tnn } else {
337 1.1 tnn intctl |= SPI_INTCTL_RF_RDY_INT_EN;
338 1.1 tnn }
339 1.1 tnn }
340 1.1 tnn if (sc->sc_wchunk) {
341 1.1 tnn intctl |= SPI_INTCTL_TF_HALF_EMP_INT_EN;
342 1.1 tnn }
343 1.1 tnn SPIREG_WRITE(sc, SPI_INTCTL, intctl);
344 1.1 tnn }
345 1.1 tnn
346 1.1 tnn static void
347 1.1 tnn sun4ispi_start(struct sun4ispi_softc * const sc)
348 1.1 tnn {
349 1.1 tnn struct spi_transfer *st;
350 1.1 tnn uint32_t ctl;
351 1.1 tnn struct spi_chunk *chunk;
352 1.1 tnn size_t burstcount;
353 1.1 tnn
354 1.1 tnn while ((st = spi_transq_first(&sc->sc_q)) != NULL) {
355 1.1 tnn
356 1.1 tnn spi_transq_dequeue(&sc->sc_q);
357 1.1 tnn
358 1.1 tnn KASSERT(sc->sc_transfer == NULL);
359 1.1 tnn sc->sc_transfer = st;
360 1.1 tnn sc->sc_rchunk = sc->sc_wchunk = st->st_chunks;
361 1.1 tnn sc->sc_running = true;
362 1.1 tnn
363 1.1 tnn burstcount = 0;
364 1.1 tnn for (chunk = st->st_chunks; chunk; chunk = chunk->chunk_next) {
365 1.1 tnn burstcount += chunk->chunk_count;
366 1.1 tnn }
367 1.1 tnn KASSERT(burstcount <= SPI_BC_BC);
368 1.1 tnn SPIREG_WRITE(sc, SPI_BC, __SHIFTIN(burstcount, SPI_BC_BC));
369 1.1 tnn SPIREG_WRITE(sc, SPI_TC, __SHIFTIN(burstcount, SPI_TC_WTC));
370 1.1 tnn
371 1.1 tnn sun4ispi_rxtx(sc);
372 1.1 tnn sun4ispi_set_interrupt_mask(sc);
373 1.1 tnn
374 1.1 tnn KASSERT(st->st_slave < sc->sc_spi.sct_nslaves);
375 1.1 tnn ctl = sc->sc_CTL | __SHIFTIN(st->st_slave, SPI_CTL_SS) | SPI_CTL_XCH;
376 1.1 tnn SPIREG_WRITE(sc, SPI_CTL, ctl);
377 1.1 tnn
378 1.1 tnn if (!cold)
379 1.1 tnn return;
380 1.1 tnn
381 1.1 tnn for (;;) {
382 1.1 tnn (void) sun4ispi_intr(sc);
383 1.1 tnn if (ISSET(st->st_flags, SPI_F_DONE))
384 1.1 tnn break;
385 1.1 tnn }
386 1.1 tnn }
387 1.1 tnn sc->sc_running = false;
388 1.1 tnn }
389 1.1 tnn
390 1.1 tnn static int
391 1.1 tnn sun4ispi_intr(void *cookie)
392 1.1 tnn {
393 1.1 tnn struct sun4ispi_softc * const sc = cookie;
394 1.1 tnn struct spi_transfer *st;
395 1.1 tnn uint32_t isr;
396 1.1 tnn
397 1.1 tnn isr = SPIREG_READ(sc, SPI_INT_STA);
398 1.1 tnn if (!isr)
399 1.1 tnn return 0;
400 1.1 tnn
401 1.1 tnn if (ISSET(isr, SPI_INT_STA_RO)) {
402 1.1 tnn device_printf(sc->sc_dev, "RXFIFO overflow\n");
403 1.1 tnn }
404 1.1 tnn if (ISSET(isr, SPI_INT_STA_TU)) {
405 1.1 tnn device_printf(sc->sc_dev, "TXFIFO underrun\n");
406 1.1 tnn }
407 1.1 tnn
408 1.1 tnn sun4ispi_rxtx(sc);
409 1.1 tnn
410 1.1 tnn if (ISSET(isr, SPI_INT_STA_TC)) {
411 1.1 tnn SPIREG_WRITE(sc, SPI_INTCTL, 0);
412 1.1 tnn KASSERT(sc->sc_rchunk == NULL);
413 1.1 tnn KASSERT(sc->sc_wchunk == NULL);
414 1.1 tnn st = sc->sc_transfer;
415 1.1 tnn sc->sc_transfer = NULL;
416 1.1 tnn KASSERT(st != NULL);
417 1.1 tnn spi_done(st, 0);
418 1.1 tnn sc->sc_running = false;
419 1.1 tnn } else {
420 1.1 tnn sun4ispi_set_interrupt_mask(sc);
421 1.1 tnn }
422 1.1 tnn SPIREG_WRITE(sc, SPI_INT_STA, isr);
423 1.1 tnn
424 1.1 tnn return 1;
425 1.1 tnn }
426