initio.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /**************************************************************************
  2. * Initio 9100 device driver for Linux.
  3. *
  4. * Copyright (c) 1994-1998 Initio Corporation
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; see the file COPYING. If not, write to
  19. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20. *
  21. * --------------------------------------------------------------------------
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the above copyright
  27. * notice, this list of conditions, and the following disclaimer,
  28. * without modification, immediately at the beginning of the file.
  29. * 2. Redistributions in binary form must reproduce the above copyright
  30. * notice, this list of conditions and the following disclaimer in the
  31. * documentation and/or other materials provided with the distribution.
  32. * 3. The name of the author may not be used to endorse or promote products
  33. * derived from this software without specific prior written permission.
  34. *
  35. * Where this Software is combined with software released under the terms of
  36. * the GNU General Public License ("GPL") and the terms of the GPL would require the
  37. * combined work to also be released under the terms of the GPL, the terms
  38. * and conditions of this License will apply in addition to those of the
  39. * GPL with the exception of any terms or conditions of this License that
  40. * conflict with, or are expressly prohibited by, the GPL.
  41. *
  42. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  43. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  44. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  45. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  46. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  47. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  48. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  50. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  51. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  52. * SUCH DAMAGE.
  53. *
  54. **************************************************************************/
  55. #include <linux/config.h>
  56. #include <linux/types.h>
  57. #define ULONG unsigned long
  58. #define USHORT unsigned short
  59. #define UCHAR unsigned char
  60. #define BYTE unsigned char
  61. #define WORD unsigned short
  62. #define DWORD unsigned long
  63. #define UBYTE unsigned char
  64. #define UWORD unsigned short
  65. #define UDWORD unsigned long
  66. #define U32 u32
  67. #define TOTAL_SG_ENTRY 32
  68. #define MAX_SUPPORTED_ADAPTERS 8
  69. #define MAX_OFFSET 15
  70. #define MAX_TARGETS 16
  71. typedef struct {
  72. unsigned short base;
  73. unsigned short vec;
  74. } i91u_config;
  75. /***************************************/
  76. /* Tulip Configuration Register Set */
  77. /***************************************/
  78. #define TUL_PVID 0x00 /* Vendor ID */
  79. #define TUL_PDID 0x02 /* Device ID */
  80. #define TUL_PCMD 0x04 /* Command */
  81. #define TUL_PSTUS 0x06 /* Status */
  82. #define TUL_PRID 0x08 /* Revision number */
  83. #define TUL_PPI 0x09 /* Programming interface */
  84. #define TUL_PSC 0x0A /* Sub Class */
  85. #define TUL_PBC 0x0B /* Base Class */
  86. #define TUL_PCLS 0x0C /* Cache line size */
  87. #define TUL_PLTR 0x0D /* Latency timer */
  88. #define TUL_PHDT 0x0E /* Header type */
  89. #define TUL_PBIST 0x0F /* BIST */
  90. #define TUL_PBAD 0x10 /* Base address */
  91. #define TUL_PBAD1 0x14 /* Base address */
  92. #define TUL_PBAD2 0x18 /* Base address */
  93. #define TUL_PBAD3 0x1C /* Base address */
  94. #define TUL_PBAD4 0x20 /* Base address */
  95. #define TUL_PBAD5 0x24 /* Base address */
  96. #define TUL_PRSVD 0x28 /* Reserved */
  97. #define TUL_PRSVD1 0x2C /* Reserved */
  98. #define TUL_PRAD 0x30 /* Expansion ROM base address */
  99. #define TUL_PRSVD2 0x34 /* Reserved */
  100. #define TUL_PRSVD3 0x38 /* Reserved */
  101. #define TUL_PINTL 0x3C /* Interrupt line */
  102. #define TUL_PINTP 0x3D /* Interrupt pin */
  103. #define TUL_PIGNT 0x3E /* MIN_GNT */
  104. #define TUL_PMGNT 0x3F /* MAX_GNT */
  105. /************************/
  106. /* Jasmin Register Set */
  107. /************************/
  108. #define TUL_HACFG0 0x40 /* H/A Configuration Register 0 */
  109. #define TUL_HACFG1 0x41 /* H/A Configuration Register 1 */
  110. #define TUL_HACFG2 0x42 /* H/A Configuration Register 2 */
  111. #define TUL_SDCFG0 0x44 /* SCSI Device Configuration 0 */
  112. #define TUL_SDCFG1 0x45 /* SCSI Device Configuration 1 */
  113. #define TUL_SDCFG2 0x46 /* SCSI Device Configuration 2 */
  114. #define TUL_SDCFG3 0x47 /* SCSI Device Configuration 3 */
  115. #define TUL_GINTS 0x50 /* Global Interrupt Status Register */
  116. #define TUL_GIMSK 0x52 /* Global Interrupt MASK Register */
  117. #define TUL_GCTRL 0x54 /* Global Control Register */
  118. #define TUL_GCTRL_EEPROM_BIT 0x04
  119. #define TUL_GCTRL1 0x55 /* Global Control Register */
  120. #define TUL_DMACFG 0x5B /* DMA configuration */
  121. #define TUL_NVRAM 0x5D /* Non-volatile RAM port */
  122. #define TUL_SCnt0 0x80 /* 00 R/W Transfer Counter Low */
  123. #define TUL_SCnt1 0x81 /* 01 R/W Transfer Counter Mid */
  124. #define TUL_SCnt2 0x82 /* 02 R/W Transfer Count High */
  125. #define TUL_SFifoCnt 0x83 /* 03 R FIFO counter */
  126. #define TUL_SIntEnable 0x84 /* 03 W Interrupt enble */
  127. #define TUL_SInt 0x84 /* 04 R Interrupt Register */
  128. #define TUL_SCtrl0 0x85 /* 05 W Control 0 */
  129. #define TUL_SStatus0 0x85 /* 05 R Status 0 */
  130. #define TUL_SCtrl1 0x86 /* 06 W Control 1 */
  131. #define TUL_SStatus1 0x86 /* 06 R Status 1 */
  132. #define TUL_SConfig 0x87 /* 07 W Configuration */
  133. #define TUL_SStatus2 0x87 /* 07 R Status 2 */
  134. #define TUL_SPeriod 0x88 /* 08 W Sync. Transfer Period & Offset */
  135. #define TUL_SOffset 0x88 /* 08 R Offset */
  136. #define TUL_SScsiId 0x89 /* 09 W SCSI ID */
  137. #define TUL_SBusId 0x89 /* 09 R SCSI BUS ID */
  138. #define TUL_STimeOut 0x8A /* 0A W Sel/Resel Time Out Register */
  139. #define TUL_SIdent 0x8A /* 0A R Identify Message Register */
  140. #define TUL_SAvail 0x8A /* 0A R Availiable Counter Register */
  141. #define TUL_SData 0x8B /* 0B R/W SCSI data in/out */
  142. #define TUL_SFifo 0x8C /* 0C R/W FIFO */
  143. #define TUL_SSignal 0x90 /* 10 R/W SCSI signal in/out */
  144. #define TUL_SCmd 0x91 /* 11 R/W Command */
  145. #define TUL_STest0 0x92 /* 12 R/W Test0 */
  146. #define TUL_STest1 0x93 /* 13 R/W Test1 */
  147. #define TUL_SCFG1 0x94 /* 14 R/W Configuration */
  148. #define TUL_XAddH 0xC0 /*DMA Transfer Physical Address */
  149. #define TUL_XAddW 0xC8 /*DMA Current Transfer Physical Address */
  150. #define TUL_XCntH 0xD0 /*DMA Transfer Counter */
  151. #define TUL_XCntW 0xD4 /*DMA Current Transfer Counter */
  152. #define TUL_XCmd 0xD8 /*DMA Command Register */
  153. #define TUL_Int 0xDC /*Interrupt Register */
  154. #define TUL_XStatus 0xDD /*DMA status Register */
  155. #define TUL_Mask 0xE0 /*Interrupt Mask Register */
  156. #define TUL_XCtrl 0xE4 /*DMA Control Register */
  157. #define TUL_XCtrl1 0xE5 /*DMA Control Register 1 */
  158. #define TUL_XFifo 0xE8 /*DMA FIFO */
  159. #define TUL_WCtrl 0xF7 /*Bus master wait state control */
  160. #define TUL_DCtrl 0xFB /*DMA delay control */
  161. /*----------------------------------------------------------------------*/
  162. /* bit definition for Command register of Configuration Space Header */
  163. /*----------------------------------------------------------------------*/
  164. #define BUSMS 0x04 /* BUS MASTER Enable */
  165. #define IOSPA 0x01 /* IO Space Enable */
  166. /*----------------------------------------------------------------------*/
  167. /* Command Codes of Tulip SCSI Command register */
  168. /*----------------------------------------------------------------------*/
  169. #define TSC_EN_RESEL 0x80 /* Enable Reselection */
  170. #define TSC_CMD_COMP 0x84 /* Command Complete Sequence */
  171. #define TSC_SEL 0x01 /* Select Without ATN Sequence */
  172. #define TSC_SEL_ATN 0x11 /* Select With ATN Sequence */
  173. #define TSC_SEL_ATN_DMA 0x51 /* Select With ATN Sequence with DMA */
  174. #define TSC_SEL_ATN3 0x31 /* Select With ATN3 Sequence */
  175. #define TSC_SEL_ATNSTOP 0x12 /* Select With ATN and Stop Sequence */
  176. #define TSC_SELATNSTOP 0x1E /* Select With ATN and Stop Sequence */
  177. #define TSC_SEL_ATN_DIRECT_IN 0x95 /* Select With ATN Sequence */
  178. #define TSC_SEL_ATN_DIRECT_OUT 0x15 /* Select With ATN Sequence */
  179. #define TSC_SEL_ATN3_DIRECT_IN 0xB5 /* Select With ATN3 Sequence */
  180. #define TSC_SEL_ATN3_DIRECT_OUT 0x35 /* Select With ATN3 Sequence */
  181. #define TSC_XF_DMA_OUT_DIRECT 0x06 /* DMA Xfer Infomation out */
  182. #define TSC_XF_DMA_IN_DIRECT 0x86 /* DMA Xfer Infomation in */
  183. #define TSC_XF_DMA_OUT 0x43 /* DMA Xfer Infomation out */
  184. #define TSC_XF_DMA_IN 0xC3 /* DMA Xfer Infomation in */
  185. #define TSC_XF_FIFO_OUT 0x03 /* FIFO Xfer Infomation out */
  186. #define TSC_XF_FIFO_IN 0x83 /* FIFO Xfer Infomation in */
  187. #define TSC_MSG_ACCEPT 0x0F /* Message Accept */
  188. /*----------------------------------------------------------------------*/
  189. /* bit definition for Tulip SCSI Control 0 Register */
  190. /*----------------------------------------------------------------------*/
  191. #define TSC_RST_SEQ 0x20 /* Reset sequence counter */
  192. #define TSC_FLUSH_FIFO 0x10 /* Flush FIFO */
  193. #define TSC_ABT_CMD 0x04 /* Abort command (sequence) */
  194. #define TSC_RST_CHIP 0x02 /* Reset SCSI Chip */
  195. #define TSC_RST_BUS 0x01 /* Reset SCSI Bus */
  196. /*----------------------------------------------------------------------*/
  197. /* bit definition for Tulip SCSI Control 1 Register */
  198. /*----------------------------------------------------------------------*/
  199. #define TSC_EN_SCAM 0x80 /* Enable SCAM */
  200. #define TSC_TIMER 0x40 /* Select timeout unit */
  201. #define TSC_EN_SCSI2 0x20 /* SCSI-2 mode */
  202. #define TSC_PWDN 0x10 /* Power down mode */
  203. #define TSC_WIDE_CPU 0x08 /* Wide CPU */
  204. #define TSC_HW_RESELECT 0x04 /* Enable HW reselect */
  205. #define TSC_EN_BUS_OUT 0x02 /* Enable SCSI data bus out latch */
  206. #define TSC_EN_BUS_IN 0x01 /* Enable SCSI data bus in latch */
  207. /*----------------------------------------------------------------------*/
  208. /* bit definition for Tulip SCSI Configuration Register */
  209. /*----------------------------------------------------------------------*/
  210. #define TSC_EN_LATCH 0x80 /* Enable phase latch */
  211. #define TSC_INITIATOR 0x40 /* Initiator mode */
  212. #define TSC_EN_SCSI_PAR 0x20 /* Enable SCSI parity */
  213. #define TSC_DMA_8BIT 0x10 /* Alternate dma 8-bits mode */
  214. #define TSC_DMA_16BIT 0x08 /* Alternate dma 16-bits mode */
  215. #define TSC_EN_WDACK 0x04 /* Enable DACK while wide SCSI xfer */
  216. #define TSC_ALT_PERIOD 0x02 /* Alternate sync period mode */
  217. #define TSC_DIS_SCSIRST 0x01 /* Disable SCSI bus reset us */
  218. #define TSC_INITDEFAULT (TSC_INITIATOR | TSC_EN_LATCH | TSC_ALT_PERIOD | TSC_DIS_SCSIRST)
  219. #define TSC_WIDE_SCSI 0x80 /* Enable Wide SCSI */
  220. /*----------------------------------------------------------------------*/
  221. /* bit definition for Tulip SCSI signal Register */
  222. /*----------------------------------------------------------------------*/
  223. #define TSC_RST_ACK 0x00 /* Release ACK signal */
  224. #define TSC_RST_ATN 0x00 /* Release ATN signal */
  225. #define TSC_RST_BSY 0x00 /* Release BSY signal */
  226. #define TSC_SET_ACK 0x40 /* ACK signal */
  227. #define TSC_SET_ATN 0x08 /* ATN signal */
  228. #define TSC_REQI 0x80 /* REQ signal */
  229. #define TSC_ACKI 0x40 /* ACK signal */
  230. #define TSC_BSYI 0x20 /* BSY signal */
  231. #define TSC_SELI 0x10 /* SEL signal */
  232. #define TSC_ATNI 0x08 /* ATN signal */
  233. #define TSC_MSGI 0x04 /* MSG signal */
  234. #define TSC_CDI 0x02 /* C/D signal */
  235. #define TSC_IOI 0x01 /* I/O signal */
  236. /*----------------------------------------------------------------------*/
  237. /* bit definition for Tulip SCSI Status 0 Register */
  238. /*----------------------------------------------------------------------*/
  239. #define TSS_INT_PENDING 0x80 /* Interrupt pending */
  240. #define TSS_SEQ_ACTIVE 0x40 /* Sequencer active */
  241. #define TSS_XFER_CNT 0x20 /* Transfer counter zero */
  242. #define TSS_FIFO_EMPTY 0x10 /* FIFO empty */
  243. #define TSS_PAR_ERROR 0x08 /* SCSI parity error */
  244. #define TSS_PH_MASK 0x07 /* SCSI phase mask */
  245. /*----------------------------------------------------------------------*/
  246. /* bit definition for Tulip SCSI Status 1 Register */
  247. /*----------------------------------------------------------------------*/
  248. #define TSS_STATUS_RCV 0x08 /* Status received */
  249. #define TSS_MSG_SEND 0x40 /* Message sent */
  250. #define TSS_CMD_PH_CMP 0x20 /* command phase done */
  251. #define TSS_DATA_PH_CMP 0x10 /* Data phase done */
  252. #define TSS_STATUS_SEND 0x08 /* Status sent */
  253. #define TSS_XFER_CMP 0x04 /* Transfer completed */
  254. #define TSS_SEL_CMP 0x02 /* Selection completed */
  255. #define TSS_ARB_CMP 0x01 /* Arbitration completed */
  256. /*----------------------------------------------------------------------*/
  257. /* bit definition for Tulip SCSI Status 2 Register */
  258. /*----------------------------------------------------------------------*/
  259. #define TSS_CMD_ABTED 0x80 /* Command aborted */
  260. #define TSS_OFFSET_0 0x40 /* Offset counter zero */
  261. #define TSS_FIFO_FULL 0x20 /* FIFO full */
  262. #define TSS_TIMEOUT_0 0x10 /* Timeout counter zero */
  263. #define TSS_BUSY_RLS 0x08 /* Busy release */
  264. #define TSS_PH_MISMATCH 0x04 /* Phase mismatch */
  265. #define TSS_SCSI_BUS_EN 0x02 /* SCSI data bus enable */
  266. #define TSS_SCSIRST 0x01 /* SCSI bus reset in progress */
  267. /*----------------------------------------------------------------------*/
  268. /* bit definition for Tulip SCSI Interrupt Register */
  269. /*----------------------------------------------------------------------*/
  270. #define TSS_RESEL_INT 0x80 /* Reselected interrupt */
  271. #define TSS_SEL_TIMEOUT 0x40 /* Selected/reselected timeout */
  272. #define TSS_BUS_SERV 0x20
  273. #define TSS_SCSIRST_INT 0x10 /* SCSI bus reset detected */
  274. #define TSS_DISC_INT 0x08 /* Disconnected interrupt */
  275. #define TSS_SEL_INT 0x04 /* Select interrupt */
  276. #define TSS_SCAM_SEL 0x02 /* SCAM selected */
  277. #define TSS_FUNC_COMP 0x01
  278. /*----------------------------------------------------------------------*/
  279. /* SCSI Phase Codes. */
  280. /*----------------------------------------------------------------------*/
  281. #define DATA_OUT 0
  282. #define DATA_IN 1 /* 4 */
  283. #define CMD_OUT 2
  284. #define STATUS_IN 3 /* 6 */
  285. #define MSG_OUT 6 /* 3 */
  286. #define MSG_IN 7
  287. /*----------------------------------------------------------------------*/
  288. /* Command Codes of Tulip xfer Command register */
  289. /*----------------------------------------------------------------------*/
  290. #define TAX_X_FORC 0x02
  291. #define TAX_X_ABT 0x04
  292. #define TAX_X_CLR_FIFO 0x08
  293. #define TAX_X_IN 0x21
  294. #define TAX_X_OUT 0x01
  295. #define TAX_SG_IN 0xA1
  296. #define TAX_SG_OUT 0x81
  297. /*----------------------------------------------------------------------*/
  298. /* Tulip Interrupt Register */
  299. /*----------------------------------------------------------------------*/
  300. #define XCMP 0x01
  301. #define FCMP 0x02
  302. #define XABT 0x04
  303. #define XERR 0x08
  304. #define SCMP 0x10
  305. #define IPEND 0x80
  306. /*----------------------------------------------------------------------*/
  307. /* Tulip DMA Status Register */
  308. /*----------------------------------------------------------------------*/
  309. #define XPEND 0x01 /* Transfer pending */
  310. #define FEMPTY 0x02 /* FIFO empty */
  311. /*----------------------------------------------------------------------*/
  312. /* bit definition for TUL_GCTRL */
  313. /*----------------------------------------------------------------------*/
  314. #define EXTSG 0x80
  315. #define EXTAD 0x60
  316. #define SEG4K 0x08
  317. #define EEPRG 0x04
  318. #define MRMUL 0x02
  319. /*----------------------------------------------------------------------*/
  320. /* bit definition for TUL_NVRAM */
  321. /*----------------------------------------------------------------------*/
  322. #define SE2CS 0x08
  323. #define SE2CLK 0x04
  324. #define SE2DO 0x02
  325. #define SE2DI 0x01
  326. /************************************************************************/
  327. /* Scatter-Gather Element Structure */
  328. /************************************************************************/
  329. typedef struct SG_Struc {
  330. U32 SG_Ptr; /* Data Pointer */
  331. U32 SG_Len; /* Data Length */
  332. } SG;
  333. /***********************************************************************
  334. SCSI Control Block
  335. ************************************************************************/
  336. typedef struct Scsi_Ctrl_Blk {
  337. struct Scsi_Ctrl_Blk *SCB_NxtScb;
  338. UBYTE SCB_Status; /*4 */
  339. UBYTE SCB_NxtStat; /*5 */
  340. UBYTE SCB_Mode; /*6 */
  341. UBYTE SCB_Msgin; /*7 SCB_Res0 */
  342. UWORD SCB_SGIdx; /*8 */
  343. UWORD SCB_SGMax; /*A */
  344. #ifdef ALPHA
  345. U32 SCB_Reserved[2]; /*C */
  346. #else
  347. U32 SCB_Reserved[3]; /*C */
  348. #endif
  349. U32 SCB_XferLen; /*18 Current xfer len */
  350. U32 SCB_TotXLen; /*1C Total xfer len */
  351. U32 SCB_PAddr; /*20 SCB phy. Addr. */
  352. UBYTE SCB_Opcode; /*24 SCB command code */
  353. UBYTE SCB_Flags; /*25 SCB Flags */
  354. UBYTE SCB_Target; /*26 Target Id */
  355. UBYTE SCB_Lun; /*27 Lun */
  356. U32 SCB_BufPtr; /*28 Data Buffer Pointer */
  357. U32 SCB_BufLen; /*2C Data Allocation Length */
  358. UBYTE SCB_SGLen; /*30 SG list # */
  359. UBYTE SCB_SenseLen; /*31 Sense Allocation Length */
  360. UBYTE SCB_HaStat; /*32 */
  361. UBYTE SCB_TaStat; /*33 */
  362. UBYTE SCB_CDBLen; /*34 CDB Length */
  363. UBYTE SCB_Ident; /*35 Identify */
  364. UBYTE SCB_TagMsg; /*36 Tag Message */
  365. UBYTE SCB_TagId; /*37 Queue Tag */
  366. UBYTE SCB_CDB[12]; /*38 */
  367. U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */
  368. U32 SCB_SensePtr; /*48 Sense data pointer */
  369. void (*SCB_Post) (BYTE *, BYTE *); /*4C POST routine */
  370. struct scsi_cmnd *SCB_Srb; /*50 SRB Pointer */
  371. SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */
  372. } SCB;
  373. /* Bit Definition for SCB_Status */
  374. #define SCB_RENT 0x01
  375. #define SCB_PEND 0x02
  376. #define SCB_CONTIG 0x04 /* Contigent Allegiance */
  377. #define SCB_SELECT 0x08
  378. #define SCB_BUSY 0x10
  379. #define SCB_DONE 0x20
  380. /* Opcodes of SCB_Opcode */
  381. #define ExecSCSI 0x1
  382. #define BusDevRst 0x2
  383. #define AbortCmd 0x3
  384. /* Bit Definition for SCB_Mode */
  385. #define SCM_RSENS 0x01 /* request sense mode */
  386. /* Bit Definition for SCB_Flags */
  387. #define SCF_DONE 0x01
  388. #define SCF_POST 0x02
  389. #define SCF_SENSE 0x04
  390. #define SCF_DIR 0x18
  391. #define SCF_NO_DCHK 0x00
  392. #define SCF_DIN 0x08
  393. #define SCF_DOUT 0x10
  394. #define SCF_NO_XF 0x18
  395. #define SCF_WR_VF 0x20 /* Write verify turn on */
  396. #define SCF_POLL 0x40
  397. #define SCF_SG 0x80
  398. /* Error Codes for SCB_HaStat */
  399. #define HOST_SEL_TOUT 0x11
  400. #define HOST_DO_DU 0x12
  401. #define HOST_BUS_FREE 0x13
  402. #define HOST_BAD_PHAS 0x14
  403. #define HOST_INV_CMD 0x16
  404. #define HOST_ABORTED 0x1A /* 07/21/98 */
  405. #define HOST_SCSI_RST 0x1B
  406. #define HOST_DEV_RST 0x1C
  407. /* Error Codes for SCB_TaStat */
  408. #define TARGET_CHKCOND 0x02
  409. #define TARGET_BUSY 0x08
  410. #define INI_QUEUE_FULL 0x28
  411. /* SCSI MESSAGE */
  412. #define MSG_COMP 0x00
  413. #define MSG_EXTEND 0x01
  414. #define MSG_SDP 0x02
  415. #define MSG_RESTORE 0x03
  416. #define MSG_DISC 0x04
  417. #define MSG_IDE 0x05
  418. #define MSG_ABORT 0x06
  419. #define MSG_REJ 0x07
  420. #define MSG_NOP 0x08
  421. #define MSG_PARITY 0x09
  422. #define MSG_LINK_COMP 0x0A
  423. #define MSG_LINK_FLAG 0x0B
  424. #define MSG_DEVRST 0x0C
  425. #define MSG_ABORT_TAG 0x0D
  426. /* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
  427. #define MSG_STAG 0x20
  428. #define MSG_HTAG 0x21
  429. #define MSG_OTAG 0x22
  430. #define MSG_IGNOREWIDE 0x23
  431. #define MSG_IDENT 0x80
  432. /***********************************************************************
  433. Target Device Control Structure
  434. **********************************************************************/
  435. typedef struct Tar_Ctrl_Struc {
  436. UWORD TCS_Flags; /* 0 */
  437. UBYTE TCS_JS_Period; /* 2 */
  438. UBYTE TCS_SConfig0; /* 3 */
  439. UWORD TCS_DrvFlags; /* 4 */
  440. UBYTE TCS_DrvHead; /* 6 */
  441. UBYTE TCS_DrvSector; /* 7 */
  442. } TCS;
  443. /***********************************************************************
  444. Target Device Control Structure
  445. **********************************************************************/
  446. /* Bit Definition for TCF_Flags */
  447. #define TCF_SCSI_RATE 0x0007
  448. #define TCF_EN_DISC 0x0008
  449. #define TCF_NO_SYNC_NEGO 0x0010
  450. #define TCF_NO_WDTR 0x0020
  451. #define TCF_EN_255 0x0040
  452. #define TCF_EN_START 0x0080
  453. #define TCF_WDTR_DONE 0x0100
  454. #define TCF_SYNC_DONE 0x0200
  455. #define TCF_BUSY 0x0400
  456. /* Bit Definition for TCF_DrvFlags */
  457. #define TCF_DRV_BUSY 0x01 /* Indicate target busy(driver) */
  458. #define TCF_DRV_EN_TAG 0x0800
  459. #define TCF_DRV_255_63 0x0400
  460. typedef struct I91u_Adpt_Struc {
  461. UWORD ADPT_BIOS; /* 0 */
  462. UWORD ADPT_BASE; /* 1 */
  463. UBYTE ADPT_Bus; /* 2 */
  464. UBYTE ADPT_Device; /* 3 */
  465. UBYTE ADPT_INTR; /* 4 */
  466. } INI_ADPT_STRUCT;
  467. /***********************************************************************
  468. Host Adapter Control Structure
  469. ************************************************************************/
  470. typedef struct Ha_Ctrl_Struc {
  471. UWORD HCS_Base; /* 00 */
  472. UWORD HCS_BIOS; /* 02 */
  473. UBYTE HCS_Intr; /* 04 */
  474. UBYTE HCS_SCSI_ID; /* 05 */
  475. UBYTE HCS_MaxTar; /* 06 */
  476. UBYTE HCS_NumScbs; /* 07 */
  477. UBYTE HCS_Flags; /* 08 */
  478. UBYTE HCS_Index; /* 09 */
  479. UBYTE HCS_HaId; /* 0A */
  480. UBYTE HCS_Config; /* 0B */
  481. UWORD HCS_IdMask; /* 0C */
  482. UBYTE HCS_Semaph; /* 0E */
  483. UBYTE HCS_Phase; /* 0F */
  484. UBYTE HCS_JSStatus0; /* 10 */
  485. UBYTE HCS_JSInt; /* 11 */
  486. UBYTE HCS_JSStatus1; /* 12 */
  487. UBYTE HCS_SConf1; /* 13 */
  488. UBYTE HCS_Msg[8]; /* 14 */
  489. SCB *HCS_NxtAvail; /* 1C */
  490. SCB *HCS_Scb; /* 20 */
  491. SCB *HCS_ScbEnd; /* 24 */
  492. SCB *HCS_NxtPend; /* 28 */
  493. SCB *HCS_NxtContig; /* 2C */
  494. SCB *HCS_ActScb; /* 30 */
  495. TCS *HCS_ActTcs; /* 34 */
  496. SCB *HCS_FirstAvail; /* 38 */
  497. SCB *HCS_LastAvail; /* 3C */
  498. SCB *HCS_FirstPend; /* 40 */
  499. SCB *HCS_LastPend; /* 44 */
  500. SCB *HCS_FirstBusy; /* 48 */
  501. SCB *HCS_LastBusy; /* 4C */
  502. SCB *HCS_FirstDone; /* 50 */
  503. SCB *HCS_LastDone; /* 54 */
  504. UBYTE HCS_MaxTags[16]; /* 58 */
  505. UBYTE HCS_ActTags[16]; /* 68 */
  506. TCS HCS_Tcs[MAX_TARGETS]; /* 78 */
  507. spinlock_t HCS_AvailLock;
  508. spinlock_t HCS_SemaphLock;
  509. struct pci_dev *pci_dev;
  510. } HCS;
  511. /* Bit Definition for HCB_Config */
  512. #define HCC_SCSI_RESET 0x01
  513. #define HCC_EN_PAR 0x02
  514. #define HCC_ACT_TERM1 0x04
  515. #define HCC_ACT_TERM2 0x08
  516. #define HCC_AUTO_TERM 0x10
  517. #define HCC_EN_PWR 0x80
  518. /* Bit Definition for HCB_Flags */
  519. #define HCF_EXPECT_DISC 0x01
  520. #define HCF_EXPECT_SELECT 0x02
  521. #define HCF_EXPECT_RESET 0x10
  522. #define HCF_EXPECT_DONE_DISC 0x20
  523. /******************************************************************
  524. Serial EEProm
  525. *******************************************************************/
  526. typedef struct _NVRAM_SCSI { /* SCSI channel configuration */
  527. UCHAR NVM_ChSCSIID; /* 0Ch -> Channel SCSI ID */
  528. UCHAR NVM_ChConfig1; /* 0Dh -> Channel config 1 */
  529. UCHAR NVM_ChConfig2; /* 0Eh -> Channel config 2 */
  530. UCHAR NVM_NumOfTarg; /* 0Fh -> Number of SCSI target */
  531. /* SCSI target configuration */
  532. UCHAR NVM_Targ0Config; /* 10h -> Target 0 configuration */
  533. UCHAR NVM_Targ1Config; /* 11h -> Target 1 configuration */
  534. UCHAR NVM_Targ2Config; /* 12h -> Target 2 configuration */
  535. UCHAR NVM_Targ3Config; /* 13h -> Target 3 configuration */
  536. UCHAR NVM_Targ4Config; /* 14h -> Target 4 configuration */
  537. UCHAR NVM_Targ5Config; /* 15h -> Target 5 configuration */
  538. UCHAR NVM_Targ6Config; /* 16h -> Target 6 configuration */
  539. UCHAR NVM_Targ7Config; /* 17h -> Target 7 configuration */
  540. UCHAR NVM_Targ8Config; /* 18h -> Target 8 configuration */
  541. UCHAR NVM_Targ9Config; /* 19h -> Target 9 configuration */
  542. UCHAR NVM_TargAConfig; /* 1Ah -> Target A configuration */
  543. UCHAR NVM_TargBConfig; /* 1Bh -> Target B configuration */
  544. UCHAR NVM_TargCConfig; /* 1Ch -> Target C configuration */
  545. UCHAR NVM_TargDConfig; /* 1Dh -> Target D configuration */
  546. UCHAR NVM_TargEConfig; /* 1Eh -> Target E configuration */
  547. UCHAR NVM_TargFConfig; /* 1Fh -> Target F configuration */
  548. } NVRAM_SCSI;
  549. typedef struct _NVRAM {
  550. /*----------header ---------------*/
  551. USHORT NVM_Signature; /* 0,1: Signature */
  552. UCHAR NVM_Size; /* 2: Size of data structure */
  553. UCHAR NVM_Revision; /* 3: Revision of data structure */
  554. /* ----Host Adapter Structure ---- */
  555. UCHAR NVM_ModelByte0; /* 4: Model number (byte 0) */
  556. UCHAR NVM_ModelByte1; /* 5: Model number (byte 1) */
  557. UCHAR NVM_ModelInfo; /* 6: Model information */
  558. UCHAR NVM_NumOfCh; /* 7: Number of SCSI channel */
  559. UCHAR NVM_BIOSConfig1; /* 8: BIOS configuration 1 */
  560. UCHAR NVM_BIOSConfig2; /* 9: BIOS configuration 2 */
  561. UCHAR NVM_HAConfig1; /* A: Hoat adapter configuration 1 */
  562. UCHAR NVM_HAConfig2; /* B: Hoat adapter configuration 2 */
  563. NVRAM_SCSI NVM_SCSIInfo[2];
  564. UCHAR NVM_reserved[10];
  565. /* ---------- CheckSum ---------- */
  566. USHORT NVM_CheckSum; /* 0x3E, 0x3F: Checksum of NVRam */
  567. } NVRAM, *PNVRAM;
  568. /* Bios Configuration for nvram->BIOSConfig1 */
  569. #define NBC1_ENABLE 0x01 /* BIOS enable */
  570. #define NBC1_8DRIVE 0x02 /* Support more than 2 drives */
  571. #define NBC1_REMOVABLE 0x04 /* Support removable drive */
  572. #define NBC1_INT19 0x08 /* Intercept int 19h */
  573. #define NBC1_BIOSSCAN 0x10 /* Dynamic BIOS scan */
  574. #define NBC1_LUNSUPPORT 0x40 /* Support LUN */
  575. /* HA Configuration Byte 1 */
  576. #define NHC1_BOOTIDMASK 0x0F /* Boot ID number */
  577. #define NHC1_LUNMASK 0x70 /* Boot LUN number */
  578. #define NHC1_CHANMASK 0x80 /* Boot Channel number */
  579. /* Bit definition for nvram->SCSIconfig1 */
  580. #define NCC1_BUSRESET 0x01 /* Reset SCSI bus at power up */
  581. #define NCC1_PARITYCHK 0x02 /* SCSI parity enable */
  582. #define NCC1_ACTTERM1 0x04 /* Enable active terminator 1 */
  583. #define NCC1_ACTTERM2 0x08 /* Enable active terminator 2 */
  584. #define NCC1_AUTOTERM 0x10 /* Enable auto terminator */
  585. #define NCC1_PWRMGR 0x80 /* Enable power management */
  586. /* Bit definition for SCSI Target configuration byte */
  587. #define NTC_DISCONNECT 0x08 /* Enable SCSI disconnect */
  588. #define NTC_SYNC 0x10 /* SYNC_NEGO */
  589. #define NTC_NO_WDTR 0x20 /* SYNC_NEGO */
  590. #define NTC_1GIGA 0x40 /* 255 head / 63 sectors (64/32) */
  591. #define NTC_SPINUP 0x80 /* Start disk drive */
  592. /* Default NVRam values */
  593. #define INI_SIGNATURE 0xC925
  594. #define NBC1_DEFAULT (NBC1_ENABLE)
  595. #define NCC1_DEFAULT (NCC1_BUSRESET | NCC1_AUTOTERM | NCC1_PARITYCHK)
  596. #define NTC_DEFAULT (NTC_NO_WDTR | NTC_1GIGA | NTC_DISCONNECT)
  597. /* SCSI related definition */
  598. #define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */
  599. #define DISC_ALLOW 0xC0 /* Disconnect is allowed */
  600. #define SCSICMD_RequestSense 0x03
  601. typedef struct _HCSinfo {
  602. ULONG base;
  603. UCHAR vec;
  604. UCHAR bios; /* High byte of BIOS address */
  605. USHORT BaseAndBios; /* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */
  606. } HCSINFO;
  607. #define TUL_RD(x,y) (UCHAR)(inb( (int)((ULONG)(x+y)) ))
  608. #define TUL_RDLONG(x,y) (ULONG)(inl((int)((ULONG)(x+y)) ))
  609. #define TUL_WR( adr,data) outb( (UCHAR)(data), (int)(adr))
  610. #define TUL_WRSHORT(adr,data) outw( (UWORD)(data), (int)(adr))
  611. #define TUL_WRLONG( adr,data) outl( (ULONG)(data), (int)(adr))
  612. #define SCSI_ABORT_SNOOZE 0
  613. #define SCSI_ABORT_SUCCESS 1
  614. #define SCSI_ABORT_PENDING 2
  615. #define SCSI_ABORT_BUSY 3
  616. #define SCSI_ABORT_NOT_RUNNING 4
  617. #define SCSI_ABORT_ERROR 5
  618. #define SCSI_RESET_SNOOZE 0
  619. #define SCSI_RESET_PUNT 1
  620. #define SCSI_RESET_SUCCESS 2
  621. #define SCSI_RESET_PENDING 3
  622. #define SCSI_RESET_WAKEUP 4
  623. #define SCSI_RESET_NOT_RUNNING 5
  624. #define SCSI_RESET_ERROR 6
  625. #define SCSI_RESET_SYNCHRONOUS 0x01
  626. #define SCSI_RESET_ASYNCHRONOUS 0x02
  627. #define SCSI_RESET_SUGGEST_BUS_RESET 0x04
  628. #define SCSI_RESET_SUGGEST_HOST_RESET 0x08
  629. #define SCSI_RESET_BUS_RESET 0x100
  630. #define SCSI_RESET_HOST_RESET 0x200
  631. #define SCSI_RESET_ACTION 0xff