xref: /netbsd/sys/arch/sun3/dev/xyreg.h (revision 4b0a220f)
1*4b0a220fSchuck /* $NetBSD: xyreg.h,v 1.5 2011/02/01 20:19:32 chuck Exp $ */
2b3a6cbaeSgwr 
3b3a6cbaeSgwr /*
4b3a6cbaeSgwr  * Copyright (c) 1995 Charles D. Cranor
5b3a6cbaeSgwr  * All rights reserved.
6b3a6cbaeSgwr  *
7b3a6cbaeSgwr  * Redistribution and use in source and binary forms, with or without
8b3a6cbaeSgwr  * modification, are permitted provided that the following conditions
9b3a6cbaeSgwr  * are met:
10b3a6cbaeSgwr  * 1. Redistributions of source code must retain the above copyright
11b3a6cbaeSgwr  *    notice, this list of conditions and the following disclaimer.
12b3a6cbaeSgwr  * 2. Redistributions in binary form must reproduce the above copyright
13b3a6cbaeSgwr  *    notice, this list of conditions and the following disclaimer in the
14b3a6cbaeSgwr  *    documentation and/or other materials provided with the distribution.
15b3a6cbaeSgwr  *
16b3a6cbaeSgwr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17b3a6cbaeSgwr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18b3a6cbaeSgwr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19b3a6cbaeSgwr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20b3a6cbaeSgwr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21b3a6cbaeSgwr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22b3a6cbaeSgwr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23b3a6cbaeSgwr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24b3a6cbaeSgwr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25b3a6cbaeSgwr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26b3a6cbaeSgwr  */
27b3a6cbaeSgwr 
28b3a6cbaeSgwr /*
29b3a6cbaeSgwr  * x y r e g . h
30b3a6cbaeSgwr  *
31b3a6cbaeSgwr  * this file contains the description of the Xylogics 450/451's hardware
32b3a6cbaeSgwr  * data structures.
33b3a6cbaeSgwr  *
34*4b0a220fSchuck  * author: Chuck Cranor <chuck@netbsd>
35b3a6cbaeSgwr  */
36b3a6cbaeSgwr 
37b3a6cbaeSgwr #define XYC_MAXDEV    2       /* max devices per controller */
38b3a6cbaeSgwr #define XYC_CTLIOPB   XYC_MAXDEV /* controller's iopb */
39b3a6cbaeSgwr #define XYC_RESETUSEC 1000000 /* max time for xyc reset (same as xdc?) */
40b3a6cbaeSgwr #define XYC_MAXIOPB   (XYC_MAXDEV+1)
41b3a6cbaeSgwr 			      /* max number of iopbs that can be active */
42b3a6cbaeSgwr #define XYC_MAXTIME   4*1000000 /* four seconds before we give up and reset */
43b3a6cbaeSgwr #define XYC_MAXTRIES  4       /* max number of times to retry an operation */
44b3a6cbaeSgwr #define XYC_INTERLEAVE 1      /* interleave (from disk label?) */
45b3a6cbaeSgwr #define XYFM_BPS	0x200 /* must be 512! */
46b3a6cbaeSgwr 
47b3a6cbaeSgwr /*
48b3a6cbaeSgwr  * xyc device interface
49b3a6cbaeSgwr  * (lives in VME address space)   [note: bytes are swapped!]
50b3a6cbaeSgwr  */
51b3a6cbaeSgwr 
52b3a6cbaeSgwr struct xyc {
53b3a6cbaeSgwr   volatile u_char xyc_reloc_hi;        /* iopb relocation (low byte) */
54b3a6cbaeSgwr   volatile u_char xyc_reloc_lo;        /* iopb relocation (high byte) */
55b3a6cbaeSgwr   volatile u_char xyc_addr_hi;         /* iopb address (low byte) */
56b3a6cbaeSgwr   volatile u_char xyc_addr_lo;         /* iopb address (high byte) */
57b3a6cbaeSgwr   volatile u_char xyc_rsetup;          /* reset/update reg */
58b3a6cbaeSgwr   volatile u_char xyc_csr;             /* control and status register */
59b3a6cbaeSgwr };
60b3a6cbaeSgwr 
61b3a6cbaeSgwr /*
62b3a6cbaeSgwr  * xyc_csr
63b3a6cbaeSgwr  */
64b3a6cbaeSgwr 
65b3a6cbaeSgwr #define XYC_GBSY     0x80     /* go/busy */
66b3a6cbaeSgwr #define XYC_ERR	     0x40     /* error */
67b3a6cbaeSgwr #define XYC_DERR     0x20     /* double error! */
68b3a6cbaeSgwr #define XYC_IPND     0x10     /* interrupt pending */
69b3a6cbaeSgwr #define XYC_ADRM     0x08     /* 24-bit addressing */
70b3a6cbaeSgwr #define XYC_AREQ     0x04     /* attention request */
71b3a6cbaeSgwr #define XYC_AACK     0x02     /* attention ack. */
72b3a6cbaeSgwr #define XYC_DRDY     0x01     /* drive ready */
73b3a6cbaeSgwr 
74b3a6cbaeSgwr /*
75b3a6cbaeSgwr  * Input/Output Parameter Block (iopb)
76b3a6cbaeSgwr  *
77b3a6cbaeSgwr  * all controller commands are done via iopb's.   to start a command you
78b3a6cbaeSgwr  * must do this:
79b3a6cbaeSgwr  * [1] allocate space in DVMA space for the iopb
80b3a6cbaeSgwr  * [2] fill out all the fields of the iopb
81b3a6cbaeSgwr  * [3] if the controller isn't busy, start the iopb by loading the address
82b3a6cbaeSgwr  *     and reloc in the xyc's registers and setting the "go" bit [done]
83b3a6cbaeSgwr  * [4] controller busy: set AREQ bit, and wait for AACK bit.
84b3a6cbaeSgwr  *     add iopb to the chain, and clear AREQ to resume I/O
85b3a6cbaeSgwr  *
86b3a6cbaeSgwr  * when the controller is done with a command it may interrupt (if you
87b3a6cbaeSgwr  * ask it to) and it will set the XYC_IPND bit in the csr.   clear
88b3a6cbaeSgwr  * the interrupt by writing one to this bit.
89b3a6cbaeSgwr  *
90b3a6cbaeSgwr  * the format of the iopb is described in section 2.4 of the manual.
91b3a6cbaeSgwr  * note that it is byte-swapped on the sun.
92b3a6cbaeSgwr  */
93b3a6cbaeSgwr 
94b3a6cbaeSgwr struct xy_iopb {
95b3a6cbaeSgwr 				 /* section 2.4.2: byte 1 */
96b3a6cbaeSgwr   volatile u_char resv1:1;	 /* reserved */
97b3a6cbaeSgwr   volatile u_char iei:1;	 /* interrupt on each IOPB done */
98b3a6cbaeSgwr   volatile u_char ierr:1;	 /* interrupt on error (no effect on 450) */
99b3a6cbaeSgwr   volatile u_char hdp:1;	 /* hold dual port drive */
100b3a6cbaeSgwr   volatile u_char asr:1;	 /* autoseek retry */
101b3a6cbaeSgwr   volatile u_char eef:1;	 /* enable extended fn. (overlap seek) */
102b3a6cbaeSgwr   volatile u_char ecm:2;	 /* ECC correction mode */
103b3a6cbaeSgwr #define XY_ECM 2		 /* use mode 2 (see section 2.4.2) */
104b3a6cbaeSgwr                                  /* section 2.4.1: byte 0 */
105b3a6cbaeSgwr   volatile u_char aud:1;	 /* auto-update iopb */
106b3a6cbaeSgwr   volatile u_char relo:1;	 /* enable multibus relocation (>16bit addrs)*/
107b3a6cbaeSgwr   volatile u_char chen:1;        /* chain enable, "next iopb" is valid */
108b3a6cbaeSgwr   volatile u_char ien:1;	 /* interrupt enable */
109b3a6cbaeSgwr   volatile u_char com:4;	 /* command */
110b3a6cbaeSgwr #define XYCMD_NOP 0x0            /* no-op */
111b3a6cbaeSgwr #define XYCMD_WR  0x1            /* write */
112b3a6cbaeSgwr #define XYCMD_RD  0x2            /* read */
113b3a6cbaeSgwr #define XYCMD_WTH 0x3		 /* write track headers */
114b3a6cbaeSgwr #define XYCMD_RTH 0x4		 /* read track headers */
115b3a6cbaeSgwr #define XYCMD_SK  0x5            /* seek */
116b3a6cbaeSgwr #define XYCMD_RST 0x6            /* drive reset */
117b3a6cbaeSgwr #define XYCMD_WFM 0x7		 /* write format */
118b3a6cbaeSgwr #define XYCMD_RDH 0x8		 /* read header, data, and ECC */
119b3a6cbaeSgwr #define XYCMD_RDS 0x9		 /* read drive status */
120b3a6cbaeSgwr #define XYCMD_WRH 0xa		 /* write header, data, and ECC */
121b3a6cbaeSgwr #define XYCMD_SDS 0xb		 /* set drive size */
122b3a6cbaeSgwr #define XYCMD_ST  0xc		 /* self test */
123b3a6cbaeSgwr #define XYCMD_R   0xd		 /* reserved */
124b3a6cbaeSgwr #define XYCMD_MBL 0xe		 /* maint. buffer load */
125b3a6cbaeSgwr #define XYCMD_MBD 0xf		 /* main. buffer dump */
126b3a6cbaeSgwr                                  /* section 2.4.4: byte 3 */
127b3a6cbaeSgwr   volatile u_char errno;	 /* error or completion code */
128b3a6cbaeSgwr                                  /* section 2.4.3: byte 2 */
129b3a6cbaeSgwr   volatile u_char errs:1;        /* error summary bit */
130b3a6cbaeSgwr   volatile u_char resv2:2;	 /* reserved */
131b3a6cbaeSgwr   volatile u_char ctyp:3;	 /* controller type */
132b3a6cbaeSgwr #define XYCT_450 1		 /* the 450 controller */
133b3a6cbaeSgwr   volatile u_char resv3:1;	 /* reserved */
134b3a6cbaeSgwr   volatile u_char done:1;	 /* done! */
135b3a6cbaeSgwr                                  /* section 2.4.6: byte 5 */
136b3a6cbaeSgwr   volatile u_char dt:2;		 /* drive type */
137b3a6cbaeSgwr #define XYC_MAXDT 3		 /* largest drive type possible */
138b3a6cbaeSgwr   volatile u_char resv4:4;	 /* reserved */
139b3a6cbaeSgwr   volatile u_char unit:2;	 /* unit # */
140b3a6cbaeSgwr                                  /* section 2.4.5: byte 4 */
141b3a6cbaeSgwr   volatile u_char bw:1;		 /* byte(1)/word(0) xfer size */
142b3a6cbaeSgwr   volatile u_char intlv:4;	 /* interleave factor (0=1:1, 1=2:1, etc.) */
1431ffa7b76Swiz   volatile u_char thro:3;	 /* DMA throttle (0=2,1=4,2=8, etc...) */
1441ffa7b76Swiz #define XY_THRO 4		 /* 4 == 32 DMA cycles */
145b3a6cbaeSgwr                                  /* section 2.4.8: byte 7 */
146b3a6cbaeSgwr   volatile u_char sect;		 /* sector # */
147b3a6cbaeSgwr                                  /* section 2.4.7: byte 6 */
148b3a6cbaeSgwr   volatile u_char head;		 /* head # */
149b3a6cbaeSgwr                                  /* section 2.4.9: byte 8,9 */
150b3a6cbaeSgwr   volatile u_short cyl;		 /* cyl # */
151b3a6cbaeSgwr                                  /* section 2.4.10: byte a,b */
152b3a6cbaeSgwr   volatile u_short scnt;	 /* sector count, also drive status */
153b3a6cbaeSgwr #define xy_dr_status scnt
154b3a6cbaeSgwr #define XYS_ONCL 0x80		 /* on-cylinder (active LOW) */
155b3a6cbaeSgwr #define XYS_DRDY 0x40		 /* drive ready (active LOW) */
156b3a6cbaeSgwr #define XYS_WRPT 0x20		 /* write protect */
157b3a6cbaeSgwr #define XYS_DPB  0x10		 /* dual-port busy */
158b3a6cbaeSgwr #define XYS_SKER 0x08		 /* hard seek error */
159b3a6cbaeSgwr #define XYS_DFLT 0x04		 /* disk fault */
160b3a6cbaeSgwr                                  /* section 2.4.11: byte c,d */
161b3a6cbaeSgwr   volatile u_short dataa;	 /* data address */
162b3a6cbaeSgwr                                  /* section 2.4.12: byte e,f */
163b3a6cbaeSgwr   volatile u_short datar;	 /* data relocation pointer */
164b3a6cbaeSgwr 				 /* section 2.4.14: byte 11 */
165b3a6cbaeSgwr   volatile u_char subfn;	 /* sub-function */
166b3a6cbaeSgwr 				 /* section 2.4.13: byte 10 */
1673f9411f6Swiz   volatile u_char hoff;		 /* head offset for fixed/removable drives */
168b3a6cbaeSgwr 				 /* section 2.4.15: byte 12,13 */
169b3a6cbaeSgwr   volatile u_short nxtiopb;	 /* next iopb address (same relocation) */
170b3a6cbaeSgwr 				 /* section 2.4.16: byte 14,15 */
171b3a6cbaeSgwr   volatile u_short eccpat;	 /* ecc pattern */
172b3a6cbaeSgwr 				 /* section 2.4.17: byte 16,17 */
173b3a6cbaeSgwr   volatile u_short eccaddr;	 /* ecc address */
174b3a6cbaeSgwr };
175b3a6cbaeSgwr 
176b3a6cbaeSgwr 
177b3a6cbaeSgwr /*
178b3a6cbaeSgwr  * errors (section 2.4.4.1)
179b3a6cbaeSgwr  */
180b3a6cbaeSgwr 
181b3a6cbaeSgwr /* software error codes */
182b3a6cbaeSgwr #define XY_ERR_FAIL 0xff         /* general total failure */
183b3a6cbaeSgwr #define XY_ERR_DERR 0xfe	 /* double error */
184b3a6cbaeSgwr /* no error */
185b3a6cbaeSgwr #define XY_ERR_AOK  0x00         /* success */
186b3a6cbaeSgwr 
187b3a6cbaeSgwr #define XY_ERR_IPEN 0x01	 /* interrupt pending */
188b3a6cbaeSgwr #define XY_ERR_BCFL 0x03	 /* busy conflict */
189b3a6cbaeSgwr #define XY_ERR_TIMO 0x04	 /* operation timeout */
190b3a6cbaeSgwr #define XY_ERR_NHDR 0x05	 /* header not found */
191b3a6cbaeSgwr #define XY_ERR_HARD 0x06	 /* hard ECC error */
192b3a6cbaeSgwr #define XY_ERR_ICYL 0x07	 /* illegal cylinder address */
193b3a6cbaeSgwr #define XY_ERR_ISEC 0x0a	 /* illegal sector address */
194b3a6cbaeSgwr #define XY_ERR_SMAL 0x0d	 /* last sector too small */
195b3a6cbaeSgwr #define XY_ERR_SACK 0x0e	 /* slave ACK error (non-existent memory) */
196b3a6cbaeSgwr #define XY_ERR_CHER 0x12	 /* cylinder and head/header error */
197b3a6cbaeSgwr #define XY_ERR_SRTR 0x13	 /* auto-seek retry successful */
198b3a6cbaeSgwr #define XY_ERR_WPRO 0x14	 /* write-protect error */
199b3a6cbaeSgwr #define XY_ERR_UIMP 0x15	 /* unimplemented command */
200b3a6cbaeSgwr #define XY_ERR_DNRY 0x16	 /* drive not ready */
201b3a6cbaeSgwr #define XY_ERR_SZER 0x17	 /* sector count zero */
202b3a6cbaeSgwr #define XY_ERR_DFLT 0x18	 /* drive faulted */
203b3a6cbaeSgwr #define XY_ERR_ISSZ 0x19	 /* illegal sector size */
204b3a6cbaeSgwr #define XY_ERR_SLTA 0x1a	 /* self test a */
205b3a6cbaeSgwr #define XY_ERR_SLTB 0x1b	 /* self test b */
206b3a6cbaeSgwr #define XY_ERR_SLTC 0x1c	 /* self test c */
207b3a6cbaeSgwr #define XY_ERR_SOFT 0x1e	 /* soft ECC error */
208b3a6cbaeSgwr #define XY_ERR_SFOK 0x1f	 /* soft ECC error recovered */
209b3a6cbaeSgwr #define XY_ERR_IHED 0x20	 /* illegal head */
210b3a6cbaeSgwr #define XY_ERR_DSEQ 0x21	 /* disk sequencer error */
211b3a6cbaeSgwr #define XY_ERR_SEEK 0x25	 /* seek error */
212b3a6cbaeSgwr 
213b3a6cbaeSgwr 
214b3a6cbaeSgwr /* error actions */
215b3a6cbaeSgwr #define XY_ERA_PROG 0x10	 /* program error: quit */
216b3a6cbaeSgwr #define XY_ERA_SOFT 0x30         /* soft error: we recovered */
217b3a6cbaeSgwr #define XY_ERA_HARD 0x40         /* hard error: retry */
218b3a6cbaeSgwr #define XY_ERA_RSET 0x60         /* hard error: reset, then retry */
219b3a6cbaeSgwr #define XY_ERA_WPRO 0x90         /* write protected */
220b3a6cbaeSgwr 
221b3a6cbaeSgwr 
222