wd33c93.h 11 KB

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