tpqic02.h
Upload User: jlfgdled
Upload Date: 2013-04-10
Package Size: 33168k
Code Size: 27k
Development Platform:

Unix_Linux

  1. /* $Id: tpqic02.h,v 1.5 1996/12/14 23:01:38 root Exp root $
  2.  *
  3.  * Include file for QIC-02 driver for Linux.
  4.  *
  5.  * Copyright (c) 1992--1995 by H. H. Bergman. All rights reserved.
  6.  *
  7.  * ******* USER CONFIG SECTION BELOW (Near line 70) *******
  8.  */
  9. #ifndef _LINUX_TPQIC02_H
  10. #define _LINUX_TPQIC02_H
  11. #include <linux/config.h>
  12. #if CONFIG_QIC02_TAPE || CONFIG_QIC02_TAPE_MODULE
  13. /* need to have QIC02_TAPE_DRIVE and QIC02_TAPE_IFC expand to something */
  14. #include <linux/mtio.h>
  15. /* Make QIC02_TAPE_IFC expand to something.
  16.  *
  17.  * The only difference between WANGTEK and EVEREX is in the 
  18.  * handling of the DMA channel 3.
  19.  * Note that the driver maps EVEREX to WANGTEK internally for speed
  20.  * reasons. Externally WANGTEK==1, EVEREX==2, ARCHIVE==3.
  21.  * These must correspond to the values used in qic02config(1).
  22.  *
  23.  * Support for Mountain controllers was added by Erik Jacobson
  24.  * and severely hacked by me.   -- hhb
  25.  * 
  26.  * Support for Emerald controllers by Alan Bain <afrb2@chiark.chu.cam.ac.uk>
  27.  * with more hacks by me.   -- hhb
  28.  */
  29. #define WANGTEK 1    /* don't know about Wangtek QIC-36 */
  30. #define EVEREX (WANGTEK+1)  /* I heard *some* of these are identical */
  31. #define EVEREX_811V EVEREX       /* With TEAC MT 2ST 45D */
  32. #define EVEREX_831V EVEREX
  33. #define ARCHIVE 3
  34. #define ARCHIVE_SC400 ARCHIVE        /* rumoured to be from the pre-SMD-age */
  35. #define ARCHIVE_SC402 ARCHIVE        /* don't know much about SC400 */
  36. #define ARCHIVE_SC499 ARCHIVE       /* SC402 and SC499R should be identical */
  37. #define MOUNTAIN 5        /* Mountain Computer Interface */
  38. #define EMERALD 6        /* Emerald Interface card */
  39. #define QIC02_TAPE_PORT_RANGE  8  /* number of IO locations to reserve */
  40. /*********** START OF USER CONFIGURABLE SECTION ************/
  41. /* Tape configuration: Select DRIVE, IFC, PORT, IRQ and DMA below.
  42.  * Runtime (re)configuration is not supported yet.
  43.  *
  44.  * Tape drive configuration: (MT_IS* constants are defined in mtio.h)
  45.  *
  46.  * QIC02_TAPE_DRIVE = MT_ISWT5150
  47.  * - Wangtek 5150, format: up to QIC-150.
  48.  * QIC02_TAPE_DRIVE = MT_ISQIC02_ALL_FEATURES
  49.  * - Enables some optional QIC02 commands that some drives may lack.
  50.  *   It is provided so you can check which are supported by your drive.
  51.  *   Refer to tpqic02.h for others.
  52.  *
  53.  * Supported interface cards: QIC02_TAPE_IFC =
  54.  * WANGTEK,
  55.  * ARCHIVE_SC402, ARCHIVE_SC499. (both same programming interface)
  56.  *
  57.  * Make sure you have the I/O ports/DMA channels 
  58.  * and IRQ stuff configured properly!
  59.  * NOTE: There may be other device drivers using the same major
  60.  *       number. This must be avoided. Check for timer.h conflicts too.
  61.  *
  62.  * If you have an EVEREX EV-831 card and you are using DMA channel 3,
  63.  * you will probably have to ``#define QIC02_TAPE_DMA3_FIX'' below.
  64.  */
  65. /* CONFIG_QIC02_DYNCONF can be defined in autoconf.h, by `make config' */
  66. /*** #undef CONFIG_QIC02_DYNCONF ***/
  67. #ifndef CONFIG_QIC02_DYNCONF
  68. #define QIC02_TAPE_DRIVE MT_ISQIC02_ALL_FEATURES  /* drive type */
  69. /* #define QIC02_TAPE_DRIVE MT_ISWT5150 */
  70. /* #define QIC02_TAPE_DRIVE MT_ISARCHIVE_5945L2 */
  71. /* #define QIC02_TAPE_DRIVE MT_ISTEAC_MT2ST */
  72. /* #define QIC02_TAPE_DRIVE MT_ISARCHIVE_2150L */
  73. /* #define QIC02_TAPE_DRIVE MT_ISARCHIVESC499 */
  74. /* Either WANGTEK, ARCHIVE or MOUNTAIN. Not EVEREX. 
  75.  * If you have an EVEREX, use WANGTEK and try the DMA3_FIX below.
  76.  */
  77. #define QIC02_TAPE_IFC WANGTEK /* interface card type */
  78. /* #define QIC02_TAPE_IFC ARCHIVE */
  79. /* #define QIC02_TAPE_IFC MOUNTAIN */
  80. #define QIC02_TAPE_PORT  0x300 /* controller port address */
  81. #define QIC02_TAPE_IRQ 5 /* For IRQ2, use 9 here, others normal. */
  82. #define QIC02_TAPE_DMA 1 /* either 1 or 3, because 2 is used by the floppy */
  83. /* If DMA3 doesn't work, but DMA1 does, and you have a 
  84.  * Wangtek/Everex card, you can try #define-ing the flag
  85.  * below. Note that you should also change the DACK jumper
  86.  * for Wangtek/Everex cards when changing the DMA channel.
  87.  */
  88. #undef QIC02_TAPE_DMA3_FIX
  89. /************ END OF USER CONFIGURABLE SECTION *************/
  90. /* I put the stuff above in config.in, but a few recompiles, to
  91.  * verify different configurations, and several days later I decided
  92.  * to change it back again.
  93.  */
  94. /* NOTE: TP_HAVE_DENS should distinguish between available densities (?)
  95.  * NOTE: Drive select is not implemented -- I have only one tape streamer,
  96.  *  so I'm unable and unmotivated to test and implement that. ;-) ;-)
  97.  */
  98. #if QIC02_TAPE_DRIVE == MT_ISWT5150
  99. #define TP_HAVE_DENS 1
  100. #define TP_HAVE_BSF 0 /* nope */
  101. #define TP_HAVE_FSR 0 /* nope */
  102. #define TP_HAVE_BSR 0 /* nope */
  103. #define TP_HAVE_EOD 0 /* most of the time */
  104. #define TP_HAVE_SEEK 0
  105. #define TP_HAVE_TELL 0
  106. #define TP_HAVE_RAS1 1
  107. #define TP_HAVE_RAS2 1
  108. #elif QIC02_TAPE_DRIVE == MT_ISARCHIVESC499 /* Archive SC-499 QIC-36 controller */
  109. #define TP_HAVE_DENS 1 /* can do set density (QIC-11 / QIC-24) */
  110. #define TP_HAVE_BSF 0
  111. #define TP_HAVE_FSR 1 /* can skip one block forwards */
  112. #define TP_HAVE_BSR 1 /* can skip one block backwards */
  113. #define TP_HAVE_EOD 1 /* can seek to end of recorded data */
  114. #define TP_HAVE_SEEK 0
  115. #define TP_HAVE_TELL 0
  116. #define TP_HAVE_RAS1 1 /* can run selftest 1 */
  117. #define TP_HAVE_RAS2 1 /* can run selftest 2 */
  118. /* These last two selftests shouldn't be used yet! */
  119. #elif (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2060L) || (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2150L)
  120. #define TP_HAVE_DENS 1 /* can do set density (QIC-24 / QIC-120 / QIC-150) */
  121. #define TP_HAVE_BSF 0
  122. #define TP_HAVE_FSR 1 /* can skip one block forwards */
  123. #define TP_HAVE_BSR 1 /* can skip one block backwards */
  124. #define TP_HAVE_EOD 1 /* can seek to end of recorded data */
  125. #define TP_HAVE_TELL 1 /* can read current block address */
  126. #define TP_HAVE_SEEK 1 /* can seek to block */
  127. #define TP_HAVE_RAS1 1 /* can run selftest 1 */
  128. #define TP_HAVE_RAS2 1 /* can run selftest 2 */
  129. /* These last two selftests shouldn't be used yet! */
  130. #elif QIC02_TAPE_DRIVE == MT_ISARCHIVE_5945L2
  131. /* can anyone verify this entry?? */
  132. #define TP_HAVE_DENS 1 /* can do set density?? (QIC-24??) */
  133. #define TP_HAVE_BSF 0
  134. #define TP_HAVE_FSR 1 /* can skip one block forwards */
  135. #define TP_HAVE_BSR 1 /* can skip one block backwards */
  136. #define TP_HAVE_EOD 1 /* can seek to end of recorded data */
  137. #define TP_HAVE_TELL 1 /* can read current block address */
  138. #define TP_HAVE_SEEK 1 /* can seek to block */
  139. #define TP_HAVE_RAS1 1 /* can run selftest 1 */
  140. #define TP_HAVE_RAS2 1 /* can run selftest 2 */
  141. /* These last two selftests shouldn't be used yet! */
  142. #elif QIC02_TAPE_DRIVE == MT_ISTEAC_MT2ST
  143. /* can anyone verify this entry?? */
  144. #define TP_HAVE_DENS 0 /* cannot do set density?? (QIC-150?) */
  145. #define TP_HAVE_BSF 0
  146. #define TP_HAVE_FSR 1 /* can skip one block forwards */
  147. #define TP_HAVE_BSR 1 /* can skip one block backwards */
  148. #define TP_HAVE_EOD 1 /* can seek to end of recorded data */
  149. #define TP_HAVE_SEEK 1 /* can seek to block */
  150. #define TP_HAVE_TELL 1 /* can read current block address */
  151. #define TP_HAVE_RAS1 1 /* can run selftest 1 */
  152. #define TP_HAVE_RAS2 1 /* can run selftest 2 */
  153. /* These last two selftests shouldn't be used yet! */
  154. #elif QIC02_TAPE_DRIVE == MT_ISQIC02_ALL_FEATURES
  155. #define TP_HAVE_DENS 1 /* can do set density */
  156. #define TP_HAVE_BSF 1 /* can search filemark backwards */
  157. #define TP_HAVE_FSR 1 /* can skip one block forwards */
  158. #define TP_HAVE_BSR 1 /* can skip one block backwards */
  159. #define TP_HAVE_EOD 1 /* can seek to end of recorded data */
  160. #define TP_HAVE_SEEK 1 /* seek to block address */
  161. #define TP_HAVE_TELL 1 /* tell current block address */
  162. #define TP_HAVE_RAS1 1 /* can run selftest 1 */
  163. #define TP_HAVE_RAS2 1 /* can run selftest 2 */
  164. /* These last two selftests shouldn't be used yet! */
  165. #else
  166. #error No QIC-02 tape drive type defined!
  167. /* If your drive is not listed above, first try the 'ALL_FEATURES',
  168.  * to see what commands are supported, then create your own entry in
  169.  * the list above. You may want to mail it to me, so that I can include
  170.  * it in the next release.
  171.  */
  172. #endif
  173. #endif /* !CONFIG_QIC02_DYNCONF */
  174. /* WANGTEK interface card specifics */
  175. #define WT_QIC02_STAT_PORT (QIC02_TAPE_PORT)
  176. #define WT_QIC02_CTL_PORT (QIC02_TAPE_PORT)
  177. #define WT_QIC02_CMD_PORT (QIC02_TAPE_PORT+1)
  178. #define WT_QIC02_DATA_PORT (QIC02_TAPE_PORT+1)
  179. /* status register bits (Active LOW!) */
  180. #define WT_QIC02_STAT_POLARITY 0
  181. #define WT_QIC02_STAT_READY 0x01
  182. #define WT_QIC02_STAT_EXCEPTION 0x02
  183. #define WT_QIC02_STAT_MASK (WT_QIC02_STAT_READY|WT_QIC02_STAT_EXCEPTION)
  184. #define WT_QIC02_STAT_RESETMASK 0x07
  185. #define WT_QIC02_STAT_RESETVAL (WT_QIC02_STAT_RESETMASK & ~WT_QIC02_STAT_EXCEPTION)
  186. /* controller register (QIC02_CTL_PORT) bits */
  187. #define WT_QIC02_CTL_RESET 0x02
  188. #define WT_QIC02_CTL_REQUEST 0x04
  189. #define WT_CTL_ONLINE 0x01
  190. #define WT_CTL_CMDOFF 0xC0 
  191. #define WT_CTL_DMA3 0x10   /* enable dma chan3 */
  192. #define WT_CTL_DMA1 0x08          /* enable dma chan1 or chan2 */
  193. /* EMERALD interface card specifics
  194.  * Much like Wangtek, only different polarity and bit locations
  195.  */
  196. #define EMR_QIC02_STAT_PORT (QIC02_TAPE_PORT)
  197. #define EMR_QIC02_CTL_PORT (QIC02_TAPE_PORT)
  198. #define EMR_QIC02_CMD_PORT (QIC02_TAPE_PORT+1)
  199. #define EMR_QIC02_DATA_PORT (QIC02_TAPE_PORT+1)
  200. /* status register bits (Active High!) */
  201. #define EMR_QIC02_STAT_POLARITY 1
  202. #define EMR_QIC02_STAT_READY 0x01
  203. #define EMR_QIC02_STAT_EXCEPTION 0x02
  204. #define EMR_QIC02_STAT_MASK (EMR_QIC02_STAT_READY|EMR_QIC02_STAT_EXCEPTION)
  205. #define EMR_QIC02_STAT_RESETMASK 0x07
  206. #define EMR_QIC02_STAT_RESETVAL (EMR_QIC02_STAT_RESETMASK & ~EMR_QIC02_STAT_EXCEPTION)
  207. /* controller register (QIC02_CTL_PORT) bits */
  208. #define EMR_QIC02_CTL_RESET 0x02
  209. #define EMR_QIC02_CTL_REQUEST 0x04
  210. #define EMR_CTL_ONLINE 0x01
  211. #define EMR_CTL_CMDOFF 0xC0 
  212. #define EMR_CTL_DMA3 0x10   /* enable dma chan3 */
  213. #define EMR_CTL_DMA1 0x08          /* enable dma chan1 or chan2 */
  214. /* ARCHIVE interface card specifics */
  215. #define AR_QIC02_STAT_PORT (QIC02_TAPE_PORT+1)
  216. #define AR_QIC02_CTL_PORT (QIC02_TAPE_PORT+1)
  217. #define AR_QIC02_CMD_PORT (QIC02_TAPE_PORT)
  218. #define AR_QIC02_DATA_PORT (QIC02_TAPE_PORT)
  219. #define AR_START_DMA_PORT (QIC02_TAPE_PORT+2)
  220. #define AR_RESET_DMA_PORT (QIC02_TAPE_PORT+3)
  221. /* STAT port bits */
  222. #define AR_QIC02_STAT_POLARITY 0
  223. #define AR_STAT_IRQF 0x80 /* active high, interrupt request flag */
  224. #define AR_QIC02_STAT_READY 0x40 /* active low */
  225. #define AR_QIC02_STAT_EXCEPTION 0x20 /* active low */
  226. #define AR_QIC02_STAT_MASK (AR_QIC02_STAT_READY|AR_QIC02_STAT_EXCEPTION)
  227. #define AR_STAT_DMADONE 0x10 /* active high, DMA done */
  228. #define AR_STAT_DIRC 0x08 /* active high, direction */
  229. #define AR_QIC02_STAT_RESETMASK 0x70 /* check RDY,EXC,DMADONE */
  230. #define AR_QIC02_STAT_RESETVAL ((AR_QIC02_STAT_RESETMASK & ~AR_STAT_IRQF & ~AR_QIC02_STAT_EXCEPTION) | AR_STAT_DMADONE)
  231. /* CTL port bits */
  232. #define AR_QIC02_CTL_RESET 0x80 /* drive reset */
  233. #define AR_QIC02_CTL_REQUEST 0x40 /* notify of new command */
  234. #define AR_CTL_IEN 0x20 /* interrupt enable */
  235. #define AR_CTL_DNIEN 0x10 /* done-interrupt enable */
  236.   /* Note: All of these bits are cleared automatically when writing to
  237.    * AR_RESET_DMA_PORT. So AR_CTL_IEN and AR_CTL_DNIEN must be
  238.    * reprogrammed before the write to AR_START_DMA_PORT.
  239.    */
  240. /* MOUNTAIN interface specifics */
  241. #define MTN_QIC02_STAT_PORT (QIC02_TAPE_PORT+1)
  242. #define MTN_QIC02_CTL_PORT (QIC02_TAPE_PORT+1)
  243. #define MTN_QIC02_CMD_PORT (QIC02_TAPE_PORT)
  244. #define MTN_QIC02_DATA_PORT (QIC02_TAPE_PORT)
  245. #define MTN_W_SELECT_DMA_PORT (QIC02_TAPE_PORT+2)
  246. #define MTN_R_DESELECT_DMA_PORT (QIC02_TAPE_PORT+2)
  247. #define MTN_W_DMA_WRITE_PORT (QIC02_TAPE_PORT+3)
  248. /* STAT port bits */
  249. #define MTN_QIC02_STAT_POLARITY  0
  250. #define MTN_QIC02_STAT_READY  0x02 /* active low */
  251. #define MTN_QIC02_STAT_EXCEPTION 0x04 /* active low */
  252. #define MTN_QIC02_STAT_MASK  (MTN_QIC02_STAT_READY|MTN_QIC02_STAT_EXCEPTION)
  253. #define MTN_STAT_DMADONE  0x01 /* active high, DMA done */
  254. #define MTN_QIC02_STAT_RESETMASK 0x07 /* check RDY,EXC,DMADONE */
  255. #define MTN_QIC02_STAT_RESETVAL  ((MTN_QIC02_STAT_RESETMASK & ~MTN_QIC02_STAT_EXCEPTION) | MTN_STAT_DMADONE)
  256. /* CTL port bits */
  257. #define MTN_QIC02_CTL_RESET_NOT  0x80 /* drive reset, active low */
  258. #define MTN_QIC02_CTL_RESET  0x80 /* Fodder #definition to keep gcc happy */
  259. #define MTN_QIC02_CTL_ONLINE  0x40 /* Put drive on line  */
  260. #define MTN_QIC02_CTL_REQUEST  0x20 /* notify of new command */
  261. #define MTN_QIC02_CTL_IRQ_DRIVER 0x10 /* Enable IRQ tristate driver */
  262. #define MTN_QIC02_CTL_DMA_DRIVER 0x08 /* Enable DMA tristate driver */
  263. #define MTN_CTL_EXC_IEN  0x04 /* Exception interrupt enable */
  264. #define MTN_CTL_RDY_IEN  0x02 /* Ready interrupt enable */
  265. #define MTN_CTL_DNIEN  0x01 /* done-interrupt enable */
  266. #define MTN_CTL_ONLINE (MTN_QIC02_CTL_RESET_NOT | MTN_QIC02_CTL_IRQ_DRIVER | MTN_QIC02_CTL_DMA_DRIVER)
  267. #ifndef CONFIG_QIC02_DYNCONF
  268. # define QIC02_TAPE_DEBUG (qic02_tape_debug)
  269. # if QIC02_TAPE_IFC == WANGTEK
  270. #  define QIC02_STAT_POLARITY WT_QIC02_STAT_POLARITY
  271. #  define QIC02_STAT_PORT WT_QIC02_STAT_PORT
  272. #  define QIC02_CTL_PORT WT_QIC02_CTL_PORT
  273. #  define QIC02_CMD_PORT WT_QIC02_CMD_PORT
  274. #  define QIC02_DATA_PORT WT_QIC02_DATA_PORT
  275. #  define QIC02_STAT_READY WT_QIC02_STAT_READY
  276. #  define QIC02_STAT_EXCEPTION WT_QIC02_STAT_EXCEPTION
  277. #  define QIC02_STAT_MASK WT_QIC02_STAT_MASK
  278. #  define QIC02_STAT_RESETMASK WT_QIC02_STAT_RESETMASK
  279. #  define QIC02_STAT_RESETVAL WT_QIC02_STAT_RESETVAL
  280. #  define QIC02_CTL_RESET WT_QIC02_CTL_RESET
  281. #  define QIC02_CTL_REQUEST WT_QIC02_CTL_REQUEST
  282. #  if QIC02_TAPE_DMA == 3
  283. #   ifdef QIC02_TAPE_DMA3_FIX
  284. #    define WT_CTL_DMA WT_CTL_DMA1
  285. #   else
  286. #    define WT_CTL_DMA WT_CTL_DMA3
  287. #   endif
  288. #  elif QIC02_TAPE_DMA == 1
  289. #    define WT_CTL_DMA WT_CTL_DMA1
  290. #  else
  291. #   error Unsupported or incorrect DMA configuration.
  292. #  endif
  293. # elif QIC02_TAPE_IFC == EMERALD
  294. #  define QIC02_STAT_POLARITY EMR_QIC02_STAT_POLARITY
  295. #  define QIC02_STAT_PORT EMR_QIC02_STAT_PORT
  296. #  define QIC02_CTL_PORT EMR_QIC02_CTL_PORT
  297. #  define QIC02_CMD_PORT EMR_QIC02_CMD_PORT
  298. #  define QIC02_DATA_PORT EMR_QIC02_DATA_PORT
  299. #  define QIC02_STAT_READY EMR_QIC02_STAT_READY
  300. #  define QIC02_STAT_EXCEPTION EMR_QIC02_STAT_EXCEPTION
  301. #  define QIC02_STAT_MASK EMR_QIC02_STAT_MASK
  302. #  define QIC02_STAT_RESETMASK EMR_QIC02_STAT_RESETMASK
  303. #  define QIC02_STAT_RESETVAL EMR_QIC02_STAT_RESETVAL
  304. #  define QIC02_CTL_RESET EMR_QIC02_CTL_RESET
  305. #  define QIC02_CTL_REQUEST EMR_QIC02_CTL_REQUEST
  306. #  if QIC02_TAPE_DMA == 3
  307. #   ifdef QIC02_TAPE_DMA3_FIX
  308. #    define EMR_CTL_DMA EMR_CTL_DMA1
  309. #   else
  310. #    define EMR_CTL_DMA EMR_CTL_DMA3
  311. #   endif
  312. #  elif QIC02_TAPE_DMA == 1
  313. #    define EMR_CTL_DMA EMR_CTL_DMA1
  314. #  else
  315. #   error Unsupported or incorrect DMA configuration.
  316. #  endif
  317. # elif QIC02_TAPE_IFC == ARCHIVE
  318. #  define QIC02_STAT_POLARITY AR_QIC02_STAT_POLARITY
  319. #  define QIC02_STAT_PORT AR_QIC02_STAT_PORT
  320. #  define QIC02_CTL_PORT AR_QIC02_CTL_PORT
  321. #  define QIC02_CMD_PORT AR_QIC02_CMD_PORT
  322. #  define QIC02_DATA_PORT AR_QIC02_DATA_PORT
  323. #  define QIC02_STAT_READY AR_QIC02_STAT_READY
  324. #  define QIC02_STAT_EXCEPTION AR_QIC02_STAT_EXCEPTION
  325. #  define QIC02_STAT_MASK AR_QIC02_STAT_MASK
  326. #  define QIC02_STAT_RESETMASK AR_QIC02_STAT_RESETMASK
  327. #  define QIC02_STAT_RESETVAL AR_QIC02_STAT_RESETVAL
  328. #  define QIC02_CTL_RESET AR_QIC02_CTL_RESET
  329. #  define QIC02_CTL_REQUEST AR_QIC02_CTL_REQUEST
  330. #  if QIC02_TAPE_DMA > 3 /* channel 2 is used by the floppy driver */
  331. #   error DMA channels other than 1 and 3 are not supported.
  332. #  endif
  333. # elif QIC02_TAPE_IFC == MOUNTAIN
  334. #  define QIC02_STAT_POLARITY MTN_QIC02_STAT_POLARITY
  335. #  define QIC02_STAT_PORT MTN_QIC02_STAT_PORT
  336. #  define QIC02_CTL_PORT MTN_QIC02_CTL_PORT
  337. #  define QIC02_CMD_PORT MTN_QIC02_CMD_PORT
  338. #  define QIC02_DATA_PORT MTN_QIC02_DATA_PORT
  339. #  define QIC02_STAT_READY MTN_QIC02_STAT_READY
  340. #  define QIC02_STAT_EXCEPTION MTN_QIC02_STAT_EXCEPTION
  341. #  define QIC02_STAT_MASK MTN_QIC02_STAT_MASK
  342. #  define QIC02_STAT_RESETMASK MTN_QIC02_STAT_RESETMASK
  343. #  define QIC02_STAT_RESETVAL MTN_QIC02_STAT_RESETVAL
  344. #  define QIC02_CTL_RESET MTN_QIC02_CTL_RESET
  345. #  define QIC02_CTL_REQUEST MTN_QIC02_CTL_REQUEST
  346. #  if QIC02_TAPE_DMA > 3 /* channel 2 is used by the floppy driver */
  347. #   error DMA channels other than 1 and 3 are not supported.
  348. #  endif
  349. # else
  350. #  error No valid interface card specified!
  351. # endif /* QIC02_TAPE_IFC */
  352.   /* An ugly hack to make sure WT_CTL_DMA is defined even for the
  353.    * static, non-Wangtek case. The alternative was even worse.
  354.    */ 
  355. # ifndef WT_CTL_DMA
  356. #  define WT_CTL_DMA WT_CTL_DMA1
  357. # endif
  358. /*******************/
  359. #else /* !CONFIG_QIC02_DYNCONF */
  360. /* Now the runtime config version, using variables instead of constants.
  361.  *
  362.  * qic02_tape_dynconf is R/O for the kernel, set from userspace.
  363.  * qic02_tape_ccb is private to the driver, R/W.
  364.  */
  365. # define QIC02_TAPE_DRIVE (qic02_tape_dynconf.mt_type)
  366. # define QIC02_TAPE_IFC (qic02_tape_ccb.ifc_type)
  367. # define QIC02_TAPE_IRQ (qic02_tape_dynconf.irqnr)
  368. # define QIC02_TAPE_DMA (qic02_tape_dynconf.dmanr)
  369. # define QIC02_TAPE_PORT (qic02_tape_dynconf.port)
  370. # define WT_CTL_DMA (qic02_tape_ccb.dma_enable_value)
  371. # define QIC02_TAPE_DEBUG (qic02_tape_dynconf.debug)
  372. # define QIC02_STAT_PORT (qic02_tape_ccb.port_stat)
  373. # define QIC02_CTL_PORT  (qic02_tape_ccb.port_ctl)
  374. # define QIC02_CMD_PORT  (qic02_tape_ccb.port_cmd)
  375. # define QIC02_DATA_PORT  (qic02_tape_ccb.port_data)
  376. # define QIC02_STAT_POLARITY (qic02_tape_ccb.stat_polarity)
  377. # define QIC02_STAT_READY (qic02_tape_ccb.stat_ready)
  378. # define QIC02_STAT_EXCEPTION (qic02_tape_ccb.stat_exception)
  379. # define QIC02_STAT_MASK (qic02_tape_ccb.stat_mask)
  380. # define QIC02_STAT_RESETMASK (qic02_tape_ccb.stat_resetmask)
  381. # define QIC02_STAT_RESETVAL (qic02_tape_ccb.stat_resetval)
  382. # define QIC02_CTL_RESET (qic02_tape_ccb.ctl_reset)
  383. # define QIC02_CTL_REQUEST (qic02_tape_ccb.ctl_request)
  384. # define TP_HAVE_DENS (qic02_tape_dynconf.have_dens)
  385. # define TP_HAVE_BSF (qic02_tape_dynconf.have_bsf)
  386. # define TP_HAVE_FSR (qic02_tape_dynconf.have_fsr)
  387. # define TP_HAVE_BSR (qic02_tape_dynconf.have_bsr)
  388. # define TP_HAVE_EOD (qic02_tape_dynconf.have_eod)
  389. # define TP_HAVE_SEEK (qic02_tape_dynconf.have_seek)
  390. # define TP_HAVE_TELL (qic02_tape_dynconf.have_tell)
  391. # define TP_HAVE_RAS1 (qic02_tape_dynconf.have_ras1)
  392. # define TP_HAVE_RAS2 (qic02_tape_dynconf.have_ras2)
  393. #endif /* CONFIG_QIC02_DYNCONF */
  394. /* "Vendor Unique" codes */
  395. /* Archive seek & tell stuff */
  396. #define AR_QCMDV_TELL_BLK 0xAE /* read current block address */
  397. #define AR_QCMDV_SEEK_BLK 0xAD /* seek to specific block */
  398. #define AR_SEEK_BUF_SIZE 3 /* address is 3 bytes */
  399. /*
  400.  * Misc common stuff
  401.  */
  402. /* Standard QIC-02 commands -- rev F.  All QIC-02 drives must support these */
  403. #define QCMD_SEL_1 0x01 /* select drive 1 */
  404. #define QCMD_SEL_2 0x02 /* select drive 2 */
  405. #define QCMD_SEL_3 0x04 /* select drive 3 */
  406. #define QCMD_SEL_4 0x08 /* select drive 4 */
  407. #define QCMD_REWIND 0x21 /* rewind tape */
  408. #define QCMD_ERASE 0x22 /* erase tape */
  409. #define QCMD_RETEN 0x24 /* retension tape */
  410. #define QCMD_WRT_DATA 0x40 /* write data */
  411. #define QCMD_WRT_FM 0x60 /* write file mark */
  412. #define QCMD_RD_DATA 0x80 /* read data */
  413. #define QCMD_RD_FM 0xA0 /* read file mark (forward direction) */
  414. #define QCMD_RD_STAT 0xC0 /* read status */
  415. /* Other (optional/vendor unique) commands */
  416.  /* Density commands are only valid when TP_BOM is set! */
  417. #define QCMD_DENS_11 0x26 /* QIC-11 */
  418. #define QCMD_DENS_24 0x27 /* QIC-24: 9 track 60MB */
  419. #define QCMD_DENS_120 0x28 /* QIC-120: 15 track 120MB */
  420. #define QCMD_DENS_150 0x29 /* QIC-150: 18 track 150MB */
  421. #define QCMD_DENS_300 0x2A /* QIC-300/QIC-2100 */
  422. #define QCMD_DENS_600 0x2B /* QIC-600/QIC-2200 */
  423. /* don't know about QIC-1000 and QIC-1350 */
  424. #define QCMD_WRTNU_DATA 0x40 /* write data, no underruns, insert filler. */
  425. #define QCMD_SPACE_FWD 0x81 /* skip next block */
  426. #define QCMD_SPACE_BCK 0x89 /* move tape head one block back -- very useful! */
  427. #define QCMD_RD_FM_BCK 0xA8 /* read filemark (backwards) */
  428. #define QCMD_SEEK_EOD 0xA3 /* skip to EOD */
  429. #define QCMD_RD_STAT_X1 0xC1 /* read extended status 1 */
  430. #define QCMD_RD_STAT_X2 0xC4 /* read extended status 2 */
  431. #define QCMD_RD_STAT_X3 0xE0 /* read extended status 3 */
  432. #define QCMD_SELF_TST1 0xC2 /* run self test 1 (nondestructive) */
  433. #define QCMD_SELF_TST2 0xCA /* run self test 2 (destructive) */
  434. /* Optional, QFA (Quick File Access) commands.
  435.  * Not all drives support this, but those that do could use these commands
  436.  * to implement semi-non-sequential access. `mt fsf` would benefit from this.
  437.  * QFA divides the tape into 2 partitions, a data and a directory partition,
  438.  * causing some incompatibility problems wrt std QIC-02 data exchange.
  439.  * It would be useful to cache the directory info, but that might be tricky
  440.  * to do in kernel-space. [Size constraints.]
  441.  * Refer to the QIC-02 specs, appendix A for more information.
  442.  * I have no idea how other *nix variants implement QFA.
  443.  * I have no idea which drives support QFA and which don't.
  444.  */
  445. #define QFA_ENABLE 0x2D /* enter QFA mode, give @ BOT only */
  446. #define QFA_DATA 0x20 /* select data partition */
  447. #define QFA_DIR 0x23 /* select directory partition */
  448. #define QFA_RD_POS 0xCF /* read position+status bytes */
  449. #define QFA_SEEK_EOD 0xA1 /* seek EOD within current partition */
  450. #define QFA_SEEK_BLK 0xAF /* seek to a block within current partition */
  451. /*
  452.  * Debugging flags
  453.  */
  454. #define TPQD_SENSE_TEXT 0x0001
  455. #define TPQD_SENSE_CNTS 0x0002
  456. #define TPQD_REWIND 0x0004
  457. #define TPQD_TERM_CYCLE 0x0008
  458. #define TPQD_IOCTLS 0x0010
  459. #define TPQD_DMAX 0x0020
  460. #define TPQD_BLKSZ 0x0040
  461. #define TPQD_MISC 0x0080
  462. #define TPQD_DEBUG 0x0100
  463. #define TPQD_DIAGS 0x1000
  464. #define TPQD_ALWAYS 0x8000
  465. #define TPQD_DEFAULT_FLAGS 0x00fc
  466. #define TPQDBG(f) ((QIC02_TAPE_DEBUG) & (TPQD_##f))
  467. /* Minor device codes for tapes:
  468.  * |7|6|5|4|3|2|1|0|
  469.  *  |  | /  | / |_____ 1=rewind on close, 0=no rewind on close
  470.  *  |  |/    |_________ Density: 000=none, 001=QIC-11, 010=24, 011=120,
  471.  *  |   |                100=QIC-150, 101..111 reserved.
  472.  *  |   |_______________ Reserved for unit numbers.
  473.  *  |___________________ Reserved for diagnostics during debugging.
  474.  */
  475. #define TP_REWCLOSE(d) ((MINOR(d)&0x01) == 1)     /* rewind bit */
  476.    /* rewind is only done if data has been transferred */
  477. #define TP_DENS(dev) ((MINOR(dev) >> 1) & 0x07)        /* tape density */
  478. #define TP_UNIT(dev) ((MINOR(dev) >> 4) & 0x07)        /* unit number */
  479. /* print excessive diagnostics */
  480. #define TP_DIAGS(dev) (QIC02_TAPE_DEBUG & TPQD_DIAGS)
  481. /* status codes returned by a WTS_RDSTAT call */
  482. struct tpstatus { /* sizeof(short)==2), LSB first */
  483. unsigned short exs; /* Drive exception flags */
  484. unsigned short dec; /* data error count: nr of blocks rewritten/soft read errors */
  485. unsigned short urc; /* underrun count: nr of times streaming was interrupted */
  486. };
  487. #define TPSTATSIZE sizeof(struct tpstatus)
  488. /* defines for tpstatus.exs -- taken from 386BSD wt driver */
  489. #define TP_POR 0x100 /* Power on or reset occurred */
  490. #define TP_EOR 0x200 /* REServed for end of RECORDED media */
  491. #define TP_PAR 0x400 /* REServed for bus parity */
  492. #define TP_BOM 0x800 /* Beginning of media */
  493. #define TP_MBD 0x1000 /* Marginal block detected */
  494. #define TP_NDT 0x2000 /* No data detected */
  495. #define TP_ILL 0x4000 /* Illegal command */
  496. #define TP_ST1 0x8000 /* Status byte 1 flag */
  497. #define TP_FIL 0x01 /* File mark detected */
  498. #define TP_BNL 0x02 /* Bad block not located */
  499. #define TP_UDA 0x04 /* Unrecoverable data error */
  500. #define TP_EOM 0x08 /* End of media */
  501. #define TP_WRP 0x10 /* Write protected cartridge */
  502. #define TP_USL 0x20 /* Unselected drive */
  503. #define TP_CNI 0x40 /* Cartridge not in place */
  504. #define TP_ST0 0x80 /* Status byte 0 flag */
  505. #define REPORT_ERR0 (TP_CNI|TP_USL|TP_WRP|TP_EOM|TP_UDA|TP_BNL|TP_FIL)
  506. #define REPORT_ERR1 (TP_ILL|TP_NDT|TP_MBD|TP_PAR)
  507. /* exception numbers */
  508. #define EXC_UNKNOWN 0 /* (extra) Unknown exception code */
  509. #define EXC_NDRV 1 /* No drive */
  510. #define EXC_NCART 2 /* No cartridge */
  511. #define EXC_WP 3 /* Write protected */
  512. #define EXC_EOM 4 /* EOM */
  513. #define EXC_RWA 5 /* read/write abort */
  514. #define EXC_XBAD 6 /* read error, bad block transferred */
  515. #define EXC_XFILLER 7 /* read error, filler block transferred */
  516. #define EXC_NDT 8 /* read error, no data */
  517. #define EXC_NDTEOM 9 /* read error, no data & EOM */
  518. #define EXC_NDTBOM 10 /* read error, no data & BOM */
  519. #define EXC_FM 11 /* Read a filemark */
  520. #define EXC_ILL 12 /* Illegal command */
  521. #define EXC_POR 13 /* Power on/reset */
  522. #define EXC_MARGINAL 14 /* Marginal block detected */
  523. #define EXC_EOR 15 /* (extra, for SEEKEOD) End Of Recorded data reached */
  524. #define EXC_BOM 16 /* (extra) BOM reached */
  525. #define TAPE_NOTIFY_TIMEOUT 1000000
  526. /* internal function return codes */
  527. #define TE_OK 0 /* everything is fine */
  528. #define TE_EX 1 /* exception detected */
  529. #define TE_ERR 2 /* some error */
  530. #define TE_NS 3 /* can't read status */
  531. #define TE_TIM 4 /* timed out */
  532. #define TE_DEAD 5 /* tape drive doesn't respond */
  533. #define TE_END 6 /******** Archive hack *****/
  534. /* timeout timer values -- check these! */
  535. #define TIM_S (4*HZ) /* 4 seconds (normal cmds) */
  536. #define TIM_M (30*HZ) /* 30 seconds (write FM) */
  537. #define TIM_R (8*60*HZ) /* 8 minutes (retensioning) */
  538. #define TIM_F (2*3600*HZ) /* est. 1.2hr for full tape read/write+2 retens */
  539. #define TIMERON(t) mod_timer(&tp_timer, jiffies + (t))
  540. #define TIMEROFF del_timer_sync(&tp_timer);
  541. #define TIMERCONT add_timer(&tp_timer);
  542. typedef char flag;
  543. #define NO 0 /* NO must be 0 */
  544. #define YES 1 /* YES must be != 0 */
  545. #ifdef TDEBUG
  546. # define TPQDEB(s) s
  547. # define TPQPUTS(s) tpqputs(s)
  548. #else
  549. # define TPQDEB(s)
  550. # define TPQPUTS(s)
  551. #endif
  552. /* NR_BLK_BUF is a `tuneable parameter'. If you're really low on
  553.  * kernel space, you could decrease it to 1, or if you got a very
  554.  * slow machine, you could increase it up to 127 blocks. Less kernel
  555.  * buffer blocks result in more context-switching.
  556.  */
  557. #define NR_BLK_BUF 20     /* max 127 blocks */
  558. #define TAPE_BLKSIZE 512   /* streamer tape block size (fixed) */
  559. #define TPQBUF_SIZE (TAPE_BLKSIZE*NR_BLK_BUF)        /* buffer size */
  560. #define BLOCKS_BEYOND_EW 2 /* nr of blocks after Early Warning hole */
  561. #define BOGUS_IRQ 32009
  562. /* This is internal data, filled in based on the ifc_type field given
  563.  * by the user. Everex is mapped to Wangtek with a different
  564.  * `dma_enable_value', if dmanr==3.
  565.  */
  566. struct qic02_ccb {
  567. long ifc_type;
  568. unsigned short port_stat; /* Status port address */
  569. unsigned short port_ctl; /* Control port address */
  570. unsigned short port_cmd; /* Command port address */
  571. unsigned short port_data; /* Data port address */
  572. /* status register bits */
  573. unsigned short stat_polarity; /* invert status bits or not */
  574. unsigned short stat_ready; /* drive ready */
  575. unsigned short stat_exception; /* drive signals exception */
  576. unsigned short stat_mask;
  577. unsigned short stat_resetmask;
  578. unsigned short stat_resetval;
  579. /* control register bits */
  580. unsigned short ctl_reset; /* reset drive */
  581. unsigned short ctl_request; /* latch command */
  582. /* This is used to change the DMA3 behaviour */
  583. unsigned short dma_enable_value;
  584. };
  585. #if MODULE
  586. static int qic02_tape_init(void);
  587. #else
  588. extern int qic02_tape_init(void);   /* for mem.c */
  589. #endif
  590. #endif /* CONFIG_QIC02_TAPE */
  591. #endif /* _LINUX_TPQIC02_H */