Home | History | Annotate | Line # | Download | only in dev
dmavar.h revision 1.8
      1  1.8  christos /*	$NetBSD: dmavar.h,v 1.8 2007/03/04 06:00:52 christos Exp $ */
      2  1.1    jeremy 
      3  1.1    jeremy /*
      4  1.1    jeremy  * Copyright (c) 1994 Peter Galbavy.  All rights reserved.
      5  1.1    jeremy  * Redistribution and use in source and binary forms, with or without
      6  1.1    jeremy  * modification, are permitted provided that the following conditions
      7  1.1    jeremy  * are met:
      8  1.1    jeremy  * 1. Redistributions of source code must retain the above copyright
      9  1.1    jeremy  *    notice, this list of conditions and the following disclaimer.
     10  1.1    jeremy  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1    jeremy  *    notice, this list of conditions and the following disclaimer in the
     12  1.1    jeremy  *    documentation and/or other materials provided with the distribution.
     13  1.1    jeremy  * 3. All advertising materials mentioning features or use of this software
     14  1.1    jeremy  *    must display the following acknowledgement:
     15  1.1    jeremy  *	This product includes software developed by Peter Galbavy.
     16  1.1    jeremy  * 4. The name of the author may not be used to endorse or promote products
     17  1.1    jeremy  *    derived from this software without specific prior written permission.
     18  1.1    jeremy  *
     19  1.1    jeremy  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  1.1    jeremy  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  1.1    jeremy  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.1    jeremy  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  1.1    jeremy  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  1.1    jeremy  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  1.1    jeremy  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  1.1    jeremy  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  1.1    jeremy  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  1.1    jeremy  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  1.1    jeremy  */
     30  1.1    jeremy 
     31  1.1    jeremy struct dma_softc {
     32  1.1    jeremy 	struct device sc_dev;			/* us as a device */
     33  1.7   tsutsui 	bus_space_tag_t sc_bst;			/* bus space tag */
     34  1.7   tsutsui 	bus_dma_tag_t sc_dmatag;		/* bus dma tag */
     35  1.7   tsutsui 
     36  1.7   tsutsui 	bus_space_handle_t sc_bsh;		/* bus space handle */
     37  1.7   tsutsui 	void *sc_client;			/* my client */
     38  1.7   tsutsui 
     39  1.1    jeremy 	int	sc_active;			/* DMA active ? */
     40  1.7   tsutsui 	bus_dmamap_t sc_dmamap;			/* bus dma map */
     41  1.1    jeremy 	u_int	sc_rev;				/* revision */
     42  1.1    jeremy 	int	sc_burst;			/* DVMA burst size in effect */
     43  1.1    jeremy 	size_t	sc_dmasize;
     44  1.8  christos 	void *	*sc_dmaaddr;
     45  1.1    jeremy 	size_t  *sc_dmalen;
     46  1.3       gwr #if 0
     47  1.1    jeremy 	void (*reset)(struct dma_softc *);	/* reset routine */
     48  1.1    jeremy 	int (*intr)(struct dma_softc *);	/* interrupt ! */
     49  1.8  christos 	int (*setup)(struct dma_softc *, void **, size_t *, int, size_t *);
     50  1.3       gwr #endif
     51  1.1    jeremy };
     52  1.1    jeremy 
     53  1.7   tsutsui #define DMA_GCSR(sc)		\
     54  1.7   tsutsui 	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, DMA_REG_CSR)
     55  1.7   tsutsui #define DMA_SCSR(sc, csr)	\
     56  1.7   tsutsui 	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, DMA_REG_CSR, (csr))
     57  1.1    jeremy 
     58  1.7   tsutsui /*
     59  1.7   tsutsui  * DMA engine interface functions.
     60  1.7   tsutsui  */
     61  1.7   tsutsui #if 0
     62  1.7   tsutsui #define DMA_RESET(sc)			(((sc)->reset)(sc))
     63  1.7   tsutsui #define DMA_INTR(sc)			(((sc)->intr)(sc))
     64  1.7   tsutsui #define DMA_SETUP(sc, a, l, d, s)	(((sc)->setup)(sc, a, l, d, s))
     65  1.7   tsutsui #endif
     66  1.7   tsutsui 
     67  1.7   tsutsui #define DMA_ISACTIVE(sc)		((sc)->sc_active)
     68  1.7   tsutsui 
     69  1.7   tsutsui #define DMA_ENINTR(sc) do {			\
     70  1.7   tsutsui 	uint32_t _csr = DMA_GCSR(sc);		\
     71  1.7   tsutsui 	_csr |= D_INT_EN;			\
     72  1.7   tsutsui 	DMA_SCSR(sc, _csr);			\
     73  1.7   tsutsui } while (/* CONSTCOND */0)
     74  1.7   tsutsui 
     75  1.7   tsutsui #define DMA_ISINTR(sc)	(DMA_GCSR(sc) & (D_INT_PEND|D_ERR_PEND))
     76  1.7   tsutsui 
     77  1.7   tsutsui #define DMA_GO(sc) do {				\
     78  1.7   tsutsui 	uint32_t _csr = DMA_GCSR(sc);		\
     79  1.7   tsutsui 	_csr |= D_EN_DMA;			\
     80  1.7   tsutsui 	DMA_SCSR(sc, _csr);			\
     81  1.7   tsutsui 	sc->sc_active = 1;			\
     82  1.7   tsutsui } while (/* CONSTCOND */0)
     83  1.7   tsutsui 
     84  1.7   tsutsui #define DMA_STOP(sc) do {			\
     85  1.7   tsutsui 	uint32_t _csr = DMA_GCSR(sc);		\
     86  1.7   tsutsui 	_csr &= ~D_EN_DMA;			\
     87  1.7   tsutsui 	DMA_SCSR(sc, _csr);			\
     88  1.7   tsutsui 	sc->sc_active = 0;			\
     89  1.7   tsutsui } while (/* CONSTCOND */0)
     90  1.7   tsutsui 
     91  1.7   tsutsui struct dma_softc *espdmafind(int);
     92  1.7   tsutsui int espdmaintr(struct dma_softc *);
     93  1.3       gwr 
     94  1.5       chs void dma_reset(struct dma_softc *);
     95  1.8  christos int  dma_setup(struct dma_softc *, void **, size_t *, int, size_t *);
     96  1.1    jeremy 
     97