sym_defs.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
  4. * of PCI-SCSI IO processors.
  5. *
  6. * Copyright (C) 1999-2001 Gerard Roudier <[email protected]>
  7. *
  8. * This driver is derived from the Linux sym53c8xx driver.
  9. * Copyright (C) 1998-2000 Gerard Roudier
  10. *
  11. * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
  12. * a port of the FreeBSD ncr driver to Linux-1.2.13.
  13. *
  14. * The original ncr driver has been written for 386bsd and FreeBSD by
  15. * Wolfgang Stanglmeier <[email protected]>
  16. * Stefan Esser <[email protected]>
  17. * Copyright (C) 1994 Wolfgang Stanglmeier
  18. *
  19. * Other major contributions:
  20. *
  21. * NVRAM detection and reading.
  22. * Copyright (C) 1997 Richard Waltham <[email protected]>
  23. *
  24. *-----------------------------------------------------------------------------
  25. */
  26. #ifndef SYM_DEFS_H
  27. #define SYM_DEFS_H
  28. #define SYM_VERSION "2.2.3"
  29. #define SYM_DRIVER_NAME "sym-" SYM_VERSION
  30. /*
  31. * SYM53C8XX device features descriptor.
  32. */
  33. struct sym_chip {
  34. u_short device_id;
  35. u_short revision_id;
  36. char *name;
  37. u_char burst_max; /* log-base-2 of max burst */
  38. u_char offset_max;
  39. u_char nr_divisor;
  40. u_char lp_probe_bit;
  41. u_int features;
  42. #define FE_LED0 (1<<0)
  43. #define FE_WIDE (1<<1) /* Wide data transfers */
  44. #define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */
  45. #define FE_ULTRA2 (1<<3) /* Ultra 2 - 40 Mtrans/sec */
  46. #define FE_DBLR (1<<4) /* Clock doubler present */
  47. #define FE_QUAD (1<<5) /* Clock quadrupler present */
  48. #define FE_ERL (1<<6) /* Enable read line */
  49. #define FE_CLSE (1<<7) /* Cache line size enable */
  50. #define FE_WRIE (1<<8) /* Write & Invalidate enable */
  51. #define FE_ERMP (1<<9) /* Enable read multiple */
  52. #define FE_BOF (1<<10) /* Burst opcode fetch */
  53. #define FE_DFS (1<<11) /* DMA fifo size */
  54. #define FE_PFEN (1<<12) /* Prefetch enable */
  55. #define FE_LDSTR (1<<13) /* Load/Store supported */
  56. #define FE_RAM (1<<14) /* On chip RAM present */
  57. #define FE_VARCLK (1<<15) /* Clock frequency may vary */
  58. #define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */
  59. #define FE_64BIT (1<<17) /* 64-bit PCI BUS interface */
  60. #define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */
  61. #define FE_NOPM (1<<19) /* Scripts handles phase mismatch */
  62. #define FE_LEDC (1<<20) /* Hardware control of LED */
  63. #define FE_ULTRA3 (1<<21) /* Ultra 3 - 80 Mtrans/sec DT */
  64. #define FE_66MHZ (1<<22) /* 66MHz PCI support */
  65. #define FE_CRC (1<<23) /* CRC support */
  66. #define FE_DIFF (1<<24) /* SCSI HVD support */
  67. #define FE_DFBC (1<<25) /* Have DFBC register */
  68. #define FE_LCKFRQ (1<<26) /* Have LCKFRQ */
  69. #define FE_C10 (1<<27) /* Various C10 core (mis)features */
  70. #define FE_U3EN (1<<28) /* U3EN bit usable */
  71. #define FE_DAC (1<<29) /* Support PCI DAC (64 bit addressing) */
  72. #define FE_ISTAT1 (1<<30) /* Have ISTAT1, MBOX0, MBOX1 registers */
  73. #define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
  74. #define FE_CACHE0_SET (FE_CACHE_SET & ~FE_ERL)
  75. };
  76. /*
  77. * SYM53C8XX IO register data structure.
  78. */
  79. struct sym_reg {
  80. /*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */
  81. /*01*/ u8 nc_scntl1; /* no reset */
  82. #define ISCON 0x10 /* connected to scsi */
  83. #define CRST 0x08 /* force reset */
  84. #define IARB 0x02 /* immediate arbitration */
  85. /*02*/ u8 nc_scntl2; /* no disconnect expected */
  86. #define SDU 0x80 /* cmd: disconnect will raise error */
  87. #define CHM 0x40 /* sta: chained mode */
  88. #define WSS 0x08 /* sta: wide scsi send [W]*/
  89. #define WSR 0x01 /* sta: wide scsi received [W]*/
  90. /*03*/ u8 nc_scntl3; /* cnf system clock dependent */
  91. #define EWS 0x08 /* cmd: enable wide scsi [W]*/
  92. #define ULTRA 0x80 /* cmd: ULTRA enable */
  93. /* bits 0-2, 7 rsvd for C1010 */
  94. /*04*/ u8 nc_scid; /* cnf host adapter scsi address */
  95. #define RRE 0x40 /* r/w:e enable response to resel. */
  96. #define SRE 0x20 /* r/w:e enable response to select */
  97. /*05*/ u8 nc_sxfer; /* ### Sync speed and count */
  98. /* bits 6-7 rsvd for C1010 */
  99. /*06*/ u8 nc_sdid; /* ### Destination-ID */
  100. /*07*/ u8 nc_gpreg; /* ??? IO-Pins */
  101. /*08*/ u8 nc_sfbr; /* ### First byte received */
  102. /*09*/ u8 nc_socl;
  103. #define CREQ 0x80 /* r/w: SCSI-REQ */
  104. #define CACK 0x40 /* r/w: SCSI-ACK */
  105. #define CBSY 0x20 /* r/w: SCSI-BSY */
  106. #define CSEL 0x10 /* r/w: SCSI-SEL */
  107. #define CATN 0x08 /* r/w: SCSI-ATN */
  108. #define CMSG 0x04 /* r/w: SCSI-MSG */
  109. #define CC_D 0x02 /* r/w: SCSI-C_D */
  110. #define CI_O 0x01 /* r/w: SCSI-I_O */
  111. /*0a*/ u8 nc_ssid;
  112. /*0b*/ u8 nc_sbcl;
  113. /*0c*/ u8 nc_dstat;
  114. #define DFE 0x80 /* sta: dma fifo empty */
  115. #define MDPE 0x40 /* int: master data parity error */
  116. #define BF 0x20 /* int: script: bus fault */
  117. #define ABRT 0x10 /* int: script: command aborted */
  118. #define SSI 0x08 /* int: script: single step */
  119. #define SIR 0x04 /* int: script: interrupt instruct. */
  120. #define IID 0x01 /* int: script: illegal instruct. */
  121. /*0d*/ u8 nc_sstat0;
  122. #define ILF 0x80 /* sta: data in SIDL register lsb */
  123. #define ORF 0x40 /* sta: data in SODR register lsb */
  124. #define OLF 0x20 /* sta: data in SODL register lsb */
  125. #define AIP 0x10 /* sta: arbitration in progress */
  126. #define LOA 0x08 /* sta: arbitration lost */
  127. #define WOA 0x04 /* sta: arbitration won */
  128. #define IRST 0x02 /* sta: scsi reset signal */
  129. #define SDP 0x01 /* sta: scsi parity signal */
  130. /*0e*/ u8 nc_sstat1;
  131. #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
  132. /*0f*/ u8 nc_sstat2;
  133. #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
  134. #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
  135. #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
  136. #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
  137. #define LDSC 0x02 /* sta: disconnect & reconnect */
  138. /*10*/ u8 nc_dsa; /* --> Base page */
  139. /*11*/ u8 nc_dsa1;
  140. /*12*/ u8 nc_dsa2;
  141. /*13*/ u8 nc_dsa3;
  142. /*14*/ u8 nc_istat; /* --> Main Command and status */
  143. #define CABRT 0x80 /* cmd: abort current operation */
  144. #define SRST 0x40 /* mod: reset chip */
  145. #define SIGP 0x20 /* r/w: message from host to script */
  146. #define SEM 0x10 /* r/w: message between host + script */
  147. #define CON 0x08 /* sta: connected to scsi */
  148. #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
  149. #define SIP 0x02 /* sta: scsi-interrupt */
  150. #define DIP 0x01 /* sta: host/script interrupt */
  151. /*15*/ u8 nc_istat1; /* 896 only */
  152. #define FLSH 0x04 /* sta: chip is flushing */
  153. #define SCRUN 0x02 /* sta: scripts are running */
  154. #define SIRQD 0x01 /* r/w: disable INT pin */
  155. /*16*/ u8 nc_mbox0; /* 896 only */
  156. /*17*/ u8 nc_mbox1; /* 896 only */
  157. /*18*/ u8 nc_ctest0;
  158. /*19*/ u8 nc_ctest1;
  159. /*1a*/ u8 nc_ctest2;
  160. #define CSIGP 0x40
  161. /* bits 0-2,7 rsvd for C1010 */
  162. /*1b*/ u8 nc_ctest3;
  163. #define FLF 0x08 /* cmd: flush dma fifo */
  164. #define CLF 0x04 /* cmd: clear dma fifo */
  165. #define FM 0x02 /* mod: fetch pin mode */
  166. #define WRIE 0x01 /* mod: write and invalidate enable */
  167. /* bits 4-7 rsvd for C1010 */
  168. /*1c*/ u32 nc_temp; /* ### Temporary stack */
  169. /*20*/ u8 nc_dfifo;
  170. /*21*/ u8 nc_ctest4;
  171. #define BDIS 0x80 /* mod: burst disable */
  172. #define MPEE 0x08 /* mod: master parity error enable */
  173. /*22*/ u8 nc_ctest5;
  174. #define DFS 0x20 /* mod: dma fifo size */
  175. /* bits 0-1, 3-7 rsvd for C1010 */
  176. /*23*/ u8 nc_ctest6;
  177. /*24*/ u32 nc_dbc; /* ### Byte count and command */
  178. /*28*/ u32 nc_dnad; /* ### Next command register */
  179. /*2c*/ u32 nc_dsp; /* --> Script Pointer */
  180. /*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */
  181. /*34*/ u8 nc_scratcha; /* Temporary register a */
  182. /*35*/ u8 nc_scratcha1;
  183. /*36*/ u8 nc_scratcha2;
  184. /*37*/ u8 nc_scratcha3;
  185. /*38*/ u8 nc_dmode;
  186. #define BL_2 0x80 /* mod: burst length shift value +2 */
  187. #define BL_1 0x40 /* mod: burst length shift value +1 */
  188. #define ERL 0x08 /* mod: enable read line */
  189. #define ERMP 0x04 /* mod: enable read multiple */
  190. #define BOF 0x02 /* mod: burst op code fetch */
  191. /*39*/ u8 nc_dien;
  192. /*3a*/ u8 nc_sbr;
  193. /*3b*/ u8 nc_dcntl; /* --> Script execution control */
  194. #define CLSE 0x80 /* mod: cache line size enable */
  195. #define PFF 0x40 /* cmd: pre-fetch flush */
  196. #define PFEN 0x20 /* mod: pre-fetch enable */
  197. #define SSM 0x10 /* mod: single step mode */
  198. #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
  199. #define STD 0x04 /* cmd: start dma mode */
  200. #define IRQD 0x02 /* mod: irq disable */
  201. #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
  202. /* bits 0-1 rsvd for C1010 */
  203. /*3c*/ u32 nc_adder;
  204. /*40*/ u16 nc_sien; /* -->: interrupt enable */
  205. /*42*/ u16 nc_sist; /* <--: interrupt status */
  206. #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
  207. #define STO 0x0400/* sta: timeout (select) */
  208. #define GEN 0x0200/* sta: timeout (general) */
  209. #define HTH 0x0100/* sta: timeout (handshake) */
  210. #define MA 0x80 /* sta: phase mismatch */
  211. #define CMP 0x40 /* sta: arbitration complete */
  212. #define SEL 0x20 /* sta: selected by another device */
  213. #define RSL 0x10 /* sta: reselected by another device*/
  214. #define SGE 0x08 /* sta: gross error (over/underflow)*/
  215. #define UDC 0x04 /* sta: unexpected disconnect */
  216. #define RST 0x02 /* sta: scsi bus reset detected */
  217. #define PAR 0x01 /* sta: scsi parity error */
  218. /*44*/ u8 nc_slpar;
  219. /*45*/ u8 nc_swide;
  220. /*46*/ u8 nc_macntl;
  221. /*47*/ u8 nc_gpcntl;
  222. /*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/
  223. /*49*/ u8 nc_stime1; /* cmd: timeout user defined */
  224. /*4a*/ u16 nc_respid; /* sta: Reselect-IDs */
  225. /*4c*/ u8 nc_stest0;
  226. /*4d*/ u8 nc_stest1;
  227. #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
  228. #define DBLEN 0x08 /* clock doubler running */
  229. #define DBLSEL 0x04 /* clock doubler selected */
  230. /*4e*/ u8 nc_stest2;
  231. #define ROF 0x40 /* reset scsi offset (after gross error!) */
  232. #define EXT 0x02 /* extended filtering */
  233. /*4f*/ u8 nc_stest3;
  234. #define TE 0x80 /* c: tolerAnt enable */
  235. #define HSC 0x20 /* c: Halt SCSI Clock */
  236. #define CSF 0x02 /* c: clear scsi fifo */
  237. /*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */
  238. /*52*/ u8 nc_stest4;
  239. #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
  240. #define SMODE_HVD 0x40 /* High Voltage Differential */
  241. #define SMODE_SE 0x80 /* Single Ended */
  242. #define SMODE_LVD 0xc0 /* Low Voltage Differential */
  243. #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
  244. /* bits 0-5 rsvd for C1010 */
  245. /*53*/ u8 nc_53_;
  246. /*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */
  247. /*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */
  248. #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */
  249. #define PMJCTL 0x40 /* Phase Mismatch Jump Control */
  250. #define ENNDJ 0x20 /* Enable Non Data PM Jump */
  251. #define DISFC 0x10 /* Disable Auto FIFO Clear */
  252. #define DILS 0x02 /* Disable Internal Load/Store */
  253. #define DPR 0x01 /* Disable Pipe Req */
  254. /*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */
  255. #define ZMOD 0x80 /* High Impedance Mode */
  256. #define DDAC 0x08 /* Disable Dual Address Cycle */
  257. #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */
  258. #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */
  259. #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */
  260. /*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */
  261. /*5a*/ u16 nc_5a_;
  262. /*5c*/ u8 nc_scr0; /* Working register B */
  263. /*5d*/ u8 nc_scr1;
  264. /*5e*/ u8 nc_scr2;
  265. /*5f*/ u8 nc_scr3;
  266. /*60*/ u8 nc_scrx[64]; /* Working register C-R */
  267. /*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */
  268. /*a4*/ u32 nc_mmws; /* Memory Move Write Selector */
  269. /*a8*/ u32 nc_sfs; /* Script Fetch Selector */
  270. /*ac*/ u32 nc_drs; /* DSA Relative Selector */
  271. /*b0*/ u32 nc_sbms; /* Static Block Move Selector */
  272. /*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */
  273. /*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */
  274. /*bc*/ u16 nc_scntl4; /* C1010 only */
  275. #define U3EN 0x80 /* Enable Ultra 3 */
  276. #define AIPCKEN 0x40 /* AIP checking enable */
  277. /* Also enable AIP generation on C10-33*/
  278. #define XCLKH_DT 0x08 /* Extra clock of data hold on DT edge */
  279. #define XCLKH_ST 0x04 /* Extra clock of data hold on ST edge */
  280. #define XCLKS_DT 0x02 /* Extra clock of data set on DT edge */
  281. #define XCLKS_ST 0x01 /* Extra clock of data set on ST edge */
  282. /*be*/ u8 nc_aipcntl0; /* AIP Control 0 C1010 only */
  283. /*bf*/ u8 nc_aipcntl1; /* AIP Control 1 C1010 only */
  284. #define DISAIP 0x08 /* Disable AIP generation C10-66 only */
  285. /*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */
  286. /*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */
  287. /*c8*/ u8 nc_rbc; /* Remaining Byte Count */
  288. /*c9*/ u8 nc_rbc1;
  289. /*ca*/ u8 nc_rbc2;
  290. /*cb*/ u8 nc_rbc3;
  291. /*cc*/ u8 nc_ua; /* Updated Address */
  292. /*cd*/ u8 nc_ua1;
  293. /*ce*/ u8 nc_ua2;
  294. /*cf*/ u8 nc_ua3;
  295. /*d0*/ u32 nc_esa; /* Entry Storage Address */
  296. /*d4*/ u8 nc_ia; /* Instruction Address */
  297. /*d5*/ u8 nc_ia1;
  298. /*d6*/ u8 nc_ia2;
  299. /*d7*/ u8 nc_ia3;
  300. /*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */
  301. /*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */
  302. /* Following for C1010 only */
  303. /*e0*/ u16 nc_crcpad; /* CRC Value */
  304. /*e2*/ u8 nc_crccntl0; /* CRC control register */
  305. #define SNDCRC 0x10 /* Send CRC Request */
  306. /*e3*/ u8 nc_crccntl1; /* CRC control register */
  307. /*e4*/ u32 nc_crcdata; /* CRC data register */
  308. /*e8*/ u32 nc_e8_;
  309. /*ec*/ u32 nc_ec_;
  310. /*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */
  311. };
  312. /*-----------------------------------------------------------
  313. *
  314. * Utility macros for the script.
  315. *
  316. *-----------------------------------------------------------
  317. */
  318. #define REGJ(p,r) (offsetof(struct sym_reg, p ## r))
  319. #define REG(r) REGJ (nc_, r)
  320. /*-----------------------------------------------------------
  321. *
  322. * SCSI phases
  323. *
  324. *-----------------------------------------------------------
  325. */
  326. #define SCR_DATA_OUT 0x00000000
  327. #define SCR_DATA_IN 0x01000000
  328. #define SCR_COMMAND 0x02000000
  329. #define SCR_STATUS 0x03000000
  330. #define SCR_DT_DATA_OUT 0x04000000
  331. #define SCR_DT_DATA_IN 0x05000000
  332. #define SCR_MSG_OUT 0x06000000
  333. #define SCR_MSG_IN 0x07000000
  334. /* DT phases are illegal for non Ultra3 mode */
  335. #define SCR_ILG_OUT 0x04000000
  336. #define SCR_ILG_IN 0x05000000
  337. /*-----------------------------------------------------------
  338. *
  339. * Data transfer via SCSI.
  340. *
  341. *-----------------------------------------------------------
  342. *
  343. * MOVE_ABS (LEN)
  344. * <<start address>>
  345. *
  346. * MOVE_IND (LEN)
  347. * <<dnad_offset>>
  348. *
  349. * MOVE_TBL
  350. * <<dnad_offset>>
  351. *
  352. *-----------------------------------------------------------
  353. */
  354. #define OPC_MOVE 0x08000000
  355. #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
  356. /* #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l)) */
  357. #define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
  358. #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
  359. /* #define SCR_CHMOV_IND(l) ((0x20000000) | (l)) */
  360. #define SCR_CHMOV_TBL (0x10000000)
  361. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  362. /* We steal the `indirect addressing' flag for target mode MOVE in scripts */
  363. #define OPC_TCHMOVE 0x08000000
  364. #define SCR_TCHMOVE_ABS(l) ((0x20000000 | OPC_TCHMOVE) | (l))
  365. #define SCR_TCHMOVE_TBL (0x30000000 | OPC_TCHMOVE)
  366. #define SCR_TMOV_ABS(l) ((0x20000000) | (l))
  367. #define SCR_TMOV_TBL (0x30000000)
  368. #endif
  369. struct sym_tblmove {
  370. u32 size;
  371. u32 addr;
  372. };
  373. /*-----------------------------------------------------------
  374. *
  375. * Selection
  376. *
  377. *-----------------------------------------------------------
  378. *
  379. * SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
  380. * <<alternate_address>>
  381. *
  382. * SEL_TBL | << dnad_offset>> [ | REL_JMP]
  383. * <<alternate_address>>
  384. *
  385. *-----------------------------------------------------------
  386. */
  387. #define SCR_SEL_ABS 0x40000000
  388. #define SCR_SEL_ABS_ATN 0x41000000
  389. #define SCR_SEL_TBL 0x42000000
  390. #define SCR_SEL_TBL_ATN 0x43000000
  391. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  392. #define SCR_RESEL_ABS 0x40000000
  393. #define SCR_RESEL_ABS_ATN 0x41000000
  394. #define SCR_RESEL_TBL 0x42000000
  395. #define SCR_RESEL_TBL_ATN 0x43000000
  396. #endif
  397. struct sym_tblsel {
  398. u_char sel_scntl4; /* C1010 only */
  399. u_char sel_sxfer;
  400. u_char sel_id;
  401. u_char sel_scntl3;
  402. };
  403. #define SCR_JMP_REL 0x04000000
  404. #define SCR_ID(id) (((u32)(id)) << 16)
  405. /*-----------------------------------------------------------
  406. *
  407. * Waiting for Disconnect or Reselect
  408. *
  409. *-----------------------------------------------------------
  410. *
  411. * WAIT_DISC
  412. * dummy: <<alternate_address>>
  413. *
  414. * WAIT_RESEL
  415. * <<alternate_address>>
  416. *
  417. *-----------------------------------------------------------
  418. */
  419. #define SCR_WAIT_DISC 0x48000000
  420. #define SCR_WAIT_RESEL 0x50000000
  421. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  422. #define SCR_DISCONNECT 0x48000000
  423. #endif
  424. /*-----------------------------------------------------------
  425. *
  426. * Bit Set / Reset
  427. *
  428. *-----------------------------------------------------------
  429. *
  430. * SET (flags {|.. })
  431. *
  432. * CLR (flags {|.. })
  433. *
  434. *-----------------------------------------------------------
  435. */
  436. #define SCR_SET(f) (0x58000000 | (f))
  437. #define SCR_CLR(f) (0x60000000 | (f))
  438. #define SCR_CARRY 0x00000400
  439. #define SCR_TRG 0x00000200
  440. #define SCR_ACK 0x00000040
  441. #define SCR_ATN 0x00000008
  442. /*-----------------------------------------------------------
  443. *
  444. * Memory to memory move
  445. *
  446. *-----------------------------------------------------------
  447. *
  448. * COPY (bytecount)
  449. * << source_address >>
  450. * << destination_address >>
  451. *
  452. * SCR_COPY sets the NO FLUSH option by default.
  453. * SCR_COPY_F does not set this option.
  454. *
  455. * For chips which do not support this option,
  456. * sym_fw_bind_script() will remove this bit.
  457. *
  458. *-----------------------------------------------------------
  459. */
  460. #define SCR_NO_FLUSH 0x01000000
  461. #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
  462. #define SCR_COPY_F(n) (0xc0000000 | (n))
  463. /*-----------------------------------------------------------
  464. *
  465. * Register move and binary operations
  466. *
  467. *-----------------------------------------------------------
  468. *
  469. * SFBR_REG (reg, op, data) reg = SFBR op data
  470. * << 0 >>
  471. *
  472. * REG_SFBR (reg, op, data) SFBR = reg op data
  473. * << 0 >>
  474. *
  475. * REG_REG (reg, op, data) reg = reg op data
  476. * << 0 >>
  477. *
  478. *-----------------------------------------------------------
  479. *
  480. * On 825A, 875, 895 and 896 chips the content
  481. * of SFBR register can be used as data (SCR_SFBR_DATA).
  482. * The 896 has additionnal IO registers starting at
  483. * offset 0x80. Bit 7 of register offset is stored in
  484. * bit 7 of the SCRIPTS instruction first DWORD.
  485. *
  486. *-----------------------------------------------------------
  487. */
  488. #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
  489. #define SCR_SFBR_REG(reg,op,data) \
  490. (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  491. #define SCR_REG_SFBR(reg,op,data) \
  492. (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  493. #define SCR_REG_REG(reg,op,data) \
  494. (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  495. #define SCR_LOAD 0x00000000
  496. #define SCR_SHL 0x01000000
  497. #define SCR_OR 0x02000000
  498. #define SCR_XOR 0x03000000
  499. #define SCR_AND 0x04000000
  500. #define SCR_SHR 0x05000000
  501. #define SCR_ADD 0x06000000
  502. #define SCR_ADDC 0x07000000
  503. #define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
  504. /*-----------------------------------------------------------
  505. *
  506. * FROM_REG (reg) SFBR = reg
  507. * << 0 >>
  508. *
  509. * TO_REG (reg) reg = SFBR
  510. * << 0 >>
  511. *
  512. * LOAD_REG (reg, data) reg = <data>
  513. * << 0 >>
  514. *
  515. * LOAD_SFBR(data) SFBR = <data>
  516. * << 0 >>
  517. *
  518. *-----------------------------------------------------------
  519. */
  520. #define SCR_FROM_REG(reg) \
  521. SCR_REG_SFBR(reg,SCR_OR,0)
  522. #define SCR_TO_REG(reg) \
  523. SCR_SFBR_REG(reg,SCR_OR,0)
  524. #define SCR_LOAD_REG(reg,data) \
  525. SCR_REG_REG(reg,SCR_LOAD,data)
  526. #define SCR_LOAD_SFBR(data) \
  527. (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
  528. /*-----------------------------------------------------------
  529. *
  530. * LOAD from memory to register.
  531. * STORE from register to memory.
  532. *
  533. * Only supported by 810A, 860, 825A, 875, 895 and 896.
  534. *
  535. *-----------------------------------------------------------
  536. *
  537. * LOAD_ABS (LEN)
  538. * <<start address>>
  539. *
  540. * LOAD_REL (LEN) (DSA relative)
  541. * <<dsa_offset>>
  542. *
  543. *-----------------------------------------------------------
  544. */
  545. #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
  546. #define SCR_NO_FLUSH2 0x02000000
  547. #define SCR_DSA_REL2 0x10000000
  548. #define SCR_LOAD_R(reg, how, n) \
  549. (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  550. #define SCR_STORE_R(reg, how, n) \
  551. (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  552. #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
  553. #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
  554. #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
  555. #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
  556. #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
  557. #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
  558. #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
  559. #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
  560. /*-----------------------------------------------------------
  561. *
  562. * Waiting for Disconnect or Reselect
  563. *
  564. *-----------------------------------------------------------
  565. *
  566. * JUMP [ | IFTRUE/IFFALSE ( ... ) ]
  567. * <<address>>
  568. *
  569. * JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
  570. * <<distance>>
  571. *
  572. * CALL [ | IFTRUE/IFFALSE ( ... ) ]
  573. * <<address>>
  574. *
  575. * CALLR [ | IFTRUE/IFFALSE ( ... ) ]
  576. * <<distance>>
  577. *
  578. * RETURN [ | IFTRUE/IFFALSE ( ... ) ]
  579. * <<dummy>>
  580. *
  581. * INT [ | IFTRUE/IFFALSE ( ... ) ]
  582. * <<ident>>
  583. *
  584. * INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
  585. * <<ident>>
  586. *
  587. * Conditions:
  588. * WHEN (phase)
  589. * IF (phase)
  590. * CARRYSET
  591. * DATA (data, mask)
  592. *
  593. *-----------------------------------------------------------
  594. */
  595. #define SCR_NO_OP 0x80000000
  596. #define SCR_JUMP 0x80080000
  597. #define SCR_JUMP64 0x80480000
  598. #define SCR_JUMPR 0x80880000
  599. #define SCR_CALL 0x88080000
  600. #define SCR_CALLR 0x88880000
  601. #define SCR_RETURN 0x90080000
  602. #define SCR_INT 0x98080000
  603. #define SCR_INT_FLY 0x98180000
  604. #define IFFALSE(arg) (0x00080000 | (arg))
  605. #define IFTRUE(arg) (0x00000000 | (arg))
  606. #define WHEN(phase) (0x00030000 | (phase))
  607. #define IF(phase) (0x00020000 | (phase))
  608. #define DATA(D) (0x00040000 | ((D) & 0xff))
  609. #define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
  610. #define CARRYSET (0x00200000)
  611. /*-----------------------------------------------------------
  612. *
  613. * SCSI constants.
  614. *
  615. *-----------------------------------------------------------
  616. */
  617. /*
  618. * Messages
  619. */
  620. #define M_COMPLETE COMMAND_COMPLETE
  621. #define M_EXTENDED EXTENDED_MESSAGE
  622. #define M_SAVE_DP SAVE_POINTERS
  623. #define M_RESTORE_DP RESTORE_POINTERS
  624. #define M_DISCONNECT DISCONNECT
  625. #define M_ID_ERROR INITIATOR_ERROR
  626. #define M_ABORT ABORT_TASK_SET
  627. #define M_REJECT MESSAGE_REJECT
  628. #define M_NOOP NOP
  629. #define M_PARITY MSG_PARITY_ERROR
  630. #define M_LCOMPLETE LINKED_CMD_COMPLETE
  631. #define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE
  632. #define M_RESET TARGET_RESET
  633. #define M_ABORT_TAG ABORT_TASK
  634. #define M_CLEAR_QUEUE CLEAR_TASK_SET
  635. #define M_INIT_REC INITIATE_RECOVERY
  636. #define M_REL_REC RELEASE_RECOVERY
  637. #define M_TERMINATE (0x11)
  638. #define M_SIMPLE_TAG SIMPLE_QUEUE_TAG
  639. #define M_HEAD_TAG HEAD_OF_QUEUE_TAG
  640. #define M_ORDERED_TAG ORDERED_QUEUE_TAG
  641. #define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE
  642. #define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER
  643. #define M_X_SYNC_REQ EXTENDED_SDTR
  644. #define M_X_WIDE_REQ EXTENDED_WDTR
  645. #define M_X_PPR_REQ EXTENDED_PPR
  646. /*
  647. * PPR protocol options
  648. */
  649. #define PPR_OPT_IU (0x01)
  650. #define PPR_OPT_DT (0x02)
  651. #define PPR_OPT_QAS (0x04)
  652. #define PPR_OPT_MASK (0x07)
  653. /*
  654. * Status
  655. */
  656. #define S_GOOD SAM_STAT_GOOD
  657. #define S_CHECK_COND SAM_STAT_CHECK_CONDITION
  658. #define S_COND_MET SAM_STAT_CONDITION_MET
  659. #define S_BUSY SAM_STAT_BUSY
  660. #define S_INT SAM_STAT_INTERMEDIATE
  661. #define S_INT_COND_MET SAM_STAT_INTERMEDIATE_CONDITION_MET
  662. #define S_CONFLICT SAM_STAT_RESERVATION_CONFLICT
  663. #define S_TERMINATED SAM_STAT_COMMAND_TERMINATED
  664. #define S_QUEUE_FULL SAM_STAT_TASK_SET_FULL
  665. #define S_ILLEGAL (0xff)
  666. #endif /* defined SYM_DEFS_H */