1 /* $NetBSD: cec.c,v 1.11 2009/05/12 09:10:15 cegger Exp $ */
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: cec.c,v 1.11 2009/05/12 09:10:15 cegger Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/callout.h>
39 #include <sys/device.h>
40 #include <sys/kernel.h>
44 #include <dev/isa/isavar.h>
45 #include <dev/isa/isadmavar.h>
47 #include <dev/gpib/gpibvar.h>
49 #include <dev/ic/nec7210reg.h>
57 #define DPRINTF(flag, str) if (cecdebug & (flag)) printf str
58 #define DBG_FOLLOW 0x01
59 #define DBG_CONFIG 0x02
61 #define DBG_REPORTTIME 0x08
65 #define DPRINTF(flag, str) /* nothing */
71 struct device sc_dev
; /* generic device glue */
73 bus_space_tag_t sc_iot
;
74 bus_space_handle_t sc_ioh
;
75 isa_chipset_tag_t sc_ic
;
79 int sc_myaddr
; /* my address */
80 struct gpib_softc
*sc_gpib
;
82 volatile int sc_flags
;
84 #define CECF_PPOLL 0x4
86 #define CECF_TIMO 0x10
87 #define CECF_USEDMA 0x20
88 int sc_ppoll_slave
; /* XXX stash our ppoll address */
89 callout_t sc_timeout_ch
;
92 int cecprobe(device_t
, cfdata_t
, void *);
93 void cecattach(device_t
, device_t
, void *);
95 CFATTACH_DECL(cec
, sizeof(struct cec_softc
),
96 cecprobe
, cecattach
, NULL
, NULL
);
98 void cecreset(void *);
99 int cecpptest(void *, int);
100 void cecppwatch(void *, int);
101 void cecppclear(void *);
102 void cecxfer(void *, int, int, void *, int, int, int);
105 int cecsendcmds(void *, void *, int);
106 int cecsenddata(void *, void *, int);
107 int cecrecvdata(void *, void *, int);
109 int cectc(void *, int);
112 static int cecwait(struct cec_softc
*, int, int);
113 static void cectimeout(void *v
);
114 static int nec7210_setaddress(struct cec_softc
*, int, int);
115 static void nec7210_init(struct cec_softc
*);
116 static void nec7210_ifc(struct cec_softc
*);
119 * Our chipset structure.
121 struct gpib_chipset_tag cec_ic
= {
139 int cecwtimeout
= 0x10000;
140 int cecdmathresh
= 3;
143 cecprobe(device_t parent
, cfdata_t match
, void *aux
)
145 struct isa_attach_args
*ia
= aux
;
146 bus_space_tag_t iot
= ia
->ia_iot
;
147 bus_space_handle_t ioh
;
149 DPRINTF(DBG_CONFIG
, ("cecprobe: called\n"));
158 if (ISA_DIRECT_CONFIG(ia
))
161 if (ia
->ia_io
[0].ir_addr
== ISA_UNKNOWN_PORT
)
164 if (ia
->ia_ndrq
> 0 && ia
->ia_drq
[0].ir_drq
== ISA_UNKNOWN_DRQ
)
167 if (bus_space_map(iot
, ia
->ia_io
[0].ir_addr
, CEC_IOSIZE
, 0, &ioh
))
170 /* XXX insert probe here */
172 ia
->ia_io
[0].ir_size
= CEC_IOSIZE
;
175 bus_space_unmap(iot
, ioh
, CEC_IOSIZE
);
181 cecattach(device_t parent
, device_t self
, void *aux
)
183 struct cec_softc
*sc
= (struct cec_softc
*)self
;
184 struct isa_attach_args
*ia
= aux
;
185 struct gpibdev_attach_args ga
;
190 DPRINTF(DBG_CONFIG
, ("cecattach: called\n"));
192 sc
->sc_iot
= ia
->ia_iot
;
193 sc
->sc_ic
= ia
->ia_ic
;
195 if (bus_space_map(sc
->sc_iot
, ia
->ia_io
[0].ir_addr
, CEC_IOSIZE
,
196 0, &sc
->sc_ioh
) != 0) {
197 aprint_error_dev(&sc
->sc_dev
, "unable to map I/O space\n");
201 if (ia
->ia_ndrq
> 0) {
202 sc
->sc_flags
|= CECF_USEDMA
;
203 sc
->sc_drq
= ia
->ia_drq
[0].ir_drq
;
205 (void) isa_drq_alloc(sc
->sc_ic
, sc
->sc_drq
);
206 maxsize
= isa_dmamaxsize(sc
->sc_ic
, sc
->sc_drq
);
207 if (isa_dmamap_create(sc
->sc_ic
, sc
->sc_drq
,
208 maxsize
, BUS_DMA_NOWAIT
| BUS_DMA_ALLOCNOW
)) {
209 aprint_error_dev(&sc
->sc_dev
, "unable to create map for drq %d\n",
211 sc
->sc_flags
&= ~CECF_USEDMA
;
215 sc
->sc_myaddr
= 15; /* XXX */
218 (void) nec7210_setaddress(sc
, sc
->sc_myaddr
, -1);
220 sc
->sc_ih
= isa_intr_establish(ia
->ia_ic
, ia
->ia_irq
[0].ir_irq
,
221 IST_EDGE
, IPL_BIO
, cecintr
, sc
);
222 if (sc
->sc_ih
== NULL
) {
223 aprint_error_dev(&sc
->sc_dev
, "couldn't establish interrupt\n");
227 callout_init(&sc
->sc_timeout_ch
, 0);
229 /* attach MI GPIB bus */
230 cec_ic
.cookie
= (void *)sc
;
232 ga
.ga_address
= sc
->sc_myaddr
;
234 (struct gpib_softc
*)config_found(self
, &ga
, gpibdevprint
);
240 struct cec_softc
*sc
= v
;
241 bus_space_tag_t iot
= sc
->sc_iot
;
242 bus_space_handle_t ioh
= sc
->sc_ioh
;
243 u_int8_t stat1
, stat2
;
245 stat1
= bus_space_read_1(iot
, ioh
, NEC7210_ISR1
);
246 stat2
= bus_space_read_1(iot
, ioh
, NEC7210_ISR2
);
248 DPRINTF(DBG_INTR
, ("cecintr: sc=%p stat1=0x%x stat2=0x%x\n",
251 if (sc
->sc_flags
& CECF_IO
) {
253 if (sc
->sc_flags
& CECF_TIMO
)
254 callout_stop(&sc
->sc_timeout_ch
);
256 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, 0);
257 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, 0);
258 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_TCA
);
259 sc
->sc_flags
&= ~(CECF_IO
| CECF_READ
| CECF_TIMO
);
260 if (sc
->sc_flags
& CECF_USEDMA
)
261 isa_dmadone(sc
->sc_ic
, sc
->sc_drq
);
262 gpibintr(sc
->sc_gpib
);
264 } else if (sc
->sc_flags
& CECF_PPOLL
) {
266 if (cecpptest(sc
, sc
->sc_ppoll_slave
)) {
267 sc
->sc_flags
&= ~CECF_PPOLL
;
268 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, 0);
269 gpibintr(sc
->sc_gpib
);
279 struct cec_softc
*sc
= v
;
282 DPRINTF(DBG_FOLLOW
, ("cecreset: sc=%p\n", sc
));
286 /* we're now the system controller */
288 /* XXX should be pushed higher */
290 /* universal device clear */
292 (void) cecsendcmds(sc
, &cmd
, 1);
293 /* delay for devices to clear */
298 cecsendcmds(void *v
, void *ptr
, int origcnt
)
300 struct cec_softc
*sc
= v
;
301 bus_space_tag_t iot
= sc
->sc_iot
;
302 bus_space_handle_t ioh
= sc
->sc_ioh
;
304 u_int8_t
*addr
= ptr
;
306 DPRINTF(DBG_FOLLOW
, ("cecsendcmds: sc=%p, ptr=%p cnt=%d\n",
310 bus_space_write_1(iot
, ioh
, NEC7210_CDOR
, *addr
++);
311 if (cecwait(sc
, 0, ISR2_CO
))
312 return (origcnt
- cnt
- 1);
319 cecrecvdata(void *v
, void *ptr
, int origcnt
)
321 struct cec_softc
*sc
= v
;
322 bus_space_tag_t iot
= sc
->sc_iot
;
323 bus_space_handle_t ioh
= sc
->sc_ioh
;
325 u_int8_t
*addr
= ptr
;
327 DPRINTF(DBG_FOLLOW
, ("cecrecvdata: sc=%p, ptr=%p cnt=%d\n",
330 /* XXX holdoff on end */
331 bus_space_write_1(sc
->sc_iot
, sc
->sc_ioh
, NEC7210_AUXMR
, AUXCMD_RHDF
);
335 if (cecwait(sc
, ISR1_DI
, 0))
336 return (origcnt
- cnt
- 1);
337 *addr
++ = bus_space_read_1(iot
, ioh
, NEC7210_DIR
);
344 cecsenddata(void *v
, void *ptr
, int origcnt
)
346 struct cec_softc
*sc
= v
;
347 bus_space_tag_t iot
= sc
->sc_iot
;
348 bus_space_handle_t ioh
= sc
->sc_ioh
;
350 u_int8_t
*addr
= ptr
;
352 DPRINTF(DBG_FOLLOW
, ("cecdsenddata: sc=%p, ptr=%p cnt=%d\n",
357 bus_space_write_1(iot
, ioh
, NEC7210_CDOR
, *addr
++);
358 if (cecwait(sc
, ISR1_DO
, 0))
359 return (origcnt
- cnt
- 1);
361 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_SEOI
);
362 bus_space_write_1(iot
, ioh
, NEC7210_CDOR
, *addr
);
363 (void) cecwait(sc
, ISR1_DO
, 0);
369 cectc(void *v
, int sync
)
371 struct cec_softc
*sc
= v
;
372 bus_space_tag_t iot
= sc
->sc_iot
;
373 bus_space_handle_t ioh
= sc
->sc_ioh
;
375 int timo
= cecwtimeout
;
377 DPRINTF(DBG_FOLLOW
, ("cectc: sc=%p, sync=%d\n", sc
, sync
));
379 adsr
= bus_space_read_1(iot
, ioh
, NEC7210_ADSR
);
381 if ((adsr
& (ADSR_CIC
| ADSR_NATN
)) == ADSR_CIC
) {
382 DPRINTF(0xff, ("cectc: already CIC\n"));
388 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_RHDF
);
389 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_TCS
);
391 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_TCA
);
394 /* wait until ATN is asserted */
396 adsr
= bus_space_read_1(iot
, ioh
, NEC7210_ADSR
);
398 DPRINTF(DBG_REPORTTIME
, ("cectc: timeout\n"));
401 if ((adsr
& ADSR_NATN
) == 0)
412 struct cec_softc
*sc
= v
;
413 bus_space_tag_t iot
= sc
->sc_iot
;
414 bus_space_handle_t ioh
= sc
->sc_ioh
;
416 int timo
= cecwtimeout
;
418 DPRINTF(DBG_FOLLOW
, ("cecgts: sc=%p\n", sc
));
420 adsr
= bus_space_read_1(iot
, ioh
, NEC7210_ADSR
);
422 if ((adsr
& (ADSR_CIC
| ADSR_NATN
)) == ADSR_NATN
) {
423 DPRINTF(0xff, ("cecgts: already standby\n"));
428 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_GTS
);
430 /* wait unit ATN is released */
432 adsr
= bus_space_read_1(iot
, ioh
, NEC7210_ADSR
);
434 DPRINTF(DBG_REPORTTIME
, ("cecgts: timeout\n"));
437 if ((adsr
& ADSR_NATN
) == ADSR_NATN
)
446 cecpptest(void *v
, int slave
)
448 struct cec_softc
*sc
= v
;
449 bus_space_tag_t iot
= sc
->sc_iot
;
450 bus_space_handle_t ioh
= sc
->sc_ioh
;
453 DPRINTF(DBG_FOLLOW
, ("cecpptest: sc=%p slave=%d\n", sc
, slave
));
455 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_EPP
);
457 ppoll
= bus_space_read_1(iot
, ioh
, NEC7210_CPTR
);
458 DPRINTF(0xff, ("cecpptest: ppoll=%x\n", ppoll
));
459 return ((ppoll
& (0x80 >> slave
)) != 0);
463 cecppwatch(void *v
, int slave
)
465 struct cec_softc
*sc
= v
;
466 bus_space_tag_t iot
= sc
->sc_iot
;
467 bus_space_handle_t ioh
= sc
->sc_ioh
;
469 DPRINTF(DBG_FOLLOW
, ("cecppwatch: sc=%p\n", sc
));
471 sc
->sc_flags
|= CECF_PPOLL
;
472 sc
->sc_ppoll_slave
= slave
;
473 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, IMR2_CO
);
474 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_EPP
);
480 struct cec_softc
*sc
= v
;
482 DPRINTF(DBG_FOLLOW
, ("cecppclear: sc=%p\n", sc
));
484 sc
->sc_flags
&= ~CECF_PPOLL
;
485 bus_space_write_1(sc
->sc_iot
, sc
->sc_ioh
, NEC7210_IMR2
, 0);
489 cecxfer(void *v
, int slave
, int sec
, void *buf
, int count
, int dir
, int timo
)
491 struct cec_softc
*sc
= v
;
492 bus_space_tag_t iot
= sc
->sc_iot
;
493 bus_space_handle_t ioh
= sc
->sc_ioh
;
496 ("cecxfer: slave=%d sec=%d buf=%p count=%d dir=%x timo=%d\n",
497 slave
, sec
, buf
, count
, dir
, timo
));
499 sc
->sc_flags
|= CECF_IO
;
500 if (dir
== GPIB_READ
)
501 sc
->sc_flags
|= CECF_READ
;
503 sc
->sc_flags
|= CECF_TIMO
;
504 callout_reset(&sc
->sc_timeout_ch
, 5*hz
, cectimeout
, sc
);
507 if (sc
->sc_flags
& CECF_READ
) {
508 DPRINTF(DBG_FOLLOW
, ("cecxfer: DMA read request\n"));
509 if ((sc
->sc_flags
& CECF_USEDMA
) != 0) {
510 isa_dmastart(sc
->sc_ic
, sc
->sc_drq
, buf
, count
, NULL
,
511 DMAMODE_READ
| DMAMODE_DEMAND
, BUS_DMA_NOWAIT
);
512 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, IMR2_DMAI
);
513 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, IMR1_END
);
514 // XXX (void) cecrecv(sc, slave, sec, NULL, 0);
515 (void) gpibrecv(&cec_ic
, slave
, sec
, NULL
, 0);
517 /* XXX this doesn't work */
518 DPRINTF(DBG_FOLLOW
, ("cecxfer: polling instead\n"));
519 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, IMR1_END
);
520 // XXX (void) cecrecv(sc, slave, sec, buf, count);
521 (void) gpibrecv(&cec_ic
, slave
, sec
, buf
, count
);
522 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, IMR2_CO
);
525 DPRINTF(DBG_FOLLOW
, ("cecxfer: DMA write request\n"));
526 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, 0);
527 if (count
< cecdmathresh
||
528 (sc
->sc_flags
& CECF_USEDMA
) == 0) {
529 DPRINTF(DBG_FOLLOW
, ("cecxfer: polling instead\n"));
530 // XXX (void) cecsend(sc, slave, sec, buf, count);
531 (void) gpibsend(&cec_ic
, slave
, sec
, buf
, count
);
532 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, IMR2_CO
);
535 /* we send the last byte with EOI set */
536 isa_dmastart(sc
->sc_ic
, sc
->sc_drq
, buf
, count
-1, NULL
,
537 DMAMODE_WRITE
| DMAMODE_DEMAND
, BUS_DMA_NOWAIT
);
538 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, IMR2_DMAO
);
539 // XXX (void) cecsend(sc, slave, sec, NULL, 0);
540 (void) gpibsend(&cec_ic
, slave
, sec
, NULL
, 0);
541 while (!isa_dmafinished(sc
->sc_ic
, sc
->sc_drq
))
543 (void) cecwait(sc
, ISR1_DO
, 0);
544 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_SEOI
);
545 bus_space_write_1(iot
, ioh
, NEC7210_CDOR
, *(char *)buf
+count
);
546 /* generate interrupt */
547 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, IMR1_DO
);
554 struct cec_softc
*sc
= v
;
560 nec7210_setaddress(struct cec_softc
*sc
, int pri
, int sec
)
562 bus_space_tag_t iot
= sc
->sc_iot
;
563 bus_space_handle_t ioh
= sc
->sc_ioh
;
566 /* assign our primary address */
567 bus_space_write_1(iot
, ioh
, NEC7210_ADDR
, (pri
& ADDR_MASK
));
569 admr
= ADMR_TRM0
| ADMR_TRM1
;
571 /* assign our secondary address */
573 bus_space_write_1(iot
, ioh
, NEC7210_ADDR
,
574 (ADDR_ARS
| (sec
& ADDR_MASK
)));
577 /* disable secondary address */
578 bus_space_write_1(iot
, ioh
, NEC7210_ADDR
,
579 (ADDR_ARS
| ADDR_DT
| ADDR_DL
));
582 bus_space_write_1(iot
, ioh
, NEC7210_ADMR
, admr
);
588 nec7210_init(struct cec_softc
*sc
)
590 bus_space_tag_t iot
= sc
->sc_iot
;
591 bus_space_handle_t ioh
= sc
->sc_ioh
;
594 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_CRST
);
596 /* clear interrupts */
597 bus_space_read_1(iot
, ioh
, NEC7210_CPTR
);
598 bus_space_read_1(iot
, ioh
, NEC7210_ISR1
);
599 bus_space_read_1(iot
, ioh
, NEC7210_ISR2
);
601 /* initialise interrupts */
602 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, 0);
603 bus_space_write_1(iot
, ioh
, NEC7210_IMR2
, 0);
604 bus_space_write_1(iot
, ioh
, NEC7210_SPMR
, 0);
605 bus_space_write_1(iot
, ioh
, NEC7210_EOSR
, 0);
607 /* set internal clock to 8MHz */
608 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, (AUXMR_ICR
| 0x8));
609 /* parallel poll unconfigure */
610 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, (AUXMR_PPOLL
| PPOLL_PPU
));
612 /* assign our address */
613 bus_space_write_1(iot
, ioh
, NEC7210_ADDR
, 0);
614 /* disable secondary address */
615 bus_space_write_1(iot
, ioh
, NEC7210_ADDR
,
616 (ADDR_ARS
| ADDR_DT
| ADDR_DL
));
618 /* setup transceivers */
619 bus_space_write_1(iot
, ioh
, NEC7210_ADMR
,
620 (ADMR_ADM0
| ADMR_TRM0
| ADMR_TRM1
));
621 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
,
622 (AUXMR_REGA
| AUX_A_HSNORM
));
624 /* set INT pin to active high */
625 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXMR_REGB
);
626 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXMR_REGE
);
628 /* holdoff on end condition */
629 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, (AUXMR_REGA
| AUX_A_HLDE
));
631 /* reconnect to bus */
632 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, (AUXMR_CMD
| AUXCMD_IEPON
));
636 * Place all devices on the bus into quiescient state ready for
637 * remote programming.
638 * Obviously, we're the system controller upon exit.
641 nec7210_ifc(struct cec_softc
*sc
)
643 bus_space_tag_t iot
= sc
->sc_iot
;
644 bus_space_handle_t ioh
= sc
->sc_ioh
;
646 /*XXX*/ bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_TCA
);
647 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_CREN
);
648 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_SIFC
);
649 /* wait for devices to enter quiescient state */
651 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_CIFC
);
652 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_SREN
);
656 cecwait(struct cec_softc
*sc
, int x1
, int x2
)
658 int timo
= cecwtimeout
;
659 bus_space_tag_t iot
= sc
->sc_iot
;
660 bus_space_handle_t ioh
= sc
->sc_ioh
;
661 u_int8_t stat1
, stat2
;
663 DPRINTF(DBG_WAIT
, ("cecwait: sc=%p, x1=0x%x x2=0x%x\n", sc
, x1
, x2
));
666 stat1
= bus_space_read_1(iot
, ioh
, NEC7210_ISR1
);
667 stat2
= bus_space_read_1(iot
, ioh
, NEC7210_ISR2
);
669 if ((stat1
& ISR1_ERR
)) {
670 DPRINTF(DBG_WAIT
, ("cecwait: got ERR\n"));
675 DPRINTF(DBG_REPORTTIME
,
676 ("cecwait: timeout x1=0x%x x2=0x%x\n", x1
, x2
));
679 if ((stat1
& x1
) || (stat2
& x2
))
689 struct cec_softc
*sc
= v
;
690 bus_space_tag_t iot
= sc
->sc_iot
;
691 bus_space_handle_t ioh
= sc
->sc_ioh
;
694 DPRINTF(DBG_FOLLOW
, ("cectimeout: sc=%p\n", sc
));
697 if (sc
->sc_flags
& CECF_IO
) {
698 bus_space_write_1(iot
, ioh
, NEC7210_IMR1
, 0);
699 bus_space_write_2(iot
, ioh
, NEC7210_IMR2
, 0);
700 bus_space_write_1(iot
, ioh
, NEC7210_AUXMR
, AUXCMD_TCA
);
701 sc
->sc_flags
&= ~(CECF_IO
| CECF_READ
| CECF_TIMO
);
702 isa_dmaabort(sc
->sc_ic
, sc
->sc_drq
);
703 aprint_error_dev(&sc
->sc_dev
, "%s timeout\n",
704 sc
->sc_flags
& CECF_READ
? "read" : "write");
705 gpibintr(sc
->sc_gpib
);