summaryrefslogtreecommitdiff
path: root/sys/arch/pc532/dev/dpreg.h
blob: df1af1257bd817637aa568eade675a029588040d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*	$NetBSD: dpreg.h,v 1.6 1994/10/26 08:24:11 cgd Exp $	*/

/* 
 * Copyright (c) 1993 Philip A. Nelson.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Philip A. Nelson.
 * 4. The name of Philip A. Nelson may not be used to endorse or promote
 *    products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *	dp.h:  defines for the dp driver.
 */

/* Most of this comes from the Minix dp driver by Bruce Culbertson. */

/* NCR 8490 SCSI controller registers
 */
#define DP_CTL		0xffd00000	/* base for control registers */
#define DP_DMA		0xffe00000	/* base for data registers */
#define DP_DMA_EOP	0xffeff000	/* SCSI DMA with EOP asserted */
#define DP_CURDATA	(DP_CTL+0)
#define DP_OUTDATA	(DP_CTL+0)
#define DP_ICMD		(DP_CTL+1)
#define DP_MODE		(DP_CTL+2)
#define DP_TCMD		(DP_CTL+3)
#define DP_STAT1	(DP_CTL+4)
#define DP_SER		(DP_CTL+4)
#define DP_STAT2	(DP_CTL+5)
#define DP_START_SEND	(DP_CTL+5)
#define DP_INDATA	(DP_CTL+6)
#define DP_EMR_ISR	(DP_CTL+7)

/* Bits in NCR 8490 registers
 */
#define DP_A_RST	0x80
#define DP_A_SEL	0x04
#define DP_S_SEL	0x02
#define DP_S_REQ	0x20
#define DP_S_BSY	0x40
#define DP_S_BSYERR	0x04
#define DP_S_PHASE	0x08
#define DP_S_IRQ	0x10
#define DP_S_DRQ	0x40
#define DP_TCMD_EDMA	0x80		/* true end of dma in tcmd */
#define DP_M_DMA	0x02
#define DP_M_BSY	0x04
#define DP_M_EDMA	0x08
#define DP_ENABLE_DB	0x01
#define DP_EMODE	0x40		/* enhanced mode */
#define DP_EF_NOP	0x00		/* enhanced functions */
#define DP_EF_ARB	0x01
#define DP_EF_RESETIP	0x02
#define DP_EF_START_RCV	0x04
#define DP_EF_ISR_NEXT	0x06
#define DP_EMR_APHS	0x80
#define DP_ISR_BSYERR	0x04
#define DP_ISR_APHS	0x08
#define DP_ISR_DPHS	0x10
#define DP_ISR_EDMA	0x20
#define DP_INT_MASK	(~(DP_ISR_APHS | DP_ISR_BSYERR | DP_ISR_EDMA))

#define DP_PHASE_DATAO	0	/* Data out */
#define DP_PHASE_DATAI	1	/* Data in */
#define DP_PHASE_CMD	2	/* CMD out */
#define DP_PHASE_STATUS	3	/* Status in */
#define DP_PHASE_MSGO	6	/* Message out */
#define DP_PHASE_MSGI	7	/* Message in */

#define DP_PHASE_NONE	4	/* will mismatch all phases (??) */

/* Driver state. Helps interrupt code decide what to do next. */
#define DP_DVR_READY	0
#define DP_DVR_STARTED  1
#define DP_DVR_ARB	2
#define DP_DVR_CMD	3
#define DP_DVR_DATA	4
#define DP_DVR_STAT	5
#define DP_DVR_MSGI	6
#define DP_DVR_SENSE	7

#define dp_clear_isr()			/* clear 8490 interrupts */	\
      WR_ADR (u_char, DP_EMR_ISR, DP_EF_RESETIP);			\
      WR_ADR (u_char, DP_EMR_ISR, DP_EF_NOP | DP_EMR_APHS);

/* Status of interrupt routine.
 */
#define ISR_NOTDONE	0
#define ISR_OK		1
#define ISR_BSYERR	2
#define ISR_RSTERR	3
#define ISR_BADPHASE	4
#define ISR_TIMEOUT	5
#define ISR_DMACNTERR	6

#define ICU_ADR		0xfffffe00
#define ICU_IO		(ICU_ADR+20)
#define ICU_DIR		(ICU_ADR+21)
#define ICU_DATA	(ICU_ADR+19)
#define ICU_SCSI_BIT	0x80

/* Miscellaneous
 */
#define WAIT_MUL	1000	/* Estimate! .. for polling. */

#define OK		1
#define NOT_OK		0