lsi64854var.h revision 219567
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 219567 2011-03-12 14:33:32Z 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;
52130293Sscottl	int			sc_datain;
53130293Sscottl	size_t			sc_dmasize;
54130293Sscottl	caddr_t			*sc_dmaaddr;
55130293Sscottl	size_t			*sc_dmalen;
56130293Sscottl
57130293Sscottl	void	(*reset)(struct lsi64854_softc *);/* reset routine */
58130293Sscottl	int	(*setup)(struct lsi64854_softc *, caddr_t *, size_t *,
59130293Sscottl			 int, size_t *);	/* DMA setup */
60130293Sscottl	int	(*intr)(void *);		/* interrupt handler */
61130293Sscottl
62130293Sscottl	u_int 			sc_dmactl;
63155089Smarius	int			sc_dodrain;
64130293Sscottl};
65130293Sscottl
66182876Smarius#define L64854_GCSR(sc)		bus_read_4((sc)->sc_res, L64854_REG_CSR)
67182876Smarius#define L64854_SCSR(sc, csr)	bus_write_4((sc)->sc_res, L64854_REG_CSR, csr)
68130293Sscottl
69130293Sscottl/*
70130293Sscottl * DMA engine interface functions.
71130293Sscottl */
72130293Sscottl#define DMA_RESET(sc)			(((sc)->reset)(sc))
73130293Sscottl#define DMA_INTR(sc)			(((sc)->intr)(sc))
74130293Sscottl#define DMA_SETUP(sc, a, l, d, s)	(((sc)->setup)(sc, a, l, d, s))
75130293Sscottl#define DMA_ISACTIVE(sc)		((sc)->sc_active)
76130293Sscottl
77130293Sscottl#define DMA_ENINTR(sc) do {			\
78145190Smarius	uint32_t csr = L64854_GCSR(sc);		\
79130293Sscottl	csr |= L64854_INT_EN;			\
80130293Sscottl	L64854_SCSR(sc, csr);			\
81130293Sscottl} while (0)
82130293Sscottl
83130293Sscottl#define DMA_ISINTR(sc)	(L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND))
84130293Sscottl
85130293Sscottl#define DMA_GO(sc) do {				\
86145190Smarius	uint32_t csr = L64854_GCSR(sc);		\
87130293Sscottl	csr |= D_EN_DMA;			\
88130293Sscottl	L64854_SCSR(sc, csr);			\
89130293Sscottl	sc->sc_active = 1;			\
90130293Sscottl} while (0)
91130293Sscottl
92146392Smariusint	lsi64854_attach(struct lsi64854_softc *);
93146392Smariusint	lsi64854_detach(struct lsi64854_softc *);
94