xref: /csrg-svn/sys/hp300/dev/dmareg.h (revision 53930)
141480Smckusick /*
241480Smckusick  * Copyright (c) 1982, 1990 The Regents of the University of California.
341480Smckusick  * All rights reserved.
441480Smckusick  *
541480Smckusick  * %sccs.include.redist.c%
641480Smckusick  *
7*53930Shibler  *	@(#)dmareg.h	7.4 (Berkeley) 06/05/92
841480Smckusick  */
941480Smckusick 
10*53930Shibler #ifdef KERNEL
11*53930Shibler #include "hp/dev/iotypes.h"	/* XXX */
12*53930Shibler #else
13*53930Shibler #include <hp/dev/iotypes.h>	/* XXX */
14*53930Shibler #endif
15*53930Shibler 
1641480Smckusick /*
1741480Smckusick  * Hardware layout for the 98620[ABC]:
1841480Smckusick  *	98620A (old 320s?):	byte/word DMA in up to 64K chunks
1941480Smckusick  *	98620B (320s only):	98620A with programmable IPL
2041480Smckusick  *	98620C (all others):	byte/word/longword DMA in up to 4Gb chunks
2141480Smckusick  */
2241480Smckusick 
2341480Smckusick struct	dmaBdevice {
2441480Smckusick 	v_char		*dmaB_addr;
2541480Smckusick 	vu_short	dmaB_count;
2641480Smckusick 	vu_short	dmaB_cmd;
2741480Smckusick #define	dmaB_stat	dmaB_cmd
2841480Smckusick };
2941480Smckusick 
3041480Smckusick struct	dmadevice {
3141480Smckusick 	v_char		*dma_addr;
3241480Smckusick 	vu_int		dma_count;
3341480Smckusick 	vu_short	dma_cmd;
3441480Smckusick 	vu_short	dma_stat;
3541480Smckusick };
3641480Smckusick 
3741480Smckusick struct	dmareg {
3841480Smckusick 	struct dmaBdevice dma_Bchan0;
3941480Smckusick 	struct dmaBdevice dma_Bchan1;
4041480Smckusick /* the rest are 98620C specific */
4141480Smckusick 	v_char		  dma_id[4];
4241480Smckusick 	vu_char		  dma_cr;
4341480Smckusick 	char		  dma_pad1[0xEB];
4441480Smckusick 	struct dmadevice  dma_chan0;
4541480Smckusick 	char		  dma_pad2[0xF4];
4641480Smckusick 	struct dmadevice  dma_chan1;
4741480Smckusick };
4841480Smckusick 
4941480Smckusick #define	NDMA		2
5041480Smckusick 
5141480Smckusick /* intr level must be >= level of any device using dma.  i.e., splbio */
5241480Smckusick #define	DMAINTLVL	5
5341480Smckusick 
5441480Smckusick /* addresses */
5549311Shibler #define	DMA_BASE	IIOV(0x500000)
5641480Smckusick 
5741480Smckusick /* command bits */
5841480Smckusick #define	DMA_ENAB	0x0001
5941480Smckusick #define	DMA_WORD	0x0002
6041480Smckusick #define	DMA_WRT		0x0004
6141480Smckusick #define	DMA_PRI		0x0008
6241480Smckusick #define	DMA_IPL(x)	(((x) - 3) << 4)
6341480Smckusick #define DMA_LWORD	0x0100
6441480Smckusick #define DMA_START	0x8000
6541480Smckusick 
6641480Smckusick /* status bits */
6741480Smckusick #define	DMA_ARMED	0x01
6841480Smckusick #define	DMA_INTR	0x02
6941480Smckusick #define DMA_ACC		0x04
7041480Smckusick #define DMA_HALT	0x08
7141480Smckusick #define DMA_BERR	0x10
7241480Smckusick #define DMA_ALIGN	0x20
7341480Smckusick #define DMA_WRAP	0x40
7441480Smckusick 
7541480Smckusick #ifdef KERNEL
7641480Smckusick /*
7741480Smckusick  * Macros to attempt to hide the HW differences between the 98620B DMA
7841480Smckusick  * board and the 1TQ4-0401 DMA chip (68020C "board").  The latter
7941480Smckusick  * includes emulation registers for the former but you need to access
8041480Smckusick  * the "native-mode" registers directly in order to do 32-bit DMA.
8141480Smckusick  *
8241480Smckusick  * DMA_CLEAR:	Clear interrupt on DMA board.  We just use the
8341480Smckusick  *		emulation registers on the 98620C as that is easiest.
8441480Smckusick  * DMA_STAT:	Read status register.  Again, we always read the
8541480Smckusick  *		emulation register.  Someday we might want to
8641480Smckusick  *		look at the 98620C status to get the extended bits.
8741480Smckusick  * DMA_ARM:	Load address, count and kick-off DMA.
8841480Smckusick  */
8941480Smckusick #define	DMA_CLEAR(dc)	{ v_int dmaclr = (int)dc->sc_Bhwaddr->dmaB_addr; }
9041480Smckusick #define	DMA_STAT(dc)	dc->sc_Bhwaddr->dmaB_stat
9141480Smckusick 
9241480Smckusick #if defined(HP320)
9345483Smckusick #define	DMA_ARM(dc)	\
9441480Smckusick 	if (dc->sc_type == DMA_B) { \
9541480Smckusick 		register struct dmaBdevice *dma = dc->sc_Bhwaddr; \
9645483Smckusick 		dma->dmaB_addr = dc->sc_cur->dc_addr; \
9745483Smckusick 		dma->dmaB_count = dc->sc_cur->dc_count - 1; \
9841480Smckusick 		dma->dmaB_cmd = dc->sc_cmd; \
9941480Smckusick 	} else { \
10041480Smckusick 		register struct dmadevice *dma = dc->sc_hwaddr; \
10145483Smckusick 		dma->dma_addr = dc->sc_cur->dc_addr; \
10245483Smckusick 		dma->dma_count = dc->sc_cur->dc_count - 1; \
10341480Smckusick 		dma->dma_cmd = dc->sc_cmd; \
10441480Smckusick 	}
10541480Smckusick #else
10645483Smckusick #define	DMA_ARM(dc)	\
10741480Smckusick 	{ \
10841480Smckusick 		register struct dmadevice *dma = dc->sc_hwaddr; \
10945483Smckusick 		dma->dma_addr = dc->sc_cur->dc_addr; \
11045483Smckusick 		dma->dma_count = dc->sc_cur->dc_count - 1; \
11141480Smckusick 		dma->dma_cmd = dc->sc_cmd; \
11241480Smckusick 	}
11341480Smckusick #endif
11441480Smckusick #endif
115