sym_defs.h 27 KB

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