wd33c93.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /*
  2. * wd33c93.h - Linux device driver definitions for the
  3. * Commodore Amiga A2091/590 SCSI controller card
  4. *
  5. * IMPORTANT: This file is for version 1.25 - 09/Jul/1997
  6. *
  7. * Copyright (c) 1996 John Shifflett, GeoLog Consulting
  8. * john@geolog.com
  9. * jshiffle@netcom.com
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. */
  22. #ifndef WD33C93_H
  23. #define WD33C93_H
  24. #define PROC_INTERFACE /* add code for /proc/scsi/wd33c93/xxx interface */
  25. #ifdef PROC_INTERFACE
  26. #define PROC_STATISTICS /* add code for keeping various real time stats */
  27. #endif
  28. #define SYNC_DEBUG /* extra info on sync negotiation printed */
  29. #define DEBUGGING_ON /* enable command-line debugging bitmask */
  30. #define DEBUG_DEFAULTS 0 /* default debugging bitmask */
  31. #ifdef DEBUGGING_ON
  32. #define DB(f,a) if (hostdata->args & (f)) a;
  33. #else
  34. #define DB(f,a)
  35. #endif
  36. #define uchar unsigned char
  37. /* wd register names */
  38. #define WD_OWN_ID 0x00
  39. #define WD_CONTROL 0x01
  40. #define WD_TIMEOUT_PERIOD 0x02
  41. #define WD_CDB_1 0x03
  42. #define WD_CDB_2 0x04
  43. #define WD_CDB_3 0x05
  44. #define WD_CDB_4 0x06
  45. #define WD_CDB_5 0x07
  46. #define WD_CDB_6 0x08
  47. #define WD_CDB_7 0x09
  48. #define WD_CDB_8 0x0a
  49. #define WD_CDB_9 0x0b
  50. #define WD_CDB_10 0x0c
  51. #define WD_CDB_11 0x0d
  52. #define WD_CDB_12 0x0e
  53. #define WD_TARGET_LUN 0x0f
  54. #define WD_COMMAND_PHASE 0x10
  55. #define WD_SYNCHRONOUS_TRANSFER 0x11
  56. #define WD_TRANSFER_COUNT_MSB 0x12
  57. #define WD_TRANSFER_COUNT 0x13
  58. #define WD_TRANSFER_COUNT_LSB 0x14
  59. #define WD_DESTINATION_ID 0x15
  60. #define WD_SOURCE_ID 0x16
  61. #define WD_SCSI_STATUS 0x17
  62. #define WD_COMMAND 0x18
  63. #define WD_DATA 0x19
  64. #define WD_QUEUE_TAG 0x1a
  65. #define WD_AUXILIARY_STATUS 0x1f
  66. /* WD commands */
  67. #define WD_CMD_RESET 0x00
  68. #define WD_CMD_ABORT 0x01
  69. #define WD_CMD_ASSERT_ATN 0x02
  70. #define WD_CMD_NEGATE_ACK 0x03
  71. #define WD_CMD_DISCONNECT 0x04
  72. #define WD_CMD_RESELECT 0x05
  73. #define WD_CMD_SEL_ATN 0x06
  74. #define WD_CMD_SEL 0x07
  75. #define WD_CMD_SEL_ATN_XFER 0x08
  76. #define WD_CMD_SEL_XFER 0x09
  77. #define WD_CMD_RESEL_RECEIVE 0x0a
  78. #define WD_CMD_RESEL_SEND 0x0b
  79. #define WD_CMD_WAIT_SEL_RECEIVE 0x0c
  80. #define WD_CMD_TRANS_ADDR 0x18
  81. #define WD_CMD_TRANS_INFO 0x20
  82. #define WD_CMD_TRANSFER_PAD 0x21
  83. #define WD_CMD_SBT_MODE 0x80
  84. /* ASR register */
  85. #define ASR_INT (0x80)
  86. #define ASR_LCI (0x40)
  87. #define ASR_BSY (0x20)
  88. #define ASR_CIP (0x10)
  89. #define ASR_PE (0x02)
  90. #define ASR_DBR (0x01)
  91. /* SCSI Bus Phases */
  92. #define PHS_DATA_OUT 0x00
  93. #define PHS_DATA_IN 0x01
  94. #define PHS_COMMAND 0x02
  95. #define PHS_STATUS 0x03
  96. #define PHS_MESS_OUT 0x06
  97. #define PHS_MESS_IN 0x07
  98. /* Command Status Register definitions */
  99. /* reset state interrupts */
  100. #define CSR_RESET 0x00
  101. #define CSR_RESET_AF 0x01
  102. /* successful completion interrupts */
  103. #define CSR_RESELECT 0x10
  104. #define CSR_SELECT 0x11
  105. #define CSR_SEL_XFER_DONE 0x16
  106. #define CSR_XFER_DONE 0x18
  107. /* paused or aborted interrupts */
  108. #define CSR_MSGIN 0x20
  109. #define CSR_SDP 0x21
  110. #define CSR_SEL_ABORT 0x22
  111. #define CSR_RESEL_ABORT 0x25
  112. #define CSR_RESEL_ABORT_AM 0x27
  113. #define CSR_ABORT 0x28
  114. /* terminated interrupts */
  115. #define CSR_INVALID 0x40
  116. #define CSR_UNEXP_DISC 0x41
  117. #define CSR_TIMEOUT 0x42
  118. #define CSR_PARITY 0x43
  119. #define CSR_PARITY_ATN 0x44
  120. #define CSR_BAD_STATUS 0x45
  121. #define CSR_UNEXP 0x48
  122. /* service required interrupts */
  123. #define CSR_RESEL 0x80
  124. #define CSR_RESEL_AM 0x81
  125. #define CSR_DISC 0x85
  126. #define CSR_SRV_REQ 0x88
  127. /* Own ID/CDB Size register */
  128. #define OWNID_EAF 0x08
  129. #define OWNID_EHP 0x10
  130. #define OWNID_RAF 0x20
  131. #define OWNID_FS_8 0x00
  132. #define OWNID_FS_12 0x40
  133. #define OWNID_FS_16 0x80
  134. /* define these so we don't have to change a2091.c, etc. */
  135. #define WD33C93_FS_8_10 OWNID_FS_8
  136. #define WD33C93_FS_12_15 OWNID_FS_12
  137. #define WD33C93_FS_16_20 OWNID_FS_16
  138. /* pass input-clock explicitly. accepted mhz values are 8-10,12-20 */
  139. #define WD33C93_FS_MHZ(mhz) (mhz)
  140. /* Control register */
  141. #define CTRL_HSP 0x01
  142. #define CTRL_HA 0x02
  143. #define CTRL_IDI 0x04
  144. #define CTRL_EDI 0x08
  145. #define CTRL_HHP 0x10
  146. #define CTRL_POLLED 0x00
  147. #define CTRL_BURST 0x20
  148. #define CTRL_BUS 0x40
  149. #define CTRL_DMA 0x80
  150. /* Timeout Period register */
  151. #define TIMEOUT_PERIOD_VALUE 20 /* 20 = 200 ms */
  152. /* Synchronous Transfer Register */
  153. #define STR_FSS 0x80
  154. /* Destination ID register */
  155. #define DSTID_DPD 0x40
  156. #define DATA_OUT_DIR 0
  157. #define DATA_IN_DIR 1
  158. #define DSTID_SCC 0x80
  159. /* Source ID register */
  160. #define SRCID_MASK 0x07
  161. #define SRCID_SIV 0x08
  162. #define SRCID_DSP 0x20
  163. #define SRCID_ES 0x40
  164. #define SRCID_ER 0x80
  165. /* This is what the 3393 chip looks like to us */
  166. typedef struct {
  167. #ifdef CONFIG_WD33C93_PIO
  168. unsigned int SASR;
  169. unsigned int SCMD;
  170. #else
  171. volatile unsigned char *SASR;
  172. volatile unsigned char *SCMD;
  173. #endif
  174. } wd33c93_regs;
  175. typedef int (*dma_setup_t) (struct scsi_cmnd *SCpnt, int dir_in);
  176. typedef void (*dma_stop_t) (struct Scsi_Host *instance,
  177. struct scsi_cmnd *SCpnt, int status);
  178. #define ILLEGAL_STATUS_BYTE 0xff
  179. #define DEFAULT_SX_PER 376 /* (ns) fairly safe */
  180. #define DEFAULT_SX_OFF 0 /* aka async */
  181. #define OPTIMUM_SX_PER 252 /* (ns) best we can do (mult-of-4) */
  182. #define OPTIMUM_SX_OFF 12 /* size of wd3393 fifo */
  183. struct sx_period {
  184. unsigned int period_ns;
  185. uchar reg_value;
  186. };
  187. /* FEF: defines for hostdata->dma_buffer_pool */
  188. #define BUF_CHIP_ALLOCED 0
  189. #define BUF_SCSI_ALLOCED 1
  190. struct WD33C93_hostdata {
  191. struct Scsi_Host *next;
  192. wd33c93_regs regs;
  193. spinlock_t lock;
  194. uchar clock_freq;
  195. uchar chip; /* what kind of wd33c93? */
  196. uchar microcode; /* microcode rev */
  197. uchar dma_buffer_pool; /* FEF: buffer from chip_ram? */
  198. int dma_dir; /* data transfer dir. */
  199. dma_setup_t dma_setup;
  200. dma_stop_t dma_stop;
  201. unsigned int dma_xfer_mask;
  202. uchar *dma_bounce_buffer;
  203. unsigned int dma_bounce_len;
  204. volatile uchar busy[8]; /* index = target, bit = lun */
  205. volatile struct scsi_cmnd *input_Q; /* commands waiting to be started */
  206. volatile struct scsi_cmnd *selecting; /* trying to select this command */
  207. volatile struct scsi_cmnd *connected; /* currently connected command */
  208. volatile struct scsi_cmnd *disconnected_Q;/* commands waiting for reconnect */
  209. uchar state; /* what we are currently doing */
  210. uchar dma; /* current state of DMA (on/off) */
  211. uchar level2; /* extent to which Level-2 commands are used */
  212. uchar disconnect; /* disconnect/reselect policy */
  213. unsigned int args; /* set from command-line argument */
  214. uchar incoming_msg[8]; /* filled during message_in phase */
  215. int incoming_ptr; /* mainly used with EXTENDED messages */
  216. uchar outgoing_msg[8]; /* send this during next message_out */
  217. int outgoing_len; /* length of outgoing message */
  218. unsigned int default_sx_per; /* default transfer period for SCSI bus */
  219. uchar sync_xfer[8]; /* sync_xfer reg settings per target */
  220. uchar sync_stat[8]; /* status of sync negotiation per target */
  221. uchar no_sync; /* bitmask: don't do sync on these targets */
  222. uchar no_dma; /* set this flag to disable DMA */
  223. uchar dma_mode; /* DMA Burst Mode or Single Byte DMA */
  224. uchar fast; /* set this flag to enable Fast SCSI */
  225. struct sx_period sx_table[9]; /* transfer periods for actual DTC-setting */
  226. #ifdef PROC_INTERFACE
  227. uchar proc; /* bitmask: what's in proc output */
  228. #ifdef PROC_STATISTICS
  229. unsigned long cmd_cnt[8]; /* # of commands issued per target */
  230. unsigned long int_cnt; /* # of interrupts serviced */
  231. unsigned long pio_cnt; /* # of pio data transfers */
  232. unsigned long dma_cnt; /* # of DMA data transfers */
  233. unsigned long disc_allowed_cnt[8]; /* # of disconnects allowed per target */
  234. unsigned long disc_done_cnt[8]; /* # of disconnects done per target*/
  235. #endif
  236. #endif
  237. };
  238. /* defines for hostdata->chip */
  239. #define C_WD33C93 0
  240. #define C_WD33C93A 1
  241. #define C_WD33C93B 2
  242. #define C_UNKNOWN_CHIP 100
  243. /* defines for hostdata->state */
  244. #define S_UNCONNECTED 0
  245. #define S_SELECTING 1
  246. #define S_RUNNING_LEVEL2 2
  247. #define S_CONNECTED 3
  248. #define S_PRE_TMP_DISC 4
  249. #define S_PRE_CMP_DISC 5
  250. /* defines for hostdata->dma */
  251. #define D_DMA_OFF 0
  252. #define D_DMA_RUNNING 1
  253. /* defines for hostdata->level2 */
  254. /* NOTE: only the first 3 are implemented so far */
  255. #define L2_NONE 1 /* no combination commands - we get lots of ints */
  256. #define L2_SELECT 2 /* start with SEL_ATN_XFER, but never resume it */
  257. #define L2_BASIC 3 /* resume after STATUS ints & RDP messages */
  258. #define L2_DATA 4 /* resume after DATA_IN/OUT ints */
  259. #define L2_MOST 5 /* resume after anything except a RESELECT int */
  260. #define L2_RESELECT 6 /* resume after everything, including RESELECT ints */
  261. #define L2_ALL 7 /* always resume */
  262. /* defines for hostdata->disconnect */
  263. #define DIS_NEVER 0
  264. #define DIS_ADAPTIVE 1
  265. #define DIS_ALWAYS 2
  266. /* defines for hostdata->args */
  267. #define DB_TEST1 1<<0
  268. #define DB_TEST2 1<<1
  269. #define DB_QUEUE_COMMAND 1<<2
  270. #define DB_EXECUTE 1<<3
  271. #define DB_INTR 1<<4
  272. #define DB_TRANSFER 1<<5
  273. #define DB_MASK 0x3f
  274. /* defines for hostdata->sync_stat[] */
  275. #define SS_UNSET 0
  276. #define SS_FIRST 1
  277. #define SS_WAITING 2
  278. #define SS_SET 3
  279. /* defines for hostdata->proc */
  280. #define PR_VERSION 1<<0
  281. #define PR_INFO 1<<1
  282. #define PR_STATISTICS 1<<2
  283. #define PR_CONNECTED 1<<3
  284. #define PR_INPUTQ 1<<4
  285. #define PR_DISCQ 1<<5
  286. #define PR_TEST 1<<6
  287. #define PR_STOP 1<<7
  288. void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs,
  289. dma_setup_t setup, dma_stop_t stop, int clock_freq);
  290. int wd33c93_abort (struct scsi_cmnd *cmd);
  291. int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd);
  292. void wd33c93_intr (struct Scsi_Host *instance);
  293. int wd33c93_show_info(struct seq_file *, struct Scsi_Host *);
  294. int wd33c93_write_info(struct Scsi_Host *, char *, int);
  295. int wd33c93_host_reset (struct scsi_cmnd *);
  296. #endif /* WD33C93_H */