1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_TPQIC02_H
11 #define _LINUX_TPQIC02_H
12
13 #include <linux/config.h>
14
15 #if CONFIG_QIC02_TAPE
16
17
18 #include <linux/mtio.h>
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #define WANGTEK 1
33 #define EVEREX (WANGTEK+1)
34 #define EVEREX_811V EVEREX
35 #define EVEREX_831V EVEREX
36 #define ARCHIVE 3
37 #define ARCHIVE_SC400 ARCHIVE
38 #define ARCHIVE_SC402 ARCHIVE
39 #define ARCHIVE_SC499 ARCHIVE
40
41 #define MOUNTAIN 5
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 #ifndef CONFIG_QIC02_DYNCONF
76
77 #define QIC02_TAPE_DRIVE MT_ISQIC02_ALL_FEATURES
78
79
80
81
82
83
84
85
86
87 #define QIC02_TAPE_IFC WANGTEK
88
89
90
91 #define QIC02_TAPE_PORT 0x300
92 #define QIC02_TAPE_IRQ 5
93 #define QIC02_TAPE_DMA 1
94
95
96
97
98
99
100 #undef QIC02_TAPE_DMA3_FIX
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 #if QIC02_TAPE_DRIVE == MT_ISWT5150
116 #define TP_HAVE_DENS 1
117 #define TP_HAVE_BSF 0
118 #define TP_HAVE_FSR 0
119 #define TP_HAVE_BSR 0
120 #define TP_HAVE_EOD 0
121 #define TP_HAVE_SEEK 0
122 #define TP_HAVE_TELL 0
123 #define TP_HAVE_RAS1 1
124 #define TP_HAVE_RAS2 1
125
126 #elif QIC02_TAPE_DRIVE == MT_ISARCHIVESC499
127 #define TP_HAVE_DENS 1
128 #define TP_HAVE_BSF 0
129 #define TP_HAVE_FSR 1
130 #define TP_HAVE_BSR 1
131 #define TP_HAVE_EOD 1
132 #define TP_HAVE_SEEK 0
133 #define TP_HAVE_TELL 0
134 #define TP_HAVE_RAS1 1
135 #define TP_HAVE_RAS2 1
136
137
138 #elif (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2060L) || (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2150L)
139 #define TP_HAVE_DENS 1
140 #define TP_HAVE_BSF 0
141 #define TP_HAVE_FSR 1
142 #define TP_HAVE_BSR 1
143 #define TP_HAVE_EOD 1
144 #define TP_HAVE_TELL 1
145 #define TP_HAVE_SEEK 1
146 #define TP_HAVE_RAS1 1
147 #define TP_HAVE_RAS2 1
148
149
150 #elif QIC02_TAPE_DRIVE == MT_ISARCHIVE_5945L2
151
152 #define TP_HAVE_DENS 1
153 #define TP_HAVE_BSF 0
154 #define TP_HAVE_FSR 1
155 #define TP_HAVE_BSR 1
156 #define TP_HAVE_EOD 1
157 #define TP_HAVE_TELL 1
158 #define TP_HAVE_SEEK 1
159 #define TP_HAVE_RAS1 1
160 #define TP_HAVE_RAS2 1
161
162
163 #elif QIC02_TAPE_DRIVE == MT_ISTEAC_MT2ST
164
165 #define TP_HAVE_DENS 0
166 #define TP_HAVE_BSF 0
167 #define TP_HAVE_FSR 1
168 #define TP_HAVE_BSR 1
169 #define TP_HAVE_EOD 1
170 #define TP_HAVE_SEEK 1
171 #define TP_HAVE_TELL 1
172 #define TP_HAVE_RAS1 1
173 #define TP_HAVE_RAS2 1
174
175
176 #elif QIC02_TAPE_DRIVE == MT_ISQIC02_ALL_FEATURES
177 #define TP_HAVE_DENS 1
178 #define TP_HAVE_BSF 1
179 #define TP_HAVE_FSR 1
180 #define TP_HAVE_BSR 1
181 #define TP_HAVE_EOD 1
182 #define TP_HAVE_SEEK 1
183 #define TP_HAVE_TELL 1
184 #define TP_HAVE_RAS1 1
185 #define TP_HAVE_RAS2 1
186
187
188
189 #else
190 #error No QIC-02 tape drive type defined!
191
192
193
194
195
196 #endif
197
198 #endif
199
200
201
202 #define WT_QIC02_STAT_PORT (QIC02_TAPE_PORT)
203 #define WT_QIC02_CTL_PORT (QIC02_TAPE_PORT)
204 #define WT_QIC02_CMD_PORT (QIC02_TAPE_PORT+1)
205 #define WT_QIC02_DATA_PORT (QIC02_TAPE_PORT+1)
206
207
208 #define WT_QIC02_STAT_READY 0x01
209 #define WT_QIC02_STAT_EXCEPTION 0x02
210 #define WT_QIC02_STAT_MASK (WT_QIC02_STAT_READY|WT_QIC02_STAT_EXCEPTION)
211
212 #define WT_QIC02_STAT_RESETMASK 0x07
213 #define WT_QIC02_STAT_RESETVAL (WT_QIC02_STAT_RESETMASK & ~WT_QIC02_STAT_EXCEPTION)
214
215
216 #define WT_QIC02_CTL_RESET 0x02
217 #define WT_QIC02_CTL_REQUEST 0x04
218 #define WT_CTL_ONLINE 0x01
219 #define WT_CTL_CMDOFF 0xC0
220
221 #define WT_CTL_DMA3 0x10
222 #define WT_CTL_DMA1 0x08
223
224
225
226
227
228 #define AR_QIC02_STAT_PORT (QIC02_TAPE_PORT+1)
229 #define AR_QIC02_CTL_PORT (QIC02_TAPE_PORT+1)
230 #define AR_QIC02_CMD_PORT (QIC02_TAPE_PORT)
231 #define AR_QIC02_DATA_PORT (QIC02_TAPE_PORT)
232
233 #define AR_START_DMA_PORT (QIC02_TAPE_PORT+2)
234 #define AR_RESET_DMA_PORT (QIC02_TAPE_PORT+3)
235
236
237 #define AR_STAT_IRQF 0x80
238 #define AR_QIC02_STAT_READY 0x40
239 #define AR_QIC02_STAT_EXCEPTION 0x20
240 #define AR_QIC02_STAT_MASK (AR_QIC02_STAT_READY|AR_QIC02_STAT_EXCEPTION)
241 #define AR_STAT_DMADONE 0x10
242 #define AR_STAT_DIRC 0x08
243
244 #define AR_QIC02_STAT_RESETMASK 0x70
245 #define AR_QIC02_STAT_RESETVAL ((AR_QIC02_STAT_RESETMASK & ~AR_STAT_IRQF & ~AR_QIC02_STAT_EXCEPTION) | AR_STAT_DMADONE)
246
247
248 #define AR_QIC02_CTL_RESET 0x80
249 #define AR_QIC02_CTL_REQUEST 0x40
250 #define AR_CTL_IEN 0x20
251 #define AR_CTL_DNIEN 0x10
252
253
254
255
256
257
258
259 #define MTN_QIC02_STAT_PORT (QIC02_TAPE_PORT+1)
260 #define MTN_QIC02_CTL_PORT (QIC02_TAPE_PORT+1)
261 #define MTN_QIC02_CMD_PORT (QIC02_TAPE_PORT)
262 #define MTN_QIC02_DATA_PORT (QIC02_TAPE_PORT)
263
264 #define MTN_W_SELECT_DMA_PORT (QIC02_TAPE_PORT+2)
265 #define MTN_R_DESELECT_DMA_PORT (QIC02_TAPE_PORT+2)
266 #define MTN_W_DMA_WRITE_PORT (QIC02_TAPE_PORT+3)
267
268
269 #define MTN_QIC02_STAT_READY 0x02
270 #define MTN_QIC02_STAT_EXCEPTION 0x04
271 #define MTN_QIC02_STAT_MASK (MTN_QIC02_STAT_READY|MTN_QIC02_STAT_EXCEPTION)
272 #define MTN_STAT_DMADONE 0x01
273
274 #define MTN_QIC02_STAT_RESETMASK 0x07
275 #define MTN_QIC02_STAT_RESETVAL ((MTN_QIC02_STAT_RESETMASK & ~MTN_QIC02_STAT_EXCEPTION) | MTN_STAT_DMADONE)
276
277
278 #define MTN_QIC02_CTL_RESET_NOT 0x80
279 #define MTN_QIC02_CTL_RESET 0x80
280
281 #define MTN_QIC02_CTL_ONLINE 0x40
282 #define MTN_QIC02_CTL_REQUEST 0x20
283 #define MTN_QIC02_CTL_IRQ_DRIVER 0x10
284 #define MTN_QIC02_CTL_DMA_DRIVER 0x08
285 #define MTN_CTL_EXC_IEN 0x04
286 #define MTN_CTL_RDY_IEN 0x02
287 #define MTN_CTL_DNIEN 0x01
288
289 #define MTN_CTL_ONLINE (MTN_QIC02_CTL_RESET_NOT | MTN_QIC02_CTL_IRQ_DRIVER | MTN_QIC02_CTL_DMA_DRIVER)
290
291
292 #ifndef CONFIG_QIC02_DYNCONF
293
294 # define QIC02_TAPE_DEBUG (qic02_tape_debug)
295
296 # if QIC02_TAPE_IFC == WANGTEK
297 # define QIC02_STAT_PORT WT_QIC02_STAT_PORT
298 # define QIC02_CTL_PORT WT_QIC02_CTL_PORT
299 # define QIC02_CMD_PORT WT_QIC02_CMD_PORT
300 # define QIC02_DATA_PORT WT_QIC02_DATA_PORT
301
302 # define QIC02_STAT_READY WT_QIC02_STAT_READY
303 # define QIC02_STAT_EXCEPTION WT_QIC02_STAT_EXCEPTION
304 # define QIC02_STAT_MASK WT_QIC02_STAT_MASK
305 # define QIC02_STAT_RESETMASK WT_QIC02_STAT_RESETMASK
306 # define QIC02_STAT_RESETVAL WT_QIC02_STAT_RESETVAL
307
308 # define QIC02_CTL_RESET WT_QIC02_CTL_RESET
309 # define QIC02_CTL_REQUEST WT_QIC02_CTL_REQUEST
310
311 # if QIC02_TAPE_DMA == 3
312 # ifdef QIC02_TAPE_DMA3_FIX
313 # define WT_CTL_DMA WT_CTL_DMA1
314 # else
315 # define WT_CTL_DMA WT_CTL_DMA3
316 # endif
317 # elif QIC02_TAPE_DMA == 1
318 # define WT_CTL_DMA WT_CTL_DMA1
319 # else
320 # error Unsupported or incorrect DMA configuration.
321 # endif
322
323 # elif QIC02_TAPE_IFC == ARCHIVE
324 # define QIC02_STAT_PORT AR_QIC02_STAT_PORT
325 # define QIC02_CTL_PORT AR_QIC02_CTL_PORT
326 # define QIC02_CMD_PORT AR_QIC02_CMD_PORT
327 # define QIC02_DATA_PORT AR_QIC02_DATA_PORT
328
329 # define QIC02_STAT_READY AR_QIC02_STAT_READY
330 # define QIC02_STAT_EXCEPTION AR_QIC02_STAT_EXCEPTION
331 # define QIC02_STAT_MASK AR_QIC02_STAT_MASK
332 # define QIC02_STAT_RESETMASK AR_QIC02_STAT_RESETMASK
333 # define QIC02_STAT_RESETVAL AR_QIC02_STAT_RESETVAL
334
335 # define QIC02_CTL_RESET AR_QIC02_CTL_RESET
336 # define QIC02_CTL_REQUEST AR_QIC02_CTL_REQUEST
337
338 # if QIC02_TAPE_DMA > 3
339 # error DMA channels other than 1 and 3 are not supported.
340 # endif
341
342 # elif QIC02_TAPE_IFC == MOUNTAIN
343 # define QIC02_STAT_PORT MTN_QIC02_STAT_PORT
344 # define QIC02_CTL_PORT MTN_QIC02_CTL_PORT
345 # define QIC02_CMD_PORT MTN_QIC02_CMD_PORT
346 # define QIC02_DATA_PORT MTN_QIC02_DATA_PORT
347
348 # define QIC02_STAT_READY MTN_QIC02_STAT_READY
349 # define QIC02_STAT_EXCEPTION MTN_QIC02_STAT_EXCEPTION
350 # define QIC02_STAT_MASK MTN_QIC02_STAT_MASK
351 # define QIC02_STAT_RESETMASK MTN_QIC02_STAT_RESETMASK
352 # define QIC02_STAT_RESETVAL MTN_QIC02_STAT_RESETVAL
353
354 # define QIC02_CTL_RESET MTN_QIC02_CTL_RESET
355 # define QIC02_CTL_REQUEST MTN_QIC02_CTL_REQUEST
356
357 # if QIC02_TAPE_DMA > 3
358 # error DMA channels other than 1 and 3 are not supported.
359 # endif
360
361 # else
362 # error No valid interface card specified!
363 # endif
364
365
366
367
368
369 # ifndef WT_CTL_DMA
370 # define WT_CTL_DMA WT_CTL_DMA1
371 # endif
372
373
374
375 #else
376
377
378
379
380
381
382
383 # define QIC02_TAPE_DRIVE (qic02_tape_dynconf.mt_type)
384 # define QIC02_TAPE_IFC (qic02_tape_ccb.ifc_type)
385 # define QIC02_TAPE_IRQ (qic02_tape_dynconf.irqnr)
386 # define QIC02_TAPE_DMA (qic02_tape_dynconf.dmanr)
387 # define QIC02_TAPE_PORT (qic02_tape_dynconf.port)
388 # define WT_CTL_DMA (qic02_tape_ccb.dma_enable_value)
389 # define QIC02_TAPE_DEBUG (qic02_tape_dynconf.debug)
390
391 # define QIC02_STAT_PORT (qic02_tape_ccb.port_stat)
392 # define QIC02_CTL_PORT (qic02_tape_ccb.port_ctl)
393 # define QIC02_CMD_PORT (qic02_tape_ccb.port_cmd)
394 # define QIC02_DATA_PORT (qic02_tape_ccb.port_data)
395
396 # define QIC02_STAT_READY (qic02_tape_ccb.stat_ready)
397 # define QIC02_STAT_EXCEPTION (qic02_tape_ccb.stat_exception)
398 # define QIC02_STAT_MASK (qic02_tape_ccb.stat_mask)
399
400 # define QIC02_STAT_RESETMASK (qic02_tape_ccb.stat_resetmask)
401 # define QIC02_STAT_RESETVAL (qic02_tape_ccb.stat_resetval)
402
403 # define QIC02_CTL_RESET (qic02_tape_ccb.ctl_reset)
404 # define QIC02_CTL_REQUEST (qic02_tape_ccb.ctl_request)
405
406 # define TP_HAVE_DENS (qic02_tape_dynconf.have_dens)
407 # define TP_HAVE_BSF (qic02_tape_dynconf.have_bsf)
408 # define TP_HAVE_FSR (qic02_tape_dynconf.have_fsr)
409 # define TP_HAVE_BSR (qic02_tape_dynconf.have_bsr)
410 # define TP_HAVE_EOD (qic02_tape_dynconf.have_eod)
411 # define TP_HAVE_SEEK (qic02_tape_dynconf.have_seek)
412 # define TP_HAVE_TELL (qic02_tape_dynconf.have_tell)
413 # define TP_HAVE_RAS1 (qic02_tape_dynconf.have_ras1)
414 # define TP_HAVE_RAS2 (qic02_tape_dynconf.have_ras2)
415
416 #endif
417
418
419
420
421 #define AR_QCMDV_TELL_BLK 0xAE
422 #define AR_QCMDV_SEEK_BLK 0xAD
423 #define AR_SEEK_BUF_SIZE 3
424
425
426
427
428
429
430
431
432 #define QCMD_SEL_1 0x01
433 #define QCMD_SEL_2 0x02
434 #define QCMD_SEL_3 0x04
435 #define QCMD_SEL_4 0x08
436 #define QCMD_REWIND 0x21
437 #define QCMD_ERASE 0x22
438 #define QCMD_RETEN 0x24
439 #define QCMD_WRT_DATA 0x40
440 #define QCMD_WRT_FM 0x60
441 #define QCMD_RD_DATA 0x80
442 #define QCMD_RD_FM 0xA0
443 #define QCMD_RD_STAT 0xC0
444
445
446
447 #define QCMD_DENS_11 0x26
448 #define QCMD_DENS_24 0x27
449 #define QCMD_DENS_120 0x28
450 #define QCMD_DENS_150 0x29
451 #define QCMD_DENS_300 0x2A
452 #define QCMD_DENS_600 0x2B
453
454
455 #define QCMD_WRTNU_DATA 0x40
456 #define QCMD_SPACE_FWD 0x81
457 #define QCMD_SPACE_BCK 0x89
458 #define QCMD_RD_FM_BCK 0xA8
459 #define QCMD_SEEK_EOD 0xA3
460 #define QCMD_RD_STAT_X1 0xC1
461 #define QCMD_RD_STAT_X2 0xC4
462 #define QCMD_RD_STAT_X3 0xE0
463 #define QCMD_SELF_TST1 0xC2
464 #define QCMD_SELF_TST2 0xCA
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479 #define QFA_ENABLE 0x2D
480 #define QFA_DATA 0x20
481 #define QFA_DIR 0x23
482 #define QFA_RD_POS 0xCF
483 #define QFA_SEEK_EOD 0xA1
484 #define QFA_SEEK_BLK 0xAF
485
486
487
488
489
490
491
492 #define TPQD_SENSE_TEXT 0x0001
493 #define TPQD_SENSE_CNTS 0x0002
494 #define TPQD_REWIND 0x0004
495 #define TPQD_TERM_CYCLE 0x0008
496 #define TPQD_IOCTLS 0x0010
497 #define TPQD_DMAX 0x0020
498 #define TPQD_BLKSZ 0x0040
499 #define TPQD_MISC 0x0080
500
501 #define TPQD_DEBUG 0x0100
502
503 #define TPQD_DIAGS 0x1000
504
505 #define TPQD_ALWAYS 0x8000
506
507 #define TPQD_DEFAULT_FLAGS 0x00fc
508
509
510 #define TPQDBG(f) ((QIC02_TAPE_DEBUG) & (TPQD_##f))
511
512
513
514
515
516
517
518
519
520
521
522 #define TP_REWCLOSE(d) ((MINOR(d)&0x01) == 1)
523
524 #define TP_DENS(dev) ((MINOR(dev) >> 1) & 0x07)
525 #define TP_UNIT(dev) ((MINOR(dev) >> 4) & 0x07)
526
527
528 #define TP_DIAGS(dev) (QIC02_TAPE_DEBUG & TPQD_DIAGS)
529
530
531 struct tpstatus {
532 unsigned short exs;
533 unsigned short dec;
534 unsigned short urc;
535 };
536 #define TPSTATSIZE sizeof(struct tpstatus)
537
538
539
540 #define TP_POR 0x100
541 #define TP_EOR 0x200
542 #define TP_PAR 0x400
543 #define TP_BOM 0x800
544 #define TP_MBD 0x1000
545 #define TP_NDT 0x2000
546 #define TP_ILL 0x4000
547 #define TP_ST1 0x8000
548 #define TP_FIL 0x01
549 #define TP_BNL 0x02
550 #define TP_UDA 0x04
551 #define TP_EOM 0x08
552 #define TP_WRP 0x10
553 #define TP_USL 0x20
554 #define TP_CNI 0x40
555 #define TP_ST0 0x80
556
557 #define REPORT_ERR0 (TP_CNI|TP_USL|TP_WRP|TP_EOM|TP_UDA|TP_BNL|TP_FIL)
558 #define REPORT_ERR1 (TP_ILL|TP_NDT|TP_MBD|TP_PAR)
559
560
561
562 #define EXC_UNKNOWN 0
563 #define EXC_NDRV 1
564 #define EXC_NCART 2
565 #define EXC_WP 3
566 #define EXC_EOM 4
567 #define EXC_RWA 5
568 #define EXC_XBAD 6
569 #define EXC_XFILLER 7
570 #define EXC_NDT 8
571 #define EXC_NDTEOM 9
572 #define EXC_NDTBOM 10
573 #define EXC_FM 11
574 #define EXC_ILL 12
575 #define EXC_POR 13
576 #define EXC_MARGINAL 14
577 #define EXC_EOR 15
578 #define EXC_BOM 16
579
580
581 #define TAPE_NOTIFY_TIMEOUT 1000000
582
583
584 #define TE_OK 0
585 #define TE_EX 1
586 #define TE_ERR 2
587 #define TE_NS 3
588 #define TE_TIM 4
589 #define TE_DEAD 5
590 #define TE_END 6
591
592
593 #define TIM_S (4*HZ)
594 #define TIM_M (30*HZ)
595 #define TIM_R (8*60*HZ)
596 #define TIM_F (2*3600*HZ)
597
598 #define TIMERON(t) timer_table[QIC02_TAPE_TIMER].expires = jiffies + (t); \
599 timer_active |= (1<<QIC02_TAPE_TIMER)
600 #define TIMEROFF timer_active &= ~(1<<QIC02_TAPE_TIMER)
601 #define TIMERCONT timer_active |= (1<<QIC02_TAPE_TIMER)
602
603
604 typedef char flag;
605 #define NO 0
606 #define YES 1
607
608
609 #ifdef TDEBUG
610 # define TPQDEB(s) s
611 # define TPQPUTS(s) tpqputs(s)
612 #else
613 # define TPQDEB(s)
614 # define TPQPUTS(s)
615 #endif
616
617
618
619
620
621
622
623 #define NR_BLK_BUF 20
624 #define TAPE_BLKSIZE 512
625 #define TPQBUF_SIZE (TAPE_BLKSIZE*NR_BLK_BUF)
626
627
628 #define BLOCKS_BEYOND_EW 2
629 #define BOGUS_IRQ 32009
630
631
632
633
634
635
636 struct qic02_ccb {
637 long ifc_type;
638
639 unsigned short port_stat;
640 unsigned short port_ctl;
641 unsigned short port_cmd;
642 unsigned short port_data;
643
644
645 unsigned short stat_ready;
646 unsigned short stat_exception;
647 unsigned short stat_mask;
648 unsigned short stat_resetmask;
649 unsigned short stat_resetval;
650
651
652 unsigned short ctl_reset;
653 unsigned short ctl_request;
654
655
656 unsigned short dma_enable_value;
657 };
658
659
660 extern int qic02_tape_init(void);
661
662
663 #endif
664
665 #endif
666