dmacvar.h revision 1.2 1 /* $NetBSD: dmacvar.h,v 1.2 1999/03/16 16:30:17 minoura Exp $ */
2
3 /*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Minoura Makoto.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Hitachi HD63450 (= Motorola MC68450) DMAC driver for x68k.
41 */
42
43 #include <dev/ic/mc68450reg.h>
44
45
46 typedef int (*dmac_intr_handler_t) __P((void*));
47
48 /*
49 * Struct that holds the channel status.
50 * Embedded in the device softc for each channel.
51 */
52 struct dmac_channel_stat {
53 int ch_channel; /* channel number */
54 char ch_name[8]; /* user device name */
55 bus_space_handle_t ch_bht; /* bus_space handle */
56 int ch_dcr; /* device description */
57 int ch_ocr; /* operation size, request mode */
58 int ch_normalv; /* normal interrupt vector */
59 int ch_errorv; /* error interrupt vector */
60 dmac_intr_handler_t ch_normal; /* normal interrupt handler */
61 dmac_intr_handler_t ch_error; /* error interrupt handler */
62 void *ch_normalarg;
63 void *ch_errorarg;
64 struct dmac_dma_xfer *ch_xfer_in_progress;
65 void *ch_map; /* transfer map for arraychain mode */
66 struct device *ch_softc; /* device softc link */
67 };
68
69 /*
70 * DMAC softc
71 */
72 struct dmac_softc {
73 struct device sc_dev;
74
75 bus_space_tag_t sc_bst;
76 bus_space_handle_t sc_bht;
77
78 struct dmac_channel_stat sc_channels[DMAC_NCHAN];
79 };
80
81 /*
82 * Structure that describes a single transfer.
83 */
84 struct dmac_dma_xfer {
85 struct dmac_channel_stat *dx_channel; /* channel structure */
86 bus_dmamap_t dx_dmamap; /* dmamap tag */
87 bus_dma_tag_t dx_tag; /* dma tag for the transfer */
88 int dx_ocr; /* direction */
89 int dx_scr; /* SCR value */
90 void *dx_device; /* (initial) device address */
91 int dx_done; /* transfer count */
92 };
93
94
95 #define DMAC_ADDR 0xe84000
96
97 #define DMAC_MAXSEGSZ 0xff00
98 #define DMAC_BOUNDARY 0
99
100 struct dmac_channel_stat *dmac_alloc_channel __P((struct device*, int, char*,
101 int,
102 dmac_intr_handler_t, void*,
103 int,
104 dmac_intr_handler_t, void*));
105 /* ch, name, normalv, normal, errorv, error */
106 int dmac_free_channel __P((struct device*, int, void*));
107 /* ch, channel */
108 struct dmac_dma_xfer *dmac_prepare_xfer __P((struct dmac_channel_stat*,
109 bus_dma_tag_t,
110 bus_dmamap_t,
111 int, int, void*));
112 /* chan, dmat, map, dir, sequence, dar */
113 #define dmac_finish_xfer(xfer) free(xfer, M_DEVBUF)
114 int dmac_start_xfer __P((struct device*, struct dmac_dma_xfer*));
115