aha152x.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. #ifndef _AHA152X_H
  2. #define _AHA152X_H
  3. /*
  4. * $Id: aha152x.h,v 2.7 2004/01/24 11:39:03 fischer Exp $
  5. */
  6. /* number of queueable commands
  7. (unless we support more than 1 cmd_per_lun this should do) */
  8. #define AHA152X_MAXQUEUE 7
  9. #define AHA152X_REVID "Adaptec 152x SCSI driver; $Revision: 2.7 $"
  10. /* port addresses */
  11. #define SCSISEQ (HOSTIOPORT0+0x00) /* SCSI sequence control */
  12. #define SXFRCTL0 (HOSTIOPORT0+0x01) /* SCSI transfer control 0 */
  13. #define SXFRCTL1 (HOSTIOPORT0+0x02) /* SCSI transfer control 1 */
  14. #define SCSISIG (HOSTIOPORT0+0x03) /* SCSI signal in/out */
  15. #define SCSIRATE (HOSTIOPORT0+0x04) /* SCSI rate control */
  16. #define SELID (HOSTIOPORT0+0x05) /* selection/reselection ID */
  17. #define SCSIID SELID /* SCSI ID */
  18. #define SCSIDAT (HOSTIOPORT0+0x06) /* SCSI latched data */
  19. #define SCSIBUS (HOSTIOPORT0+0x07) /* SCSI data bus */
  20. #define STCNT0 (HOSTIOPORT0+0x08) /* SCSI transfer count 0 */
  21. #define STCNT1 (HOSTIOPORT0+0x09) /* SCSI transfer count 1 */
  22. #define STCNT2 (HOSTIOPORT0+0x0a) /* SCSI transfer count 2 */
  23. #define SSTAT0 (HOSTIOPORT0+0x0b) /* SCSI interrupt status 0 */
  24. #define SSTAT1 (HOSTIOPORT0+0x0c) /* SCSI interrupt status 1 */
  25. #define SSTAT2 (HOSTIOPORT0+0x0d) /* SCSI interrupt status 2 */
  26. #define SCSITEST (HOSTIOPORT0+0x0e) /* SCSI test control */
  27. #define SSTAT3 SCSITEST /* SCSI interrupt status 3 */
  28. #define SSTAT4 (HOSTIOPORT0+0x0f) /* SCSI status 4 */
  29. #define SIMODE0 (HOSTIOPORT1+0x10) /* SCSI interrupt mode 0 */
  30. #define SIMODE1 (HOSTIOPORT1+0x11) /* SCSI interrupt mode 1 */
  31. #define DMACNTRL0 (HOSTIOPORT1+0x12) /* DMA control 0 */
  32. #define DMACNTRL1 (HOSTIOPORT1+0x13) /* DMA control 1 */
  33. #define DMASTAT (HOSTIOPORT1+0x14) /* DMA status */
  34. #define FIFOSTAT (HOSTIOPORT1+0x15) /* FIFO status */
  35. #define DATAPORT (HOSTIOPORT1+0x16) /* DATA port */
  36. #define BRSTCNTRL (HOSTIOPORT1+0x18) /* burst control */
  37. #define PORTA (HOSTIOPORT1+0x1a) /* PORT A */
  38. #define PORTB (HOSTIOPORT1+0x1b) /* PORT B */
  39. #define REV (HOSTIOPORT1+0x1c) /* revision */
  40. #define STACK (HOSTIOPORT1+0x1d) /* stack */
  41. #define TEST (HOSTIOPORT1+0x1e) /* test register */
  42. #define IO_RANGE 0x20
  43. /* used in aha152x_porttest */
  44. #define O_PORTA 0x1a /* PORT A */
  45. #define O_PORTB 0x1b /* PORT B */
  46. #define O_DMACNTRL1 0x13 /* DMA control 1 */
  47. #define O_STACK 0x1d /* stack */
  48. /* used in tc1550_porttest */
  49. #define O_TC_PORTA 0x0a /* PORT A */
  50. #define O_TC_PORTB 0x0b /* PORT B */
  51. #define O_TC_DMACNTRL1 0x03 /* DMA control 1 */
  52. #define O_TC_STACK 0x0d /* stack */
  53. /* bits and bitmasks to ports */
  54. /* SCSI sequence control */
  55. #define TEMODEO 0x80
  56. #define ENSELO 0x40
  57. #define ENSELI 0x20
  58. #define ENRESELI 0x10
  59. #define ENAUTOATNO 0x08
  60. #define ENAUTOATNI 0x04
  61. #define ENAUTOATNP 0x02
  62. #define SCSIRSTO 0x01
  63. /* SCSI transfer control 0 */
  64. #define SCSIEN 0x80
  65. #define DMAEN 0x40
  66. #define CH1 0x20
  67. #define CLRSTCNT 0x10
  68. #define SPIOEN 0x08
  69. #define CLRCH1 0x02
  70. /* SCSI transfer control 1 */
  71. #define BITBUCKET 0x80
  72. #define SWRAPEN 0x40
  73. #define ENSPCHK 0x20
  74. #define STIMESEL 0x18 /* mask */
  75. #define STIMESEL_ 3
  76. #define ENSTIMER 0x04
  77. #define BYTEALIGN 0x02
  78. /* SCSI signal IN */
  79. #define SIG_CDI 0x80
  80. #define SIG_IOI 0x40
  81. #define SIG_MSGI 0x20
  82. #define SIG_ATNI 0x10
  83. #define SIG_SELI 0x08
  84. #define SIG_BSYI 0x04
  85. #define SIG_REQI 0x02
  86. #define SIG_ACKI 0x01
  87. /* SCSI Phases */
  88. #define P_MASK (SIG_MSGI|SIG_CDI|SIG_IOI)
  89. #define P_DATAO (0)
  90. #define P_DATAI (SIG_IOI)
  91. #define P_CMD (SIG_CDI)
  92. #define P_STATUS (SIG_CDI|SIG_IOI)
  93. #define P_MSGO (SIG_MSGI|SIG_CDI)
  94. #define P_MSGI (SIG_MSGI|SIG_CDI|SIG_IOI)
  95. /* SCSI signal OUT */
  96. #define SIG_CDO 0x80
  97. #define SIG_IOO 0x40
  98. #define SIG_MSGO 0x20
  99. #define SIG_ATNO 0x10
  100. #define SIG_SELO 0x08
  101. #define SIG_BSYO 0x04
  102. #define SIG_REQO 0x02
  103. #define SIG_ACKO 0x01
  104. /* SCSI rate control */
  105. #define SXFR 0x70 /* mask */
  106. #define SXFR_ 4
  107. #define SOFS 0x0f /* mask */
  108. /* SCSI ID */
  109. #define OID 0x70
  110. #define OID_ 4
  111. #define TID 0x07
  112. /* SCSI transfer count */
  113. #define GETSTCNT() ( (GETPORT(STCNT2)<<16) \
  114. + (GETPORT(STCNT1)<< 8) \
  115. + GETPORT(STCNT0) )
  116. #define SETSTCNT(X) { SETPORT(STCNT2, ((X) & 0xFF0000) >> 16); \
  117. SETPORT(STCNT1, ((X) & 0x00FF00) >> 8); \
  118. SETPORT(STCNT0, ((X) & 0x0000FF) ); }
  119. /* SCSI interrupt status */
  120. #define TARGET 0x80
  121. #define SELDO 0x40
  122. #define SELDI 0x20
  123. #define SELINGO 0x10
  124. #define SWRAP 0x08
  125. #define SDONE 0x04
  126. #define SPIORDY 0x02
  127. #define DMADONE 0x01
  128. #define SETSDONE 0x80
  129. #define CLRSELDO 0x40
  130. #define CLRSELDI 0x20
  131. #define CLRSELINGO 0x10
  132. #define CLRSWRAP 0x08
  133. #define CLRSDONE 0x04
  134. #define CLRSPIORDY 0x02
  135. #define CLRDMADONE 0x01
  136. /* SCSI status 1 */
  137. #define SELTO 0x80
  138. #define ATNTARG 0x40
  139. #define SCSIRSTI 0x20
  140. #define PHASEMIS 0x10
  141. #define BUSFREE 0x08
  142. #define SCSIPERR 0x04
  143. #define PHASECHG 0x02
  144. #define REQINIT 0x01
  145. #define CLRSELTIMO 0x80
  146. #define CLRATNO 0x40
  147. #define CLRSCSIRSTI 0x20
  148. #define CLRBUSFREE 0x08
  149. #define CLRSCSIPERR 0x04
  150. #define CLRPHASECHG 0x02
  151. #define CLRREQINIT 0x01
  152. /* SCSI status 2 */
  153. #define SOFFSET 0x20
  154. #define SEMPTY 0x10
  155. #define SFULL 0x08
  156. #define SFCNT 0x07 /* mask */
  157. /* SCSI status 3 */
  158. #define SCSICNT 0xf0 /* mask */
  159. #define SCSICNT_ 4
  160. #define OFFCNT 0x0f /* mask */
  161. /* SCSI TEST control */
  162. #define SCTESTU 0x08
  163. #define SCTESTD 0x04
  164. #define STCTEST 0x01
  165. /* SCSI status 4 */
  166. #define SYNCERR 0x04
  167. #define FWERR 0x02
  168. #define FRERR 0x01
  169. #define CLRSYNCERR 0x04
  170. #define CLRFWERR 0x02
  171. #define CLRFRERR 0x01
  172. /* SCSI interrupt mode 0 */
  173. #define ENSELDO 0x40
  174. #define ENSELDI 0x20
  175. #define ENSELINGO 0x10
  176. #define ENSWRAP 0x08
  177. #define ENSDONE 0x04
  178. #define ENSPIORDY 0x02
  179. #define ENDMADONE 0x01
  180. /* SCSI interrupt mode 1 */
  181. #define ENSELTIMO 0x80
  182. #define ENATNTARG 0x40
  183. #define ENSCSIRST 0x20
  184. #define ENPHASEMIS 0x10
  185. #define ENBUSFREE 0x08
  186. #define ENSCSIPERR 0x04
  187. #define ENPHASECHG 0x02
  188. #define ENREQINIT 0x01
  189. /* DMA control 0 */
  190. #define ENDMA 0x80
  191. #define _8BIT 0x40
  192. #define DMA 0x20
  193. #define WRITE_READ 0x08
  194. #define INTEN 0x04
  195. #define RSTFIFO 0x02
  196. #define SWINT 0x01
  197. /* DMA control 1 */
  198. #define PWRDWN 0x80
  199. #define STK 0x07 /* mask */
  200. /* DMA status */
  201. #define ATDONE 0x80
  202. #define WORDRDY 0x40
  203. #define INTSTAT 0x20
  204. #define DFIFOFULL 0x10
  205. #define DFIFOEMP 0x08
  206. /* BURST control */
  207. #define BON 0xf0
  208. #define BOFF 0x0f
  209. /* TEST REGISTER */
  210. #define BOFFTMR 0x40
  211. #define BONTMR 0x20
  212. #define STCNTH 0x10
  213. #define STCNTM 0x08
  214. #define STCNTL 0x04
  215. #define SCSIBLK 0x02
  216. #define DMABLK 0x01
  217. /* On the AHA-152x board PORTA and PORTB contain
  218. some information about the board's configuration. */
  219. typedef union {
  220. struct {
  221. unsigned reserved:2; /* reserved */
  222. unsigned tardisc:1; /* Target disconnect: 0=disabled, 1=enabled */
  223. unsigned syncneg:1; /* Initial sync neg: 0=disabled, 1=enabled */
  224. unsigned msgclasses:2; /* Message classes
  225. 0=#4
  226. 1=#0, #1, #2, #3, #4
  227. 2=#0, #3, #4
  228. 3=#0, #4
  229. */
  230. unsigned boot:1; /* boot: 0=disabled, 1=enabled */
  231. unsigned dma:1; /* Transfer mode: 0=PIO; 1=DMA */
  232. unsigned id:3; /* SCSI-id */
  233. unsigned irq:2; /* IRQ-Channel: 0,3=12, 1=10, 2=11 */
  234. unsigned dmachan:2; /* DMA-Channel: 0=0, 1=5, 2=6, 3=7 */
  235. unsigned parity:1; /* SCSI-parity: 1=enabled 0=disabled */
  236. } fields;
  237. unsigned short port;
  238. } aha152x_config ;
  239. #define cf_parity fields.parity
  240. #define cf_dmachan fields.dmachan
  241. #define cf_irq fields.irq
  242. #define cf_id fields.id
  243. #define cf_dma fields.dma
  244. #define cf_boot fields.boot
  245. #define cf_msgclasses fields.msgclasses
  246. #define cf_syncneg fields.syncneg
  247. #define cf_tardisc fields.tardisc
  248. #define cf_port port
  249. /* Some macros to manipulate ports and their bits */
  250. #define SETPORT(PORT, VAL) outb( (VAL), (PORT) )
  251. #define GETPORT(PORT) inb( PORT )
  252. #define SETBITS(PORT, BITS) outb( (inb(PORT) | (BITS)), (PORT) )
  253. #define CLRBITS(PORT, BITS) outb( (inb(PORT) & ~(BITS)), (PORT) )
  254. #define TESTHI(PORT, BITS) ((inb(PORT) & (BITS)) == (BITS))
  255. #define TESTLO(PORT, BITS) ((inb(PORT) & (BITS)) == 0)
  256. #define SETRATE(RATE) SETPORT(SCSIRATE,(RATE) & 0x7f)
  257. #if defined(AHA152X_DEBUG)
  258. enum {
  259. debug_procinfo = 0x0001,
  260. debug_queue = 0x0002,
  261. debug_locking = 0x0004,
  262. debug_intr = 0x0008,
  263. debug_selection = 0x0010,
  264. debug_msgo = 0x0020,
  265. debug_msgi = 0x0040,
  266. debug_status = 0x0080,
  267. debug_cmd = 0x0100,
  268. debug_datai = 0x0200,
  269. debug_datao = 0x0400,
  270. debug_eh = 0x0800,
  271. debug_done = 0x1000,
  272. debug_phases = 0x2000,
  273. };
  274. #endif
  275. /* for the pcmcia stub */
  276. struct aha152x_setup {
  277. int io_port;
  278. int irq;
  279. int scsiid;
  280. int reconnect;
  281. int parity;
  282. int synchronous;
  283. int delay;
  284. int ext_trans;
  285. int tc1550;
  286. #if defined(AHA152X_DEBUG)
  287. int debug;
  288. #endif
  289. char *conf;
  290. };
  291. struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *);
  292. void aha152x_release(struct Scsi_Host *);
  293. int aha152x_host_reset_host(struct Scsi_Host *);
  294. #endif /* _AHA152X_H */