sym53c8xx.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. * (C) Copyright 2001
  3. * Denis Peter, MPL AG Switzerland
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. *
  7. * Most of these definitions are derived from
  8. * linux/drivers/scsi/sym53c8xx_defs.h
  9. */
  10. #ifndef _SYM53C8XX_DEFS_H
  11. #define _SYM53C8XX_DEFS_H
  12. #define SCNTL0 0x00 /* full arb., ena parity, par->ATN */
  13. #define SCNTL1 0x01 /* no reset */
  14. #define ISCON 0x10 /* connected to scsi */
  15. #define CRST 0x08 /* force reset */
  16. #define IARB 0x02 /* immediate arbitration */
  17. #define SCNTL2 0x02 /* no disconnect expected */
  18. #define SDU 0x80 /* cmd: disconnect will raise error */
  19. #define CHM 0x40 /* sta: chained mode */
  20. #define WSS 0x08 /* sta: wide scsi send [W]*/
  21. #define WSR 0x01 /* sta: wide scsi received [W]*/
  22. #define SCNTL3 0x03 /* cnf system clock dependent */
  23. #define EWS 0x08 /* cmd: enable wide scsi [W]*/
  24. #define ULTRA 0x80 /* cmd: ULTRA enable */
  25. /* bits 0-2, 7 rsvd for C1010 */
  26. #define SCID 0x04 /* cnf host adapter scsi address */
  27. #define RRE 0x40 /* r/w:e enable response to resel. */
  28. #define SRE 0x20 /* r/w:e enable response to select */
  29. #define SXFER 0x05 /* ### Sync speed and count */
  30. /* bits 6-7 rsvd for C1010 */
  31. #define SDID 0x06 /* ### Destination-ID */
  32. #define GPREG 0x07 /* ??? IO-Pins */
  33. #define SFBR 0x08 /* ### First byte in phase */
  34. #define SOCL 0x09
  35. #define CREQ 0x80 /* r/w: SCSI-REQ */
  36. #define CACK 0x40 /* r/w: SCSI-ACK */
  37. #define CBSY 0x20 /* r/w: SCSI-BSY */
  38. #define CSEL 0x10 /* r/w: SCSI-SEL */
  39. #define CATN 0x08 /* r/w: SCSI-ATN */
  40. #define CMSG 0x04 /* r/w: SCSI-MSG */
  41. #define CC_D 0x02 /* r/w: SCSI-C_D */
  42. #define CI_O 0x01 /* r/w: SCSI-I_O */
  43. #define SSID 0x0a
  44. #define SBCL 0x0b
  45. #define DSTAT 0x0c
  46. #define DFE 0x80 /* sta: dma fifo empty */
  47. #define MDPE 0x40 /* int: master data parity error */
  48. #define BF 0x20 /* int: script: bus fault */
  49. #define ABRT 0x10 /* int: script: command aborted */
  50. #define SSI 0x08 /* int: script: single step */
  51. #define SIR 0x04 /* int: script: interrupt instruct. */
  52. #define IID 0x01 /* int: script: illegal instruct. */
  53. #define SSTAT0 0x0d
  54. #define ILF 0x80 /* sta: data in SIDL register lsb */
  55. #define ORF 0x40 /* sta: data in SODR register lsb */
  56. #define OLF 0x20 /* sta: data in SODL register lsb */
  57. #define AIP 0x10 /* sta: arbitration in progress */
  58. #define LOA 0x08 /* sta: arbitration lost */
  59. #define WOA 0x04 /* sta: arbitration won */
  60. #define IRST 0x02 /* sta: scsi reset signal */
  61. #define SDP 0x01 /* sta: scsi parity signal */
  62. #define SSTAT1 0x0e
  63. #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
  64. #define SSTAT2 0x0f
  65. #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
  66. #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
  67. #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
  68. #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
  69. #define LDSC 0x02 /* sta: disconnect & reconnect */
  70. #define DSA 0x10 /* --> Base page */
  71. #define DSA1 0x11
  72. #define DSA2 0x12
  73. #define DSA3 0x13
  74. #define ISTAT 0x14 /* --> Main Command and status */
  75. #define CABRT 0x80 /* cmd: abort current operation */
  76. #define SRST 0x40 /* mod: reset chip */
  77. #define SIGP 0x20 /* r/w: message from host to ncr */
  78. #define SEM 0x10 /* r/w: message between host + ncr */
  79. #define CON 0x08 /* sta: connected to scsi */
  80. #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
  81. #define SIP 0x02 /* sta: scsi-interrupt */
  82. #define DIP 0x01 /* sta: host/script interrupt */
  83. #define CTEST0 0x18
  84. #define CTEST1 0x19
  85. #define CTEST2 0x1a
  86. #define CSIGP 0x40
  87. /* bits 0-2,7 rsvd for C1010 */
  88. #define CTEST3 0x1b
  89. #define FLF 0x08 /* cmd: flush dma fifo */
  90. #define CLF 0x04 /* cmd: clear dma fifo */
  91. #define FM 0x02 /* mod: fetch pin mode */
  92. #define WRIE 0x01 /* mod: write and invalidate enable */
  93. /* bits 4-7 rsvd for C1010 */
  94. #define DFIFO 0x20
  95. #define CTEST4 0x21
  96. #define BDIS 0x80 /* mod: burst disable */
  97. #define MPEE 0x08 /* mod: master parity error enable */
  98. #define CTEST5 0x22
  99. #define DFS 0x20 /* mod: dma fifo size */
  100. /* bits 0-1, 3-7 rsvd for C1010 */
  101. #define CTEST6 0x23
  102. #define DBC 0x24 /* ### Byte count and command */
  103. #define DNAD 0x28 /* ### Next command register */
  104. #define DSP 0x2c /* --> Script Pointer */
  105. #define DSPS 0x30 /* --> Script pointer save/opcode#2 */
  106. #define SCRATCHA 0x34 /* Temporary register a */
  107. #define SCRATCHA1 0x35
  108. #define SCRATCHA2 0x36
  109. #define SCRATCHA3 0x37
  110. #define DMODE 0x38
  111. #define BL_2 0x80 /* mod: burst length shift value +2 */
  112. #define BL_1 0x40 /* mod: burst length shift value +1 */
  113. #define ERL 0x08 /* mod: enable read line */
  114. #define ERMP 0x04 /* mod: enable read multiple */
  115. #define BOF 0x02 /* mod: burst op code fetch */
  116. #define MAN 0x01 /* mod: manual start */
  117. #define DIEN 0x39
  118. #define SBR 0x3a
  119. #define DCNTL 0x3b /* --> Script execution control */
  120. #define CLSE 0x80 /* mod: cache line size enable */
  121. #define PFF 0x40 /* cmd: pre-fetch flush */
  122. #define PFEN 0x20 /* mod: pre-fetch enable */
  123. #define SSM 0x10 /* mod: single step mode */
  124. #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
  125. #define STD 0x04 /* cmd: start dma mode */
  126. #define IRQD 0x02 /* mod: irq disable */
  127. #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
  128. /* bits 0-1 rsvd for C1010 */
  129. #define ADDER 0x3c
  130. #define SIEN 0x40 /* -->: interrupt enable */
  131. #define SIST 0x42 /* <--: interrupt status */
  132. #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
  133. #define STO 0x0400/* sta: timeout (select) */
  134. #define GEN 0x0200/* sta: timeout (general) */
  135. #define HTH 0x0100/* sta: timeout (handshake) */
  136. #define MA 0x80 /* sta: phase mismatch */
  137. #define CMP 0x40 /* sta: arbitration complete */
  138. #define SEL 0x20 /* sta: selected by another device */
  139. #define RSL 0x10 /* sta: reselected by another device*/
  140. #define SGE 0x08 /* sta: gross error (over/underflow)*/
  141. #define UDC 0x04 /* sta: unexpected disconnect */
  142. #define RST 0x02 /* sta: scsi bus reset detected */
  143. #define PAR 0x01 /* sta: scsi parity error */
  144. #define SLPAR 0x44
  145. #define SWIDE 0x45
  146. #define MACNTL 0x46
  147. #define GPCNTL 0x47
  148. #define STIME0 0x48 /* cmd: timeout for select&handshake*/
  149. #define STIME1 0x49 /* cmd: timeout user defined */
  150. #define RESPID 0x4a /* sta: Reselect-IDs */
  151. #define STEST0 0x4c
  152. #define STEST1 0x4d
  153. #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
  154. #define DBLEN 0x08 /* clock doubler running */
  155. #define DBLSEL 0x04 /* clock doubler selected */
  156. #define STEST2 0x4e
  157. #define ROF 0x40 /* reset scsi offset (after gross error!) */
  158. #define EXT 0x02 /* extended filtering */
  159. #define STEST3 0x4f
  160. #define TE 0x80 /* c: tolerAnt enable */
  161. #define HSC 0x20 /* c: Halt SCSI Clock */
  162. #define CSF 0x02 /* c: clear scsi fifo */
  163. #define SIDL 0x50 /* Lowlevel: latched from scsi data */
  164. #define STEST4 0x52
  165. #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
  166. #define SMODE_HVD 0x40 /* High Voltage Differential */
  167. #define SMODE_SE 0x80 /* Single Ended */
  168. #define SMODE_LVD 0xc0 /* Low Voltage Differential */
  169. #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
  170. /* bits 0-5 rsvd for C1010 */
  171. #define SODL 0x54 /* Lowlevel: data out to scsi data */
  172. #define SBDL 0x58 /* Lowlevel: data from scsi data */
  173. /*-----------------------------------------------------------
  174. **
  175. ** Utility macros for the script.
  176. **
  177. **-----------------------------------------------------------
  178. */
  179. #define REG(r) (r)
  180. /*-----------------------------------------------------------
  181. **
  182. ** SCSI phases
  183. **
  184. ** DT phases illegal for ncr driver.
  185. **
  186. **-----------------------------------------------------------
  187. */
  188. #define SCR_DATA_OUT 0x00000000
  189. #define SCR_DATA_IN 0x01000000
  190. #define SCR_COMMAND 0x02000000
  191. #define SCR_STATUS 0x03000000
  192. #define SCR_DT_DATA_OUT 0x04000000
  193. #define SCR_DT_DATA_IN 0x05000000
  194. #define SCR_MSG_OUT 0x06000000
  195. #define SCR_MSG_IN 0x07000000
  196. #define SCR_ILG_OUT 0x04000000
  197. #define SCR_ILG_IN 0x05000000
  198. /*-----------------------------------------------------------
  199. **
  200. ** Data transfer via SCSI.
  201. **
  202. **-----------------------------------------------------------
  203. **
  204. ** MOVE_ABS (LEN)
  205. ** <<start address>>
  206. **
  207. ** MOVE_IND (LEN)
  208. ** <<dnad_offset>>
  209. **
  210. ** MOVE_TBL
  211. ** <<dnad_offset>>
  212. **
  213. **-----------------------------------------------------------
  214. */
  215. #define OPC_MOVE 0x08000000
  216. #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
  217. #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
  218. #define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
  219. #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
  220. #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
  221. #define SCR_CHMOV_TBL (0x10000000)
  222. /*-----------------------------------------------------------
  223. **
  224. ** Selection
  225. **
  226. **-----------------------------------------------------------
  227. **
  228. ** SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
  229. ** <<alternate_address>>
  230. **
  231. ** SEL_TBL | << dnad_offset>> [ | REL_JMP]
  232. ** <<alternate_address>>
  233. **
  234. **-----------------------------------------------------------
  235. */
  236. #define SCR_SEL_ABS 0x40000000
  237. #define SCR_SEL_ABS_ATN 0x41000000
  238. #define SCR_SEL_TBL 0x42000000
  239. #define SCR_SEL_TBL_ATN 0x43000000
  240. #define SCR_JMP_REL 0x04000000
  241. #define SCR_ID(id) (((unsigned long)(id)) << 16)
  242. /*-----------------------------------------------------------
  243. **
  244. ** Waiting for Disconnect or Reselect
  245. **
  246. **-----------------------------------------------------------
  247. **
  248. ** WAIT_DISC
  249. ** dummy: <<alternate_address>>
  250. **
  251. ** WAIT_RESEL
  252. ** <<alternate_address>>
  253. **
  254. **-----------------------------------------------------------
  255. */
  256. #define SCR_WAIT_DISC 0x48000000
  257. #define SCR_WAIT_RESEL 0x50000000
  258. /*-----------------------------------------------------------
  259. **
  260. ** Bit Set / Reset
  261. **
  262. **-----------------------------------------------------------
  263. **
  264. ** SET (flags {|.. })
  265. **
  266. ** CLR (flags {|.. })
  267. **
  268. **-----------------------------------------------------------
  269. */
  270. #define SCR_SET(f) (0x58000000 | (f))
  271. #define SCR_CLR(f) (0x60000000 | (f))
  272. #define SCR_CARRY 0x00000400
  273. #define SCR_TRG 0x00000200
  274. #define SCR_ACK 0x00000040
  275. #define SCR_ATN 0x00000008
  276. /*-----------------------------------------------------------
  277. **
  278. ** Memory to memory move
  279. **
  280. **-----------------------------------------------------------
  281. **
  282. ** COPY (bytecount)
  283. ** << source_address >>
  284. ** << destination_address >>
  285. **
  286. ** SCR_COPY sets the NO FLUSH option by default.
  287. ** SCR_COPY_F does not set this option.
  288. **
  289. ** For chips which do not support this option,
  290. ** ncr_copy_and_bind() will remove this bit.
  291. **-----------------------------------------------------------
  292. */
  293. #define SCR_NO_FLUSH 0x01000000
  294. #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
  295. #define SCR_COPY_F(n) (0xc0000000 | (n))
  296. /*-----------------------------------------------------------
  297. **
  298. ** Register move and binary operations
  299. **
  300. **-----------------------------------------------------------
  301. **
  302. ** SFBR_REG (reg, op, data) reg = SFBR op data
  303. ** << 0 >>
  304. **
  305. ** REG_SFBR (reg, op, data) SFBR = reg op data
  306. ** << 0 >>
  307. **
  308. ** REG_REG (reg, op, data) reg = reg op data
  309. ** << 0 >>
  310. **
  311. **-----------------------------------------------------------
  312. ** On 810A, 860, 825A, 875, 895 and 896 chips the content
  313. ** of SFBR register can be used as data (SCR_SFBR_DATA).
  314. ** The 896 has additionnal IO registers starting at
  315. ** offset 0x80. Bit 7 of register offset is stored in
  316. ** bit 7 of the SCRIPTS instruction first DWORD.
  317. **-----------------------------------------------------------
  318. */
  319. #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul)) /* + ((ofs) & 0x80)) */
  320. #define SCR_SFBR_REG(reg,op,data) \
  321. (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  322. #define SCR_REG_SFBR(reg,op,data) \
  323. (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  324. #define SCR_REG_REG(reg,op,data) \
  325. (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  326. #define SCR_LOAD 0x00000000
  327. #define SCR_SHL 0x01000000
  328. #define SCR_OR 0x02000000
  329. #define SCR_XOR 0x03000000
  330. #define SCR_AND 0x04000000
  331. #define SCR_SHR 0x05000000
  332. #define SCR_ADD 0x06000000
  333. #define SCR_ADDC 0x07000000
  334. #define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
  335. /*-----------------------------------------------------------
  336. **
  337. ** FROM_REG (reg) SFBR = reg
  338. ** << 0 >>
  339. **
  340. ** TO_REG (reg) reg = SFBR
  341. ** << 0 >>
  342. **
  343. ** LOAD_REG (reg, data) reg = <data>
  344. ** << 0 >>
  345. **
  346. ** LOAD_SFBR(data) SFBR = <data>
  347. ** << 0 >>
  348. **
  349. **-----------------------------------------------------------
  350. */
  351. #define SCR_FROM_REG(reg) \
  352. SCR_REG_SFBR(reg,SCR_OR,0)
  353. #define SCR_TO_REG(reg) \
  354. SCR_SFBR_REG(reg,SCR_OR,0)
  355. #define SCR_LOAD_REG(reg,data) \
  356. SCR_REG_REG(reg,SCR_LOAD,data)
  357. #define SCR_LOAD_SFBR(data) \
  358. (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
  359. /*-----------------------------------------------------------
  360. **
  361. ** LOAD from memory to register.
  362. ** STORE from register to memory.
  363. **
  364. ** Only supported by 810A, 860, 825A, 875, 895 and 896.
  365. **
  366. **-----------------------------------------------------------
  367. **
  368. ** LOAD_ABS (LEN)
  369. ** <<start address>>
  370. **
  371. ** LOAD_REL (LEN) (DSA relative)
  372. ** <<dsa_offset>>
  373. **
  374. **-----------------------------------------------------------
  375. */
  376. #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
  377. #define SCR_NO_FLUSH2 0x02000000
  378. #define SCR_DSA_REL2 0x10000000
  379. #define SCR_LOAD_R(reg, how, n) \
  380. (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  381. #define SCR_STORE_R(reg, how, n) \
  382. (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  383. #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
  384. #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
  385. #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
  386. #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
  387. #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
  388. #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
  389. #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
  390. #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
  391. /*-----------------------------------------------------------
  392. **
  393. ** Waiting for Disconnect or Reselect
  394. **
  395. **-----------------------------------------------------------
  396. **
  397. ** JUMP [ | IFTRUE/IFFALSE ( ... ) ]
  398. ** <<address>>
  399. **
  400. ** JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
  401. ** <<distance>>
  402. **
  403. ** CALL [ | IFTRUE/IFFALSE ( ... ) ]
  404. ** <<address>>
  405. **
  406. ** CALLR [ | IFTRUE/IFFALSE ( ... ) ]
  407. ** <<distance>>
  408. **
  409. ** RETURN [ | IFTRUE/IFFALSE ( ... ) ]
  410. ** <<dummy>>
  411. **
  412. ** INT [ | IFTRUE/IFFALSE ( ... ) ]
  413. ** <<ident>>
  414. **
  415. ** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
  416. ** <<ident>>
  417. **
  418. ** Conditions:
  419. ** WHEN (phase)
  420. ** IF (phase)
  421. ** CARRYSET
  422. ** DATA (data, mask)
  423. **
  424. **-----------------------------------------------------------
  425. */
  426. #define SCR_NO_OP 0x80000000
  427. #define SCR_JUMP 0x80080000
  428. #define SCR_JUMP64 0x80480000
  429. #define SCR_JUMPR 0x80880000
  430. #define SCR_CALL 0x88080000
  431. #define SCR_CALLR 0x88880000
  432. #define SCR_RETURN 0x90080000
  433. #define SCR_INT 0x98080000
  434. #define SCR_INT_FLY 0x98180000
  435. #define IFFALSE(arg) (0x00080000 | (arg))
  436. #define IFTRUE(arg) (0x00000000 | (arg))
  437. #define WHEN(phase) (0x00030000 | (phase))
  438. #define IF(phase) (0x00020000 | (phase))
  439. #define DATA(D) (0x00040000 | ((D) & 0xff))
  440. #define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
  441. #define CARRYSET (0x00200000)
  442. #define SIR_COMPLETE 0x10000000
  443. /* script errors */
  444. #define SIR_SEL_ATN_NO_MSG_OUT 0x00000001
  445. #define SIR_CMD_OUT_ILL_PH 0x00000002
  446. #define SIR_STATUS_ILL_PH 0x00000003
  447. #define SIR_MSG_RECEIVED 0x00000004
  448. #define SIR_DATA_IN_ERR 0x00000005
  449. #define SIR_DATA_OUT_ERR 0x00000006
  450. #define SIR_SCRIPT_ERROR 0x00000007
  451. #define SIR_MSG_OUT_NO_CMD 0x00000008
  452. #define SIR_MSG_OVER7 0x00000009
  453. /* Fly interrupt */
  454. #define INT_ON_FY 0x00000080
  455. /* Hardware errors are defined in scsi.h */
  456. #define SCSI_IDENTIFY 0xC0
  457. #endif