aha152x.h 10.0 KB

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