FreeBSD/Linux Kernel Cross Reference
sys/chips/fdc_82077.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: fdc_82077.h,v $
29 * Revision 2.3 93/01/14 17:16:17 danner
30 * Store for future reference attempt at getting it working.
31 * [92/12/10 af]
32 *
33 * Revision 2.2 92/03/02 18:32:39 rpd
34 * Created from the Intel specs:
35 * "Peripherals Handbook", Vol 1-2, 1990.
36 * [92/01/19 af]
37 *
38 */
39 /*
40 * File: fdi_82077_hdw.h
41 * Author: Alessandro Forin, Carnegie Mellon University
42 * Date: 1/92
43 *
44 * Defines for the Intel 82077 Floppy Disk Controller chip.
45 * Includes defines for 8272A and 82072.
46 */
47
48 #ifndef _FDC_82077_H_
49 #define _FDC_82077_H_
50
51 /*
52 * Chips we claim to understand, and their modes
53 */
54 #define fdc_8272a 0
55 #define fdc_82072 1
56 #define fdc_82077aa 2
57
58 #define at_mode 0
59 #define ps2_mode 1
60 #define mod30_mode 2
61
62 #define DRIVES_PER_FDC 4
63
64 /*
65 * Register maps
66 */
67 typedef struct {
68 volatile unsigned char fd_sra; /* r: status register A */
69 volatile unsigned char fd_srb; /* r: status register B */
70 volatile unsigned char fd_dor; /* rw: digital output reg */
71 volatile unsigned char fd_tdr; /* rw: tape drive register */
72 volatile unsigned char fd_msr; /* r: main status register */
73 #define fd_dsr fd_msr /* w: data rate select reg */
74 volatile unsigned char fd_data; /* rw: fifo */
75 volatile unsigned char fd_xxx; /* --reserved-- */
76 volatile unsigned char fd_dir; /* r: digital input reg */
77 #define fd_ccr fd_dir /* w: config control reg */
78 } fd_regmap_t;
79
80 typedef struct {
81 volatile unsigned char fd_msr; /* r: main status register */
82 volatile unsigned char fd_data; /* rw: data register */
83 } fd_8272a_regmap_t;
84
85 typedef fd_8272a_regmap_t fd_82072_regmap_t;
86 /*#define fd_dsr fd_msr /* w: data rate select reg */
87
88 /*
89 * Status register A (82077AA only)
90 *
91 * Only available in PS/2 (ps2) and Model 30 (m30) modes,
92 * not available in PC/AT (at) mode.
93 * Some signals have inverted polarity (~) on mod30
94 */
95
96 #define FD_SRA_INT 0x80 /* interrupt */
97 #define FD_SRA_DRV2 0x40 /* 2nd drive installed (ps2) */
98 #define FD_SRA_DRQ 0x40 /* dma request (mod30) */
99 #define FD_SRA_STEP 0x20 /* step pulse (~mod30) */
100 #define FD_SRA_TRK0 0x10 /* Track 0 (~mod30) */
101 #define FD_SRA_HDSEL 0x08 /* select head 1 (~mod30) */
102 #define FD_SRA_INDX 0x04 /* Index hole (~mod30) */
103 #define FD_SRA_WP 0x02 /* write protect (~mod30) */
104 #define FD_SRA_DIR 0x01 /* step dir, 1->center (~mod30) */
105
106 /*
107 * Status register B (82077AA only)
108 * Not available in at mode.
109 */
110
111 #define FD_SRB_DRV2 0x80 /* 2nd drive installed (mod30) */
112 /* wired 1 on ps2 */
113
114 #define FD_SRB_DS1 0x40 /* drive select 1 (mod30) */
115 /* wired 1 on ps2 */
116
117 #define FD_SRB_DS0 0x20 /* drive select 0 */
118 #define FD_SRB_WRDATA 0x10 /* out data (toggle or ~trigger) */
119 #define FD_SRB_RDDATA 0x08 /* in data (toggle or ~trigger) */
120 #define FD_SRB_WE 0x04 /* write enable (~mod30) */
121 #define FD_SRB_MOT_1 0x02 /* motor enable drive 1 (ps2) */
122 #define FD_SRB_DS3 0x02 /* drive select 3 (mod30) */
123 #define FD_SRB_MOT_0 0x01 /* motor enable drive 0 (ps2) */
124 #define FD_SRB_DS2 0x01 /* drive select 2 (mod30) */
125
126 /*
127 * Digital output register (82077AA only)
128 */
129
130 #define FD_DOR_MOT_3 0x80 /* motor enable drive 3 */
131 #define FD_DOR_MOT_2 0x40
132 #define FD_DOR_MOT_1 0x20
133 #define FD_DOR_MOT_0 0x10
134 #define FD_DOR_DMA_GATE 0x08 /* enable dma (mod30,at) */
135 #define FD_DOR_ENABLE 0x04 /* chip reset (inverted) */
136 #define FD_DOR_DRIVE_0 0x00 /* select drive no 0 */
137 #define FD_DOR_DRIVE_1 0x01
138 #define FD_DOR_DRIVE_2 0x02
139 #define FD_DOR_DRIVE_3 0x03
140
141 /*
142 * Tape drive register (82077AA only)
143 */
144
145 #define FD_TDR_TAPE_1 0x01 /* unit 1 is a tape */
146 #define FD_TDR_TAPE_2 0x02
147 #define FD_TDR_TAPE_3 0x03
148 #define FD_TDR_xxx 0xfc
149
150 /*
151 * Data-rate select register (82077AA and 82072)
152 */
153
154 #define FD_DSR_RESET 0x80 /* self-clearing reset */
155 #define FD_DSR_POWER_DOWN 0x40 /* stop clocks and oscill */
156 #define FD_DSR_zero 0x20 /* wired zero on 82077AA */
157 #define FD_DSR_EPLL 0x20 /* enable PLL on 82072 */
158
159 #define FD_DSR_PRECOMP_MASK 0x1c /* precompensation value */
160 # define FD_DSR_PRECOMP_SHIFT 2
161
162 # define FD_DSR_PRECOMP_DEFAULT 0 /* 41.67@1Mbps else 125ns */
163 # define FD_DSR_PRECOMP_41_67 1
164 # define FD_DSR_PRECOMP_83_34 2
165 # define FD_DSR_PRECOMP_125_00 3
166 # define FD_DSR_PRECOMP_166_67 4
167 # define FD_DSR_PRECOMP_208_33 5
168 # define FD_DSR_PRECOMP_250_00 6
169 # define FD_DSR_PRECOMP_DISABLE 7 /* 0.00ns */
170
171 #define FD_DSR_DATA_RATE_MASK 0x03
172 #define FD_DSR_SD_250 0x00 /* fm modulation, 250Kbps bit clock */
173 #define FD_DSR_SD_150 0x01
174 #define FD_DSR_SD_125 0x02
175
176 #define FD_DSR_DD_500 0x00 /* mfm modulation, 500Kbps */
177 #define FD_DSR_DD_300 0x01
178 #define FD_DSR_DD_250 0x02
179 #define FD_DSR_DD_1000 0x03 /* illegal for 82077 */
180
181 /*
182 * Main status register (all chips)
183 */
184
185 #define FD_MSR_RQM 0x80 /* request from master (allowed) */
186 #define FD_MSR_DIO 0x40 /* data in/out, 1->master read */
187 #define FD_MSR_NON_DMA 0x20 /* dma disabled */
188 #define FD_MSR_CMD_BSY 0x10 /* command in progress */
189 #define FD_MSR_DRV_3_BSY 0x08 /* drive busy seeking */
190 #define FD_MSR_DRV_2_BSY 0x04
191 #define FD_MSR_DRV_1_BSY 0x02
192 #define FD_MSR_DRV_0_BSY 0x01
193
194 /*
195 * FIFO (82077AA and 82072)
196 *
197 * Service delay is
198 * Threshold * 8
199 * delay = ------------- - 1.5 usecs
200 * Data-rate
201 */
202
203 #define FD_FIFO_DEEP 16
204
205 /*
206 * Digital input register (82077AA only)
207 */
208
209 #define FD_DIR_DSK_CHG 0x80 /* disk was changed (~mod30) */
210
211 #define FD_DIR_ones 0x78 /* wired ones for ps2 */
212 #define FD_DIR_zeroes 0x70 /* wired zeroes for mod30 */
213 #define FD_DIR_undef 0x7f /* undefined for at */
214
215 #define FD_DIR_DR_MASK_PS2 0x06 /* current data rate (ps2) */
216 # define FD_DIR_DR_SHIFT_PS2 1
217 #define FD_DIR_LOW_DENS 0x01 /* zero for 500/1M dr (ps2) */
218
219 #define FD_DIR_DMA_GATE 0x08 /* same as DOR (mod30) */
220 #define FD_DIR_NOPREC 0x04 /* same as CCR (mod30) */
221 #define FD_DIR_DR_MASK_M30 0x03 /* current data rate (mod30) */
222 # define FD_DIR_DR_SHIFT_M30 0
223
224 /*
225 * Configuration control register (82077AA only)
226 */
227
228 #define FD_CCR_DATA_RATE_MASK 0x03 /* see DSR for values */
229 #define FD_CCR_NOPREC 0x04 /* "has no function" (mod30) */
230
231
232 /*
233 * Programming
234 *
235 * Legend for command bytes, when applicable
236 *
237 * hds bit 2 of byte 1, head select (1 -> head 1)
238 * ds bits 0-1 of byte 1, drive select
239 * c cylinder number (max 76 for 8272A, else 255)
240 * h head number
241 * r sector number
242 * n number of bytes in sector
243 * eot end-of-track, e.g. final sector number
244 * gpl gap length
245 * dtl data length (for partial sectors)
246 * st0-3 status byte
247 * srt step rate time
248 * hut head unload time
249 * hlt head load time
250 * nd disable DMA
251 * mot do not turn motor on before checking drive status
252 * pcn present cylinder number
253 * ncn new cylinder number
254 * rcn relative cylinder number (new=present+rcn)
255 * sc sectors/cylinder
256 * d filler byte
257 * ? undefined
258 * hsda high-speed disk adjust (doubles motor on/off delays)
259 * moff motor off timer, one disk revolution increments
260 * mon motor on timer, ditto
261 * eis enable implied seeks
262 * dfifo disable fifo
263 * poll disable poll
264 * fifthr fifo threshold (1 to 16 bytes)
265 * pretrk precomp starts on this trackno (0-255)
266 * wgate change timings of WE signal, in perpendicular mode
267 * gap change gap2 length, in perpendicular mode
268 * ec in verify, qualify terminating conditions (sc viz eot)
269 */
270
271 /* First byte of command, qualifiers */
272 #define FD_CMD_MT 0x80 /* Multi-track */
273 #define FD_CMD_MFM 0x40 /* Double density */
274 #define FD_CMD_SK 0x20 /* skip deleted data address mark */
275 #define FD_CMD_DIR 0x40 /* relative seek direction (up) */
276
277 /* command codes and description */
278
279 /*
280 * Read an entire track.
281 * Qualifiers: MFM, SK (8272A only)
282 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
283 * Result total: 7 st0,st1,st2,c,h,r,n
284 */
285 #define FD_CMD_READ_TRACK 0x02
286
287 /*
288 * Specify timers
289 * Qualifiers:
290 * Bytes total: 3 code,srt+hut,hlt+nd
291 * Result total:
292 */
293 #define FD_CMD_SPECIFY 0x03
294
295 /*
296 * Sense status of drive
297 * Qualifiers:
298 * Bytes total: 2 code,hds+ds +mot(82072 only)
299 * Result total: 1 st3
300 */
301 #define FD_CMD_SENSE_DRIVE_STATUS 0x04
302 # define FD_CMD_SDS_NO_MOT 0x80
303
304 /*
305 * Write
306 * Qualifiers: MT, MFM
307 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
308 * Result total: 7 st0,st1,st2,c,h,r,n
309 */
310 #define FD_CMD_WRITE_DATA 0x05
311
312 /*
313 * Read
314 * Qualifiers: MT, MFM, SK
315 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
316 * Result total: 7 st0,st1,st2,c,h,r,n
317 */
318 #define FD_CMD_READ_DATA 0x06
319
320 /*
321 * Seek to track 0
322 * Qualifiers:
323 * Bytes total: 2 code,ds
324 * Result total:
325 */
326 #define FD_CMD_RECALIBRATE 0x07
327
328 /*
329 * Sense interrupt status
330 * Qualifiers:
331 * Bytes total: 1 code
332 * Result total: 2 st0,pcn
333 */
334 #define FD_CMD_SENSE_INT_STATUS 0x08
335
336 /*
337 * Write data and mark deleted
338 * Qualifiers: MT, MFM
339 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
340 * Result total: 7 st0,st1,st2,c,h,r,n
341 */
342 #define FD_CMD_WRITE_DELETED_DATA 0x09
343
344 /*
345 * Read current head position
346 * Qualifiers: MFM
347 * Bytes total: 2 code,hds+ds
348 * Result total: 7 st0,st1,st2,c,h,r,n
349 */
350 #define FD_CMD_READ_ID 0x0a
351
352 /*
353 * Set value of MOT pin, unconditionally
354 * Qualifiers: see
355 * Bytes total: 1 code+..
356 * Result total: none returns to command phase
357 */
358 #define FD_CMD_MOTOR_ON_OFF 0x0b /* 82072 only */
359
360 # define FD_CMD_MOT_ON 0x80
361 # define FD_CMD_MOT_DS 0x60
362 # define FD_CMD_MOT_DS_SHIFT 5
363
364 /*
365 * Read data despite deleted address mark
366 * Qualifiers: MT, MFM, SK
367 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
368 * Result total: 7 st0,st1,st2,c,h,r,n
369 */
370 #define FD_CMD_READ_DELETED_DATA 0x0c
371
372 /*
373 * Media initialization
374 * Qualifiers: MFM
375 * Bytes total: 6 code,hds+ds,n,sc,gpl,d
376 * Data: 4*sc/2 c,h,r,n
377 * Result total: 7 st0,st1,st2,?,?,?,?
378 */
379 #define FD_CMD_FORMAT_TRACK 0x0d
380
381 /*
382 * Dump internal register status
383 * Qualifiers:
384 * Bytes total: 1 code
385 * Result total: 10 pcn0,pcn1,pcn2,pcn3,srt+hut,hlt+nd,
386 * sc/eot,hsda+moff+mon,
387 * eis+dfifo+poll+fifothr, pretrk
388 * Notes: 82077AA does not provide for hsda+moff+mon
389 */
390 #define FD_CMD_DUMPREG 0x0e /* not 8272a */
391
392 /*
393 * Move head
394 * Qualifiers:
395 * Bytes total: 3 code,hds+ds,ncn
396 * Result total:
397 */
398 #define FD_CMD_SEEK 0x0f
399
400 /*
401 *
402 * Qualifiers:
403 * Bytes total: 1 code
404 * Result total: 1 version
405 */
406 #define FD_CMD_VERSION 0x10 /* 82077AA only */
407 # define FD_VERSION_82077AA 0x90
408
409 /*
410 * Scan disk data
411 * Qualifiers: MT, MFM, SK
412 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
413 * Result total: 7 st0,st1,st2,c,h,r,n
414 */
415 #define FD_CMD_SCAN_EQUAL 0x11 /* 8272A only */
416
417 /*
418 * Specify timers
419 * Qualifiers:
420 * Bytes total: 2 code,wgate+gap
421 * Result total:
422 */
423 #define FD_CMD_PERPENDICULAR_MODE 0x12 /* 82077AA only */
424
425 /*
426 * Set configuration parameters
427 * Qualifiers:
428 * Bytes total: 4 code,hsda+moff+mon,eis+dfifo+poll+fifothr,
429 * pretrk
430 * Result total:
431 * Notes: 82077AA does not provide for hsda+moff+mon
432 */
433 #define FD_CMD_CONFIGURE 0x13 /* not 8272a */
434
435 /*
436 * Verify CRC of disk data
437 * Qualifiers: MT, MFM, SK
438 * Bytes total: 9 code,ec+hds+ds,c,h,r,n,eot,gpl,dtl/sc
439 * Result total: 7 st0,st1,st2,c,h,r,n
440 */
441 #define FD_CMD_VERIFY 0x16 /* 82077AA only */
442
443 /*
444 * Scan disk data (disk less-or-equal memory)
445 * Qualifiers: MT, MFM, SK
446 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
447 * Result total: 7 st0,st1,st2,c,h,r,n
448 */
449 #define FD_CMD_SCAN_LOW_OR_EQUAL 0x19 /* 8272A only */
450
451 /*
452 * Scan disk data (disk greater-or-equal memory)
453 * Qualifiers: MT, MFM, SK
454 * Bytes total: 9 code,hds+ds,c,h,r,n,eot,gpl,dtl
455 * Result total: 7 st0,st1,st2,c,h,r,n
456 */
457 #define FD_CMD_SCAN_HIGH_OR_EQUAL 0x1d /* 8272A only */
458
459 /*
460 * Specify timers
461 * Qualifiers: DIR
462 * Bytes total: 3 code,hds+ds,rcn
463 * Result total:
464 */
465 #define FD_CMD_RELATIVE_SEEK 0x8f /* not 8272a */
466
467 /*
468 * Any invalid command code
469 * Qualifiers:
470 * Bytes total: 1 code
471 * Result total: 1 st0 (st0 == 0x80)
472 */
473 #define FD_CMD_INVALID 0xff
474
475
476 /*
477 * Results and statii
478 *
479 * The typical command returns three status bytes,
480 * followed by four drive status bytes.
481 */
482
483 /*
484 * Status register 0
485 */
486 #define FD_ST0_IC_MASK 0xc0 /* interrupt completion code */
487
488 # define FD_ST0_IC_OK 0x00 /* terminated ok */
489 # define FD_ST0_IC_AT 0x40 /* exec phase ended sour */
490 # define FD_ST0_IC_BAD_CMD 0x80 /* didnt grok */
491 # define FD_ST0_IC_AT_POLL 0xc0 /* polling got in the way */
492
493 #define FD_ST0_SE 0x20 /* (implied) seek ended */
494 #define FD_ST0_EC 0x10 /* equipment check */
495 #define FD_ST0_NR 0x08 /* not ready (raz for 82077aa) */
496 #define FD_ST0_H 0x04 /* currently selected head */
497 #define FD_ST0_DS 0x03 /* currently selected drive */
498
499 /*
500 * Status register 1
501 */
502
503 #define FD_ST1_EN 0x80 /* end of cylinder (TC not set?) */
504 #define FD_ST1_zero 0x48
505 #define FD_ST1_DE 0x20 /* data error, bad CRC */
506 #define FD_ST1_OR 0x10 /* overrun/underrun
507 #define FD_ST1_ND 0x04 /* no data, sector not found */
508 #define FD_ST1_NW 0x02 /* write protect signal */
509 #define FD_ST1_MA 0x01 /* missing address mark */
510
511 /*
512 * Status register 2
513 */
514
515 #define FD_ST2_zero 0x80
516 #define FD_ST2_CM 0x40 /* control mark, improper read */
517 #define FD_ST2_DD 0x20 /* the CRC error was for data */
518 #define FD_ST2_WC 0x10 /* wrong cylinder */
519 #define FD_ST2_SH 0x08 /* scan hit (8272a only) */
520 #define FD_ST2_SN 0x04 /* scan not met (8272a only) */
521 #define FD_ST2_BC 0x02 /* bad cylinder, has 0xff mark */
522 #define FD_ST2_MD 0x01 /* missing data mark */
523
524 /*
525 * Status register 3
526 * (sense drive status)
527 */
528
529 #define FD_ST3_FT 0x80 /* fault pin (0 if not 8272a) */
530 #define FD_ST3_WP 0x40 /* write protect pin */
531 #define FD_ST3_RDY 0x20 /* ready pin (1 on 82077aa) */
532 #define FD_ST3_T0 0x10 /* track0 pin */
533 #define FD_ST3_TS 0x08 /* two-sided pin (1 if not 8272a) */
534 #define FD_ST3_HD 0x04 /* hdsel pin */
535 #define FD_ST3_DS 0x03 /* drive select pins (1&0) */
536
537
538 #endif /* _FDC_82077_H_ */
Cache object: 7822ec6cccd6748e6d3e4d8544f5cc2f
|