xref: /freebsd/sys/dev/ic/nec765.h (revision c3aac50f284c6cca5b4f2eb46aaa13812cb8b630)
15b81b6b3SRodney W. Grimes /*-
25b81b6b3SRodney W. Grimes  * Copyright (c) 1991 The Regents of the University of California.
35b81b6b3SRodney W. Grimes  * All rights reserved.
45b81b6b3SRodney W. Grimes  *
55b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
65b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
75b81b6b3SRodney W. Grimes  * are met:
85b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
95b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
105b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
115b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
125b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
135b81b6b3SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
145b81b6b3SRodney W. Grimes  *    must display the following acknowledgement:
155b81b6b3SRodney W. Grimes  *	This product includes software developed by the University of
165b81b6b3SRodney W. Grimes  *	California, Berkeley and its contributors.
175b81b6b3SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
185b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
195b81b6b3SRodney W. Grimes  *    without specific prior written permission.
205b81b6b3SRodney W. Grimes  *
215b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
225b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
235b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
245b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
255b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
265b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
275b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
285b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
295b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
305b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
315b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
325b81b6b3SRodney W. Grimes  *
336f78ca60SRodney W. Grimes  *	from: @(#)nec765.h	7.1 (Berkeley) 5/9/91
34c3aac50fSPeter Wemm  * $FreeBSD$
355b81b6b3SRodney W. Grimes  */
365b81b6b3SRodney W. Grimes 
375b81b6b3SRodney W. Grimes /*
385b81b6b3SRodney W. Grimes  * Nec 765 floppy disc controller definitions
395b81b6b3SRodney W. Grimes  */
405b81b6b3SRodney W. Grimes 
415b81b6b3SRodney W. Grimes /* Main status register */
425b81b6b3SRodney W. Grimes #define NE7_DAB	0x01	/* Diskette drive A is seeking, thus busy */
435b81b6b3SRodney W. Grimes #define NE7_DBB	0x02	/* Diskette drive B is seeking, thus busy */
445b81b6b3SRodney W. Grimes #define NE7_CB	0x10	/* Diskette Controller Busy */
455b81b6b3SRodney W. Grimes #define NE7_NDM	0x20	/* Diskette Controller in Non Dma Mode */
465b81b6b3SRodney W. Grimes #define NE7_DIO	0x40	/* Diskette Controller Data register I/O */
475b81b6b3SRodney W. Grimes #define NE7_RQM	0x80	/* Diskette Controller ReQuest for Master */
485b81b6b3SRodney W. Grimes 
495b81b6b3SRodney W. Grimes /* Status register ST0 */
503a2f7427SDavid Greenman #define NE7_ST0BITS	"\020\010invld\007abnrml\006seek_cmplt\005equ_chck\004drive_notrdy\003top_head"
513a2f7427SDavid Greenman 
523a2f7427SDavid Greenman #define NE7_ST0_IC	0xc0	/* interrupt completion code */
533a2f7427SDavid Greenman 
543a2f7427SDavid Greenman #define NE7_ST0_IC_RC	0xc0	/* terminated due to ready changed, n/a */
553a2f7427SDavid Greenman #define NE7_ST0_IC_IV	0x80	/* invalid command; must reset FDC */
563a2f7427SDavid Greenman #define NE7_ST0_IC_AT	0x40	/* abnormal termination, check error stat */
573a2f7427SDavid Greenman #define NE7_ST0_IC_NT	0x00	/* normal termination */
583a2f7427SDavid Greenman 
593a2f7427SDavid Greenman #define NE7_ST0_SE	0x20	/* seek end */
603a2f7427SDavid Greenman #define NE7_ST0_EC	0x10	/* equipment check, recalibrated but no trk0 */
613a2f7427SDavid Greenman #define NE7_ST0_NR	0x08	/* not ready (n/a) */
623a2f7427SDavid Greenman #define NE7_ST0_HD	0x04	/* upper head selected */
633a2f7427SDavid Greenman #define NE7_ST0_DR	0x03	/* drive code */
645b81b6b3SRodney W. Grimes 
655b81b6b3SRodney W. Grimes /* Status register ST1 */
665b81b6b3SRodney W. Grimes #define NE7_ST1BITS	"\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am"
675b81b6b3SRodney W. Grimes 
683a2f7427SDavid Greenman #define NE7_ST1_EN	0x80	/* end of cylinder, access past last record */
693a2f7427SDavid Greenman #define NE7_ST1_DE	0x20	/* data error, CRC fail in ID or data */
703a2f7427SDavid Greenman #define NE7_ST1_OR	0x10	/* DMA overrun, DMA failed to do i/o quickly */
713a2f7427SDavid Greenman #define NE7_ST1_ND	0x04	/* no data, sector not found or CRC in ID f. */
723a2f7427SDavid Greenman #define NE7_ST1_NW	0x02	/* not writeable, attempt to violate WP */
733a2f7427SDavid Greenman #define NE7_ST1_MA	0x01	/* missing address mark (in ID or data field)*/
743a2f7427SDavid Greenman 
755b81b6b3SRodney W. Grimes /* Status register ST2 */
765b81b6b3SRodney W. Grimes #define NE7_ST2BITS	"\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam"
775b81b6b3SRodney W. Grimes 
783a2f7427SDavid Greenman #define NE7_ST2_CM	0x40	/* control mark; found deleted data */
793a2f7427SDavid Greenman #define NE7_ST2_DD	0x20	/* data error in data field, CRC fail */
803a2f7427SDavid Greenman #define NE7_ST2_WC	0x10	/* wrong cylinder, ID field mismatches cmd */
813a2f7427SDavid Greenman #define NE7_ST2_SH	0x08	/* scan equal hit */
823a2f7427SDavid Greenman #define NE7_ST2_SN	0x04	/* scan not satisfied */
833a2f7427SDavid Greenman #define NE7_ST2_BC	0x02	/* bad cylinder, cylinder marked 0xff */
843a2f7427SDavid Greenman #define NE7_ST2_MD	0x01	/* missing address mark in data field */
853a2f7427SDavid Greenman 
865b81b6b3SRodney W. Grimes /* Status register ST3 */
875b81b6b3SRodney W. Grimes #define NE7_ST3BITS	"\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002"
885b81b6b3SRodney W. Grimes 
893a2f7427SDavid Greenman #define NE7_ST3_FT	0x80	/* fault; PC: n/a */
903a2f7427SDavid Greenman #define NE7_ST3_WP	0x40	/* write protected */
913a2f7427SDavid Greenman #define NE7_ST3_RD	0x20	/* ready; PC: always true */
923a2f7427SDavid Greenman #define NE7_ST3_T0	0x10	/* track 0 */
933a2f7427SDavid Greenman #define NE7_ST3_TS	0x08	/* two-sided; PC: n/a */
943a2f7427SDavid Greenman #define NE7_ST3_HD	0x04	/* upper head select */
953a2f7427SDavid Greenman #define NE7_ST3_US	0x03	/* unit select */
963a2f7427SDavid Greenman 
975b81b6b3SRodney W. Grimes /* Commands */
983a2f7427SDavid Greenman /*
993a2f7427SDavid Greenman  * the top three bits -- where appropriate -- are set as follows:
1003a2f7427SDavid Greenman  *
1013a2f7427SDavid Greenman  * 0x80 - MT  multi-track; allow both sides to be handled in single cmd
1023a2f7427SDavid Greenman  * 0x40 - MFM modified frequency modulation; use MFM encoding
1033a2f7427SDavid Greenman  * 0x20 - SK  skip; skip sectors marked as "deleted"
1043a2f7427SDavid Greenman  */
1053a2f7427SDavid Greenman #define NE7CMD_READTRK	0x42	/*  read whole track */
1065b81b6b3SRodney W. Grimes #define NE7CMD_SPECIFY	3	/*  specify drive parameters - requires unit
1075b81b6b3SRodney W. Grimes 					parameters byte */
1085b81b6b3SRodney W. Grimes #define NE7CMD_SENSED	4	/*  sense drive - requires unit select byte */
1095b81b6b3SRodney W. Grimes #define NE7CMD_WRITE	0xc5	/*  write - requires eight additional bytes */
1105b81b6b3SRodney W. Grimes #define NE7CMD_READ	0xe6	/*  read - requires eight additional bytes */
1115b81b6b3SRodney W. Grimes #define NE7CMD_RECAL	7	/*  recalibrate drive - requires
1125b81b6b3SRodney W. Grimes 					unit select byte */
1135b81b6b3SRodney W. Grimes #define NE7CMD_SENSEI	8	/*  sense controller interrupt status */
1143a2f7427SDavid Greenman #define NE7CMD_WRITEDEL	0xc9	/*  write deleted data */
1153a2f7427SDavid Greenman #define NE7CMD_READID	0x4a	/*  read ID field */
1163a2f7427SDavid Greenman #define NE7CMD_READDEL	0xec	/*  read deleted data */
1173a2f7427SDavid Greenman #define NE7CMD_FORMAT	0x4d	/*  format - requires five additional bytes */
1183a2f7427SDavid Greenman #define NE7CMD_SEEK	0x0f	/*  seek drive - requires unit select byte
1195b81b6b3SRodney W. Grimes 					and new cyl byte */
1203a2f7427SDavid Greenman #define NE7CMD_SCNEQU	0xf1	/*  scan equal */
1213a2f7427SDavid Greenman #define NE7CMD_SCNLE	0xf9	/*  scan less or equal */
1223a2f7427SDavid Greenman #define NE7CMD_SCNGE	0xfd	/*  scan greater or equal */
1233a2f7427SDavid Greenman 
124dc5df763SJoerg Wunsch /*
125dc5df763SJoerg Wunsch  * Enhanced controller commands:
126dc5df763SJoerg Wunsch  */
127dc5df763SJoerg Wunsch #define NE7CMD_VERSION	0x10	/*  version (ok for all controllers) */
128dc5df763SJoerg Wunsch 
129d66c374fSTor Egge #define I8207X_CONFIGURE 0x13   /*  configure enhanced features */
1303a2f7427SDavid Greenman 
1313a2f7427SDavid Greenman /*
1323a2f7427SDavid Greenman  * "specify" definitions
1333a2f7427SDavid Greenman  *
1343a2f7427SDavid Greenman  * acronyms (times are relative to a FDC clock of 8 MHz):
1353a2f7427SDavid Greenman  * srt - step rate; PC usually 3 ms
1363a2f7427SDavid Greenman  * hut - head unload time; PC usually maximum of 240 ms
1373a2f7427SDavid Greenman  * hlt - head load time; PC usually minimum of 2 ms
1383a2f7427SDavid Greenman  * nd  - no DMA flag; PC usually not set (0)
1393a2f7427SDavid Greenman  */
1403a2f7427SDavid Greenman 
1413a2f7427SDavid Greenman #define NE7_SPEC_1(srt, hut) (((16 - (srt)) << 4) | (((hut) / 16)))
1423a2f7427SDavid Greenman #define NE7_SPEC_2(hlt, nd)  (((hlt) & 0xFE) | ((nd) & 1))
143