Home | History | Annotate | Line # | Download | only in pcmcia
esp_pcmcia.c revision 1.32.6.1
      1  1.32.6.1     joerg /*	$NetBSD: esp_pcmcia.c,v 1.32.6.1 2007/10/26 15:47:06 joerg Exp $	*/
      2       1.1   mycroft 
      3       1.1   mycroft /*-
      4      1.18   mycroft  * Copyright (c) 2000, 2004 The NetBSD Foundation, Inc.
      5       1.1   mycroft  * All rights reserved.
      6       1.1   mycroft  *
      7       1.1   mycroft  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   mycroft  * by Charles M. Hannum.
      9       1.1   mycroft  *
     10       1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     11       1.1   mycroft  * modification, are permitted provided that the following conditions
     12       1.1   mycroft  * are met:
     13       1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     14       1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     15       1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     17       1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     18       1.1   mycroft  * 3. All advertising materials mentioning features or use of this software
     19       1.1   mycroft  *    must display the following acknowledgement:
     20       1.1   mycroft  *        This product includes software developed by the NetBSD
     21       1.1   mycroft  *        Foundation, Inc. and its contributors.
     22       1.1   mycroft  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1   mycroft  *    contributors may be used to endorse or promote products derived
     24       1.1   mycroft  *    from this software without specific prior written permission.
     25       1.1   mycroft  *
     26       1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.1   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1   mycroft  */
     38      1.10     lukem 
     39      1.10     lukem #include <sys/cdefs.h>
     40  1.32.6.1     joerg __KERNEL_RCSID(0, "$NetBSD: esp_pcmcia.c,v 1.32.6.1 2007/10/26 15:47:06 joerg Exp $");
     41       1.1   mycroft 
     42       1.1   mycroft #include <sys/param.h>
     43       1.1   mycroft #include <sys/systm.h>
     44       1.1   mycroft #include <sys/device.h>
     45       1.1   mycroft #include <sys/buf.h>
     46       1.1   mycroft 
     47  1.32.6.1     joerg #include <sys/bus.h>
     48  1.32.6.1     joerg #include <sys/intr.h>
     49       1.1   mycroft 
     50       1.1   mycroft #include <dev/scsipi/scsi_all.h>
     51       1.1   mycroft #include <dev/scsipi/scsipi_all.h>
     52       1.1   mycroft #include <dev/scsipi/scsiconf.h>
     53       1.1   mycroft 
     54       1.1   mycroft #include <dev/pcmcia/pcmciareg.h>
     55       1.1   mycroft #include <dev/pcmcia/pcmciavar.h>
     56       1.1   mycroft #include <dev/pcmcia/pcmciadevs.h>
     57       1.1   mycroft 
     58       1.1   mycroft #include <dev/ic/ncr53c9xreg.h>
     59       1.1   mycroft #include <dev/ic/ncr53c9xvar.h>
     60       1.1   mycroft 
     61       1.1   mycroft struct esp_pcmcia_softc {
     62       1.1   mycroft 	struct ncr53c9x_softc	sc_ncr53c9x;	/* glue to MI code */
     63       1.1   mycroft 
     64       1.1   mycroft 	int		sc_active;		/* Pseudo-DMA state vars */
     65       1.1   mycroft 	int		sc_tc;
     66       1.1   mycroft 	int		sc_datain;
     67       1.1   mycroft 	size_t		sc_dmasize;
     68       1.1   mycroft 	size_t		sc_dmatrans;
     69       1.1   mycroft 	char		**sc_dmaaddr;
     70       1.1   mycroft 	size_t		*sc_pdmalen;
     71       1.1   mycroft 
     72       1.1   mycroft 	/* PCMCIA-specific goo. */
     73       1.1   mycroft 	struct pcmcia_function *sc_pf;		/* our PCMCIA function */
     74       1.1   mycroft 	void *sc_ih;				/* interrupt handler */
     75       1.5   thorpej #ifdef ESP_PCMCIA_POLL
     76       1.5   thorpej 	struct callout sc_poll_ch;
     77       1.5   thorpej #endif
     78      1.18   mycroft 	bus_space_tag_t	sc_iot;
     79      1.18   mycroft 	bus_space_handle_t sc_ioh;
     80      1.18   mycroft 
     81      1.18   mycroft 	int sc_state;
     82      1.18   mycroft #define ESP_PCMCIA_ATTACHED	3
     83       1.1   mycroft };
     84       1.1   mycroft 
     85      1.26     perry int	esp_pcmcia_match(struct device *, struct cfdata *, void *);
     86      1.25     perry int	esp_pcmcia_validate_config(struct pcmcia_config_entry *);
     87      1.26     perry void	esp_pcmcia_attach(struct device *, struct device *, void *);
     88      1.25     perry void	esp_pcmcia_init(struct esp_pcmcia_softc *);
     89      1.25     perry int	esp_pcmcia_detach(struct device *, int);
     90      1.25     perry int	esp_pcmcia_enable(struct device *, int);
     91       1.1   mycroft 
     92      1.13   thorpej CFATTACH_DECL(esp_pcmcia, sizeof(struct esp_pcmcia_softc),
     93      1.14   thorpej     esp_pcmcia_match, esp_pcmcia_attach, esp_pcmcia_detach, NULL);
     94       1.1   mycroft 
     95       1.1   mycroft /*
     96       1.1   mycroft  * Functions and the switch for the MI code.
     97       1.1   mycroft  */
     98       1.1   mycroft #ifdef ESP_PCMCIA_POLL
     99      1.25     perry void	esp_pcmcia_poll(void *);
    100       1.1   mycroft #endif
    101      1.25     perry u_char	esp_pcmcia_read_reg(struct ncr53c9x_softc *, int);
    102      1.25     perry void	esp_pcmcia_write_reg(struct ncr53c9x_softc *, int, u_char);
    103      1.25     perry int	esp_pcmcia_dma_isintr(struct ncr53c9x_softc *);
    104      1.25     perry void	esp_pcmcia_dma_reset(struct ncr53c9x_softc *);
    105      1.25     perry int	esp_pcmcia_dma_intr(struct ncr53c9x_softc *);
    106      1.31  christos int	esp_pcmcia_dma_setup(struct ncr53c9x_softc *, void **,
    107      1.25     perry 	    size_t *, int, size_t *);
    108      1.25     perry void	esp_pcmcia_dma_go(struct ncr53c9x_softc *);
    109      1.25     perry void	esp_pcmcia_dma_stop(struct ncr53c9x_softc *);
    110      1.25     perry int	esp_pcmcia_dma_isactive(struct ncr53c9x_softc *);
    111       1.1   mycroft 
    112      1.23   mycroft const struct ncr53c9x_glue esp_pcmcia_glue = {
    113       1.1   mycroft 	esp_pcmcia_read_reg,
    114       1.1   mycroft 	esp_pcmcia_write_reg,
    115       1.1   mycroft 	esp_pcmcia_dma_isintr,
    116       1.1   mycroft 	esp_pcmcia_dma_reset,
    117       1.1   mycroft 	esp_pcmcia_dma_intr,
    118       1.1   mycroft 	esp_pcmcia_dma_setup,
    119       1.1   mycroft 	esp_pcmcia_dma_go,
    120       1.1   mycroft 	esp_pcmcia_dma_stop,
    121       1.1   mycroft 	esp_pcmcia_dma_isactive,
    122       1.1   mycroft 	NULL,			/* gl_clear_latched_intr */
    123       1.1   mycroft };
    124       1.1   mycroft 
    125      1.21   mycroft const struct pcmcia_product esp_pcmcia_products[] = {
    126      1.21   mycroft 	{ PCMCIA_VENDOR_PANASONIC, PCMCIA_PRODUCT_PANASONIC_KXLC002,
    127      1.21   mycroft 	  PCMCIA_CIS_PANASONIC_KXLC002 },
    128       1.1   mycroft 
    129      1.21   mycroft 	{ PCMCIA_VENDOR_RATOC, PCMCIA_PRODUCT_RATOC_REX_9530,
    130      1.21   mycroft 	  PCMCIA_CIS_RATOC_REX_9530 },
    131       1.1   mycroft };
    132      1.21   mycroft const size_t esp_pcmcia_nproducts =
    133      1.21   mycroft     sizeof(esp_pcmcia_products) / sizeof(esp_pcmcia_products[0]);
    134      1.16     itohy 
    135       1.1   mycroft int
    136      1.29  christos esp_pcmcia_match(struct device *parent, struct cfdata *match,
    137      1.28  christos     void *aux)
    138       1.1   mycroft {
    139       1.1   mycroft 	struct pcmcia_attach_args *pa = aux;
    140       1.1   mycroft 
    141      1.21   mycroft 	if (pcmcia_product_lookup(pa, esp_pcmcia_products, esp_pcmcia_nproducts,
    142      1.21   mycroft 	    sizeof(esp_pcmcia_products[0]), NULL))
    143       1.1   mycroft 		return (1);
    144       1.1   mycroft 	return (0);
    145       1.1   mycroft }
    146       1.1   mycroft 
    147      1.18   mycroft int
    148      1.18   mycroft esp_pcmcia_validate_config(cfe)
    149      1.18   mycroft 	struct pcmcia_config_entry *cfe;
    150      1.18   mycroft {
    151      1.18   mycroft 	if (cfe->iftype != PCMCIA_IFTYPE_IO ||
    152      1.18   mycroft 	    cfe->num_memspace != 0 ||
    153      1.18   mycroft 	    cfe->num_iospace != 1)
    154      1.18   mycroft 		return (EINVAL);
    155      1.18   mycroft 	return (0);
    156      1.18   mycroft }
    157      1.18   mycroft 
    158       1.1   mycroft void
    159      1.29  christos esp_pcmcia_attach(struct device *parent, struct device *self,
    160      1.28  christos     void *aux)
    161       1.1   mycroft {
    162       1.1   mycroft 	struct esp_pcmcia_softc *esc = (void *)self;
    163       1.1   mycroft 	struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
    164       1.1   mycroft 	struct pcmcia_attach_args *pa = aux;
    165       1.1   mycroft 	struct pcmcia_config_entry *cfe;
    166       1.1   mycroft 	struct pcmcia_function *pf = pa->pf;
    167      1.18   mycroft 	int error;
    168       1.1   mycroft 
    169       1.1   mycroft 	esc->sc_pf = pf;
    170       1.1   mycroft 
    171      1.18   mycroft 	error = pcmcia_function_configure(pf, esp_pcmcia_validate_config);
    172      1.18   mycroft 	if (error) {
    173      1.18   mycroft 		aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
    174      1.18   mycroft 		    error);
    175      1.18   mycroft 		return;
    176       1.1   mycroft 	}
    177       1.1   mycroft 
    178      1.18   mycroft 	cfe = pf->cfe;
    179      1.18   mycroft 	esc->sc_iot = cfe->iospace[0].handle.iot;
    180      1.18   mycroft 	esc->sc_ioh = cfe->iospace[0].handle.ioh;
    181      1.18   mycroft 	esp_pcmcia_init(esc);
    182       1.1   mycroft 
    183      1.30     itohy 	printf("%s", self->dv_xname);
    184       1.1   mycroft 
    185       1.9    bouyer 	sc->sc_adapter.adapt_minphys = minphys;
    186       1.9    bouyer 	sc->sc_adapter.adapt_request = ncr53c9x_scsipi_request;
    187      1.15  jdolecek 	sc->sc_adapter.adapt_enable = esp_pcmcia_enable;
    188      1.18   mycroft 
    189       1.9    bouyer 	ncr53c9x_attach(sc);
    190      1.18   mycroft 	esc->sc_state = ESP_PCMCIA_ATTACHED;
    191       1.1   mycroft }
    192       1.1   mycroft 
    193       1.1   mycroft void
    194       1.1   mycroft esp_pcmcia_init(esc)
    195       1.1   mycroft 	struct esp_pcmcia_softc *esc;
    196       1.1   mycroft {
    197       1.1   mycroft 	struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
    198       1.1   mycroft 
    199       1.1   mycroft 	/* id 7, clock 40M, parity ON, sync OFF, fast ON, slow ON */
    200       1.1   mycroft 
    201       1.1   mycroft 	sc->sc_glue = &esp_pcmcia_glue;
    202       1.1   mycroft 
    203       1.5   thorpej #ifdef ESP_PCMCIA_POLL
    204      1.32        ad 	callout_init(&esc->sc_poll_ch, 0);
    205       1.5   thorpej #endif
    206       1.5   thorpej 
    207       1.1   mycroft 	sc->sc_rev = NCR_VARIANT_ESP406;
    208       1.1   mycroft 	sc->sc_id = 7;
    209       1.1   mycroft 	sc->sc_freq = 40;
    210       1.2   mycroft 	/* try -PARENB -SLOW */
    211       1.1   mycroft 	sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB | NCRCFG1_SLOW;
    212       1.2   mycroft 	/* try +FE */
    213       1.1   mycroft 	sc->sc_cfg2 = NCRCFG2_SCSI2;
    214       1.2   mycroft 	/* try -IDM -FSCSI -FCLK */
    215       1.2   mycroft 	sc->sc_cfg3 = NCRESPCFG3_CDB | NCRESPCFG3_FCLK | NCRESPCFG3_IDM |
    216       1.2   mycroft 	    NCRESPCFG3_FSCSI;
    217       1.1   mycroft 	sc->sc_cfg4 = NCRCFG4_ACTNEG;
    218       1.2   mycroft 	/* try +INTP */
    219       1.1   mycroft 	sc->sc_cfg5 = NCRCFG5_CRS1 | NCRCFG5_AADDR | NCRCFG5_PTRINC;
    220       1.1   mycroft 	sc->sc_minsync = 0;
    221       1.1   mycroft 	sc->sc_maxxfer = 64 * 1024;
    222       1.1   mycroft }
    223       1.1   mycroft 
    224       1.1   mycroft int
    225       1.1   mycroft esp_pcmcia_detach(self, flags)
    226       1.1   mycroft 	struct device *self;
    227       1.1   mycroft 	int flags;
    228       1.1   mycroft {
    229      1.18   mycroft 	struct esp_pcmcia_softc *sc = (void *)self;
    230       1.1   mycroft 	int error;
    231       1.1   mycroft 
    232      1.18   mycroft 	if (sc->sc_state != ESP_PCMCIA_ATTACHED)
    233       1.1   mycroft 		return (0);
    234       1.1   mycroft 
    235      1.18   mycroft 	error = ncr53c9x_detach(&sc->sc_ncr53c9x, flags);
    236       1.1   mycroft 	if (error)
    237       1.1   mycroft 		return (error);
    238       1.1   mycroft 
    239      1.18   mycroft 	pcmcia_function_unconfigure(sc->sc_pf);
    240       1.1   mycroft 
    241       1.1   mycroft 	return (0);
    242       1.1   mycroft }
    243       1.1   mycroft 
    244       1.1   mycroft int
    245       1.1   mycroft esp_pcmcia_enable(arg, onoff)
    246      1.15  jdolecek 	struct device *arg;
    247       1.1   mycroft 	int onoff;
    248       1.1   mycroft {
    249      1.18   mycroft 	struct esp_pcmcia_softc *sc = (void *)arg;
    250      1.19   mycroft 	int error;
    251       1.1   mycroft 
    252       1.1   mycroft 	if (onoff) {
    253       1.1   mycroft #ifdef ESP_PCMCIA_POLL
    254      1.24   mycroft 		callout_reset(&sc->sc_poll_ch, 1, esp_pcmcia_poll, sc);
    255       1.1   mycroft #else
    256      1.24   mycroft 		/* Establish the interrupt handler. */
    257      1.24   mycroft 		sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
    258      1.24   mycroft 		    ncr53c9x_intr, &sc->sc_ncr53c9x);
    259      1.24   mycroft 		if (!sc->sc_ih)
    260      1.24   mycroft 			return (EIO);
    261       1.1   mycroft #endif
    262       1.1   mycroft 
    263      1.24   mycroft 		error = pcmcia_function_enable(sc->sc_pf);
    264      1.24   mycroft 		if (error) {
    265      1.24   mycroft 			pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
    266      1.24   mycroft 			sc->sc_ih = 0;
    267      1.24   mycroft 			return (error);
    268      1.24   mycroft 		}
    269       1.1   mycroft 
    270      1.24   mycroft 		/* Initialize only chip.  */
    271      1.24   mycroft 		ncr53c9x_init(&sc->sc_ncr53c9x, 0);
    272       1.1   mycroft 	} else {
    273      1.18   mycroft 		pcmcia_function_disable(sc->sc_pf);
    274       1.1   mycroft #ifdef ESP_PCMCIA_POLL
    275      1.18   mycroft 		callout_stop(&sc->sc_poll_ch);
    276       1.1   mycroft #else
    277      1.18   mycroft 		pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
    278      1.18   mycroft 		sc->sc_ih = 0;
    279       1.1   mycroft #endif
    280       1.1   mycroft 	}
    281       1.1   mycroft 
    282       1.1   mycroft 	return (0);
    283       1.1   mycroft }
    284       1.1   mycroft 
    285       1.1   mycroft #ifdef ESP_PCMCIA_POLL
    286       1.1   mycroft void
    287       1.1   mycroft esp_pcmcia_poll(arg)
    288       1.1   mycroft 	void *arg;
    289       1.1   mycroft {
    290       1.1   mycroft 	struct esp_pcmcia_softc *esc = arg;
    291       1.1   mycroft 
    292       1.1   mycroft 	(void) ncr53c9x_intr(&esc->sc_ncr53c9x);
    293       1.5   thorpej 	callout_reset(&esc->sc_poll_ch, 1, esp_pcmcia_poll, esc);
    294       1.1   mycroft }
    295       1.1   mycroft #endif
    296       1.1   mycroft 
    297       1.1   mycroft /*
    298       1.1   mycroft  * Glue functions.
    299       1.1   mycroft  */
    300       1.1   mycroft u_char
    301       1.1   mycroft esp_pcmcia_read_reg(sc, reg)
    302       1.1   mycroft 	struct ncr53c9x_softc *sc;
    303       1.1   mycroft 	int reg;
    304       1.1   mycroft {
    305       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    306       1.1   mycroft 	u_char v;
    307       1.1   mycroft 
    308      1.18   mycroft 	v = bus_space_read_1(esc->sc_iot, esc->sc_ioh, reg);
    309       1.1   mycroft 	return v;
    310       1.1   mycroft }
    311       1.1   mycroft 
    312       1.1   mycroft void
    313       1.1   mycroft esp_pcmcia_write_reg(sc, reg, val)
    314       1.1   mycroft 	struct ncr53c9x_softc *sc;
    315       1.1   mycroft 	int reg;
    316       1.1   mycroft 	u_char val;
    317       1.1   mycroft {
    318       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    319       1.1   mycroft 	u_char v = val;
    320       1.1   mycroft 
    321       1.1   mycroft 	if (reg == NCR_CMD && v == (NCRCMD_TRANS|NCRCMD_DMA))
    322       1.1   mycroft 		v = NCRCMD_TRANS;
    323      1.18   mycroft 	bus_space_write_1(esc->sc_iot, esc->sc_ioh, reg, v);
    324       1.1   mycroft }
    325       1.1   mycroft 
    326       1.1   mycroft int
    327       1.1   mycroft esp_pcmcia_dma_isintr(sc)
    328       1.1   mycroft 	struct ncr53c9x_softc *sc;
    329       1.1   mycroft {
    330       1.1   mycroft 
    331       1.1   mycroft 	return NCR_READ_REG(sc, NCR_STAT) & NCRSTAT_INT;
    332       1.1   mycroft }
    333       1.1   mycroft 
    334       1.1   mycroft void
    335       1.1   mycroft esp_pcmcia_dma_reset(sc)
    336       1.1   mycroft 	struct ncr53c9x_softc *sc;
    337       1.1   mycroft {
    338       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    339       1.1   mycroft 
    340       1.1   mycroft 	esc->sc_active = 0;
    341       1.1   mycroft 	esc->sc_tc = 0;
    342       1.1   mycroft }
    343       1.1   mycroft 
    344       1.1   mycroft int
    345       1.1   mycroft esp_pcmcia_dma_intr(sc)
    346       1.1   mycroft 	struct ncr53c9x_softc *sc;
    347       1.1   mycroft {
    348       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    349       1.1   mycroft 	u_char	*p;
    350       1.1   mycroft 	u_int	espphase, espstat, espintr;
    351       1.1   mycroft 	int	cnt;
    352       1.1   mycroft 
    353       1.1   mycroft 	if (esc->sc_active == 0) {
    354       1.1   mycroft 		printf("%s: dma_intr--inactive DMA\n", sc->sc_dev.dv_xname);
    355       1.1   mycroft 		return -1;
    356       1.1   mycroft 	}
    357       1.1   mycroft 
    358       1.1   mycroft 	if ((sc->sc_espintr & NCRINTR_BS) == 0) {
    359       1.1   mycroft 		esc->sc_active = 0;
    360       1.1   mycroft 		return 0;
    361       1.1   mycroft 	}
    362       1.1   mycroft 
    363       1.1   mycroft 	cnt = *esc->sc_pdmalen;
    364       1.1   mycroft 	if (*esc->sc_pdmalen == 0) {
    365       1.1   mycroft 		printf("%s: data interrupt, but no count left\n",
    366       1.1   mycroft 		    sc->sc_dev.dv_xname);
    367       1.1   mycroft 	}
    368       1.1   mycroft 
    369       1.1   mycroft 	p = *esc->sc_dmaaddr;
    370       1.1   mycroft 	espphase = sc->sc_phase;
    371       1.1   mycroft 	espstat = (u_int) sc->sc_espstat;
    372       1.1   mycroft 	espintr = (u_int) sc->sc_espintr;
    373       1.1   mycroft 	do {
    374       1.1   mycroft 		if (esc->sc_datain) {
    375       1.4   mycroft 			*p++ = NCR_READ_REG(sc, NCR_FIFO);
    376       1.4   mycroft 			cnt--;
    377       1.4   mycroft 			if (espphase == DATA_IN_PHASE)
    378       1.1   mycroft 				NCR_WRITE_REG(sc, NCR_CMD, NCRCMD_TRANS);
    379       1.4   mycroft 			else
    380       1.1   mycroft 				esc->sc_active = 0;
    381      1.16     itohy 		} else {
    382       1.1   mycroft 			if (espphase == DATA_OUT_PHASE ||
    383       1.1   mycroft 			    espphase == MESSAGE_OUT_PHASE) {
    384       1.1   mycroft 				NCR_WRITE_REG(sc, NCR_FIFO, *p++);
    385       1.1   mycroft 				cnt--;
    386       1.1   mycroft 				NCR_WRITE_REG(sc, NCR_CMD, NCRCMD_TRANS);
    387       1.1   mycroft 			} else
    388       1.1   mycroft 				esc->sc_active = 0;
    389       1.1   mycroft 		}
    390       1.1   mycroft 
    391       1.1   mycroft 		if (esc->sc_active) {
    392       1.3   tsutsui 			while (!(NCR_READ_REG(sc, NCR_STAT) & NCRSTAT_INT));
    393       1.1   mycroft 			espstat = NCR_READ_REG(sc, NCR_STAT);
    394       1.1   mycroft 			espintr = NCR_READ_REG(sc, NCR_INTR);
    395       1.1   mycroft 			espphase = (espintr & NCRINTR_DIS)
    396       1.1   mycroft 				    ? /* Disconnected */ BUSFREE_PHASE
    397       1.1   mycroft 				    : espstat & PHASE_MASK;
    398       1.1   mycroft 		}
    399       1.1   mycroft 	} while (esc->sc_active && espintr);
    400       1.1   mycroft 	sc->sc_phase = espphase;
    401       1.1   mycroft 	sc->sc_espstat = (u_char) espstat;
    402       1.1   mycroft 	sc->sc_espintr = (u_char) espintr;
    403       1.1   mycroft 	*esc->sc_dmaaddr = p;
    404       1.1   mycroft 	*esc->sc_pdmalen = cnt;
    405       1.1   mycroft 
    406       1.1   mycroft 	if (*esc->sc_pdmalen == 0)
    407       1.1   mycroft 		esc->sc_tc = NCRSTAT_TC;
    408       1.1   mycroft 	sc->sc_espstat |= esc->sc_tc;
    409       1.1   mycroft 	return 0;
    410       1.1   mycroft }
    411       1.1   mycroft 
    412       1.1   mycroft int
    413       1.1   mycroft esp_pcmcia_dma_setup(sc, addr, len, datain, dmasize)
    414       1.1   mycroft 	struct ncr53c9x_softc *sc;
    415      1.31  christos 	void **addr;
    416       1.1   mycroft 	size_t *len;
    417       1.1   mycroft 	int datain;
    418       1.1   mycroft 	size_t *dmasize;
    419       1.1   mycroft {
    420       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    421       1.1   mycroft 
    422      1.31  christos 	esc->sc_dmaaddr = (void *)addr;
    423       1.1   mycroft 	esc->sc_pdmalen = len;
    424       1.1   mycroft 	esc->sc_datain = datain;
    425       1.1   mycroft 	esc->sc_dmasize = *dmasize;
    426       1.1   mycroft 	esc->sc_tc = 0;
    427       1.1   mycroft 
    428       1.1   mycroft 	return 0;
    429       1.1   mycroft }
    430       1.1   mycroft 
    431       1.1   mycroft void
    432       1.1   mycroft esp_pcmcia_dma_go(sc)
    433       1.1   mycroft 	struct ncr53c9x_softc *sc;
    434       1.1   mycroft {
    435       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    436       1.1   mycroft 
    437       1.1   mycroft 	esc->sc_active = 1;
    438       1.1   mycroft }
    439       1.1   mycroft 
    440       1.1   mycroft void
    441      1.29  christos esp_pcmcia_dma_stop(struct ncr53c9x_softc *sc)
    442       1.1   mycroft {
    443       1.1   mycroft }
    444       1.1   mycroft 
    445       1.1   mycroft int
    446       1.1   mycroft esp_pcmcia_dma_isactive(sc)
    447       1.1   mycroft 	struct ncr53c9x_softc *sc;
    448       1.1   mycroft {
    449       1.1   mycroft 	struct esp_pcmcia_softc *esc = (struct esp_pcmcia_softc *)sc;
    450       1.1   mycroft 
    451       1.1   mycroft 	return (esc->sc_active);
    452       1.1   mycroft }
    453