dmareg.h revision 1.3 1 /*
2 * Copyright (c) 1982, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: @(#)dmareg.h 8.1 (Berkeley) 6/10/93
34 * $Id: dmareg.h,v 1.3 1994/05/23 05:58:49 mycroft Exp $
35 */
36
37 #include <hp300/dev/iotypes.h> /* XXX */
38
39 /*
40 * Hardware layout for the 98620[ABC]:
41 * 98620A (old 320s?): byte/word DMA in up to 64K chunks
42 * 98620B (320s only): 98620A with programmable IPL
43 * 98620C (all others): byte/word/longword DMA in up to 4Gb chunks
44 */
45
46 struct dmaBdevice {
47 v_char *dmaB_addr;
48 vu_short dmaB_count;
49 vu_short dmaB_cmd;
50 #define dmaB_stat dmaB_cmd
51 };
52
53 struct dmadevice {
54 v_char *dma_addr;
55 vu_int dma_count;
56 vu_short dma_cmd;
57 vu_short dma_stat;
58 };
59
60 struct dmareg {
61 struct dmaBdevice dma_Bchan0;
62 struct dmaBdevice dma_Bchan1;
63 /* the rest are 98620C specific */
64 v_char dma_id[4];
65 vu_char dma_cr;
66 char dma_pad1[0xEB];
67 struct dmadevice dma_chan0;
68 char dma_pad2[0xF4];
69 struct dmadevice dma_chan1;
70 };
71
72 #define NDMA 2
73
74 /* intr level must be >= level of any device using dma. i.e., splbio */
75 #define DMAINTLVL 5
76
77 /* addresses */
78 #define DMA_BASE IIOV(0x500000)
79
80 /* command bits */
81 #define DMA_ENAB 0x0001
82 #define DMA_WORD 0x0002
83 #define DMA_WRT 0x0004
84 #define DMA_PRI 0x0008
85 #define DMA_IPL(x) (((x) - 3) << 4)
86 #define DMA_LWORD 0x0100
87 #define DMA_START 0x8000
88
89 /* status bits */
90 #define DMA_ARMED 0x01
91 #define DMA_INTR 0x02
92 #define DMA_ACC 0x04
93 #define DMA_HALT 0x08
94 #define DMA_BERR 0x10
95 #define DMA_ALIGN 0x20
96 #define DMA_WRAP 0x40
97
98 #ifdef KERNEL
99 /*
100 * Macros to attempt to hide the HW differences between the 98620B DMA
101 * board and the 1TQ4-0401 DMA chip (68020C "board"). The latter
102 * includes emulation registers for the former but you need to access
103 * the "native-mode" registers directly in order to do 32-bit DMA.
104 *
105 * DMA_CLEAR: Clear interrupt on DMA board. We just use the
106 * emulation registers on the 98620C as that is easiest.
107 * DMA_STAT: Read status register. Again, we always read the
108 * emulation register. Someday we might want to
109 * look at the 98620C status to get the extended bits.
110 * DMA_ARM: Load address, count and kick-off DMA.
111 */
112 #define DMA_CLEAR(dc) { v_int dmaclr = (int)dc->sc_Bhwaddr->dmaB_addr; }
113 #define DMA_STAT(dc) dc->sc_Bhwaddr->dmaB_stat
114
115 #if defined(HP320)
116 #define DMA_ARM(dc) \
117 if (dc->sc_type == DMA_B) { \
118 register struct dmaBdevice *dma = dc->sc_Bhwaddr; \
119 dma->dmaB_addr = dc->sc_cur->dc_addr; \
120 dma->dmaB_count = dc->sc_cur->dc_count - 1; \
121 dma->dmaB_cmd = dc->sc_cmd; \
122 } else { \
123 register struct dmadevice *dma = dc->sc_hwaddr; \
124 dma->dma_addr = dc->sc_cur->dc_addr; \
125 dma->dma_count = dc->sc_cur->dc_count - 1; \
126 dma->dma_cmd = dc->sc_cmd; \
127 }
128 #else
129 #define DMA_ARM(dc) \
130 { \
131 register struct dmadevice *dma = dc->sc_hwaddr; \
132 dma->dma_addr = dc->sc_cur->dc_addr; \
133 dma->dma_count = dc->sc_cur->dc_count - 1; \
134 dma->dma_cmd = dc->sc_cmd; \
135 }
136 #endif
137 #endif
138