xref: /csrg-svn/sys/hp300/dev/dmareg.h (revision 45483)
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*45483Smckusick  *	@(#)dmareg.h	7.2 (Berkeley) 11/04/90
841480Smckusick  */
941480Smckusick 
1041480Smckusick /*
1141480Smckusick  * Hardware layout for the 98620[ABC]:
1241480Smckusick  *	98620A (old 320s?):	byte/word DMA in up to 64K chunks
1341480Smckusick  *	98620B (320s only):	98620A with programmable IPL
1441480Smckusick  *	98620C (all others):	byte/word/longword DMA in up to 4Gb chunks
1541480Smckusick  */
1641480Smckusick #define v_char		volatile char
1741480Smckusick #define	v_int		volatile int
1841480Smckusick #define vu_char		volatile u_char
1941480Smckusick #define vu_short	volatile u_short
2041480Smckusick #define vu_int		volatile u_int
2141480Smckusick 
2241480Smckusick struct	dmaBdevice {
2341480Smckusick 	v_char		*dmaB_addr;
2441480Smckusick 	vu_short	dmaB_count;
2541480Smckusick 	vu_short	dmaB_cmd;
2641480Smckusick #define	dmaB_stat	dmaB_cmd
2741480Smckusick };
2841480Smckusick 
2941480Smckusick struct	dmadevice {
3041480Smckusick 	v_char		*dma_addr;
3141480Smckusick 	vu_int		dma_count;
3241480Smckusick 	vu_short	dma_cmd;
3341480Smckusick 	vu_short	dma_stat;
3441480Smckusick };
3541480Smckusick 
3641480Smckusick struct	dmareg {
3741480Smckusick 	struct dmaBdevice dma_Bchan0;
3841480Smckusick 	struct dmaBdevice dma_Bchan1;
3941480Smckusick /* the rest are 98620C specific */
4041480Smckusick 	v_char		  dma_id[4];
4141480Smckusick 	vu_char		  dma_cr;
4241480Smckusick 	char		  dma_pad1[0xEB];
4341480Smckusick 	struct dmadevice  dma_chan0;
4441480Smckusick 	char		  dma_pad2[0xF4];
4541480Smckusick 	struct dmadevice  dma_chan1;
4641480Smckusick };
4741480Smckusick 
4841480Smckusick #define	NDMA		2
4941480Smckusick 
5041480Smckusick /* intr level must be >= level of any device using dma.  i.e., splbio */
5141480Smckusick #define	DMAINTLVL	5
5241480Smckusick 
5341480Smckusick /* addresses */
5441480Smckusick #define	DMA_BASE	IOV(0x500000)
5541480Smckusick 
5641480Smckusick /* command bits */
5741480Smckusick #define	DMA_ENAB	0x0001
5841480Smckusick #define	DMA_WORD	0x0002
5941480Smckusick #define	DMA_WRT		0x0004
6041480Smckusick #define	DMA_PRI		0x0008
6141480Smckusick #define	DMA_IPL(x)	(((x) - 3) << 4)
6241480Smckusick #define DMA_LWORD	0x0100
6341480Smckusick #define DMA_START	0x8000
6441480Smckusick 
6541480Smckusick /* status bits */
6641480Smckusick #define	DMA_ARMED	0x01
6741480Smckusick #define	DMA_INTR	0x02
6841480Smckusick #define DMA_ACC		0x04
6941480Smckusick #define DMA_HALT	0x08
7041480Smckusick #define DMA_BERR	0x10
7141480Smckusick #define DMA_ALIGN	0x20
7241480Smckusick #define DMA_WRAP	0x40
7341480Smckusick 
7441480Smckusick #ifdef KERNEL
7541480Smckusick /*
7641480Smckusick  * Macros to attempt to hide the HW differences between the 98620B DMA
7741480Smckusick  * board and the 1TQ4-0401 DMA chip (68020C "board").  The latter
7841480Smckusick  * includes emulation registers for the former but you need to access
7941480Smckusick  * the "native-mode" registers directly in order to do 32-bit DMA.
8041480Smckusick  *
8141480Smckusick  * DMA_CLEAR:	Clear interrupt on DMA board.  We just use the
8241480Smckusick  *		emulation registers on the 98620C as that is easiest.
8341480Smckusick  * DMA_STAT:	Read status register.  Again, we always read the
8441480Smckusick  *		emulation register.  Someday we might want to
8541480Smckusick  *		look at the 98620C status to get the extended bits.
8641480Smckusick  * DMA_ARM:	Load address, count and kick-off DMA.
8741480Smckusick  */
8841480Smckusick #define	DMA_CLEAR(dc)	{ v_int dmaclr = (int)dc->sc_Bhwaddr->dmaB_addr; }
8941480Smckusick #define	DMA_STAT(dc)	dc->sc_Bhwaddr->dmaB_stat
9041480Smckusick 
9141480Smckusick #if defined(HP320)
92*45483Smckusick #define	DMA_ARM(dc)	\
9341480Smckusick 	if (dc->sc_type == DMA_B) { \
9441480Smckusick 		register struct dmaBdevice *dma = dc->sc_Bhwaddr; \
95*45483Smckusick 		dma->dmaB_addr = dc->sc_cur->dc_addr; \
96*45483Smckusick 		dma->dmaB_count = dc->sc_cur->dc_count - 1; \
9741480Smckusick 		dma->dmaB_cmd = dc->sc_cmd; \
9841480Smckusick 	} else { \
9941480Smckusick 		register struct dmadevice *dma = dc->sc_hwaddr; \
100*45483Smckusick 		dma->dma_addr = dc->sc_cur->dc_addr; \
101*45483Smckusick 		dma->dma_count = dc->sc_cur->dc_count - 1; \
10241480Smckusick 		dma->dma_cmd = dc->sc_cmd; \
10341480Smckusick 	}
10441480Smckusick #else
105*45483Smckusick #define	DMA_ARM(dc)	\
10641480Smckusick 	{ \
10741480Smckusick 		register struct dmadevice *dma = dc->sc_hwaddr; \
108*45483Smckusick 		dma->dma_addr = dc->sc_cur->dc_addr; \
109*45483Smckusick 		dma->dma_count = dc->sc_cur->dc_count - 1; \
11041480Smckusick 		dma->dma_cmd = dc->sc_cmd; \
11141480Smckusick 	}
11241480Smckusick #endif
11341480Smckusick #endif
114