xref: /openbsd-src/sys/dev/ic/lsi64854var.h (revision d874cce4b1d9fe6b41c9e4f2117a77d8a4a37b92)
1*d874cce4Sray /*	$OpenBSD: lsi64854var.h,v 1.7 2008/06/26 05:42:15 ray Exp $	*/
28f375c82Sjason /*	$NetBSD: lsi64854var.h,v 1.4 2001/03/29 02:58:39 petrov Exp $ */
38f375c82Sjason 
48f375c82Sjason /*-
58f375c82Sjason  * Copyright (c) 1998 The NetBSD Foundation, Inc.
68f375c82Sjason  * All rights reserved.
78f375c82Sjason  *
88f375c82Sjason  * This code is derived from software contributed to The NetBSD Foundation
98f375c82Sjason  * by Paul Kranenburg.
108f375c82Sjason  *
118f375c82Sjason  * Redistribution and use in source and binary forms, with or without
128f375c82Sjason  * modification, are permitted provided that the following conditions
138f375c82Sjason  * are met:
148f375c82Sjason  * 1. Redistributions of source code must retain the above copyright
158f375c82Sjason  *    notice, this list of conditions and the following disclaimer.
168f375c82Sjason  * 2. Redistributions in binary form must reproduce the above copyright
178f375c82Sjason  *    notice, this list of conditions and the following disclaimer in the
188f375c82Sjason  *    documentation and/or other materials provided with the distribution.
198f375c82Sjason  *
208f375c82Sjason  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
218f375c82Sjason  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
228f375c82Sjason  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
238f375c82Sjason  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
248f375c82Sjason  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
258f375c82Sjason  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
268f375c82Sjason  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
278f375c82Sjason  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
288f375c82Sjason  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
298f375c82Sjason  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
308f375c82Sjason  * POSSIBILITY OF SUCH DAMAGE.
318f375c82Sjason  */
328f375c82Sjason 
338f375c82Sjason struct lsi64854_softc {
348f375c82Sjason 	struct device		sc_dev;		/* base device */
358f375c82Sjason 	bus_space_tag_t		sc_bustag;	/* bus tags */
368f375c82Sjason 	bus_dma_tag_t		sc_dmatag;
378f375c82Sjason 
388f375c82Sjason 	bus_space_handle_t	sc_regs;	/* the registers */
398f375c82Sjason 	u_int			sc_rev;		/* revision */
40e4d25771Stodd 	int			sc_burst;	/* max supported burst size */
418f375c82Sjason 
428f375c82Sjason 	int			sc_channel;
438f375c82Sjason #define L64854_CHANNEL_SCSI	1
448f375c82Sjason #define L64854_CHANNEL_ENET	2
458f375c82Sjason #define L64854_CHANNEL_PP	3
468f375c82Sjason 	void			*sc_client;
478f375c82Sjason 
488f375c82Sjason 	int			sc_active;	/* DMA active ? */
498f375c82Sjason 	bus_dmamap_t		sc_dmamap;	/* DMA map for bus_dma_* */
508f375c82Sjason 	caddr_t			sc_dvmaaddr;	/* DVMA cookie */
518f375c82Sjason 	size_t			sc_dmasize;
528f375c82Sjason 	caddr_t			*sc_dmaaddr;
538f375c82Sjason 	size_t			*sc_dmalen;
548f375c82Sjason 
55c4071fd1Smillert 	void	(*reset)(struct lsi64854_softc *);/* reset routine */
56c4071fd1Smillert 	int	(*setup)(struct lsi64854_softc *, caddr_t *, size_t *,
57c4071fd1Smillert 			      int, size_t *);	/* dma setup */
58c4071fd1Smillert 	int	(*intr)(void *);		/* interrupt handler */
598f375c82Sjason 
60c4071fd1Smillert 	int	(*sc_intrchain)(void *);	/* next handler in intr chain */
618f375c82Sjason 	void	*sc_intrchainarg;		/* arg for next intr handler */
628f375c82Sjason 
638f375c82Sjason 	u_int 			sc_dmactl;
648f375c82Sjason };
658f375c82Sjason 
668f375c82Sjason #define L64854_GCSR(sc)	\
678f375c82Sjason 	(bus_space_read_4((sc)->sc_bustag, (sc)->sc_regs, L64854_REG_CSR))
688f375c82Sjason 
698f375c82Sjason #define L64854_SCSR(sc, csr)	\
708f375c82Sjason 	bus_space_write_4((sc)->sc_bustag, (sc)->sc_regs, L64854_REG_CSR, csr)
718f375c82Sjason 
728f375c82Sjason 
738f375c82Sjason /*
748f375c82Sjason  * DMA engine interface functions.
758f375c82Sjason  */
768f375c82Sjason #define DMA_RESET(sc)			(((sc)->reset)(sc))
778f375c82Sjason #define DMA_INTR(sc)			(((sc)->intr)(sc))
788f375c82Sjason #define DMA_SETUP(sc, a, l, d, s)	(((sc)->setup)(sc, a, l, d, s))
798f375c82Sjason 
808f375c82Sjason #define DMA_ISACTIVE(sc)		((sc)->sc_active)
818f375c82Sjason 
828f375c82Sjason #define DMA_ENINTR(sc) do {			\
838f375c82Sjason 	u_int32_t csr = L64854_GCSR(sc);	\
848f375c82Sjason 	csr |= L64854_INT_EN;			\
858f375c82Sjason 	L64854_SCSR(sc, csr);			\
868f375c82Sjason } while (0)
878f375c82Sjason 
888f375c82Sjason #define DMA_ISINTR(sc)	(L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND))
898f375c82Sjason 
908f375c82Sjason #define DMA_GO(sc) do {				\
918f375c82Sjason 	u_int32_t csr = L64854_GCSR(sc);	\
928f375c82Sjason 	csr |= D_EN_DMA;			\
938f375c82Sjason 	L64854_SCSR(sc, csr);			\
948f375c82Sjason 	sc->sc_active = 1;			\
958f375c82Sjason } while (0)
968f375c82Sjason 
978f375c82Sjason 
9879d1ee1bSmiod int	lsi64854_attach(struct lsi64854_softc *);
99c4071fd1Smillert int	lsi64854_enet_intr(void *);
100