lsi64854var.h revision 146392
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 146392 2005-05-19 14:51:10Z marius $ */ 40130293Sscottl 41130293Sscottlstruct lsi64854_softc { 42130293Sscottl device_t sc_dev; 43130293Sscottl 44130293Sscottl int sc_rid; 45130293Sscottl struct resource *sc_res; 46130293Sscottl bus_space_handle_t sc_regh; 47130293Sscottl bus_space_tag_t sc_regt; 48130293Sscottl u_int sc_rev; /* revision */ 49130293Sscottl int sc_burst; /* max suported burst size */ 50130293Sscottl 51130293Sscottl int sc_channel; 52130293Sscottl#define L64854_CHANNEL_SCSI 1 53130293Sscottl#define L64854_CHANNEL_ENET 2 54130293Sscottl#define L64854_CHANNEL_PP 3 55130293Sscottl void *sc_client; 56130293Sscottl 57130293Sscottl int sc_active; /* DMA active ? */ 58130293Sscottl bus_dmamap_t sc_dmamap; /* DMA map for bus_dma_* */ 59130293Sscottl 60130293Sscottl bus_dma_tag_t sc_parent_dmat; 61130293Sscottl bus_dma_tag_t sc_buffer_dmat; 62130293Sscottl int sc_datain; 63130293Sscottl size_t sc_dmasize; 64130293Sscottl caddr_t *sc_dmaaddr; 65130293Sscottl size_t *sc_dmalen; 66130293Sscottl 67130293Sscottl void (*reset)(struct lsi64854_softc *);/* reset routine */ 68130293Sscottl int (*setup)(struct lsi64854_softc *, caddr_t *, size_t *, 69130293Sscottl int, size_t *); /* DMA setup */ 70130293Sscottl int (*intr)(void *); /* interrupt handler */ 71130293Sscottl 72146392Smarius driver_intr_t *sc_intrchain; /* next handler in intr chain */ 73146392Smarius void *sc_intrchainarg; /* arg for next intr handler */ 74130293Sscottl 75130293Sscottl u_int sc_dmactl; 76130293Sscottl}; 77130293Sscottl 78130293Sscottl#define L64854_GCSR(sc) \ 79130293Sscottl (bus_space_read_4((sc)->sc_regt, (sc)->sc_regh, L64854_REG_CSR)) 80130293Sscottl 81130293Sscottl#define L64854_SCSR(sc, csr) \ 82130293Sscottl bus_space_write_4((sc)->sc_regt, (sc)->sc_regh, L64854_REG_CSR, csr) 83130293Sscottl 84130293Sscottl 85130293Sscottl/* 86130293Sscottl * DMA engine interface functions. 87130293Sscottl */ 88130293Sscottl#define DMA_RESET(sc) (((sc)->reset)(sc)) 89130293Sscottl#define DMA_INTR(sc) (((sc)->intr)(sc)) 90130293Sscottl#define DMA_SETUP(sc, a, l, d, s) (((sc)->setup)(sc, a, l, d, s)) 91130293Sscottl 92130293Sscottl#define DMA_ISACTIVE(sc) ((sc)->sc_active) 93130293Sscottl 94130293Sscottl#define DMA_ENINTR(sc) do { \ 95145190Smarius uint32_t csr = L64854_GCSR(sc); \ 96130293Sscottl csr |= L64854_INT_EN; \ 97130293Sscottl L64854_SCSR(sc, csr); \ 98130293Sscottl} while (0) 99130293Sscottl 100130293Sscottl#define DMA_ISINTR(sc) (L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND)) 101130293Sscottl 102130293Sscottl#define DMA_GO(sc) do { \ 103145190Smarius uint32_t csr = L64854_GCSR(sc); \ 104130293Sscottl csr |= D_EN_DMA; \ 105130293Sscottl L64854_SCSR(sc, csr); \ 106130293Sscottl sc->sc_active = 1; \ 107130293Sscottl} while (0) 108130293Sscottl 109130293Sscottl 110146392Smariusint lsi64854_attach(struct lsi64854_softc *); 111146392Smariusint lsi64854_detach(struct lsi64854_softc *); 112130293Sscottlint lsi64854_scsi_intr(void *); 113130293Sscottlint lsi64854_enet_intr(void *); 114130293Sscottlint lsi64854_pp_intr(void *); 115