lsi64854var.h revision 182876
1145200Smarius/* $NetBSD: lsi64854var.h,v 1.6 2005/02/04 02:10:36 perry Exp $ */ 2130293Sscottl 3130293Sscottl/*- 4130293Sscottl * Copyright (c) 1998 The NetBSD Foundation, Inc. 5130293Sscottl * All rights reserved. 6130293Sscottl * 7130293Sscottl * This code is derived from software contributed to The NetBSD Foundation 8130293Sscottl * by Paul Kranenburg. 9130293Sscottl * 10130293Sscottl * Redistribution and use in source and binary forms, with or without 11130293Sscottl * modification, are permitted provided that the following conditions 12130293Sscottl * are met: 13130293Sscottl * 1. Redistributions of source code must retain the above copyright 14130293Sscottl * notice, this list of conditions and the following disclaimer. 15130293Sscottl * 2. Redistributions in binary form must reproduce the above copyright 16130293Sscottl * notice, this list of conditions and the following disclaimer in the 17130293Sscottl * documentation and/or other materials provided with the distribution. 18130293Sscottl * 3. All advertising materials mentioning features or use of this software 19130293Sscottl * must display the following acknowledgement: 20130293Sscottl * This product includes software developed by the NetBSD 21130293Sscottl * Foundation, Inc. and its contributors. 22130293Sscottl * 4. Neither the name of The NetBSD Foundation nor the names of its 23130293Sscottl * contributors may be used to endorse or promote products derived 24130293Sscottl * from this software without specific prior written permission. 25130293Sscottl * 26130293Sscottl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27130293Sscottl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28130293Sscottl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29130293Sscottl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30130293Sscottl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31130293Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32130293Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33130293Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34130293Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35130293Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36130293Sscottl * POSSIBILITY OF SUCH DAMAGE. 37130293Sscottl */ 38130293Sscottl 39130293Sscottl/* $FreeBSD: head/sys/sparc64/sbus/lsi64854var.h 182876 2008-09-08 20:20:44Z marius $ */ 40130293Sscottl 41130293Sscottlstruct lsi64854_softc { 42130293Sscottl device_t sc_dev; 43130293Sscottl 44130293Sscottl struct resource *sc_res; 45130293Sscottl u_int sc_rev; /* revision */ 46130293Sscottl int sc_burst; /* max suported burst size */ 47130293Sscottl 48130293Sscottl int sc_channel; 49130293Sscottl#define L64854_CHANNEL_SCSI 1 50130293Sscottl#define L64854_CHANNEL_ENET 2 51130293Sscottl#define L64854_CHANNEL_PP 3 52130293Sscottl void *sc_client; 53130293Sscottl 54182876Smarius int sc_active; /* DMA active? */ 55130293Sscottl bus_dmamap_t sc_dmamap; /* DMA map for bus_dma_* */ 56130293Sscottl 57130293Sscottl bus_dma_tag_t sc_parent_dmat; 58130293Sscottl bus_dma_tag_t sc_buffer_dmat; 59130293Sscottl int sc_datain; 60130293Sscottl size_t sc_dmasize; 61130293Sscottl caddr_t *sc_dmaaddr; 62130293Sscottl size_t *sc_dmalen; 63130293Sscottl 64130293Sscottl void (*reset)(struct lsi64854_softc *);/* reset routine */ 65130293Sscottl int (*setup)(struct lsi64854_softc *, caddr_t *, size_t *, 66130293Sscottl int, size_t *); /* DMA setup */ 67130293Sscottl int (*intr)(void *); /* interrupt handler */ 68130293Sscottl 69130293Sscottl u_int sc_dmactl; 70155089Smarius int sc_dodrain; 71130293Sscottl}; 72130293Sscottl 73182876Smarius#define L64854_GCSR(sc) bus_read_4((sc)->sc_res, L64854_REG_CSR) 74182876Smarius#define L64854_SCSR(sc, csr) bus_write_4((sc)->sc_res, L64854_REG_CSR, csr) 75130293Sscottl 76130293Sscottl/* 77130293Sscottl * DMA engine interface functions. 78130293Sscottl */ 79130293Sscottl#define DMA_RESET(sc) (((sc)->reset)(sc)) 80130293Sscottl#define DMA_INTR(sc) (((sc)->intr)(sc)) 81130293Sscottl#define DMA_SETUP(sc, a, l, d, s) (((sc)->setup)(sc, a, l, d, s)) 82130293Sscottl#define DMA_ISACTIVE(sc) ((sc)->sc_active) 83130293Sscottl 84130293Sscottl#define DMA_ENINTR(sc) do { \ 85145190Smarius uint32_t csr = L64854_GCSR(sc); \ 86130293Sscottl csr |= L64854_INT_EN; \ 87130293Sscottl L64854_SCSR(sc, csr); \ 88130293Sscottl} while (0) 89130293Sscottl 90130293Sscottl#define DMA_ISINTR(sc) (L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND)) 91130293Sscottl 92130293Sscottl#define DMA_GO(sc) do { \ 93145190Smarius uint32_t csr = L64854_GCSR(sc); \ 94130293Sscottl csr |= D_EN_DMA; \ 95130293Sscottl L64854_SCSR(sc, csr); \ 96130293Sscottl sc->sc_active = 1; \ 97130293Sscottl} while (0) 98130293Sscottl 99146392Smariusint lsi64854_attach(struct lsi64854_softc *); 100146392Smariusint lsi64854_detach(struct lsi64854_softc *); 101