1/*	$NetBSD: nextdmavar.h,v 1.14 2005/12/11 12:18:25 christos Exp $	*/
2/*
3 * Copyright (c) 1998 Darrin B. Jewell
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27
28struct nextdma_channel {
29	const char		*nd_name;
30	int			nd_base;
31	int			nd_size;
32	u_long			nd_intr;
33	int			(*nd_intrfunc)(void *);
34};
35
36struct nextdma_config {
37	/* This is called to get another map to dma */
38	bus_dmamap_t		(*nd_continue_cb)(void *);
39	/* This is called when a map has completed dma */
40	void			(*nd_completed_cb)(bus_dmamap_t, void *);
41	/* This is called when dma shuts down */
42	void			(*nd_shutdown_cb) (void *);
43	/* callback argument */
44	void			*nd_cb_arg;
45};
46
47struct nextdma_status {
48	bus_dmamap_t	nd_map;			/* map currently in dd_next */
49	int		nd_idx;			/* idx of segment currently in dd_next */
50	bus_dmamap_t	nd_map_cont;		/* map needed to continue DMA */
51	int		nd_idx_cont;		/* segment index to continue DMA */
52	int		nd_exception;
53};
54
55struct nextdma_softc {
56	struct device		sc_dev;
57	struct nextdma_channel	*sc_chan;
58	bus_space_handle_t	sc_bsh;		/* bus space handle */
59	bus_space_tag_t		sc_bst;		/* bus space tag */
60	bus_dma_tag_t		sc_dmat;
61	struct nextdma_config	sc_conf;
62	struct nextdma_status	sc_stat;
63	struct evcnt		sc_intrcnt;
64};
65
66#define nextdma_setconf(nsc, elem, val) nsc->sc_conf.nd_##elem = (val)
67
68/* Configure the interface & initialize private structure vars */
69void nextdma_config(struct nextdma_softc *);
70void nextdma_init(struct nextdma_softc *);
71void nextdma_start(struct nextdma_softc *, u_long);
72
73/* query to see if nextdma is finished */
74int nextdma_finished(struct nextdma_softc *);
75void nextdma_reset(struct nextdma_softc *);
76
77void nextdma_print(struct nextdma_softc *);
78
79struct nextdma_softc *nextdma_findchannel(const char *);
80