2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD
4 * Copyright (c) 2004 Scott Long
5 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 /* $NetBSD: esp_sbus.c,v 1.51 2009/09/17 16:28:12 tsutsui Exp $ */
34 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
35 * All rights reserved.
37 * This code is derived from software contributed to The NetBSD Foundation
38 * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
39 * Simulation Facility, NASA Ames Research Center; Paul Kranenburg.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
50 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
51 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
54 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60 * POSSIBILITY OF SUCH DAMAGE.
63 #include <sys/cdefs.h>
64 __FBSDID("$FreeBSD$");
66 #include <sys/param.h>
67 #include <sys/systm.h>
69 #include <sys/kernel.h>
71 #include <sys/module.h>
72 #include <sys/mutex.h>
75 #include <dev/ofw/ofw_bus.h>
76 #include <dev/ofw/openfirm.h>
77 #include <machine/bus.h>
78 #include <machine/ofw_machdep.h>
79 #include <machine/resource.h>
82 #include <cam/cam_ccb.h>
83 #include <cam/scsi/scsi_all.h>
84 #include <cam/scsi/scsi_message.h>
86 #include <sparc64/sbus/lsi64854reg.h>
87 #include <sparc64/sbus/lsi64854var.h>
88 #include <sparc64/sbus/sbusvar.h>
90 #include <dev/esp/ncr53c9xreg.h>
91 #include <dev/esp/ncr53c9xvar.h>
93 /* #define ESP_SBUS_DEBUG */
96 struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */
99 struct resource *sc_res;
101 struct resource *sc_irqres;
104 struct lsi64854_softc *sc_dma; /* pointer to my DMA */
107 static int esp_probe(device_t);
108 static int esp_dma_attach(device_t);
109 static int esp_dma_detach(device_t);
110 static int esp_sbus_attach(device_t);
111 static int esp_sbus_detach(device_t);
112 static int esp_suspend(device_t);
113 static int esp_resume(device_t);
115 static device_method_t esp_dma_methods[] = {
116 DEVMETHOD(device_probe, esp_probe),
117 DEVMETHOD(device_attach, esp_dma_attach),
118 DEVMETHOD(device_detach, esp_dma_detach),
119 DEVMETHOD(device_suspend, esp_suspend),
120 DEVMETHOD(device_resume, esp_resume),
125 static driver_t esp_dma_driver = {
128 sizeof(struct esp_softc)
131 DRIVER_MODULE(esp, dma, esp_dma_driver, esp_devclass, 0, 0);
132 MODULE_DEPEND(esp, dma, 1, 1, 1);
134 static device_method_t esp_sbus_methods[] = {
135 DEVMETHOD(device_probe, esp_probe),
136 DEVMETHOD(device_attach, esp_sbus_attach),
137 DEVMETHOD(device_detach, esp_sbus_detach),
138 DEVMETHOD(device_suspend, esp_suspend),
139 DEVMETHOD(device_resume, esp_resume),
144 static driver_t esp_sbus_driver = {
147 sizeof(struct esp_softc)
150 DRIVER_MODULE(esp, sbus, esp_sbus_driver, esp_devclass, 0, 0);
151 MODULE_DEPEND(esp, sbus, 1, 1, 1);
154 * Functions and the switch for the MI code
156 static uint8_t esp_read_reg(struct ncr53c9x_softc *sc, int reg);
157 static void esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v);
158 static int esp_dma_isintr(struct ncr53c9x_softc *sc);
159 static void esp_dma_reset(struct ncr53c9x_softc *sc);
160 static int esp_dma_intr(struct ncr53c9x_softc *sc);
161 static int esp_dma_setup(struct ncr53c9x_softc *sc, void **addr,
162 size_t *len, int datain, size_t *dmasize);
163 static void esp_dma_go(struct ncr53c9x_softc *sc);
164 static void esp_dma_stop(struct ncr53c9x_softc *sc);
165 static int esp_dma_isactive(struct ncr53c9x_softc *sc);
166 static int espattach(struct esp_softc *esc,
167 const struct ncr53c9x_glue *gluep);
168 static int espdetach(struct esp_softc *esc);
170 static const struct ncr53c9x_glue esp_sbus_glue = {
183 esp_probe(device_t dev)
187 name = ofw_bus_get_name(dev);
188 if (strcmp("SUNW,fas", name) == 0) {
189 device_set_desc(dev, "Sun FAS366 Fast-Wide SCSI");
190 return (BUS_PROBE_DEFAULT);
191 } else if (strcmp("esp", name) == 0) {
192 device_set_desc(dev, "Sun ESP SCSI/Sun FAS Fast-SCSI");
193 return (BUS_PROBE_DEFAULT);
200 esp_sbus_attach(device_t dev)
202 struct esp_softc *esc;
203 struct ncr53c9x_softc *sc;
204 struct lsi64854_softc *lsc;
206 int error, i, nchildren;
208 esc = device_get_softc(dev);
209 sc = &esc->sc_ncr53c9x;
213 sc->sc_freq = sbus_get_clockfreq(dev);
215 if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") == 0) {
217 * Allocate space for DMA, in SUNW,fas there are no
218 * separate DMA devices.
220 lsc = malloc(sizeof (struct lsi64854_softc), M_DEVBUF,
223 device_printf(dev, "out of memory (lsi64854_softc)\n");
229 * SUNW,fas have 2 register spaces: DMA (lsi64854) and
230 * SCSI core (ncr53c9x).
233 /* Allocate DMA registers. */
235 if ((lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
236 &i, RF_ACTIVE)) == NULL) {
237 device_printf(dev, "cannot allocate DMA registers\n");
242 /* Create a parent DMA tag based on this bus. */
243 error = bus_dma_tag_create(
244 bus_get_dma_tag(dev), /* parent */
245 1, 0, /* alignment, boundary */
246 BUS_SPACE_MAXADDR, /* lowaddr */
247 BUS_SPACE_MAXADDR, /* highaddr */
248 NULL, NULL, /* filter, filterarg */
249 BUS_SPACE_MAXSIZE, /* maxsize */
250 BUS_SPACE_UNRESTRICTED, /* nsegments */
251 BUS_SPACE_MAXSIZE, /* maxsegsize */
253 NULL, NULL, /* no locking */
254 &lsc->sc_parent_dmat);
256 device_printf(dev, "cannot allocate parent DMA tag\n");
260 i = sbus_get_burstsz(dev);
262 #ifdef ESP_SBUS_DEBUG
263 printf("%s: burst 0x%x\n", __func__, i);
266 lsc->sc_burst = (i & SBUS_BURST_32) ? 32 :
267 (i & SBUS_BURST_16) ? 16 : 0;
269 lsc->sc_channel = L64854_CHANNEL_SCSI;
274 * Allocate SCSI core registers.
277 if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
278 &i, RF_ACTIVE)) == NULL) {
280 "cannot allocate SCSI core registers\n");
282 goto fail_sbus_lpdma;
286 * Search accompanying DMA engine. It should have been
287 * already attached otherwise there isn't much we can do.
289 if (device_get_children(device_get_parent(dev), &children,
291 device_printf(dev, "cannot determine siblings\n");
294 for (i = 0; i < nchildren; i++) {
295 if (device_is_attached(children[i]) &&
296 sbus_get_slot(children[i]) ==
297 sbus_get_slot(dev) &&
298 strcmp(ofw_bus_get_name(children[i]),
301 esc->sc_dma = (struct lsi64854_softc *)
302 device_get_softc(children[i]);
306 free(children, M_TEMP);
307 if (esc->sc_dma == NULL) {
308 device_printf(dev, "cannot find DMA engine\n");
311 esc->sc_dma->sc_client = sc;
314 * Allocate SCSI core registers.
317 if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
318 &i, RF_ACTIVE)) == NULL) {
320 "cannot allocate SCSI core registers\n");
325 error = espattach(esc, &esp_sbus_glue);
327 device_printf(dev, "espattach failed\n");
334 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res),
336 if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0)
339 bus_dma_tag_destroy(lsc->sc_parent_dmat);
341 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res),
349 esp_sbus_detach(device_t dev)
351 struct esp_softc *esc;
352 struct lsi64854_softc *lsc;
355 esc = device_get_softc(dev);
358 error = espdetach(esc);
361 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res),
363 if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0)
365 bus_dma_tag_destroy(lsc->sc_parent_dmat);
366 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res),
374 esp_dma_attach(device_t dev)
376 struct esp_softc *esc;
377 struct ncr53c9x_softc *sc;
380 esc = device_get_softc(dev);
381 sc = &esc->sc_ncr53c9x;
384 if (OF_getprop(ofw_bus_get_node(dev), "clock-frequency",
385 &sc->sc_freq, sizeof(sc->sc_freq)) == -1) {
386 printf("failed to query OFW for clock-frequency\n");
391 esc->sc_dma = (struct lsi64854_softc *)
392 device_get_softc(device_get_parent(dev));
393 esc->sc_dma->sc_client = sc;
396 * Allocate SCSI core registers.
399 if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
400 &i, RF_ACTIVE)) == NULL) {
401 device_printf(dev, "cannot allocate SCSI core registers\n");
405 error = espattach(esc, &esp_sbus_glue);
407 device_printf(dev, "espattach failed\n");
414 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res),
420 esp_dma_detach(device_t dev)
422 struct esp_softc *esc;
425 esc = device_get_softc(dev);
427 error = espdetach(esc);
430 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res),
437 esp_suspend(device_t dev)
444 esp_resume(device_t dev)
451 espattach(struct esp_softc *esc, const struct ncr53c9x_glue *gluep)
453 struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
454 unsigned int uid = 0;
459 sc->sc_id = OF_getscsinitid(esc->sc_dev);
461 #ifdef ESP_SBUS_DEBUG
462 device_printf(esc->sc_dev, "%s: sc_id %d, freq %d\n",
463 __func__, sc->sc_id, sc->sc_freq);
467 * The `ESC' DMA chip must be reset before we can access
470 if (esc->sc_dma->sc_rev == DMAREV_ESC)
471 DMA_RESET(esc->sc_dma);
474 * Set up glue for MI code early; we use some of it here.
479 sc->sc_freq /= 1000000;
482 * XXX More of this should be in ncr53c9x_attach(), but
483 * XXX should we really poke around the chip that much in
484 * XXX the MI code? Think about this more...
488 * Read the part-unique ID code of the SCSI chip. The contained
489 * value is only valid if all of the following conditions are met:
490 * - After power-up or chip reset.
491 * - Before any value is written to this register.
492 * - The NCRCFG2_FE bit is set.
493 * - A (NCRCMD_NOP | NCRCMD_DMA) command has been issued.
495 NCRCMD(sc, NCRCMD_RSTCHIP);
496 NCRCMD(sc, NCRCMD_NOP);
497 sc->sc_cfg2 = NCRCFG2_FE;
498 NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2);
499 NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA);
500 uid = NCR_READ_REG(sc, NCR_UID);
503 * It is necessary to try to load the 2nd config register here,
504 * to find out what rev the esp chip is, else the ncr53c9x_reset
505 * will not set up the defaults correctly.
507 sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB;
508 NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1);
510 NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2);
511 sc->sc_cfg2 = NCRCFG2_SCSI2 | NCRCFG2_RPE;
512 NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2);
514 if ((NCR_READ_REG(sc, NCR_CFG2) & ~NCRCFG2_RSVD) !=
515 (NCRCFG2_SCSI2 | NCRCFG2_RPE))
516 sc->sc_rev = NCR_VARIANT_ESP100;
518 sc->sc_cfg2 = NCRCFG2_SCSI2;
519 NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2);
521 NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3);
522 sc->sc_cfg3 = (NCRCFG3_CDB | NCRCFG3_FCLK);
523 NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3);
524 if (NCR_READ_REG(sc, NCR_CFG3) !=
525 (NCRCFG3_CDB | NCRCFG3_FCLK))
526 sc->sc_rev = NCR_VARIANT_ESP100A;
528 /* NCRCFG2_FE enables > 64K transfers. */
529 sc->sc_cfg2 |= NCRCFG2_FE;
531 NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3);
532 if (sc->sc_freq <= 25)
533 sc->sc_rev = NCR_VARIANT_ESP200;
535 switch ((uid & 0xf8) >> 3) {
537 sc->sc_rev = NCR_VARIANT_FAS100A;
541 if ((uid & 0x07) == 0x02)
550 sc->sc_rev = NCR_VARIANT_FAS366;
555 * We could just treat unknown chips
556 * as ESP200 but then we would most
557 * likely drive them out of specs.
559 device_printf(esc->sc_dev,
568 #ifdef ESP_SBUS_DEBUG
569 printf("%s: revision %d, uid 0x%x\n", __func__, sc->sc_rev, uid);
573 * This is the value used to start sync negotiations
574 * Note that the NCR register "SYNCTP" is programmed
575 * in "clocks per byte", and has a minimum value of 4.
576 * The SCSI period used in negotiation is one-fourth
577 * of the time (in nanoseconds) needed to transfer one byte.
578 * Since the chip's clock is given in MHz, we have the following
579 * formula: 4 * period = (1000 / freq) * 4
581 sc->sc_minsync = 1000 / sc->sc_freq;
584 * Except for some variants the maximum transfer size is 64k.
586 sc->sc_maxxfer = 64 * 1024;
587 sc->sc_maxoffset = 15;
588 sc->sc_extended_geom = 1;
591 * Alas, we must now modify the value a bit, because it's
592 * only valid when we can switch on FASTCLK and FASTSCSI bits
593 * in the config register 3...
595 switch (sc->sc_rev) {
596 case NCR_VARIANT_ESP100:
597 sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT;
598 sc->sc_minsync = 0; /* No synch on old chip? */
601 case NCR_VARIANT_ESP100A:
602 case NCR_VARIANT_ESP200:
603 sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT;
604 /* Min clocks/byte is 5 */
605 sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5);
608 case NCR_VARIANT_FAS100A:
609 case NCR_VARIANT_FAS216:
610 case NCR_VARIANT_FAS236:
612 * The onboard SCSI chips in Sun Ultra 1 are actually
613 * documented to be NCR53C9X which use NCRCFG3_FCLK and
614 * NCRCFG3_FSCSI. BSD/OS however probes these chips as
615 * FAS100A and uses NCRF9XCFG3_FCLK and NCRF9XCFG3_FSCSI
616 * instead which seems to be correct as otherwise sync
617 * negotiation just doesn't work. Using NCRF9XCFG3_FCLK
618 * and NCRF9XCFG3_FSCSI with these chips in fact also
619 * yields Fast-SCSI speed.
621 sc->sc_features = NCR_F_FASTSCSI;
622 sc->sc_cfg3 = NCRF9XCFG3_FCLK;
623 sc->sc_cfg3_fscsi = NCRF9XCFG3_FSCSI;
624 sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT;
625 sc->sc_maxxfer = 16 * 1024 * 1024;
628 case NCR_VARIANT_FAS366:
629 sc->sc_maxwidth = MSG_EXT_WDTR_BUS_16_BIT;
630 sc->sc_maxxfer = 16 * 1024 * 1024;
635 * Given that we allocate resources based on sc->sc_maxxfer it doesn't
636 * make sense to supply a value higher than the maximum actually used.
638 sc->sc_maxxfer = min(sc->sc_maxxfer, MAXPHYS);
640 /* Attach the DMA engine. */
641 error = lsi64854_attach(esc->sc_dma);
643 device_printf(esc->sc_dev, "lsi64854_attach failed\n");
647 /* Establish interrupt channel. */
649 if ((esc->sc_irqres = bus_alloc_resource_any(esc->sc_dev, SYS_RES_IRQ,
650 &i, RF_SHAREABLE|RF_ACTIVE)) == NULL) {
651 device_printf(esc->sc_dev, "cannot allocate interrupt\n");
654 if (bus_setup_intr(esc->sc_dev, esc->sc_irqres,
655 INTR_MPSAFE | INTR_TYPE_CAM, NULL, ncr53c9x_intr, sc,
657 device_printf(esc->sc_dev, "cannot set up interrupt\n");
662 /* Turn on target selection using the `DMA' method. */
663 if (sc->sc_rev != NCR_VARIANT_FAS366)
664 sc->sc_features |= NCR_F_DMASELECT;
666 /* Do the common parts of attachment. */
667 sc->sc_dev = esc->sc_dev;
668 error = ncr53c9x_attach(sc);
670 device_printf(esc->sc_dev, "ncr53c9x_attach failed\n");
677 bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq);
679 bus_release_resource(esc->sc_dev, SYS_RES_IRQ,
680 rman_get_rid(esc->sc_irqres), esc->sc_irqres);
682 lsi64854_detach(esc->sc_dma);
684 NCR_LOCK_DESTROY(sc);
689 espdetach(struct esp_softc *esc)
691 struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
694 bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq);
695 error = ncr53c9x_detach(sc);
698 error = lsi64854_detach(esc->sc_dma);
701 NCR_LOCK_DESTROY(sc);
702 bus_release_resource(esc->sc_dev, SYS_RES_IRQ,
703 rman_get_rid(esc->sc_irqres), esc->sc_irqres);
712 #ifdef ESP_SBUS_DEBUG
713 static int esp_sbus_debug = 0;
715 static const struct {
718 } const esp__read_regnames [] = {
719 { "TCL", 0}, /* 0/00 */
720 { "TCM", 0}, /* 1/04 */
721 { "FIFO", 0}, /* 2/08 */
722 { "CMD", 0}, /* 3/0c */
723 { "STAT", 0}, /* 4/10 */
724 { "INTR", 0}, /* 5/14 */
725 { "STEP", 0}, /* 6/18 */
726 { "FFLAGS", 1}, /* 7/1c */
727 { "CFG1", 1}, /* 8/20 */
728 { "STAT2", 0}, /* 9/24 */
729 { "CFG4", 1}, /* a/28 */
730 { "CFG2", 1}, /* b/2c */
731 { "CFG3", 1}, /* c/30 */
732 { "-none", 1}, /* d/34 */
733 { "TCH", 1}, /* e/38 */
734 { "TCX", 1}, /* f/3c */
737 static const const struct {
740 } const esp__write_regnames[] = {
741 { "TCL", 1}, /* 0/00 */
742 { "TCM", 1}, /* 1/04 */
743 { "FIFO", 0}, /* 2/08 */
744 { "CMD", 0}, /* 3/0c */
745 { "SELID", 1}, /* 4/10 */
746 { "TIMEOUT", 1}, /* 5/14 */
747 { "SYNCTP", 1}, /* 6/18 */
748 { "SYNCOFF", 1}, /* 7/1c */
749 { "CFG1", 1}, /* 8/20 */
750 { "CCF", 1}, /* 9/24 */
751 { "TEST", 1}, /* a/28 */
752 { "CFG2", 1}, /* b/2c */
753 { "CFG3", 1}, /* c/30 */
754 { "-none", 1}, /* d/34 */
755 { "TCH", 1}, /* e/38 */
756 { "TCX", 1}, /* f/3c */
761 esp_read_reg(struct ncr53c9x_softc *sc, int reg)
763 struct esp_softc *esc = (struct esp_softc *)sc;
766 v = bus_read_1(esc->sc_res, reg * 4);
768 #ifdef ESP_SBUS_DEBUG
769 if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag)
770 printf("RD:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ?
771 esp__read_regnames[reg].r_name : "<***>", v);
778 esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v)
780 struct esp_softc *esc = (struct esp_softc *)sc;
782 #ifdef ESP_SBUS_DEBUG
783 if (esp_sbus_debug && (reg < 0x10) && esp__write_regnames[reg].r_flag)
784 printf("WR:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ?
785 esp__write_regnames[reg].r_name : "<***>", v);
788 bus_write_1(esc->sc_res, reg * 4, v);
792 esp_dma_isintr(struct ncr53c9x_softc *sc)
794 struct esp_softc *esc = (struct esp_softc *)sc;
796 return (DMA_ISINTR(esc->sc_dma));
800 esp_dma_reset(struct ncr53c9x_softc *sc)
802 struct esp_softc *esc = (struct esp_softc *)sc;
804 DMA_RESET(esc->sc_dma);
808 esp_dma_intr(struct ncr53c9x_softc *sc)
810 struct esp_softc *esc = (struct esp_softc *)sc;
812 return (DMA_INTR(esc->sc_dma));
816 esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len,
817 int datain, size_t *dmasize)
819 struct esp_softc *esc = (struct esp_softc *)sc;
821 return (DMA_SETUP(esc->sc_dma, addr, len, datain, dmasize));
825 esp_dma_go(struct ncr53c9x_softc *sc)
827 struct esp_softc *esc = (struct esp_softc *)sc;
833 esp_dma_stop(struct ncr53c9x_softc *sc)
835 struct esp_softc *esc = (struct esp_softc *)sc;
837 L64854_SCSR(esc->sc_dma, L64854_GCSR(esc->sc_dma) & ~D_EN_DMA);
841 esp_dma_isactive(struct ncr53c9x_softc *sc)
843 struct esp_softc *esc = (struct esp_softc *)sc;
845 return (DMA_ISACTIVE(esc->sc_dma));