lsi64854var.h revision 226947
1219567Smarius/* $NetBSD: lsi64854var.h,v 1.12 2008/04/28 20:23:50 martin 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 * 19130293Sscottl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20130293Sscottl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21130293Sscottl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22130293Sscottl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23130293Sscottl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24130293Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25130293Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26130293Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27130293Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28130293Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29130293Sscottl * POSSIBILITY OF SUCH DAMAGE. 30130293Sscottl */ 31130293Sscottl 32130293Sscottl/* $FreeBSD: head/sys/sparc64/sbus/lsi64854var.h 226947 2011-10-30 21:17:42Z marius $ */ 33130293Sscottl 34130293Sscottlstruct lsi64854_softc { 35130293Sscottl device_t sc_dev; 36130293Sscottl 37130293Sscottl struct resource *sc_res; 38130293Sscottl u_int sc_rev; /* revision */ 39130293Sscottl int sc_burst; /* max suported burst size */ 40130293Sscottl 41130293Sscottl int sc_channel; 42130293Sscottl#define L64854_CHANNEL_SCSI 1 43130293Sscottl#define L64854_CHANNEL_ENET 2 44130293Sscottl#define L64854_CHANNEL_PP 3 45130293Sscottl void *sc_client; 46130293Sscottl 47182876Smarius int sc_active; /* DMA active? */ 48130293Sscottl bus_dmamap_t sc_dmamap; /* DMA map for bus_dma_* */ 49130293Sscottl 50130293Sscottl bus_dma_tag_t sc_parent_dmat; 51130293Sscottl bus_dma_tag_t sc_buffer_dmat; 52226947Smarius bus_size_t sc_maxdmasize; 53130293Sscottl int sc_datain; 54130293Sscottl size_t sc_dmasize; 55226381Smarius void **sc_dmaaddr; 56130293Sscottl size_t *sc_dmalen; 57130293Sscottl 58130293Sscottl void (*reset)(struct lsi64854_softc *);/* reset routine */ 59226381Smarius int (*setup)(struct lsi64854_softc *, void **, size_t *, 60226381Smarius int, size_t *); /* DMA setup */ 61130293Sscottl int (*intr)(void *); /* interrupt handler */ 62130293Sscottl 63130293Sscottl u_int sc_dmactl; 64155089Smarius int sc_dodrain; 65130293Sscottl}; 66130293Sscottl 67182876Smarius#define L64854_GCSR(sc) bus_read_4((sc)->sc_res, L64854_REG_CSR) 68182876Smarius#define L64854_SCSR(sc, csr) bus_write_4((sc)->sc_res, L64854_REG_CSR, csr) 69130293Sscottl 70130293Sscottl/* 71130293Sscottl * DMA engine interface functions. 72130293Sscottl */ 73130293Sscottl#define DMA_RESET(sc) (((sc)->reset)(sc)) 74130293Sscottl#define DMA_INTR(sc) (((sc)->intr)(sc)) 75130293Sscottl#define DMA_SETUP(sc, a, l, d, s) (((sc)->setup)(sc, a, l, d, s)) 76130293Sscottl#define DMA_ISACTIVE(sc) ((sc)->sc_active) 77130293Sscottl 78130293Sscottl#define DMA_ENINTR(sc) do { \ 79145190Smarius uint32_t csr = L64854_GCSR(sc); \ 80130293Sscottl csr |= L64854_INT_EN; \ 81130293Sscottl L64854_SCSR(sc, csr); \ 82226381Smarius} while (/* CONSTCOND */0) 83130293Sscottl 84130293Sscottl#define DMA_ISINTR(sc) (L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND)) 85130293Sscottl 86130293Sscottl#define DMA_GO(sc) do { \ 87145190Smarius uint32_t csr = L64854_GCSR(sc); \ 88130293Sscottl csr |= D_EN_DMA; \ 89130293Sscottl L64854_SCSR(sc, csr); \ 90130293Sscottl sc->sc_active = 1; \ 91226381Smarius} while (/* CONSTCOND */0) 92130293Sscottl 93146392Smariusint lsi64854_attach(struct lsi64854_softc *); 94146392Smariusint lsi64854_detach(struct lsi64854_softc *); 95