xref: /netbsd/sys/arch/x68k/dev/fdreg.h (revision a38595c0)
1*a38595c0Stsutsui /*	$NetBSD: fdreg.h,v 1.6 2012/10/14 18:38:32 tsutsui Exp $	*/
2320e7320Soki 
3320e7320Soki /*-
4320e7320Soki  * Copyright (c) 1991 The Regents of the University of California.
5320e7320Soki  * All rights reserved.
6320e7320Soki  *
7320e7320Soki  * Redistribution and use in source and binary forms, with or without
8320e7320Soki  * modification, are permitted provided that the following conditions
9320e7320Soki  * are met:
10320e7320Soki  * 1. Redistributions of source code must retain the above copyright
11320e7320Soki  *    notice, this list of conditions and the following disclaimer.
12320e7320Soki  * 2. Redistributions in binary form must reproduce the above copyright
13320e7320Soki  *    notice, this list of conditions and the following disclaimer in the
14320e7320Soki  *    documentation and/or other materials provided with the distribution.
15aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
16320e7320Soki  *    may be used to endorse or promote products derived from this software
17320e7320Soki  *    without specific prior written permission.
18320e7320Soki  *
19320e7320Soki  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20320e7320Soki  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21320e7320Soki  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22320e7320Soki  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23320e7320Soki  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24320e7320Soki  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25320e7320Soki  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26320e7320Soki  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27320e7320Soki  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28320e7320Soki  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29320e7320Soki  * SUCH DAMAGE.
30320e7320Soki  *
31320e7320Soki  *	@(#)fdreg.h	7.1 (Berkeley) 5/9/91
32320e7320Soki  */
33320e7320Soki 
34320e7320Soki /*
35320e7320Soki  * x680x0 floppy controller registers and bitfields
36320e7320Soki  */
37320e7320Soki 
38320e7320Soki /* uses NEC72065 controller */
39320e7320Soki #include <dev/ic/nec765reg.h>
40320e7320Soki 
41320e7320Soki /* registers */
42ba80d2c6Sminoura #define	fdsts	0	/* NEC 765 Main Status Register (R) */
43ba80d2c6Sminoura #define	fddata	1	/* NEC 765 Data Register (R/W) */
44320e7320Soki #define fdout	2	/* Digital Output Register (W) */
45ba80d2c6Sminoura #define	fdctl	3	/* Control Register (W) */
46320e7320Soki #define	FDC_500KBPS	0x00	/* 500KBPS MFM drive transfer rate */
47320e7320Soki #define	FDC_300KBPS	0x01	/* 300KBPS MFM drive transfer rate */
48320e7320Soki #define	FDC_250KBPS	0x02	/* 250KBPS MFM drive transfer rate */
49320e7320Soki #define	FDC_125KBPS	0x03	/* 125KBPS FM drive transfer rate */
50320e7320Soki 
51320e7320Soki #define	FDC_BSIZE	512
52ba80d2c6Sminoura #define	FDC_MAXIOSIZE	MAXBSIZE
53ba80d2c6Sminoura 
54ba80d2c6Sminoura /* Floppy disk controller command bytes. */
55ba80d2c6Sminoura #define NE7CMD_RESET       0x36	/* reset command for fdc */
56ba80d2c6Sminoura 
57ba80d2c6Sminoura /* default attach args */
58ba80d2c6Sminoura #define FDC_ADDR 0xe94000	/* builtin fdc is here */
59f704c790Stsutsui #define FDC_MAPSIZE 0x2000	/* builtin fdc I/O range */
60ba80d2c6Sminoura #define FDC_INTR 96		/* interrupt vector */
61ba80d2c6Sminoura #define FDC_DMA 0		/* DMA ch# */
62ba80d2c6Sminoura #define FDC_DMAINTR 100		/* DMA interrupt vector */
63*a38595c0Stsutsui 
64*a38595c0Stsutsui /*
65*a38595c0Stsutsui  * fdformat parameters
66*a38595c0Stsutsui  */
67*a38595c0Stsutsui 
68*a38595c0Stsutsui #define FD_MAX_NSEC	18	/* highest known number of spt */
69*a38595c0Stsutsui 
70*a38595c0Stsutsui struct ne7_fd_formb {
71*a38595c0Stsutsui 	int cyl, head;
72*a38595c0Stsutsui 	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
73*a38595c0Stsutsui 
74*a38595c0Stsutsui 	union {
75*a38595c0Stsutsui 		struct fd_form_data {
76*a38595c0Stsutsui 			/*
77*a38595c0Stsutsui 			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
78*a38595c0Stsutsui 			 * it is hardware-dependent since it exactly
79*a38595c0Stsutsui 			 * matches the byte sequence to write to FDC
80*a38595c0Stsutsui 			 * during its `format track' operation
81*a38595c0Stsutsui 			 */
82*a38595c0Stsutsui 			uint8_t secshift; /* 0 -> 128, ...; usually 2 -> 512 */
83*a38595c0Stsutsui 			uint8_t nsecs;    /* must be <= FD_MAX_NSEC */
84*a38595c0Stsutsui 			uint8_t gaplen;   /* GAP 3 length; usually 84 */
85*a38595c0Stsutsui 			uint8_t fillbyte; /* usually 0xf6 */
86*a38595c0Stsutsui 			struct fd_idfield_data {
87*a38595c0Stsutsui 				/*
88*a38595c0Stsutsui 				 * data to write into id fields;
89*a38595c0Stsutsui 				 * for obscure formats, they mustn't match
90*a38595c0Stsutsui 				 * the real values (but mostly do)
91*a38595c0Stsutsui 				 */
92*a38595c0Stsutsui 				uint8_t cylno;		/* 0 thru 79 (or 39) */
93*a38595c0Stsutsui 				uint8_t headno;		/* 0, or 1 */
94*a38595c0Stsutsui 				uint8_t secno;		/* starting at 1! */
95*a38595c0Stsutsui 				uint8_t secsize;	/* usually 2 */
96*a38595c0Stsutsui 			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
97*a38595c0Stsutsui 		} structured;
98*a38595c0Stsutsui 		uint8_t raw[1];	/* to have continuous indexed access */
99*a38595c0Stsutsui 	} format_info;
100*a38595c0Stsutsui };
101*a38595c0Stsutsui 
102*a38595c0Stsutsui /* make life easier */
103*a38595c0Stsutsui # define fd_formb_secshift   format_info.structured.secshift
104*a38595c0Stsutsui # define fd_formb_nsecs      format_info.structured.nsecs
105*a38595c0Stsutsui # define fd_formb_gaplen     format_info.structured.gaplen
106*a38595c0Stsutsui # define fd_formb_fillbyte   format_info.structured.fillbyte
107*a38595c0Stsutsui /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
108*a38595c0Stsutsui # define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
109*a38595c0Stsutsui # define fd_formb_headno(i)  format_info.structured.idfields[i].headno
110*a38595c0Stsutsui # define fd_formb_secno(i)   format_info.structured.idfields[i].secno
111*a38595c0Stsutsui # define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
112