xref: /freebsd/sys/dev/ic/nec765.h (revision 0da90eb878fdcd8c766c609afbf5f53cc56858e7)
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  * 4. Neither the name of the University nor the names of its contributors
145b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
155b81b6b3SRodney W. Grimes  *    without specific prior written permission.
165b81b6b3SRodney W. Grimes  *
175b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
185b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
195b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
205b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
215b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
225b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
235b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
255b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
265b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
275b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
285b81b6b3SRodney W. Grimes  *
296f78ca60SRodney W. Grimes  *	from: @(#)nec765.h	7.1 (Berkeley) 5/9/91
30c3aac50fSPeter Wemm  * $FreeBSD$
315b81b6b3SRodney W. Grimes  */
325b81b6b3SRodney W. Grimes 
335b81b6b3SRodney W. Grimes /*
345b81b6b3SRodney W. Grimes  * Nec 765 floppy disc controller definitions
355b81b6b3SRodney W. Grimes  */
365b81b6b3SRodney W. Grimes 
375b81b6b3SRodney W. Grimes /* Main status register */
385b81b6b3SRodney W. Grimes #define NE7_DAB		0x01	/* Diskette drive A is seeking, thus busy */
395b81b6b3SRodney W. Grimes #define NE7_DBB		0x02	/* Diskette drive B is seeking, thus busy */
405b81b6b3SRodney W. Grimes #define NE7_CB		0x10	/* Diskette Controller Busy */
415b81b6b3SRodney W. Grimes #define NE7_NDM		0x20	/* Diskette Controller in Non Dma Mode */
425b81b6b3SRodney W. Grimes #define NE7_DIO		0x40	/* Diskette Controller Data register I/O */
435b81b6b3SRodney W. Grimes #define NE7_RQM		0x80	/* Diskette Controller ReQuest for Master */
445b81b6b3SRodney W. Grimes 
455b81b6b3SRodney W. Grimes /* Status register ST0 */
463a2f7427SDavid Greenman #define NE7_ST0BITS	"\020\010invld\007abnrml\006seek_cmplt\005equ_chck\004drive_notrdy\003top_head"
473a2f7427SDavid Greenman 
483a2f7427SDavid Greenman #define NE7_ST0_IC	0xc0	/* interrupt completion code */
493a2f7427SDavid Greenman 
503a2f7427SDavid Greenman #define NE7_ST0_IC_RC	0xc0	/* terminated due to ready changed, n/a */
513a2f7427SDavid Greenman #define NE7_ST0_IC_IV	0x80	/* invalid command; must reset FDC */
523a2f7427SDavid Greenman #define NE7_ST0_IC_AT	0x40	/* abnormal termination, check error stat */
533a2f7427SDavid Greenman #define NE7_ST0_IC_NT	0x00	/* normal termination */
543a2f7427SDavid Greenman 
553a2f7427SDavid Greenman #define NE7_ST0_SE	0x20	/* seek end */
563a2f7427SDavid Greenman #define NE7_ST0_EC	0x10	/* equipment check, recalibrated but no trk0 */
573a2f7427SDavid Greenman #define NE7_ST0_NR	0x08	/* not ready (n/a) */
583a2f7427SDavid Greenman #define NE7_ST0_HD	0x04	/* upper head selected */
593a2f7427SDavid Greenman #define NE7_ST0_DR	0x03	/* drive code */
605b81b6b3SRodney W. Grimes 
615b81b6b3SRodney W. Grimes /* Status register ST1 */
625b81b6b3SRodney W. Grimes #define NE7_ST1BITS	"\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am"
635b81b6b3SRodney W. Grimes 
643a2f7427SDavid Greenman #define NE7_ST1_EN	0x80	/* end of cylinder, access past last record */
653a2f7427SDavid Greenman #define NE7_ST1_DE	0x20	/* data error, CRC fail in ID or data */
663a2f7427SDavid Greenman #define NE7_ST1_OR	0x10	/* DMA overrun, DMA failed to do i/o quickly */
673a2f7427SDavid Greenman #define NE7_ST1_ND	0x04	/* no data, sector not found or CRC in ID f. */
683a2f7427SDavid Greenman #define NE7_ST1_NW	0x02	/* not writeable, attempt to violate WP */
693a2f7427SDavid Greenman #define NE7_ST1_MA	0x01	/* missing address mark (in ID or data field)*/
703a2f7427SDavid Greenman 
715b81b6b3SRodney W. Grimes /* Status register ST2 */
725b81b6b3SRodney W. Grimes #define NE7_ST2BITS	"\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam"
735b81b6b3SRodney W. Grimes 
743a2f7427SDavid Greenman #define NE7_ST2_CM	0x40	/* control mark; found deleted data */
753a2f7427SDavid Greenman #define NE7_ST2_DD	0x20	/* data error in data field, CRC fail */
763a2f7427SDavid Greenman #define NE7_ST2_WC	0x10	/* wrong cylinder, ID field mismatches cmd */
773a2f7427SDavid Greenman #define NE7_ST2_SH	0x08	/* scan equal hit */
783a2f7427SDavid Greenman #define NE7_ST2_SN	0x04	/* scan not satisfied */
793a2f7427SDavid Greenman #define NE7_ST2_BC	0x02	/* bad cylinder, cylinder marked 0xff */
803a2f7427SDavid Greenman #define NE7_ST2_MD	0x01	/* missing address mark in data field */
813a2f7427SDavid Greenman 
825b81b6b3SRodney W. Grimes /* Status register ST3 */
835b81b6b3SRodney W. Grimes #define NE7_ST3BITS	"\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002"
845b81b6b3SRodney W. Grimes 
853a2f7427SDavid Greenman #define NE7_ST3_FT	0x80	/* fault; PC: n/a */
863a2f7427SDavid Greenman #define NE7_ST3_WP	0x40	/* write protected */
873a2f7427SDavid Greenman #define NE7_ST3_RD	0x20	/* ready; PC: always true */
883a2f7427SDavid Greenman #define NE7_ST3_T0	0x10	/* track 0 */
893a2f7427SDavid Greenman #define NE7_ST3_TS	0x08	/* two-sided; PC: n/a */
903a2f7427SDavid Greenman #define NE7_ST3_HD	0x04	/* upper head select */
913a2f7427SDavid Greenman #define NE7_ST3_US	0x03	/* unit select */
923a2f7427SDavid Greenman 
9350d99d1aSJung-uk Kim /* Data Rate Select Register DSR (enhanced controller) */
9450d99d1aSJung-uk Kim #define I8207X_DSR_SR	0x80	/* software reset */
9550d99d1aSJung-uk Kim #define I8207X_DSR_LP	0x40	/* low power */
9650d99d1aSJung-uk Kim #define I8207X_DSR_PS	0x1c	/* precompensation select */
9750d99d1aSJung-uk Kim #define I8207X_DSR_RS	0x03	/* data rate select */
9850d99d1aSJung-uk Kim 
995b81b6b3SRodney W. Grimes /* Commands */
1003a2f7427SDavid Greenman /*
1013a2f7427SDavid Greenman  * the top three bits -- where appropriate -- are set as follows:
1023a2f7427SDavid Greenman  *
10394896f7bSJoerg Wunsch  * MT  - multi-track; allow both sides to be handled in single cmd
10494896f7bSJoerg Wunsch  * MFM - modified frequency modulation; use MFM encoding
10594896f7bSJoerg Wunsch  * SK  - skip; skip sectors marked as "deleted"
1063a2f7427SDavid Greenman  */
10794896f7bSJoerg Wunsch 
10894896f7bSJoerg Wunsch #define NE7CMD_MT	0x80	/* READ, WRITE, WRITEDEL, READDEL, SCAN* */
10994896f7bSJoerg Wunsch #define NE7CMD_MFM	0x40	/* same as MT, plus READTRK, READID, FORMAT */
11094896f7bSJoerg Wunsch #define NE7CMD_SK	0x20	/* READ, READDEL, SCAN* */
11194896f7bSJoerg Wunsch 
1120da90eb8SJung-uk Kim #define NE7CMD_READTRK	0x02	/*  read whole track */
1130da90eb8SJung-uk Kim #define NE7CMD_SPECIFY	0x03	/*  specify drive parameters - requires unit
11494896f7bSJoerg Wunsch 				 *  parameters byte */
1150da90eb8SJung-uk Kim #define NE7CMD_SENSED	0x04	/*  sense drive - requires unit select byte */
1160da90eb8SJung-uk Kim #define NE7CMD_WRITE	0x05	/*  write - requires eight additional bytes */
1170da90eb8SJung-uk Kim #define NE7CMD_READ	0x06	/*  read - requires eight additional bytes */
1180da90eb8SJung-uk Kim #define NE7CMD_RECAL	0x07	/*  recalibrate drive - requires
11994896f7bSJoerg Wunsch 				 *  unit select byte */
1200da90eb8SJung-uk Kim #define NE7CMD_SENSEI	0x08	/*  sense controller interrupt status */
1210da90eb8SJung-uk Kim #define NE7CMD_WRITEDEL	0x09	/*  write deleted data */
1220da90eb8SJung-uk Kim #define NE7CMD_READID	0x0a	/*  read ID field */
1230da90eb8SJung-uk Kim #define NE7CMD_READDEL	0x0c	/*  read deleted data */
1240da90eb8SJung-uk Kim #define NE7CMD_FORMAT	0x0d	/*  format - requires five additional bytes */
1250da90eb8SJung-uk Kim #define NE7CMD_SEEK	0x0f	/*  seek drive - requires unit select byte
12694896f7bSJoerg Wunsch 				 *  and new cyl byte */
1270da90eb8SJung-uk Kim #define NE7CMD_VERSION	0x10	/*  get version */
12894896f7bSJoerg Wunsch #define NE7CMD_SCNEQU	0x11	/*  scan equal */
12994896f7bSJoerg Wunsch #define NE7CMD_SCNLE	0x19	/*  scan less or equal */
13094896f7bSJoerg Wunsch #define NE7CMD_SCNGE	0x1d	/*  scan greater or equal */
1313a2f7427SDavid Greenman 
132dc5df763SJoerg Wunsch /*
133dc5df763SJoerg Wunsch  * Enhanced controller commands:
134dc5df763SJoerg Wunsch  */
1350da90eb8SJung-uk Kim #define I8207X_DUMPREG	0x0e	/*  dump internal registers */
1360da90eb8SJung-uk Kim #define I8207X_CONFIG	0x13	/*  configure enhanced features */
1373a2f7427SDavid Greenman 
1383a2f7427SDavid Greenman /*
1393a2f7427SDavid Greenman  * "specify" definitions
1403a2f7427SDavid Greenman  *
1413a2f7427SDavid Greenman  * acronyms (times are relative to a FDC clock of 8 MHz):
1423a2f7427SDavid Greenman  * srt - step rate; PC usually 3 ms
1433a2f7427SDavid Greenman  * hut - head unload time; PC usually maximum of 240 ms
1443a2f7427SDavid Greenman  * hlt - head load time; PC usually minimum of 2 ms
1453a2f7427SDavid Greenman  * nd  - no DMA flag; PC usually not set (0)
1463a2f7427SDavid Greenman  */
1473a2f7427SDavid Greenman 
1483a2f7427SDavid Greenman #define NE7_SPEC_1(srt, hut)	(((16 - (srt)) << 4) | (((hut) / 16)))
1493a2f7427SDavid Greenman #define NE7_SPEC_2(hlt, nd)	(((hlt) & 0xFE) | ((nd) & 1))
150