initio.h 29 KB

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