a100u2w.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /*
  2. * Initio A100 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. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  25. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. *
  33. * Revision History:
  34. * 06/18/98 HL, Initial production Version 1.02
  35. * 12/19/98 bv, Use spinlocks for 2.1.95 and up
  36. * 06/25/02 Doug Ledford <dledford@redhat.com>
  37. * - This and the i60uscsi.h file are almost identical,
  38. * merged them into a single header used by both .c files.
  39. * 14/06/07 Alan Cox <alan@redhat.com>
  40. * - Grand cleanup and Linuxisation
  41. */
  42. #define inia100_REVID "Initio INI-A100U2W SCSI device driver; Revision: 1.02d"
  43. #if 1
  44. #define ORC_MAXQUEUE 245
  45. #define ORC_MAXTAGS 64
  46. #else
  47. #define ORC_MAXQUEUE 25
  48. #define ORC_MAXTAGS 8
  49. #endif
  50. #define TOTAL_SG_ENTRY 32
  51. #define MAX_TARGETS 16
  52. #define IMAX_CDB 15
  53. #define SENSE_SIZE 14
  54. /************************************************************************/
  55. /* Scatter-Gather Element Structure */
  56. /************************************************************************/
  57. struct orc_sgent {
  58. u32 base; /* Data Pointer */
  59. u32 length; /* Data Length */
  60. };
  61. /* SCSI related definition */
  62. #define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */
  63. #define DISC_ALLOW 0xC0 /* Disconnect is allowed */
  64. #define ORC_OFFSET_SCB 16
  65. #define ORC_MAX_SCBS 250
  66. #define MAX_CHANNELS 2
  67. #define MAX_ESCB_ELE 64
  68. #define TCF_DRV_255_63 0x0400
  69. /********************************************************/
  70. /* Orchid Host Command Set */
  71. /********************************************************/
  72. #define ORC_CMD_NOP 0x00 /* Host command - NOP */
  73. #define ORC_CMD_VERSION 0x01 /* Host command - Get F/W version */
  74. #define ORC_CMD_ECHO 0x02 /* Host command - ECHO */
  75. #define ORC_CMD_SET_NVM 0x03 /* Host command - Set NVRAM */
  76. #define ORC_CMD_GET_NVM 0x04 /* Host command - Get NVRAM */
  77. #define ORC_CMD_GET_BUS_STATUS 0x05 /* Host command - Get SCSI bus status */
  78. #define ORC_CMD_ABORT_SCB 0x06 /* Host command - Abort SCB */
  79. #define ORC_CMD_ISSUE_SCB 0x07 /* Host command - Issue SCB */
  80. /********************************************************/
  81. /* Orchid Register Set */
  82. /********************************************************/
  83. #define ORC_GINTS 0xA0 /* Global Interrupt Status */
  84. #define QINT 0x04 /* Reply Queue Interrupt */
  85. #define ORC_GIMSK 0xA1 /* Global Interrupt MASK */
  86. #define MQINT 0x04 /* Mask Reply Queue Interrupt */
  87. #define ORC_GCFG 0xA2 /* Global Configure */
  88. #define EEPRG 0x01 /* Enable EEPROM programming */
  89. #define ORC_GSTAT 0xA3 /* Global status */
  90. #define WIDEBUS 0x10 /* Wide SCSI Devices connected */
  91. #define ORC_HDATA 0xA4 /* Host Data */
  92. #define ORC_HCTRL 0xA5 /* Host Control */
  93. #define SCSIRST 0x80 /* SCSI bus reset */
  94. #define HDO 0x40 /* Host data out */
  95. #define HOSTSTOP 0x02 /* Host stop RISC engine */
  96. #define DEVRST 0x01 /* Device reset */
  97. #define ORC_HSTUS 0xA6 /* Host Status */
  98. #define HDI 0x02 /* Host data in */
  99. #define RREADY 0x01 /* RISC engine is ready to receive */
  100. #define ORC_NVRAM 0xA7 /* Nvram port address */
  101. #define SE2CS 0x008
  102. #define SE2CLK 0x004
  103. #define SE2DO 0x002
  104. #define SE2DI 0x001
  105. #define ORC_PQUEUE 0xA8 /* Posting queue FIFO */
  106. #define ORC_PQCNT 0xA9 /* Posting queue FIFO Cnt */
  107. #define ORC_RQUEUE 0xAA /* Reply queue FIFO */
  108. #define ORC_RQUEUECNT 0xAB /* Reply queue FIFO Cnt */
  109. #define ORC_FWBASEADR 0xAC /* Firmware base address */
  110. #define ORC_EBIOSADR0 0xB0 /* External Bios address */
  111. #define ORC_EBIOSADR1 0xB1 /* External Bios address */
  112. #define ORC_EBIOSADR2 0xB2 /* External Bios address */
  113. #define ORC_EBIOSDATA 0xB3 /* External Bios address */
  114. #define ORC_SCBSIZE 0xB7 /* SCB size register */
  115. #define ORC_SCBBASE0 0xB8 /* SCB base address 0 */
  116. #define ORC_SCBBASE1 0xBC /* SCB base address 1 */
  117. #define ORC_RISCCTL 0xE0 /* RISC Control */
  118. #define PRGMRST 0x002
  119. #define DOWNLOAD 0x001
  120. #define ORC_PRGMCTR0 0xE2 /* RISC program counter */
  121. #define ORC_PRGMCTR1 0xE3 /* RISC program counter */
  122. #define ORC_RISCRAM 0xEC /* RISC RAM data port 4 bytes */
  123. struct orc_extended_scb { /* Extended SCB */
  124. struct orc_sgent sglist[TOTAL_SG_ENTRY]; /*0 Start of SG list */
  125. struct scsi_cmnd *srb; /*50 SRB Pointer */
  126. };
  127. /***********************************************************************
  128. SCSI Control Block
  129. 0x40 bytes long, the last 8 are user bytes
  130. ************************************************************************/
  131. struct orc_scb { /* Scsi_Ctrl_Blk */
  132. u8 opcode; /*00 SCB command code&residual */
  133. u8 flags; /*01 SCB Flags */
  134. u8 target; /*02 Target Id */
  135. u8 lun; /*03 Lun */
  136. u32 reserved0; /*04 Reserved for ORCHID must 0 */
  137. u32 xferlen; /*08 Data Transfer Length */
  138. u32 reserved1; /*0C Reserved for ORCHID must 0 */
  139. u32 sg_len; /*10 SG list # * 8 */
  140. u32 sg_addr; /*14 SG List Buf physical Addr */
  141. u32 sg_addrhigh; /*18 SG Buffer high physical Addr */
  142. u8 hastat; /*1C Host Status */
  143. u8 tastat; /*1D Target Status */
  144. u8 status; /*1E SCB status */
  145. u8 link; /*1F Link pointer, default 0xFF */
  146. u8 sense_len; /*20 Sense Allocation Length */
  147. u8 cdb_len; /*21 CDB Length */
  148. u8 ident; /*22 Identify */
  149. u8 tag_msg; /*23 Tag Message */
  150. u8 cdb[IMAX_CDB]; /*24 SCSI CDBs */
  151. u8 scbidx; /*3C Index for this ORCSCB */
  152. u32 sense_addr; /*34 Sense Buffer physical Addr */
  153. struct orc_extended_scb *escb; /*38 Extended SCB Pointer */
  154. /* 64bit pointer or 32bit pointer + reserved ? */
  155. #ifndef CONFIG_64BIT
  156. u8 reserved2[4]; /*3E Reserved for Driver use */
  157. #endif
  158. };
  159. /* Opcodes of ORCSCB_Opcode */
  160. #define ORC_EXECSCSI 0x00 /* SCSI initiator command with residual */
  161. #define ORC_BUSDEVRST 0x01 /* SCSI Bus Device Reset */
  162. /* Status of ORCSCB_Status */
  163. #define ORCSCB_COMPLETE 0x00 /* SCB request completed */
  164. #define ORCSCB_POST 0x01 /* SCB is posted by the HOST */
  165. /* Bit Definition for ORCSCB_Flags */
  166. #define SCF_DISINT 0x01 /* Disable HOST interrupt */
  167. #define SCF_DIR 0x18 /* Direction bits */
  168. #define SCF_NO_DCHK 0x00 /* Direction determined by SCSI */
  169. #define SCF_DIN 0x08 /* From Target to Initiator */
  170. #define SCF_DOUT 0x10 /* From Initiator to Target */
  171. #define SCF_NO_XF 0x18 /* No data transfer */
  172. #define SCF_POLL 0x40
  173. /* Error Codes for ORCSCB_HaStat */
  174. #define HOST_SEL_TOUT 0x11
  175. #define HOST_DO_DU 0x12
  176. #define HOST_BUS_FREE 0x13
  177. #define HOST_BAD_PHAS 0x14
  178. #define HOST_INV_CMD 0x16
  179. #define HOST_SCSI_RST 0x1B
  180. #define HOST_DEV_RST 0x1C
  181. /* Error Codes for ORCSCB_TaStat */
  182. #define TARGET_CHK_COND 0x02
  183. #define TARGET_BUSY 0x08
  184. #define TARGET_TAG_FULL 0x28
  185. /***********************************************************************
  186. Target Device Control Structure
  187. **********************************************************************/
  188. struct orc_target {
  189. u8 TCS_DrvDASD; /* 6 */
  190. u8 TCS_DrvSCSI; /* 7 */
  191. u8 TCS_DrvHead; /* 8 */
  192. u16 TCS_DrvFlags; /* 4 */
  193. u8 TCS_DrvSector; /* 7 */
  194. };
  195. /* Bit Definition for TCF_DrvFlags */
  196. #define TCS_DF_NODASD_SUPT 0x20 /* Suppress OS/2 DASD Mgr support */
  197. #define TCS_DF_NOSCSI_SUPT 0x40 /* Suppress OS/2 SCSI Mgr support */
  198. /***********************************************************************
  199. Host Adapter Control Structure
  200. ************************************************************************/
  201. struct orc_host {
  202. unsigned long base; /* Base address */
  203. u8 index; /* Index (Channel)*/
  204. u8 scsi_id; /* H/A SCSI ID */
  205. u8 BIOScfg; /*BIOS configuration */
  206. u8 flags;
  207. u8 max_targets; /* SCSI0MAXTags */
  208. struct orc_scb *scb_virt; /* Virtual Pointer to SCB array */
  209. dma_addr_t scb_phys; /* Scb Physical address */
  210. struct orc_extended_scb *escb_virt; /* Virtual pointer to ESCB Scatter list */
  211. dma_addr_t escb_phys; /* scatter list Physical address */
  212. u8 target_flag[16]; /* target configuration, TCF_EN_TAG */
  213. u8 max_tags[16]; /* ORC_MAX_SCBS */
  214. u32 allocation_map[MAX_CHANNELS][8]; /* Max STB is 256, So 256/32 */
  215. spinlock_t allocation_lock;
  216. struct pci_dev *pdev;
  217. };
  218. /* Bit Definition for HCS_Flags */
  219. #define HCF_SCSI_RESET 0x01 /* SCSI BUS RESET */
  220. #define HCF_PARITY 0x02 /* parity card */
  221. #define HCF_LVDS 0x10 /* parity card */
  222. /* Bit Definition for TargetFlag */
  223. #define TCF_EN_255 0x08
  224. #define TCF_EN_TAG 0x10
  225. #define TCF_BUSY 0x20
  226. #define TCF_DISCONNECT 0x40
  227. #define TCF_SPIN_UP 0x80
  228. /* Bit Definition for HCS_AFlags */
  229. #define HCS_AF_IGNORE 0x01 /* Adapter ignore */
  230. #define HCS_AF_DISABLE_RESET 0x10 /* Adapter disable reset */
  231. #define HCS_AF_DISABLE_ADPT 0x80 /* Adapter disable */
  232. struct orc_nvram {
  233. /*----------header ---------------*/
  234. u8 SubVendorID0; /* 00 - Sub Vendor ID */
  235. u8 SubVendorID1; /* 00 - Sub Vendor ID */
  236. u8 SubSysID0; /* 02 - Sub System ID */
  237. u8 SubSysID1; /* 02 - Sub System ID */
  238. u8 SubClass; /* 04 - Sub Class */
  239. u8 VendorID0; /* 05 - Vendor ID */
  240. u8 VendorID1; /* 05 - Vendor ID */
  241. u8 DeviceID0; /* 07 - Device ID */
  242. u8 DeviceID1; /* 07 - Device ID */
  243. u8 Reserved0[2]; /* 09 - Reserved */
  244. u8 revision; /* 0B - revision of data structure */
  245. /* ----Host Adapter Structure ---- */
  246. u8 NumOfCh; /* 0C - Number of SCSI channel */
  247. u8 BIOSConfig1; /* 0D - BIOS configuration 1 */
  248. u8 BIOSConfig2; /* 0E - BIOS boot channel&target ID */
  249. u8 BIOSConfig3; /* 0F - BIOS configuration 3 */
  250. /* ----SCSI channel Structure ---- */
  251. /* from "CTRL-I SCSI Host Adapter SetUp menu " */
  252. u8 scsi_id; /* 10 - Channel 0 SCSI ID */
  253. u8 SCSI0Config; /* 11 - Channel 0 SCSI configuration */
  254. u8 SCSI0MaxTags; /* 12 - Channel 0 Maximum tags */
  255. u8 SCSI0ResetTime; /* 13 - Channel 0 Reset recovering time */
  256. u8 ReservedforChannel0[2]; /* 14 - Reserved */
  257. /* ----SCSI target Structure ---- */
  258. /* from "CTRL-I SCSI device SetUp menu " */
  259. u8 Target00Config; /* 16 - Channel 0 Target 0 config */
  260. u8 Target01Config; /* 17 - Channel 0 Target 1 config */
  261. u8 Target02Config; /* 18 - Channel 0 Target 2 config */
  262. u8 Target03Config; /* 19 - Channel 0 Target 3 config */
  263. u8 Target04Config; /* 1A - Channel 0 Target 4 config */
  264. u8 Target05Config; /* 1B - Channel 0 Target 5 config */
  265. u8 Target06Config; /* 1C - Channel 0 Target 6 config */
  266. u8 Target07Config; /* 1D - Channel 0 Target 7 config */
  267. u8 Target08Config; /* 1E - Channel 0 Target 8 config */
  268. u8 Target09Config; /* 1F - Channel 0 Target 9 config */
  269. u8 Target0AConfig; /* 20 - Channel 0 Target A config */
  270. u8 Target0BConfig; /* 21 - Channel 0 Target B config */
  271. u8 Target0CConfig; /* 22 - Channel 0 Target C config */
  272. u8 Target0DConfig; /* 23 - Channel 0 Target D config */
  273. u8 Target0EConfig; /* 24 - Channel 0 Target E config */
  274. u8 Target0FConfig; /* 25 - Channel 0 Target F config */
  275. u8 SCSI1Id; /* 26 - Channel 1 SCSI ID */
  276. u8 SCSI1Config; /* 27 - Channel 1 SCSI configuration */
  277. u8 SCSI1MaxTags; /* 28 - Channel 1 Maximum tags */
  278. u8 SCSI1ResetTime; /* 29 - Channel 1 Reset recovering time */
  279. u8 ReservedforChannel1[2]; /* 2A - Reserved */
  280. /* ----SCSI target Structure ---- */
  281. /* from "CTRL-I SCSI device SetUp menu " */
  282. u8 Target10Config; /* 2C - Channel 1 Target 0 config */
  283. u8 Target11Config; /* 2D - Channel 1 Target 1 config */
  284. u8 Target12Config; /* 2E - Channel 1 Target 2 config */
  285. u8 Target13Config; /* 2F - Channel 1 Target 3 config */
  286. u8 Target14Config; /* 30 - Channel 1 Target 4 config */
  287. u8 Target15Config; /* 31 - Channel 1 Target 5 config */
  288. u8 Target16Config; /* 32 - Channel 1 Target 6 config */
  289. u8 Target17Config; /* 33 - Channel 1 Target 7 config */
  290. u8 Target18Config; /* 34 - Channel 1 Target 8 config */
  291. u8 Target19Config; /* 35 - Channel 1 Target 9 config */
  292. u8 Target1AConfig; /* 36 - Channel 1 Target A config */
  293. u8 Target1BConfig; /* 37 - Channel 1 Target B config */
  294. u8 Target1CConfig; /* 38 - Channel 1 Target C config */
  295. u8 Target1DConfig; /* 39 - Channel 1 Target D config */
  296. u8 Target1EConfig; /* 3A - Channel 1 Target E config */
  297. u8 Target1FConfig; /* 3B - Channel 1 Target F config */
  298. u8 reserved[3]; /* 3C - Reserved */
  299. /* ---------- CheckSum ---------- */
  300. u8 CheckSum; /* 3F - Checksum of NVRam */
  301. };
  302. /* Bios Configuration for nvram->BIOSConfig1 */
  303. #define NBC_BIOSENABLE 0x01 /* BIOS enable */
  304. #define NBC_CDROM 0x02 /* Support bootable CDROM */
  305. #define NBC_REMOVABLE 0x04 /* Support removable drive */
  306. /* Bios Configuration for nvram->BIOSConfig2 */
  307. #define NBB_TARGET_MASK 0x0F /* Boot SCSI target ID number */
  308. #define NBB_CHANL_MASK 0xF0 /* Boot SCSI channel number */
  309. /* Bit definition for nvram->SCSIConfig */
  310. #define NCC_BUSRESET 0x01 /* Reset SCSI bus at power up */
  311. #define NCC_PARITYCHK 0x02 /* SCSI parity enable */
  312. #define NCC_LVDS 0x10 /* Enable LVDS */
  313. #define NCC_ACTTERM1 0x20 /* Enable active terminator 1 */
  314. #define NCC_ACTTERM2 0x40 /* Enable active terminator 2 */
  315. #define NCC_AUTOTERM 0x80 /* Enable auto termination */
  316. /* Bit definition for nvram->TargetxConfig */
  317. #define NTC_PERIOD 0x07 /* Maximum Sync. Speed */
  318. #define NTC_1GIGA 0x08 /* 255 head / 63 sectors (64/32) */
  319. #define NTC_NO_SYNC 0x10 /* NO SYNC. NEGO */
  320. #define NTC_NO_WIDESYNC 0x20 /* NO WIDE SYNC. NEGO */
  321. #define NTC_DISC_ENABLE 0x40 /* Enable SCSI disconnect */
  322. #define NTC_SPINUP 0x80 /* Start disk drive */
  323. /* Default NVRam values */
  324. #define NBC_DEFAULT (NBC_ENABLE)
  325. #define NCC_DEFAULT (NCC_BUSRESET | NCC_AUTOTERM | NCC_PARITYCHK)
  326. #define NCC_MAX_TAGS 0x20 /* Maximum tags per target */
  327. #define NCC_RESET_TIME 0x0A /* SCSI RESET recovering time */
  328. #define NTC_DEFAULT (NTC_1GIGA | NTC_NO_WIDESYNC | NTC_DISC_ENABLE)