xref: /netbsd-src/sys/dev/ic/wdcreg.h (revision ae9172d6cd9432a6a1a56760d86b32c57a66c39c)
1 /*	$NetBSD: wdcreg.h,v 1.11 1994/11/23 07:56:52 mycroft Exp $	*/
2 
3 /*-
4  * Copyright (c) 1991 The Regents of the University of California.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * William Jolitz.
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 University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)wdreg.h	7.1 (Berkeley) 5/9/91
39  */
40 
41 /*
42  * Disk Controller register definitions.
43  */
44 #define	wd_data		0x000	/* data register (R/W - 16 bits) */
45 #define wd_error	0x001	/* error register (R) */
46 #define	wd_precomp	0x001	/* write precompensation (W) */
47 #define	wd_features	0x001	/* features (W) */
48 #define	wd_seccnt	0x002	/* sector count (R/W) */
49 #define	wd_sector	0x003	/* first sector number (R/W) */
50 #define	wd_cyl_lo	0x004	/* cylinder address, low byte (R/W) */
51 #define	wd_cyl_hi	0x005	/* cylinder address, high byte (R/W) */
52 #define	wd_sdh		0x006	/* sector size/drive/head (R/W) */
53 #define	wd_command	0x007	/* command register (W)	*/
54 #define	wd_status	0x007	/* immediate status (R)	*/
55 
56 #define	wd_altsts	0x206	/* alternate fixed disk status (via 1015) (R) */
57 #define	wd_ctlr		0x206	/* fixed disk controller control (via 1015) (W) */
58 #define  WDCTL_4BIT	 0x08	/* use four head bits (wd1003) */
59 #define  WDCTL_RST	 0x04	/* reset the controller */
60 #define  WDCTL_IDS	 0x02	/* disable controller interrupts */
61 #define	wd_digin	0x207	/* disk controller input (via 1015) (R) */
62 
63 /*
64  * Status bits.
65  */
66 #define	WDCS_BSY	0x80	/* busy */
67 #define	WDCS_DRDY	0x40	/* drive ready */
68 #define	WDCS_DWF	0x20	/* drive write fault */
69 #define	WDCS_DSC	0x10	/* drive seek complete */
70 #define	WDCS_DRQ	0x08	/* data request */
71 #define	WDCS_CORR	0x04	/* corrected data */
72 #define	WDCS_IDX	0x02	/* index */
73 #define	WDCS_ERR	0x01	/* error */
74 #define WDCS_BITS	"\020\010bsy\007drdy\006dwf\005dsc\004drq\003corr\002idx\001err"
75 
76 /*
77  * Error bits.
78  */
79 #define	WDCE_BBK	0x80	/* bad block detected */
80 #define	WDCE_UNC	0x40	/* uncorrectable data error */
81 #define	WDCE_MC		0x20	/* media changed */
82 #define	WDCE_IDNF	0x10	/* id not found */
83 #define	WDCE_ABRT	0x08	/* aborted command */
84 #define	WDCE_MCR	0x04	/* media change requested */
85 #define	WDCE_TK0NF	0x02	/* track 0 not found */
86 #define	WDCE_AMNF	0x01	/* address mark not found */
87 #define WDERR_BITS	"\020\010bbk\007unc\006mc\005idnf\004mcr\003abrt\002tk0nf\001amnf"
88 
89 /*
90  * Commands for Disk Controller.
91  */
92 #define	WDCC_RECAL	0x10	/* disk restore code -- resets cntlr */
93 
94 #define	WDCC_READ	0x20	/* disk read code */
95 #define	WDCC_WRITE	0x30	/* disk write code */
96 #define	 WDCC__LONG	 0x02	 /* modifier -- access ecc bytes */
97 #define	 WDCC__NORETRY	 0x01	 /* modifier -- no retrys */
98 
99 #define	WDCC_FORMAT	0x50	/* disk format code */
100 #define	WDCC_DIAGNOSE	0x90	/* controller diagnostic */
101 #define	WDCC_IDP	0x91	/* initialize drive parameters */
102 
103 #define	WDCC_READMULTI	0xc4	/* read multiple */
104 #define	WDCC_WRITEMULTI	0xc5	/* write multiple */
105 #define	WDCC_SETMULTI	0xc6	/* set multiple mode */
106 
107 #define	WDCC_READDMA	0xc8	/* read with DMA */
108 #define	WDCC_WRITEDMA	0xca	/* write with DMA */
109 
110 #define	WDCC_ACKMC	0xdb	/* acknowledge media change */
111 #define	WDCC_LOCK	0xde	/* lock drawer */
112 #define	WDCC_UNLOCK	0xdf	/* unlock drawer */
113 
114 #define	WDCC_IDENTIFY	0xec	/* read parameters from controller */
115 #define	WDCC_CACHEC	0xef	/* cache control */
116 
117 #define	WDSD_IBM	0xa0	/* forced to 512 byte sector, ecc */
118 #define	WDSD_CHS	0x00	/* cylinder/head/sector addressing */
119 #define	WDSD_LBA	0x40	/* logical block addressing */
120 
121 
122 #ifdef KERNEL
123 /*
124  * read parameters command returns this:
125  */
126 struct wdparams {
127 	/* drive info */
128 	short	wdp_config;		/* general configuration */
129 #define	WD_CFG_REMOVABLE	0x0080
130 #define	WD_CFG_FIXED		0x0040
131 	short	wdp_cylinders;		/* number of non-removable cylinders */
132 	char	__reserved1[2];
133 	short	wdp_heads;		/* number of heads */
134 	short	wdp_unfbytespertrk;	/* number of unformatted bytes/track */
135 	short	wdp_unfbytespersec;	/* number of unformatted bytes/sector */
136 	short	wdp_sectors;		/* number of sectors */
137 	char	wdp_vendor1[6];
138 	/* controller info */
139 	char	wdp_serial[20];		/* serial number */
140 	short	wdp_buftype;		/* buffer type */
141 #define	WD_BUF_SINGLEPORTSECTOR	1	 /* single port, single sector buffer */
142 #define	WD_BUF_DUALPORTMULTI	2	 /* dual port, multiple sector buffer */
143 #define	WD_BUF_DUALPORTMULTICACHE 3	 /* above plus track cache */
144 	short	wdp_bufsize;		/* buffer size, in 512-byte units */
145 	short	wdp_eccbytes;		/* ecc bytes appended */
146 	char	wdp_revision[8];	/* firmware revision */
147 	char	wdp_model[40];		/* model name */
148 	u_char	wdp_maxmulti;		/* maximum sectors per interrupt */
149 	char	wdp_vendor2[1];
150 	short	wdp_usedmovsd;		/* can use double word read/write? */
151 	char	wdp_vendor3[1];
152 	char	wdp_capabilities;	/* capability flags */
153 #define	WD_CAP_LBA	0x02
154 #define	WD_CAP_DMA	0x01
155 	char	__reserved2[2];
156 	char	wdp_vendor4[1];
157 	char	wdp_piotiming;		/* PIO timing mode */
158 	char	wdp_vendor5[1];
159 	char	wdp_dmatiming;		/* DMA timing mode */
160 };
161 #endif KERNEL
162