acornscsi.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*
  2. * linux/drivers/acorn/scsi/acornscsi.h
  3. *
  4. * Copyright (C) 1997 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Acorn SCSI driver
  11. */
  12. #ifndef ACORNSCSI_H
  13. #define ACORNSCSI_H
  14. /* SBIC registers */
  15. #define SBIC_OWNID 0
  16. #define OWNID_FS1 (1<<7)
  17. #define OWNID_FS2 (1<<6)
  18. #define OWNID_EHP (1<<4)
  19. #define OWNID_EAF (1<<3)
  20. #define SBIC_CTRL 1
  21. #define CTRL_DMAMODE (1<<7)
  22. #define CTRL_DMADBAMODE (1<<6)
  23. #define CTRL_DMABURST (1<<5)
  24. #define CTRL_DMAPOLLED 0
  25. #define CTRL_HHP (1<<4)
  26. #define CTRL_EDI (1<<3)
  27. #define CTRL_IDI (1<<2)
  28. #define CTRL_HA (1<<1)
  29. #define CTRL_HSP (1<<0)
  30. #define SBIC_TIMEOUT 2
  31. #define SBIC_TOTSECTS 3
  32. #define SBIC_TOTHEADS 4
  33. #define SBIC_TOTCYLH 5
  34. #define SBIC_TOTCYLL 6
  35. #define SBIC_LOGADDRH 7
  36. #define SBIC_LOGADDRM2 8
  37. #define SBIC_LOGADDRM1 9
  38. #define SBIC_LOGADDRL 10
  39. #define SBIC_SECTORNUM 11
  40. #define SBIC_HEADNUM 12
  41. #define SBIC_CYLH 13
  42. #define SBIC_CYLL 14
  43. #define SBIC_TARGETLUN 15
  44. #define TARGETLUN_TLV (1<<7)
  45. #define TARGETLUN_DOK (1<<6)
  46. #define SBIC_CMNDPHASE 16
  47. #define SBIC_SYNCHTRANSFER 17
  48. #define SYNCHTRANSFER_OF0 0x00
  49. #define SYNCHTRANSFER_OF1 0x01
  50. #define SYNCHTRANSFER_OF2 0x02
  51. #define SYNCHTRANSFER_OF3 0x03
  52. #define SYNCHTRANSFER_OF4 0x04
  53. #define SYNCHTRANSFER_OF5 0x05
  54. #define SYNCHTRANSFER_OF6 0x06
  55. #define SYNCHTRANSFER_OF7 0x07
  56. #define SYNCHTRANSFER_OF8 0x08
  57. #define SYNCHTRANSFER_OF9 0x09
  58. #define SYNCHTRANSFER_OF10 0x0A
  59. #define SYNCHTRANSFER_OF11 0x0B
  60. #define SYNCHTRANSFER_OF12 0x0C
  61. #define SYNCHTRANSFER_8DBA 0x00
  62. #define SYNCHTRANSFER_2DBA 0x20
  63. #define SYNCHTRANSFER_3DBA 0x30
  64. #define SYNCHTRANSFER_4DBA 0x40
  65. #define SYNCHTRANSFER_5DBA 0x50
  66. #define SYNCHTRANSFER_6DBA 0x60
  67. #define SYNCHTRANSFER_7DBA 0x70
  68. #define SBIC_TRANSCNTH 18
  69. #define SBIC_TRANSCNTM 19
  70. #define SBIC_TRANSCNTL 20
  71. #define SBIC_DESTID 21
  72. #define DESTID_SCC (1<<7)
  73. #define DESTID_DPD (1<<6)
  74. #define SBIC_SOURCEID 22
  75. #define SOURCEID_ER (1<<7)
  76. #define SOURCEID_ES (1<<6)
  77. #define SOURCEID_DSP (1<<5)
  78. #define SOURCEID_SIV (1<<4)
  79. #define SBIC_SSR 23
  80. #define SBIC_CMND 24
  81. #define CMND_RESET 0x00
  82. #define CMND_ABORT 0x01
  83. #define CMND_ASSERTATN 0x02
  84. #define CMND_NEGATEACK 0x03
  85. #define CMND_DISCONNECT 0x04
  86. #define CMND_RESELECT 0x05
  87. #define CMND_SELWITHATN 0x06
  88. #define CMND_SELECT 0x07
  89. #define CMND_SELECTATNTRANSFER 0x08
  90. #define CMND_SELECTTRANSFER 0x09
  91. #define CMND_RESELECTRXDATA 0x0A
  92. #define CMND_RESELECTTXDATA 0x0B
  93. #define CMND_WAITFORSELRECV 0x0C
  94. #define CMND_SENDSTATCMD 0x0D
  95. #define CMND_SENDDISCONNECT 0x0E
  96. #define CMND_SETIDI 0x0F
  97. #define CMND_RECEIVECMD 0x10
  98. #define CMND_RECEIVEDTA 0x11
  99. #define CMND_RECEIVEMSG 0x12
  100. #define CMND_RECEIVEUSP 0x13
  101. #define CMND_SENDCMD 0x14
  102. #define CMND_SENDDATA 0x15
  103. #define CMND_SENDMSG 0x16
  104. #define CMND_SENDUSP 0x17
  105. #define CMND_TRANSLATEADDR 0x18
  106. #define CMND_XFERINFO 0x20
  107. #define CMND_SBT (1<<7)
  108. #define SBIC_DATA 25
  109. #define SBIC_ASR 26
  110. #define ASR_INT (1<<7)
  111. #define ASR_LCI (1<<6)
  112. #define ASR_BSY (1<<5)
  113. #define ASR_CIP (1<<4)
  114. #define ASR_PE (1<<1)
  115. #define ASR_DBR (1<<0)
  116. /* DMAC registers */
  117. #define DMAC_INIT 0x00
  118. #define INIT_8BIT (1)
  119. #define DMAC_CHANNEL 0x80
  120. #define CHANNEL_0 0x00
  121. #define CHANNEL_1 0x01
  122. #define CHANNEL_2 0x02
  123. #define CHANNEL_3 0x03
  124. #define DMAC_TXCNTLO 0x01
  125. #define DMAC_TXCNTHI 0x81
  126. #define DMAC_TXADRLO 0x02
  127. #define DMAC_TXADRMD 0x82
  128. #define DMAC_TXADRHI 0x03
  129. #define DMAC_DEVCON0 0x04
  130. #define DEVCON0_AKL (1<<7)
  131. #define DEVCON0_RQL (1<<6)
  132. #define DEVCON0_EXW (1<<5)
  133. #define DEVCON0_ROT (1<<4)
  134. #define DEVCON0_CMP (1<<3)
  135. #define DEVCON0_DDMA (1<<2)
  136. #define DEVCON0_AHLD (1<<1)
  137. #define DEVCON0_MTM (1<<0)
  138. #define DMAC_DEVCON1 0x84
  139. #define DEVCON1_WEV (1<<1)
  140. #define DEVCON1_BHLD (1<<0)
  141. #define DMAC_MODECON 0x05
  142. #define MODECON_WOED 0x01
  143. #define MODECON_VERIFY 0x00
  144. #define MODECON_READ 0x04
  145. #define MODECON_WRITE 0x08
  146. #define MODECON_AUTOINIT 0x10
  147. #define MODECON_ADDRDIR 0x20
  148. #define MODECON_DEMAND 0x00
  149. #define MODECON_SINGLE 0x40
  150. #define MODECON_BLOCK 0x80
  151. #define MODECON_CASCADE 0xC0
  152. #define DMAC_STATUS 0x85
  153. #define STATUS_TC0 (1<<0)
  154. #define STATUS_RQ0 (1<<4)
  155. #define DMAC_TEMPLO 0x06
  156. #define DMAC_TEMPHI 0x86
  157. #define DMAC_REQREG 0x07
  158. #define DMAC_MASKREG 0x87
  159. #define MASKREG_M0 0x01
  160. #define MASKREG_M1 0x02
  161. #define MASKREG_M2 0x04
  162. #define MASKREG_M3 0x08
  163. /* miscellaneous internal variables */
  164. #define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0)
  165. #define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1)
  166. /*
  167. * SCSI driver phases
  168. */
  169. typedef enum {
  170. PHASE_IDLE, /* we're not planning on doing anything */
  171. PHASE_CONNECTING, /* connecting to a target */
  172. PHASE_CONNECTED, /* connected to a target */
  173. PHASE_MSGOUT, /* message out to device */
  174. PHASE_RECONNECTED, /* reconnected */
  175. PHASE_COMMANDPAUSED, /* command partly sent */
  176. PHASE_COMMAND, /* command all sent */
  177. PHASE_DATAOUT, /* data out to device */
  178. PHASE_DATAIN, /* data in from device */
  179. PHASE_STATUSIN, /* status in from device */
  180. PHASE_MSGIN, /* message in from device */
  181. PHASE_DONE, /* finished */
  182. PHASE_ABORTED, /* aborted */
  183. PHASE_DISCONNECT, /* disconnecting */
  184. } phase_t;
  185. /*
  186. * After interrupt, what to do now
  187. */
  188. typedef enum {
  189. INTR_IDLE, /* not expecting another IRQ */
  190. INTR_NEXT_COMMAND, /* start next command */
  191. INTR_PROCESSING, /* interrupt routine still processing */
  192. } intr_ret_t;
  193. /*
  194. * DMA direction
  195. */
  196. typedef enum {
  197. DMA_OUT, /* DMA from memory to chip */
  198. DMA_IN /* DMA from chip to memory */
  199. } dmadir_t;
  200. /*
  201. * Synchronous transfer state
  202. */
  203. typedef enum { /* Synchronous transfer state */
  204. SYNC_ASYNCHRONOUS, /* don't negotiate synchronous transfers*/
  205. SYNC_NEGOCIATE, /* start negotiation */
  206. SYNC_SENT_REQUEST, /* sent SDTR message */
  207. SYNC_COMPLETED, /* received SDTR reply */
  208. } syncxfer_t;
  209. /*
  210. * Command type
  211. */
  212. typedef enum { /* command type */
  213. CMD_READ, /* READ_6, READ_10, READ_12 */
  214. CMD_WRITE, /* WRITE_6, WRITE_10, WRITE_12 */
  215. CMD_MISC, /* Others */
  216. } cmdtype_t;
  217. /*
  218. * Data phase direction
  219. */
  220. typedef enum { /* Data direction */
  221. DATADIR_IN, /* Data in phase expected */
  222. DATADIR_OUT /* Data out phase expected */
  223. } datadir_t;
  224. #include "queue.h"
  225. #include "msgqueue.h"
  226. #define STATUS_BUFFER_SIZE 32
  227. /*
  228. * This is used to dump the previous states of the SBIC
  229. */
  230. struct status_entry {
  231. unsigned long when;
  232. unsigned char ssr;
  233. unsigned char ph;
  234. unsigned char irq;
  235. unsigned char unused;
  236. };
  237. #define ADD_STATUS(_q,_ssr,_ph,_irq) \
  238. ({ \
  239. host->status[(_q)][host->status_ptr[(_q)]].when = jiffies; \
  240. host->status[(_q)][host->status_ptr[(_q)]].ssr = (_ssr); \
  241. host->status[(_q)][host->status_ptr[(_q)]].ph = (_ph); \
  242. host->status[(_q)][host->status_ptr[(_q)]].irq = (_irq); \
  243. host->status_ptr[(_q)] = (host->status_ptr[(_q)] + 1) & (STATUS_BUFFER_SIZE - 1); \
  244. })
  245. /*
  246. * AcornSCSI host specific data
  247. */
  248. typedef struct acornscsi_hostdata {
  249. /* miscellaneous */
  250. struct Scsi_Host *host; /* host */
  251. struct scsi_cmnd *SCpnt; /* currently processing command */
  252. struct scsi_cmnd *origSCpnt; /* original connecting command */
  253. void __iomem *base; /* memc base address */
  254. void __iomem *fast; /* fast ioc base address */
  255. /* driver information */
  256. struct {
  257. unsigned int irq; /* interrupt */
  258. phase_t phase; /* current phase */
  259. struct {
  260. unsigned char target; /* reconnected target */
  261. unsigned char lun; /* reconnected lun */
  262. unsigned char tag; /* reconnected tag */
  263. } reconnected;
  264. struct scsi_pointer SCp; /* current commands data pointer */
  265. MsgQueue_t msgs;
  266. unsigned short last_message; /* last message to be sent */
  267. unsigned char disconnectable:1; /* this command can be disconnected */
  268. } scsi;
  269. /* statistics information */
  270. struct {
  271. unsigned int queues;
  272. unsigned int removes;
  273. unsigned int fins;
  274. unsigned int reads;
  275. unsigned int writes;
  276. unsigned int miscs;
  277. unsigned int disconnects;
  278. unsigned int aborts;
  279. unsigned int resets;
  280. } stats;
  281. /* queue handling */
  282. struct {
  283. Queue_t issue; /* issue queue */
  284. Queue_t disconnected; /* disconnected command queue */
  285. } queues;
  286. /* per-device info */
  287. struct {
  288. unsigned char sync_xfer; /* synchronous transfer (SBIC value) */
  289. syncxfer_t sync_state; /* sync xfer negotiation state */
  290. unsigned char disconnect_ok:1; /* device can disconnect */
  291. } device[8];
  292. unsigned long busyluns[64 / sizeof(unsigned long)];/* array of bits indicating LUNs busy */
  293. /* DMA info */
  294. struct {
  295. unsigned int free_addr; /* next free address */
  296. unsigned int start_addr; /* start address of current transfer */
  297. dmadir_t direction; /* dma direction */
  298. unsigned int transferred; /* number of bytes transferred */
  299. unsigned int xfer_start; /* scheduled DMA transfer start */
  300. unsigned int xfer_length; /* scheduled DMA transfer length */
  301. char *xfer_ptr; /* pointer to area */
  302. unsigned char xfer_required:1; /* set if we need to transfer something */
  303. unsigned char xfer_setup:1; /* set if DMA is setup */
  304. unsigned char xfer_done:1; /* set if DMA reached end of BH list */
  305. } dma;
  306. /* card info */
  307. struct {
  308. unsigned char page_reg; /* current setting of page reg */
  309. } card;
  310. unsigned char status_ptr[9];
  311. struct status_entry status[9][STATUS_BUFFER_SIZE];
  312. } AS_Host;
  313. #endif /* ACORNSCSI_H */