53c7xx.h 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  1. /*
  2. * 53c710 driver. Modified from Drew Eckhardts driver
  3. * for 53c810 by Richard Hirst [richard@sleepie.demon.co.uk]
  4. *
  5. * I have left the code for the 53c8xx family in here, because it didn't
  6. * seem worth removing it. The possibility of IO_MAPPED chips rather
  7. * than MEMORY_MAPPED remains, in case someone wants to add support for
  8. * 53c710 chips on Intel PCs (some older machines have them on the
  9. * motherboard).
  10. *
  11. * NOTE THERE MAY BE PROBLEMS WITH CASTS IN read8 AND Co.
  12. */
  13. /*
  14. * NCR 53c{7,8}0x0 driver, header file
  15. *
  16. * Sponsored by
  17. * iX Multiuser Multitasking Magazine
  18. * Hannover, Germany
  19. * hm@ix.de
  20. *
  21. * Copyright 1993, 1994, 1995 Drew Eckhardt
  22. * Visionary Computing
  23. * (Unix and Linux consulting and custom programming)
  24. * drew@PoohSticks.ORG
  25. * +1 (303) 786-7975
  26. *
  27. * TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.
  28. *
  29. * PRE-ALPHA
  30. *
  31. * For more information, please consult
  32. *
  33. * NCR 53C700/53C700-66
  34. * SCSI I/O Processor
  35. * Data Manual
  36. *
  37. * NCR 53C810
  38. * PCI-SCSI I/O Processor
  39. * Data Manual
  40. *
  41. * NCR Microelectronics
  42. * 1635 Aeroplaza Drive
  43. * Colorado Springs, CO 80916
  44. * +1 (719) 578-3400
  45. *
  46. * Toll free literature number
  47. * +1 (800) 334-5454
  48. *
  49. */
  50. #ifndef NCR53c710_H
  51. #define NCR53c710_H
  52. #ifndef HOSTS_C
  53. /* SCSI control 0 rw, default = 0xc0 */
  54. #define SCNTL0_REG 0x00
  55. #define SCNTL0_ARB1 0x80 /* 0 0 = simple arbitration */
  56. #define SCNTL0_ARB2 0x40 /* 1 1 = full arbitration */
  57. #define SCNTL0_STRT 0x20 /* Start Sequence */
  58. #define SCNTL0_WATN 0x10 /* Select with ATN */
  59. #define SCNTL0_EPC 0x08 /* Enable parity checking */
  60. /* Bit 2 is reserved on 800 series chips */
  61. #define SCNTL0_EPG_700 0x04 /* Enable parity generation */
  62. #define SCNTL0_AAP 0x02 /* ATN/ on parity error */
  63. #define SCNTL0_TRG 0x01 /* Target mode */
  64. /* SCSI control 1 rw, default = 0x00 */
  65. #define SCNTL1_REG 0x01
  66. #define SCNTL1_EXC 0x80 /* Extra Clock Cycle of Data setup */
  67. #define SCNTL1_ADB 0x40 /* contents of SODL on bus */
  68. #define SCNTL1_ESR_700 0x20 /* Enable SIOP response to selection
  69. and reselection */
  70. #define SCNTL1_DHP_800 0x20 /* Disable halt on parity error or ATN
  71. target mode only */
  72. #define SCNTL1_CON 0x10 /* Connected */
  73. #define SCNTL1_RST 0x08 /* SCSI RST/ */
  74. #define SCNTL1_AESP 0x04 /* Force bad parity */
  75. #define SCNTL1_SND_700 0x02 /* Start SCSI send */
  76. #define SCNTL1_IARB_800 0x02 /* Immediate Arbitration, start
  77. arbitration immediately after
  78. busfree is detected */
  79. #define SCNTL1_RCV_700 0x01 /* Start SCSI receive */
  80. #define SCNTL1_SST_800 0x01 /* Start SCSI transfer */
  81. /* SCSI control 2 rw, */
  82. #define SCNTL2_REG_800 0x02
  83. #define SCNTL2_800_SDU 0x80 /* SCSI disconnect unexpected */
  84. /* SCSI control 3 rw */
  85. #define SCNTL3_REG_800 0x03
  86. #define SCNTL3_800_SCF_SHIFT 4
  87. #define SCNTL3_800_SCF_MASK 0x70
  88. #define SCNTL3_800_SCF2 0x40 /* Synchronous divisor */
  89. #define SCNTL3_800_SCF1 0x20 /* 0x00 = SCLK/3 */
  90. #define SCNTL3_800_SCF0 0x10 /* 0x10 = SCLK/1 */
  91. /* 0x20 = SCLK/1.5
  92. 0x30 = SCLK/2
  93. 0x40 = SCLK/3 */
  94. #define SCNTL3_800_CCF_SHIFT 0
  95. #define SCNTL3_800_CCF_MASK 0x07
  96. #define SCNTL3_800_CCF2 0x04 /* 0x00 50.01 to 66 */
  97. #define SCNTL3_800_CCF1 0x02 /* 0x01 16.67 to 25 */
  98. #define SCNTL3_800_CCF0 0x01 /* 0x02 25.01 - 37.5
  99. 0x03 37.51 - 50
  100. 0x04 50.01 - 66 */
  101. /*
  102. * SCSI destination ID rw - the appropriate bit is set for the selected
  103. * target ID. This is written by the SCSI SCRIPTS processor.
  104. * default = 0x00
  105. */
  106. #define SDID_REG_700 0x02
  107. #define SDID_REG_800 0x06
  108. #define GP_REG_800 0x07 /* General purpose IO */
  109. #define GP_800_IO1 0x02
  110. #define GP_800_IO2 0x01
  111. /* SCSI interrupt enable rw, default = 0x00 */
  112. #define SIEN_REG_700 0x03
  113. #define SIEN0_REG_800 0x40
  114. #define SIEN_MA 0x80 /* Phase mismatch (ini) or ATN (tgt) */
  115. #define SIEN_FC 0x40 /* Function complete */
  116. #define SIEN_700_STO 0x20 /* Selection or reselection timeout */
  117. #define SIEN_800_SEL 0x20 /* Selected */
  118. #define SIEN_700_SEL 0x10 /* Selected or reselected */
  119. #define SIEN_800_RESEL 0x10 /* Reselected */
  120. #define SIEN_SGE 0x08 /* SCSI gross error */
  121. #define SIEN_UDC 0x04 /* Unexpected disconnect */
  122. #define SIEN_RST 0x02 /* SCSI RST/ received */
  123. #define SIEN_PAR 0x01 /* Parity error */
  124. /*
  125. * SCSI chip ID rw
  126. * NCR53c700 :
  127. * When arbitrating, the highest bit is used, when reselection or selection
  128. * occurs, the chip responds to all IDs for which a bit is set.
  129. * default = 0x00
  130. * NCR53c810 :
  131. * Uses bit mapping
  132. */
  133. #define SCID_REG 0x04
  134. /* Bit 7 is reserved on 800 series chips */
  135. #define SCID_800_RRE 0x40 /* Enable response to reselection */
  136. #define SCID_800_SRE 0x20 /* Enable response to selection */
  137. /* Bits four and three are reserved on 800 series chips */
  138. #define SCID_800_ENC_MASK 0x07 /* Encoded SCSI ID */
  139. /* SCSI transfer rw, default = 0x00 */
  140. #define SXFER_REG 0x05
  141. #define SXFER_DHP 0x80 /* Disable halt on parity */
  142. #define SXFER_TP2 0x40 /* Transfer period msb */
  143. #define SXFER_TP1 0x20
  144. #define SXFER_TP0 0x10 /* lsb */
  145. #define SXFER_TP_MASK 0x70
  146. /* FIXME : SXFER_TP_SHIFT == 5 is right for '8xx chips */
  147. #define SXFER_TP_SHIFT 5
  148. #define SXFER_TP_4 0x00 /* Divisors */
  149. #define SXFER_TP_5 0x10<<1
  150. #define SXFER_TP_6 0x20<<1
  151. #define SXFER_TP_7 0x30<<1
  152. #define SXFER_TP_8 0x40<<1
  153. #define SXFER_TP_9 0x50<<1
  154. #define SXFER_TP_10 0x60<<1
  155. #define SXFER_TP_11 0x70<<1
  156. #define SXFER_MO3 0x08 /* Max offset msb */
  157. #define SXFER_MO2 0x04
  158. #define SXFER_MO1 0x02
  159. #define SXFER_MO0 0x01 /* lsb */
  160. #define SXFER_MO_MASK 0x0f
  161. #define SXFER_MO_SHIFT 0
  162. /*
  163. * SCSI output data latch rw
  164. * The contents of this register are driven onto the SCSI bus when
  165. * the Assert Data Bus bit of the SCNTL1 register is set and
  166. * the CD, IO, and MSG bits of the SOCL register match the SCSI phase
  167. */
  168. #define SODL_REG_700 0x06
  169. #define SODL_REG_800 0x54
  170. /*
  171. * SCSI output control latch rw, default = 0
  172. * Note that when the chip is being manually programmed as an initiator,
  173. * the MSG, CD, and IO bits must be set correctly for the phase the target
  174. * is driving the bus in. Otherwise no data transfer will occur due to
  175. * phase mismatch.
  176. */
  177. #define SOCL_REG 0x07
  178. #define SOCL_REQ 0x80 /* REQ */
  179. #define SOCL_ACK 0x40 /* ACK */
  180. #define SOCL_BSY 0x20 /* BSY */
  181. #define SOCL_SEL 0x10 /* SEL */
  182. #define SOCL_ATN 0x08 /* ATN */
  183. #define SOCL_MSG 0x04 /* MSG */
  184. #define SOCL_CD 0x02 /* C/D */
  185. #define SOCL_IO 0x01 /* I/O */
  186. /*
  187. * SCSI first byte received latch ro
  188. * This register contains the first byte received during a block MOVE
  189. * SCSI SCRIPTS instruction, including
  190. *
  191. * Initiator mode Target mode
  192. * Message in Command
  193. * Status Message out
  194. * Data in Data out
  195. *
  196. * It also contains the selecting or reselecting device's ID and our
  197. * ID.
  198. *
  199. * Note that this is the register the various IF conditionals can
  200. * operate on.
  201. */
  202. #define SFBR_REG 0x08
  203. /*
  204. * SCSI input data latch ro
  205. * In initiator mode, data is latched into this register on the rising
  206. * edge of REQ/. In target mode, data is latched on the rising edge of
  207. * ACK/
  208. */
  209. #define SIDL_REG_700 0x09
  210. #define SIDL_REG_800 0x50
  211. /*
  212. * SCSI bus data lines ro
  213. * This register reflects the instantaneous status of the SCSI data
  214. * lines. Note that SCNTL0 must be set to disable parity checking,
  215. * otherwise reading this register will latch new parity.
  216. */
  217. #define SBDL_REG_700 0x0a
  218. #define SBDL_REG_800 0x58
  219. #define SSID_REG_800 0x0a
  220. #define SSID_800_VAL 0x80 /* Exactly two bits asserted at sel */
  221. #define SSID_800_ENCID_MASK 0x07 /* Device which performed operation */
  222. /*
  223. * SCSI bus control lines rw,
  224. * instantaneous readout of control lines
  225. */
  226. #define SBCL_REG 0x0b
  227. #define SBCL_REQ 0x80 /* REQ ro */
  228. #define SBCL_ACK 0x40 /* ACK ro */
  229. #define SBCL_BSY 0x20 /* BSY ro */
  230. #define SBCL_SEL 0x10 /* SEL ro */
  231. #define SBCL_ATN 0x08 /* ATN ro */
  232. #define SBCL_MSG 0x04 /* MSG ro */
  233. #define SBCL_CD 0x02 /* C/D ro */
  234. #define SBCL_IO 0x01 /* I/O ro */
  235. #define SBCL_PHASE_CMDOUT SBCL_CD
  236. #define SBCL_PHASE_DATAIN SBCL_IO
  237. #define SBCL_PHASE_DATAOUT 0
  238. #define SBCL_PHASE_MSGIN (SBCL_CD|SBCL_IO|SBCL_MSG)
  239. #define SBCL_PHASE_MSGOUT (SBCL_CD|SBCL_MSG)
  240. #define SBCL_PHASE_STATIN (SBCL_CD|SBCL_IO)
  241. #define SBCL_PHASE_MASK (SBCL_CD|SBCL_IO|SBCL_MSG)
  242. /*
  243. * Synchronous SCSI Clock Control bits
  244. * 0 - set by DCNTL
  245. * 1 - SCLK / 1.0
  246. * 2 - SCLK / 1.5
  247. * 3 - SCLK / 2.0
  248. */
  249. #define SBCL_SSCF1 0x02 /* wo, -66 only */
  250. #define SBCL_SSCF0 0x01 /* wo, -66 only */
  251. #define SBCL_SSCF_MASK 0x03
  252. /*
  253. * XXX note : when reading the DSTAT and STAT registers to clear interrupts,
  254. * insure that 10 clocks elapse between the two
  255. */
  256. /* DMA status ro */
  257. #define DSTAT_REG 0x0c
  258. #define DSTAT_DFE 0x80 /* DMA FIFO empty */
  259. #define DSTAT_800_MDPE 0x40 /* Master Data Parity Error */
  260. #define DSTAT_800_BF 0x20 /* Bus Fault */
  261. #define DSTAT_ABRT 0x10 /* Aborted - set on error */
  262. #define DSTAT_SSI 0x08 /* SCRIPTS single step interrupt */
  263. #define DSTAT_SIR 0x04 /* SCRIPTS interrupt received -
  264. set when INT instruction is
  265. executed */
  266. #define DSTAT_WTD 0x02 /* Watchdog timeout detected */
  267. #define DSTAT_OPC 0x01 /* Illegal instruction */
  268. #define DSTAT_800_IID 0x01 /* Same thing, different name */
  269. /* NCR53c800 moves this stuff into SIST0 */
  270. #define SSTAT0_REG 0x0d /* SCSI status 0 ro */
  271. #define SIST0_REG_800 0x42
  272. #define SSTAT0_MA 0x80 /* ini : phase mismatch,
  273. * tgt : ATN/ asserted
  274. */
  275. #define SSTAT0_CMP 0x40 /* function complete */
  276. #define SSTAT0_700_STO 0x20 /* Selection or reselection timeout */
  277. #define SIST0_800_SEL 0x20 /* Selected */
  278. #define SSTAT0_700_SEL 0x10 /* Selected or reselected */
  279. #define SIST0_800_RSL 0x10 /* Reselected */
  280. #define SSTAT0_SGE 0x08 /* SCSI gross error */
  281. #define SSTAT0_UDC 0x04 /* Unexpected disconnect */
  282. #define SSTAT0_RST 0x02 /* SCSI RST/ received */
  283. #define SSTAT0_PAR 0x01 /* Parity error */
  284. /* And uses SSTAT0 for what was SSTAT1 */
  285. #define SSTAT1_REG 0x0e /* SCSI status 1 ro */
  286. #define SSTAT1_ILF 0x80 /* SIDL full */
  287. #define SSTAT1_ORF 0x40 /* SODR full */
  288. #define SSTAT1_OLF 0x20 /* SODL full */
  289. #define SSTAT1_AIP 0x10 /* Arbitration in progress */
  290. #define SSTAT1_LOA 0x08 /* Lost arbitration */
  291. #define SSTAT1_WOA 0x04 /* Won arbitration */
  292. #define SSTAT1_RST 0x02 /* Instant readout of RST/ */
  293. #define SSTAT1_SDP 0x01 /* Instant readout of SDP/ */
  294. #define SSTAT2_REG 0x0f /* SCSI status 2 ro */
  295. #define SSTAT2_FF3 0x80 /* number of bytes in synchronous */
  296. #define SSTAT2_FF2 0x40 /* data FIFO */
  297. #define SSTAT2_FF1 0x20
  298. #define SSTAT2_FF0 0x10
  299. #define SSTAT2_FF_MASK 0xf0
  300. #define SSTAT2_FF_SHIFT 4
  301. /*
  302. * Latched signals, latched on the leading edge of REQ/ for initiators,
  303. * ACK/ for targets.
  304. */
  305. #define SSTAT2_SDP 0x08 /* SDP */
  306. #define SSTAT2_MSG 0x04 /* MSG */
  307. #define SSTAT2_CD 0x02 /* C/D */
  308. #define SSTAT2_IO 0x01 /* I/O */
  309. #define SSTAT2_PHASE_CMDOUT SSTAT2_CD
  310. #define SSTAT2_PHASE_DATAIN SSTAT2_IO
  311. #define SSTAT2_PHASE_DATAOUT 0
  312. #define SSTAT2_PHASE_MSGIN (SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
  313. #define SSTAT2_PHASE_MSGOUT (SSTAT2_CD|SSTAT2_MSG)
  314. #define SSTAT2_PHASE_STATIN (SSTAT2_CD|SSTAT2_IO)
  315. #define SSTAT2_PHASE_MASK (SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
  316. /* NCR53c700-66 only */
  317. #define SCRATCHA_REG_00 0x10 /* through 0x13 Scratch A rw */
  318. /* NCR53c710 and higher */
  319. #define DSA_REG 0x10 /* DATA structure address */
  320. #define CTEST0_REG_700 0x14 /* Chip test 0 ro */
  321. #define CTEST0_REG_800 0x18 /* Chip test 0 rw, general purpose */
  322. /* 0x80 - 0x04 are reserved */
  323. #define CTEST0_700_RTRG 0x02 /* Real target mode */
  324. #define CTEST0_700_DDIR 0x01 /* Data direction, 1 =
  325. * SCSI bus to host, 0 =
  326. * host to SCSI.
  327. */
  328. #define CTEST1_REG_700 0x15 /* Chip test 1 ro */
  329. #define CTEST1_REG_800 0x19 /* Chip test 1 ro */
  330. #define CTEST1_FMT3 0x80 /* Identify which byte lanes are empty */
  331. #define CTEST1_FMT2 0x40 /* in the DMA FIFO */
  332. #define CTEST1_FMT1 0x20
  333. #define CTEST1_FMT0 0x10
  334. #define CTEST1_FFL3 0x08 /* Identify which bytes lanes are full */
  335. #define CTEST1_FFL2 0x04 /* in the DMA FIFO */
  336. #define CTEST1_FFL1 0x02
  337. #define CTEST1_FFL0 0x01
  338. #define CTEST2_REG_700 0x16 /* Chip test 2 ro */
  339. #define CTEST2_REG_800 0x1a /* Chip test 2 ro */
  340. #define CTEST2_800_DDIR 0x80 /* 1 = SCSI->host */
  341. #define CTEST2_800_SIGP 0x40 /* A copy of SIGP in ISTAT.
  342. Reading this register clears */
  343. #define CTEST2_800_CIO 0x20 /* Configured as IO */.
  344. #define CTEST2_800_CM 0x10 /* Configured as memory */
  345. /* 0x80 - 0x40 are reserved on 700 series chips */
  346. #define CTEST2_700_SOFF 0x20 /* SCSI Offset Compare,
  347. * As an initiator, this bit is
  348. * one when the synchronous offset
  349. * is zero, as a target this bit
  350. * is one when the synchronous
  351. * offset is at the maximum
  352. * defined in SXFER
  353. */
  354. #define CTEST2_700_SFP 0x10 /* SCSI FIFO parity bit,
  355. * reading CTEST3 unloads a byte
  356. * from the FIFO and sets this
  357. */
  358. #define CTEST2_700_DFP 0x08 /* DMA FIFO parity bit,
  359. * reading CTEST6 unloads a byte
  360. * from the FIFO and sets this
  361. */
  362. #define CTEST2_TEOP 0x04 /* SCSI true end of process,
  363. * indicates a totally finished
  364. * transfer
  365. */
  366. #define CTEST2_DREQ 0x02 /* Data request signal */
  367. /* 0x01 is reserved on 700 series chips */
  368. #define CTEST2_800_DACK 0x01
  369. /*
  370. * Chip test 3 ro
  371. * Unloads the bottom byte of the eight deep SCSI synchronous FIFO,
  372. * check SSTAT2 FIFO full bits to determine size. Note that a GROSS
  373. * error results if a read is attempted on this register. Also note
  374. * that 16 and 32 bit reads of this register will cause corruption.
  375. */
  376. #define CTEST3_REG_700 0x17
  377. /* Chip test 3 rw */
  378. #define CTEST3_REG_800 0x1b
  379. #define CTEST3_800_V3 0x80 /* Chip revision */
  380. #define CTEST3_800_V2 0x40
  381. #define CTEST3_800_V1 0x20
  382. #define CTEST3_800_V0 0x10
  383. #define CTEST3_800_FLF 0x08 /* Flush DMA FIFO */
  384. #define CTEST3_800_CLF 0x04 /* Clear DMA FIFO */
  385. #define CTEST3_800_FM 0x02 /* Fetch mode pin */
  386. /* bit 0 is reserved on 800 series chips */
  387. #define CTEST4_REG_700 0x18 /* Chip test 4 rw */
  388. #define CTEST4_REG_800 0x21 /* Chip test 4 rw */
  389. /* 0x80 is reserved on 700 series chips */
  390. #define CTEST4_800_BDIS 0x80 /* Burst mode disable */
  391. #define CTEST4_ZMOD 0x40 /* High impedance mode */
  392. #define CTEST4_SZM 0x20 /* SCSI bus high impedance */
  393. #define CTEST4_700_SLBE 0x10 /* SCSI loopback enabled */
  394. #define CTEST4_800_SRTM 0x10 /* Shadow Register Test Mode */
  395. #define CTEST4_700_SFWR 0x08 /* SCSI FIFO write enable,
  396. * redirects writes from SODL
  397. * to the SCSI FIFO.
  398. */
  399. #define CTEST4_800_MPEE 0x08 /* Enable parity checking
  400. during master cycles on PCI
  401. bus */
  402. /*
  403. * These bits send the contents of the CTEST6 register to the appropriate
  404. * byte lane of the 32 bit DMA FIFO. Normal operation is zero, otherwise
  405. * the high bit means the low two bits select the byte lane.
  406. */
  407. #define CTEST4_FBL2 0x04
  408. #define CTEST4_FBL1 0x02
  409. #define CTEST4_FBL0 0x01
  410. #define CTEST4_FBL_MASK 0x07
  411. #define CTEST4_FBL_0 0x04 /* Select DMA FIFO byte lane 0 */
  412. #define CTEST4_FBL_1 0x05 /* Select DMA FIFO byte lane 1 */
  413. #define CTEST4_FBL_2 0x06 /* Select DMA FIFO byte lane 2 */
  414. #define CTEST4_FBL_3 0x07 /* Select DMA FIFO byte lane 3 */
  415. #define CTEST4_800_SAVE (CTEST4_800_BDIS)
  416. #define CTEST5_REG_700 0x19 /* Chip test 5 rw */
  417. #define CTEST5_REG_800 0x22 /* Chip test 5 rw */
  418. /*
  419. * Clock Address Incrementor. When set, it increments the
  420. * DNAD register to the next bus size boundary. It automatically
  421. * resets itself when the operation is complete.
  422. */
  423. #define CTEST5_ADCK 0x80
  424. /*
  425. * Clock Byte Counter. When set, it decrements the DBC register to
  426. * the next bus size boundary.
  427. */
  428. #define CTEST5_BBCK 0x40
  429. /*
  430. * Reset SCSI Offset. Setting this bit to 1 clears the current offset
  431. * pointer in the SCSI synchronous offset counter (SSTAT). This bit
  432. * is set to 1 if a SCSI Gross Error Condition occurs. The offset should
  433. * be cleared when a synchronous transfer fails. When written, it is
  434. * automatically cleared after the SCSI synchronous offset counter is
  435. * reset.
  436. */
  437. /* Bit 5 is reserved on 800 series chips */
  438. #define CTEST5_700_ROFF 0x20
  439. /*
  440. * Master Control for Set or Reset pulses. When 1, causes the low
  441. * four bits of register to set when set, 0 causes the low bits to
  442. * clear when set.
  443. */
  444. #define CTEST5_MASR 0x10
  445. #define CTEST5_DDIR 0x08 /* DMA direction */
  446. /*
  447. * Bits 2-0 are reserved on 800 series chips
  448. */
  449. #define CTEST5_700_EOP 0x04 /* End of process */
  450. #define CTEST5_700_DREQ 0x02 /* Data request */
  451. #define CTEST5_700_DACK 0x01 /* Data acknowledge */
  452. /*
  453. * Chip test 6 rw - writing to this register writes to the byte
  454. * lane in the DMA FIFO as determined by the FBL bits in the CTEST4
  455. * register.
  456. */
  457. #define CTEST6_REG_700 0x1a
  458. #define CTEST6_REG_800 0x23
  459. #define CTEST7_REG 0x1b /* Chip test 7 rw */
  460. /* 0x80 - 0x40 are reserved on NCR53c700 and NCR53c700-66 chips */
  461. #define CTEST7_10_CDIS 0x80 /* Cache burst disable */
  462. #define CTEST7_10_SC1 0x40 /* Snoop control bits */
  463. #define CTEST7_10_SC0 0x20
  464. #define CTEST7_10_SC_MASK 0x60
  465. /* 0x20 is reserved on the NCR53c700 */
  466. #define CTEST7_0060_FM 0x20 /* Fetch mode */
  467. #define CTEST7_STD 0x10 /* Selection timeout disable */
  468. #define CTEST7_DFP 0x08 /* DMA FIFO parity bit for CTEST6 */
  469. #define CTEST7_EVP 0x04 /* 1 = host bus even parity, 0 = odd */
  470. #define CTEST7_10_TT1 0x02 /* Transfer type */
  471. #define CTEST7_00_DC 0x02 /* Set to drive DC low during instruction
  472. fetch */
  473. #define CTEST7_DIFF 0x01 /* Differential mode */
  474. #define CTEST7_SAVE ( CTEST7_EVP | CTEST7_DIFF )
  475. #define TEMP_REG 0x1c /* through 0x1f Temporary stack rw */
  476. #define DFIFO_REG 0x20 /* DMA FIFO rw */
  477. /*
  478. * 0x80 is reserved on the NCR53c710, the CLF and FLF bits have been
  479. * moved into the CTEST8 register.
  480. */
  481. #define DFIFO_00_FLF 0x80 /* Flush DMA FIFO to memory */
  482. #define DFIFO_00_CLF 0x40 /* Clear DMA and SCSI FIFOs */
  483. #define DFIFO_BO6 0x40
  484. #define DFIFO_BO5 0x20
  485. #define DFIFO_BO4 0x10
  486. #define DFIFO_BO3 0x08
  487. #define DFIFO_BO2 0x04
  488. #define DFIFO_BO1 0x02
  489. #define DFIFO_BO0 0x01
  490. #define DFIFO_10_BO_MASK 0x7f /* 7 bit counter */
  491. #define DFIFO_00_BO_MASK 0x3f /* 6 bit counter */
  492. /*
  493. * Interrupt status rw
  494. * Note that this is the only register which can be read while SCSI
  495. * SCRIPTS are being executed.
  496. */
  497. #define ISTAT_REG_700 0x21
  498. #define ISTAT_REG_800 0x14
  499. #define ISTAT_ABRT 0x80 /* Software abort, write
  500. *1 to abort, wait for interrupt. */
  501. /* 0x40 and 0x20 are reserved on NCR53c700 and NCR53c700-66 chips */
  502. #define ISTAT_10_SRST 0x40 /* software reset */
  503. #define ISTAT_10_SIGP 0x20 /* signal script */
  504. /* 0x10 is reserved on NCR53c700 series chips */
  505. #define ISTAT_800_SEM 0x10 /* semaphore */
  506. #define ISTAT_CON 0x08 /* 1 when connected */
  507. #define ISTAT_800_INTF 0x04 /* Interrupt on the fly */
  508. #define ISTAT_700_PRE 0x04 /* Pointer register empty.
  509. * Set to 1 when DSPS and DSP
  510. * registers are empty in pipeline
  511. * mode, always set otherwise.
  512. */
  513. #define ISTAT_SIP 0x02 /* SCSI interrupt pending from
  514. * SCSI portion of SIOP see
  515. * SSTAT0
  516. */
  517. #define ISTAT_DIP 0x01 /* DMA interrupt pending
  518. * see DSTAT
  519. */
  520. /* NCR53c700-66 and NCR53c710 only */
  521. #define CTEST8_REG 0x22 /* Chip test 8 rw */
  522. #define CTEST8_0066_EAS 0x80 /* Enable alternate SCSI clock,
  523. * ie read from SCLK/ rather than CLK/
  524. */
  525. #define CTEST8_0066_EFM 0x40 /* Enable fetch and master outputs */
  526. #define CTEST8_0066_GRP 0x20 /* Generate Receive Parity for
  527. * pass through. This insures that
  528. * bad parity won't reach the host
  529. * bus.
  530. */
  531. #define CTEST8_0066_TE 0x10 /* TolerANT enable. Enable
  532. * active negation, should only
  533. * be used for slow SCSI
  534. * non-differential.
  535. */
  536. #define CTEST8_0066_HSC 0x08 /* Halt SCSI clock */
  537. #define CTEST8_0066_SRA 0x04 /* Shorten REQ/ACK filtering,
  538. * must be set for fast SCSI-II
  539. * speeds.
  540. */
  541. #define CTEST8_0066_DAS 0x02 /* Disable automatic target/initiator
  542. * switching.
  543. */
  544. #define CTEST8_0066_LDE 0x01 /* Last disconnect enable.
  545. * The status of pending
  546. * disconnect is maintained by
  547. * the core, eliminating
  548. * the possibility of missing a
  549. * selection or reselection
  550. * while waiting to fetch a
  551. * WAIT DISCONNECT opcode.
  552. */
  553. #define CTEST8_10_V3 0x80 /* Chip revision */
  554. #define CTEST8_10_V2 0x40
  555. #define CTEST8_10_V1 0x20
  556. #define CTEST8_10_V0 0x10
  557. #define CTEST8_10_V_MASK 0xf0
  558. #define CTEST8_10_FLF 0x08 /* Flush FIFOs */
  559. #define CTEST8_10_CLF 0x04 /* Clear FIFOs */
  560. #define CTEST8_10_FM 0x02 /* Fetch pin mode */
  561. #define CTEST8_10_SM 0x01 /* Snoop pin mode */
  562. /*
  563. * The CTEST9 register may be used to differentiate between a
  564. * NCR53c700 and a NCR53c710.
  565. *
  566. * Write 0xff to this register.
  567. * Read it.
  568. * If the contents are 0xff, it is a NCR53c700
  569. * If the contents are 0x00, it is a NCR53c700-66 first revision
  570. * If the contents are some other value, it is some other NCR53c700-66
  571. */
  572. #define CTEST9_REG_00 0x23 /* Chip test 9 ro */
  573. #define LCRC_REG_10 0x23
  574. /*
  575. * 0x24 through 0x27 are the DMA byte counter register. Instructions
  576. * write their high 8 bits into the DCMD register, the low 24 bits into
  577. * the DBC register.
  578. *
  579. * Function is dependent on the command type being executed.
  580. */
  581. #define DBC_REG 0x24
  582. /*
  583. * For Block Move Instructions, DBC is a 24 bit quantity representing
  584. * the number of bytes to transfer.
  585. * For Transfer Control Instructions, DBC is bit fielded as follows :
  586. */
  587. /* Bits 20 - 23 should be clear */
  588. #define DBC_TCI_TRUE (1 << 19) /* Jump when true */
  589. #define DBC_TCI_COMPARE_DATA (1 << 18) /* Compare data */
  590. #define DBC_TCI_COMPARE_PHASE (1 << 17) /* Compare phase with DCMD field */
  591. #define DBC_TCI_WAIT_FOR_VALID (1 << 16) /* Wait for REQ */
  592. /* Bits 8 - 15 are reserved on some implementations ? */
  593. #define DBC_TCI_MASK_MASK 0xff00 /* Mask for data compare */
  594. #define DBC_TCI_MASK_SHIFT 8
  595. #define DBC_TCI_DATA_MASK 0xff /* Data to be compared */
  596. #define DBC_TCI_DATA_SHIFT 0
  597. #define DBC_RWRI_IMMEDIATE_MASK 0xff00 /* Immediate data */
  598. #define DBC_RWRI_IMMEDIATE_SHIFT 8 /* Amount to shift */
  599. #define DBC_RWRI_ADDRESS_MASK 0x3f0000 /* Register address */
  600. #define DBC_RWRI_ADDRESS_SHIFT 16
  601. /*
  602. * DMA command r/w
  603. */
  604. #define DCMD_REG 0x27
  605. #define DCMD_TYPE_MASK 0xc0 /* Masks off type */
  606. #define DCMD_TYPE_BMI 0x00 /* Indicates a Block Move instruction */
  607. #define DCMD_BMI_IO 0x01 /* I/O, CD, and MSG bits selecting */
  608. #define DCMD_BMI_CD 0x02 /* the phase for the block MOVE */
  609. #define DCMD_BMI_MSG 0x04 /* instruction */
  610. #define DCMD_BMI_OP_MASK 0x18 /* mask for opcode */
  611. #define DCMD_BMI_OP_MOVE_T 0x00 /* MOVE */
  612. #define DCMD_BMI_OP_MOVE_I 0x08 /* MOVE Initiator */
  613. #define DCMD_BMI_INDIRECT 0x20 /* Indirect addressing */
  614. #define DCMD_TYPE_TCI 0x80 /* Indicates a Transfer Control
  615. instruction */
  616. #define DCMD_TCI_IO 0x01 /* I/O, CD, and MSG bits selecting */
  617. #define DCMD_TCI_CD 0x02 /* the phase for the block MOVE */
  618. #define DCMD_TCI_MSG 0x04 /* instruction */
  619. #define DCMD_TCI_OP_MASK 0x38 /* mask for opcode */
  620. #define DCMD_TCI_OP_JUMP 0x00 /* JUMP */
  621. #define DCMD_TCI_OP_CALL 0x08 /* CALL */
  622. #define DCMD_TCI_OP_RETURN 0x10 /* RETURN */
  623. #define DCMD_TCI_OP_INT 0x18 /* INT */
  624. #define DCMD_TYPE_RWRI 0x40 /* Indicates I/O or register Read/Write
  625. instruction */
  626. #define DCMD_RWRI_OPC_MASK 0x38 /* Opcode mask */
  627. #define DCMD_RWRI_OPC_WRITE 0x28 /* Write SFBR to register */
  628. #define DCMD_RWRI_OPC_READ 0x30 /* Read register to SFBR */
  629. #define DCMD_RWRI_OPC_MODIFY 0x38 /* Modify in place */
  630. #define DCMD_RWRI_OP_MASK 0x07
  631. #define DCMD_RWRI_OP_MOVE 0x00
  632. #define DCMD_RWRI_OP_SHL 0x01
  633. #define DCMD_RWRI_OP_OR 0x02
  634. #define DCMD_RWRI_OP_XOR 0x03
  635. #define DCMD_RWRI_OP_AND 0x04
  636. #define DCMD_RWRI_OP_SHR 0x05
  637. #define DCMD_RWRI_OP_ADD 0x06
  638. #define DCMD_RWRI_OP_ADDC 0x07
  639. #define DCMD_TYPE_MMI 0xc0 /* Indicates a Memory Move instruction
  640. (three words) */
  641. #define DNAD_REG 0x28 /* through 0x2b DMA next address for
  642. data */
  643. #define DSP_REG 0x2c /* through 0x2f DMA SCRIPTS pointer rw */
  644. #define DSPS_REG 0x30 /* through 0x33 DMA SCRIPTS pointer
  645. save rw */
  646. #define DMODE_REG_00 0x34 /* DMA mode rw */
  647. #define DMODE_00_BL1 0x80 /* Burst length bits */
  648. #define DMODE_00_BL0 0x40
  649. #define DMODE_BL_MASK 0xc0
  650. /* Burst lengths (800) */
  651. #define DMODE_BL_2 0x00 /* 2 transfer */
  652. #define DMODE_BL_4 0x40 /* 4 transfers */
  653. #define DMODE_BL_8 0x80 /* 8 transfers */
  654. #define DMODE_BL_16 0xc0 /* 16 transfers */
  655. #define DMODE_10_BL_1 0x00 /* 1 transfer */
  656. #define DMODE_10_BL_2 0x40 /* 2 transfers */
  657. #define DMODE_10_BL_4 0x80 /* 4 transfers */
  658. #define DMODE_10_BL_8 0xc0 /* 8 transfers */
  659. #define DMODE_10_FC2 0x20 /* Driven to FC2 pin */
  660. #define DMODE_10_FC1 0x10 /* Driven to FC1 pin */
  661. #define DMODE_710_PD 0x08 /* Program/data on FC0 pin */
  662. #define DMODE_710_UO 0x02 /* User prog. output */
  663. #define DMODE_700_BW16 0x20 /* Host buswidth = 16 */
  664. #define DMODE_700_286 0x10 /* 286 mode */
  665. #define DMODE_700_IOM 0x08 /* Transfer to IO port */
  666. #define DMODE_700_FAM 0x04 /* Fixed address mode */
  667. #define DMODE_700_PIPE 0x02 /* Pipeline mode disables
  668. * automatic fetch / exec
  669. */
  670. #define DMODE_MAN 0x01 /* Manual start mode,
  671. * requires a 1 to be written
  672. * to the start DMA bit in the DCNTL
  673. * register to run scripts
  674. */
  675. #define DMODE_700_SAVE ( DMODE_00_BL_MASK | DMODE_00_BW16 | DMODE_00_286 )
  676. /* NCR53c800 series only */
  677. #define SCRATCHA_REG_800 0x34 /* through 0x37 Scratch A rw */
  678. /* NCR53c710 only */
  679. #define SCRATCHB_REG_10 0x34 /* through 0x37 scratch B rw */
  680. #define DMODE_REG_10 0x38 /* DMA mode rw, NCR53c710 and newer */
  681. #define DMODE_800_SIOM 0x20 /* Source IO = 1 */
  682. #define DMODE_800_DIOM 0x10 /* Destination IO = 1 */
  683. #define DMODE_800_ERL 0x08 /* Enable Read Line */
  684. /* 35-38 are reserved on 700 and 700-66 series chips */
  685. #define DIEN_REG 0x39 /* DMA interrupt enable rw */
  686. /* 0x80, 0x40, and 0x20 are reserved on 700-series chips */
  687. #define DIEN_800_MDPE 0x40 /* Master data parity error */
  688. #define DIEN_800_BF 0x20 /* BUS fault */
  689. #define DIEN_700_BF 0x20 /* BUS fault */
  690. #define DIEN_ABRT 0x10 /* Enable aborted interrupt */
  691. #define DIEN_SSI 0x08 /* Enable single step interrupt */
  692. #define DIEN_SIR 0x04 /* Enable SCRIPTS INT command
  693. * interrupt
  694. */
  695. /* 0x02 is reserved on 800 series chips */
  696. #define DIEN_700_WTD 0x02 /* Enable watchdog timeout interrupt */
  697. #define DIEN_700_OPC 0x01 /* Enable illegal instruction
  698. * interrupt
  699. */
  700. #define DIEN_800_IID 0x01 /* Same meaning, different name */
  701. /*
  702. * DMA watchdog timer rw
  703. * set in 16 CLK input periods.
  704. */
  705. #define DWT_REG 0x3a
  706. /* DMA control rw */
  707. #define DCNTL_REG 0x3b
  708. #define DCNTL_700_CF1 0x80 /* Clock divisor bits */
  709. #define DCNTL_700_CF0 0x40
  710. #define DCNTL_700_CF_MASK 0xc0
  711. /* Clock divisors Divisor SCLK range (MHZ) */
  712. #define DCNTL_700_CF_2 0x00 /* 2.0 37.51-50.00 */
  713. #define DCNTL_700_CF_1_5 0x40 /* 1.5 25.01-37.50 */
  714. #define DCNTL_700_CF_1 0x80 /* 1.0 16.67-25.00 */
  715. #define DCNTL_700_CF_3 0xc0 /* 3.0 50.01-66.67 (53c700-66) */
  716. #define DCNTL_700_S16 0x20 /* Load scripts 16 bits at a time */
  717. #define DCNTL_SSM 0x10 /* Single step mode */
  718. #define DCNTL_700_LLM 0x08 /* Low level mode, can only be set
  719. * after selection */
  720. #define DCNTL_800_IRQM 0x08 /* Totem pole IRQ pin */
  721. #define DCNTL_STD 0x04 /* Start DMA / SCRIPTS */
  722. /* 0x02 is reserved */
  723. #define DCNTL_00_RST 0x01 /* Software reset, resets everything
  724. * but 286 mode bit in DMODE. On the
  725. * NCR53c710, this bit moved to CTEST8
  726. */
  727. #define DCNTL_10_COM 0x01 /* 700 software compatibility mode */
  728. #define DCNTL_10_EA 0x20 /* Enable Ack - needed for MVME16x */
  729. #define DCNTL_700_SAVE ( DCNTL_CF_MASK | DCNTL_S16)
  730. /* NCR53c700-66 only */
  731. #define SCRATCHB_REG_00 0x3c /* through 0x3f scratch b rw */
  732. #define SCRATCHB_REG_800 0x5c /* through 0x5f scratch b rw */
  733. /* NCR53c710 only */
  734. #define ADDER_REG_10 0x3c /* Adder, NCR53c710 only */
  735. #define SIEN1_REG_800 0x41
  736. #define SIEN1_800_STO 0x04 /* selection/reselection timeout */
  737. #define SIEN1_800_GEN 0x02 /* general purpose timer */
  738. #define SIEN1_800_HTH 0x01 /* handshake to handshake */
  739. #define SIST1_REG_800 0x43
  740. #define SIST1_800_STO 0x04 /* selection/reselection timeout */
  741. #define SIST1_800_GEN 0x02 /* general purpose timer */
  742. #define SIST1_800_HTH 0x01 /* handshake to handshake */
  743. #define SLPAR_REG_800 0x44 /* Parity */
  744. #define MACNTL_REG_800 0x46 /* Memory access control */
  745. #define MACNTL_800_TYP3 0x80
  746. #define MACNTL_800_TYP2 0x40
  747. #define MACNTL_800_TYP1 0x20
  748. #define MACNTL_800_TYP0 0x10
  749. #define MACNTL_800_DWR 0x08
  750. #define MACNTL_800_DRD 0x04
  751. #define MACNTL_800_PSCPT 0x02
  752. #define MACNTL_800_SCPTS 0x01
  753. #define GPCNTL_REG_800 0x47 /* General Purpose Pin Control */
  754. /* Timeouts are expressed such that 0=off, 1=100us, doubling after that */
  755. #define STIME0_REG_800 0x48 /* SCSI Timer Register 0 */
  756. #define STIME0_800_HTH_MASK 0xf0 /* Handshake to Handshake timeout */
  757. #define STIME0_800_HTH_SHIFT 4
  758. #define STIME0_800_SEL_MASK 0x0f /* Selection timeout */
  759. #define STIME0_800_SEL_SHIFT 0
  760. #define STIME1_REG_800 0x49
  761. #define STIME1_800_GEN_MASK 0x0f /* General purpose timer */
  762. #define RESPID_REG_800 0x4a /* Response ID, bit fielded. 8
  763. bits on narrow chips, 16 on WIDE */
  764. #define STEST0_REG_800 0x4c
  765. #define STEST0_800_SLT 0x08 /* Selection response logic test */
  766. #define STEST0_800_ART 0x04 /* Arbitration priority encoder test */
  767. #define STEST0_800_SOZ 0x02 /* Synchronous offset zero */
  768. #define STEST0_800_SOM 0x01 /* Synchronous offset maximum */
  769. #define STEST1_REG_800 0x4d
  770. #define STEST1_800_SCLK 0x80 /* Disable SCSI clock */
  771. #define STEST2_REG_800 0x4e
  772. #define STEST2_800_SCE 0x80 /* Enable SOCL/SODL */
  773. #define STEST2_800_ROF 0x40 /* Reset SCSI sync offset */
  774. #define STEST2_800_SLB 0x10 /* Enable SCSI loopback mode */
  775. #define STEST2_800_SZM 0x08 /* SCSI high impedance mode */
  776. #define STEST2_800_EXT 0x02 /* Extend REQ/ACK filter 30 to 60ns */
  777. #define STEST2_800_LOW 0x01 /* SCSI low level mode */
  778. #define STEST3_REG_800 0x4f
  779. #define STEST3_800_TE 0x80 /* Enable active negation */
  780. #define STEST3_800_STR 0x40 /* SCSI FIFO test read */
  781. #define STEST3_800_HSC 0x20 /* Halt SCSI clock */
  782. #define STEST3_800_DSI 0x10 /* Disable single initiator response */
  783. #define STEST3_800_TTM 0x04 /* Time test mode */
  784. #define STEST3_800_CSF 0x02 /* Clear SCSI FIFO */
  785. #define STEST3_800_STW 0x01 /* SCSI FIFO test write */
  786. #define OPTION_PARITY 0x1 /* Enable parity checking */
  787. #define OPTION_TAGGED_QUEUE 0x2 /* Enable SCSI-II tagged queuing */
  788. #define OPTION_700 0x8 /* Always run NCR53c700 scripts */
  789. #define OPTION_INTFLY 0x10 /* Use INTFLY interrupts */
  790. #define OPTION_DEBUG_INTR 0x20 /* Debug interrupts */
  791. #define OPTION_DEBUG_INIT_ONLY 0x40 /* Run initialization code and
  792. simple test code, return
  793. DID_NO_CONNECT if any SCSI
  794. commands are attempted. */
  795. #define OPTION_DEBUG_READ_ONLY 0x80 /* Return DID_ERROR if any
  796. SCSI write is attempted */
  797. #define OPTION_DEBUG_TRACE 0x100 /* Animated trace mode, print
  798. each address and instruction
  799. executed to debug buffer. */
  800. #define OPTION_DEBUG_SINGLE 0x200 /* stop after executing one
  801. instruction */
  802. #define OPTION_SYNCHRONOUS 0x400 /* Enable sync SCSI. */
  803. #define OPTION_MEMORY_MAPPED 0x800 /* NCR registers have valid
  804. memory mapping */
  805. #define OPTION_IO_MAPPED 0x1000 /* NCR registers have valid
  806. I/O mapping */
  807. #define OPTION_DEBUG_PROBE_ONLY 0x2000 /* Probe only, don't even init */
  808. #define OPTION_DEBUG_TESTS_ONLY 0x4000 /* Probe, init, run selected tests */
  809. #define OPTION_DEBUG_TEST0 0x08000 /* Run test 0 */
  810. #define OPTION_DEBUG_TEST1 0x10000 /* Run test 1 */
  811. #define OPTION_DEBUG_TEST2 0x20000 /* Run test 2 */
  812. #define OPTION_DEBUG_DUMP 0x40000 /* Dump commands */
  813. #define OPTION_DEBUG_TARGET_LIMIT 0x80000 /* Only talk to target+luns specified */
  814. #define OPTION_DEBUG_NCOMMANDS_LIMIT 0x100000 /* Limit the number of commands */
  815. #define OPTION_DEBUG_SCRIPT 0x200000 /* Print when checkpoints are passed */
  816. #define OPTION_DEBUG_FIXUP 0x400000 /* print fixup values */
  817. #define OPTION_DEBUG_DSA 0x800000
  818. #define OPTION_DEBUG_CORRUPTION 0x1000000 /* Detect script corruption */
  819. #define OPTION_DEBUG_SDTR 0x2000000 /* Debug SDTR problem */
  820. #define OPTION_DEBUG_MISMATCH 0x4000000 /* Debug phase mismatches */
  821. #define OPTION_DISCONNECT 0x8000000 /* Allow disconnect */
  822. #define OPTION_DEBUG_DISCONNECT 0x10000000
  823. #define OPTION_ALWAYS_SYNCHRONOUS 0x20000000 /* Negotiate sync. transfers
  824. on power up */
  825. #define OPTION_DEBUG_QUEUES 0x80000000
  826. #define OPTION_DEBUG_ALLOCATION 0x100000000LL
  827. #define OPTION_DEBUG_SYNCHRONOUS 0x200000000LL /* Sanity check SXFER and
  828. SCNTL3 registers */
  829. #define OPTION_NO_ASYNC 0x400000000LL /* Don't automagically send
  830. SDTR for async transfers when
  831. we haven't been told to do
  832. a synchronous transfer. */
  833. #define OPTION_NO_PRINT_RACE 0x800000000LL /* Don't print message when
  834. the reselect/WAIT DISCONNECT
  835. race condition hits */
  836. #if !defined(PERM_OPTIONS)
  837. #define PERM_OPTIONS 0
  838. #endif
  839. /*
  840. * Some data which is accessed by the NCR chip must be 4-byte aligned.
  841. * For some hosts the default is less than that (eg. 68K uses 2-byte).
  842. * Alignment has only been forced where it is important; also if one
  843. * 32 bit structure field is aligned then it is assumed that following
  844. * 32 bit fields are also aligned. Take care when adding fields
  845. * which are other than 32 bit.
  846. */
  847. struct NCR53c7x0_synchronous {
  848. u32 select_indirect /* Value used for indirect selection */
  849. __attribute__ ((aligned (4)));
  850. u32 sscf_710; /* Used to set SSCF bits for 710 */
  851. u32 script[8]; /* Size ?? Script used when target is
  852. reselected */
  853. unsigned char synchronous_want[5]; /* Per target desired SDTR */
  854. /*
  855. * Set_synchronous programs these, select_indirect and current settings after
  856. * int_debug_should show a match.
  857. */
  858. unsigned char sxfer_sanity, scntl3_sanity;
  859. };
  860. #define CMD_FLAG_SDTR 1 /* Initiating synchronous
  861. transfer negotiation */
  862. #define CMD_FLAG_WDTR 2 /* Initiating wide transfer
  863. negotiation */
  864. #define CMD_FLAG_DID_SDTR 4 /* did SDTR */
  865. #define CMD_FLAG_DID_WDTR 8 /* did WDTR */
  866. struct NCR53c7x0_table_indirect {
  867. u32 count;
  868. void *address;
  869. };
  870. enum ncr_event {
  871. EVENT_NONE = 0,
  872. /*
  873. * Order is IMPORTANT, since these must correspond to the event interrupts
  874. * in 53c7,8xx.scr
  875. */
  876. EVENT_ISSUE_QUEUE = 0x5000000, /* 0 Command was added to issue queue */
  877. EVENT_START_QUEUE, /* 1 Command moved to start queue */
  878. EVENT_SELECT, /* 2 Command completed selection */
  879. EVENT_DISCONNECT, /* 3 Command disconnected */
  880. EVENT_RESELECT, /* 4 Command reselected */
  881. EVENT_COMPLETE, /* 5 Command completed */
  882. EVENT_IDLE, /* 6 */
  883. EVENT_SELECT_FAILED, /* 7 */
  884. EVENT_BEFORE_SELECT, /* 8 */
  885. EVENT_RESELECT_FAILED /* 9 */
  886. };
  887. struct NCR53c7x0_event {
  888. enum ncr_event event; /* What type of event */
  889. unsigned char target;
  890. unsigned char lun;
  891. struct timeval time;
  892. u32 *dsa; /* What's in the DSA register now (virt) */
  893. /*
  894. * A few things from that SCSI pid so we know what happened after
  895. * the Scsi_Cmnd structure in question may have disappeared.
  896. */
  897. unsigned long pid; /* The SCSI PID which caused this
  898. event */
  899. unsigned char cmnd[12];
  900. };
  901. /*
  902. * Things in the NCR53c7x0_cmd structure are split into two parts :
  903. *
  904. * 1. A fixed portion, for things which are not accessed directly by static NCR
  905. * code (ie, are referenced only by the Linux side of the driver,
  906. * or only by dynamically generated code).
  907. *
  908. * 2. The DSA portion, for things which are accessed directly by static NCR
  909. * code.
  910. *
  911. * This is a little ugly, but it
  912. * 1. Avoids conflicts between the NCR code's picture of the structure, and
  913. * Linux code's idea of what it looks like.
  914. *
  915. * 2. Minimizes the pain in the Linux side of the code needed
  916. * to calculate real dsa locations for things, etc.
  917. *
  918. */
  919. struct NCR53c7x0_cmd {
  920. void *real; /* Real, unaligned address for
  921. free function */
  922. void (* free)(void *, int); /* Command to deallocate; NULL
  923. for structures allocated with
  924. scsi_register, etc. */
  925. Scsi_Cmnd *cmd; /* Associated Scsi_Cmnd
  926. structure, Scsi_Cmnd points
  927. at NCR53c7x0_cmd using
  928. host_scribble structure */
  929. int size; /* scsi_malloc'd size of this
  930. structure */
  931. int flags; /* CMD_* flags */
  932. unsigned char cmnd[12]; /* CDB, copied from Scsi_Cmnd */
  933. int result; /* Copy to Scsi_Cmnd when done */
  934. struct { /* Private non-cached bounce buffer */
  935. unsigned char buf[256];
  936. u32 addr;
  937. u32 len;
  938. } bounce;
  939. /*
  940. * SDTR and WIDE messages are an either/or affair
  941. * in this message, since we will go into message out and send
  942. * _the whole mess_ without dropping out of message out to
  943. * let the target go into message in after sending the first
  944. * message.
  945. */
  946. unsigned char select[11]; /* Select message, includes
  947. IDENTIFY
  948. (optional) QUEUE TAG
  949. (optional) SDTR or WDTR
  950. */
  951. volatile struct NCR53c7x0_cmd *next; /* Linux maintained lists (free,
  952. running, eventually finished */
  953. u32 *data_transfer_start; /* Start of data transfer routines */
  954. u32 *data_transfer_end; /* Address after end of data transfer o
  955. routines */
  956. /*
  957. * The following three fields were moved from the DSA proper to here
  958. * since only dynamically generated NCR code refers to them, meaning
  959. * we don't need dsa_* absolutes, and it is simpler to let the
  960. * host code refer to them directly.
  961. */
  962. /*
  963. * HARD CODED : residual and saved_residual need to agree with the sizes
  964. * used in NCR53c7,8xx.scr.
  965. *
  966. * FIXME: we want to consider the case where we have odd-length
  967. * scatter/gather buffers and a WIDE transfer, in which case
  968. * we'll need to use the CHAIN MOVE instruction. Ick.
  969. */
  970. u32 residual[6] __attribute__ ((aligned (4)));
  971. /* Residual data transfer which
  972. allows pointer code to work
  973. right.
  974. [0-1] : Conditional call to
  975. appropriate other transfer
  976. routine.
  977. [2-3] : Residual block transfer
  978. instruction.
  979. [4-5] : Jump to instruction
  980. after splice.
  981. */
  982. u32 saved_residual[6]; /* Copy of old residual, so we
  983. can get another partial
  984. transfer and still recover
  985. */
  986. u32 saved_data_pointer; /* Saved data pointer */
  987. u32 dsa_next_addr; /* _Address_ of dsa_next field
  988. in this dsa for RISCy
  989. style constant. */
  990. u32 dsa_addr; /* Address of dsa; RISCy style
  991. constant */
  992. u32 dsa[0]; /* Variable length (depending
  993. on host type, number of scatter /
  994. gather buffers, etc). */
  995. };
  996. struct NCR53c7x0_break {
  997. u32 *address, old_instruction[2];
  998. struct NCR53c7x0_break *next;
  999. unsigned char old_size; /* Size of old instruction */
  1000. };
  1001. /* Indicates that the NCR is not executing code */
  1002. #define STATE_HALTED 0
  1003. /*
  1004. * Indicates that the NCR is executing the wait for select / reselect
  1005. * script. Only used when running NCR53c700 compatible scripts, only
  1006. * state during which an ABORT is _not_ considered an error condition.
  1007. */
  1008. #define STATE_WAITING 1
  1009. /* Indicates that the NCR is executing other code. */
  1010. #define STATE_RUNNING 2
  1011. /*
  1012. * Indicates that the NCR was being aborted.
  1013. */
  1014. #define STATE_ABORTING 3
  1015. /* Indicates that the NCR was successfully aborted. */
  1016. #define STATE_ABORTED 4
  1017. /* Indicates that the NCR has been disabled due to a fatal error */
  1018. #define STATE_DISABLED 5
  1019. /*
  1020. * Where knowledge of SCSI SCRIPT(tm) specified values are needed
  1021. * in an interrupt handler, an interrupt handler exists for each
  1022. * different SCSI script so we don't have name space problems.
  1023. *
  1024. * Return values of these handlers are as follows :
  1025. */
  1026. #define SPECIFIC_INT_NOTHING 0 /* don't even restart */
  1027. #define SPECIFIC_INT_RESTART 1 /* restart at the next instruction */
  1028. #define SPECIFIC_INT_ABORT 2 /* recoverable error, abort cmd */
  1029. #define SPECIFIC_INT_PANIC 3 /* unrecoverable error, panic */
  1030. #define SPECIFIC_INT_DONE 4 /* normal command completion */
  1031. #define SPECIFIC_INT_BREAK 5 /* break point encountered */
  1032. struct NCR53c7x0_hostdata {
  1033. int size; /* Size of entire Scsi_Host
  1034. structure */
  1035. int board; /* set to board type, useful if
  1036. we have host specific things,
  1037. ie, a general purpose I/O
  1038. bit is being used to enable
  1039. termination, etc. */
  1040. int chip; /* set to chip type; 700-66 is
  1041. 700-66, rest are last three
  1042. digits of part number */
  1043. char valid_ids[8]; /* Valid SCSI ID's for adapter */
  1044. u32 *dsp; /* dsp to restart with after
  1045. all stacked interrupts are
  1046. handled. */
  1047. unsigned dsp_changed:1; /* Has dsp changed within this
  1048. set of stacked interrupts ? */
  1049. unsigned char dstat; /* Most recent value of dstat */
  1050. unsigned dstat_valid:1;
  1051. unsigned expecting_iid:1; /* Expect IID interrupt */
  1052. unsigned expecting_sto:1; /* Expect STO interrupt */
  1053. /*
  1054. * The code stays cleaner if we use variables with function
  1055. * pointers and offsets that are unique for the different
  1056. * scripts rather than having a slew of switch(hostdata->chip)
  1057. * statements.
  1058. *
  1059. * It also means that the #defines from the SCSI SCRIPTS(tm)
  1060. * don't have to be visible outside of the script-specific
  1061. * instructions, preventing name space pollution.
  1062. */
  1063. void (* init_fixup)(struct Scsi_Host *host);
  1064. void (* init_save_regs)(struct Scsi_Host *host);
  1065. void (* dsa_fixup)(struct NCR53c7x0_cmd *cmd);
  1066. void (* soft_reset)(struct Scsi_Host *host);
  1067. int (* run_tests)(struct Scsi_Host *host);
  1068. /*
  1069. * Called when DSTAT_SIR is set, indicating an interrupt generated
  1070. * by the INT instruction, where values are unique for each SCSI
  1071. * script. Should return one of the SPEC_* values.
  1072. */
  1073. int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
  1074. int dsa_len; /* Size of DSA structure */
  1075. /*
  1076. * Location of DSA fields for the SCSI SCRIPT corresponding to this
  1077. * chip.
  1078. */
  1079. s32 dsa_start;
  1080. s32 dsa_end;
  1081. s32 dsa_next;
  1082. s32 dsa_prev;
  1083. s32 dsa_cmnd;
  1084. s32 dsa_select;
  1085. s32 dsa_msgout;
  1086. s32 dsa_cmdout;
  1087. s32 dsa_dataout;
  1088. s32 dsa_datain;
  1089. s32 dsa_msgin;
  1090. s32 dsa_msgout_other;
  1091. s32 dsa_write_sync;
  1092. s32 dsa_write_resume;
  1093. s32 dsa_check_reselect;
  1094. s32 dsa_status;
  1095. s32 dsa_saved_pointer;
  1096. s32 dsa_jump_dest;
  1097. /*
  1098. * Important entry points that generic fixup code needs
  1099. * to know about, fixed up.
  1100. */
  1101. s32 E_accept_message;
  1102. s32 E_command_complete;
  1103. s32 E_data_transfer;
  1104. s32 E_dsa_code_template;
  1105. s32 E_dsa_code_template_end;
  1106. s32 E_end_data_transfer;
  1107. s32 E_msg_in;
  1108. s32 E_initiator_abort;
  1109. s32 E_other_transfer;
  1110. s32 E_other_in;
  1111. s32 E_other_out;
  1112. s32 E_target_abort;
  1113. s32 E_debug_break;
  1114. s32 E_reject_message;
  1115. s32 E_respond_message;
  1116. s32 E_select;
  1117. s32 E_select_msgout;
  1118. s32 E_test_0;
  1119. s32 E_test_1;
  1120. s32 E_test_2;
  1121. s32 E_test_3;
  1122. s32 E_dsa_zero;
  1123. s32 E_cmdout_cmdout;
  1124. s32 E_wait_reselect;
  1125. s32 E_dsa_code_begin;
  1126. long long options; /* Bitfielded set of options enabled */
  1127. volatile u32 test_completed; /* Test completed */
  1128. int test_running; /* Test currently running */
  1129. s32 test_source
  1130. __attribute__ ((aligned (4)));
  1131. volatile s32 test_dest;
  1132. volatile int state; /* state of driver, only used for
  1133. OPTION_700 */
  1134. unsigned char dmode; /*
  1135. * set to the address of the DMODE
  1136. * register for this chip.
  1137. */
  1138. unsigned char istat; /*
  1139. * set to the address of the ISTAT
  1140. * register for this chip.
  1141. */
  1142. int scsi_clock; /*
  1143. * SCSI clock in HZ. 0 may be used
  1144. * for unknown, although this will
  1145. * disable synchronous negotiation.
  1146. */
  1147. volatile int intrs; /* Number of interrupts */
  1148. volatile int resets; /* Number of SCSI resets */
  1149. unsigned char saved_dmode;
  1150. unsigned char saved_ctest4;
  1151. unsigned char saved_ctest7;
  1152. unsigned char saved_dcntl;
  1153. unsigned char saved_scntl3;
  1154. unsigned char this_id_mask;
  1155. /* Debugger information */
  1156. struct NCR53c7x0_break *breakpoints, /* Linked list of all break points */
  1157. *breakpoint_current; /* Current breakpoint being stepped
  1158. through, NULL if we are running
  1159. normally. */
  1160. #ifdef NCR_DEBUG
  1161. int debug_size; /* Size of debug buffer */
  1162. volatile int debug_count; /* Current data count */
  1163. volatile char *debug_buf; /* Output ring buffer */
  1164. volatile char *debug_write; /* Current write pointer */
  1165. volatile char *debug_read; /* Current read pointer */
  1166. #endif /* def NCR_DEBUG */
  1167. /* XXX - primitive debugging junk, remove when working ? */
  1168. int debug_print_limit; /* Number of commands to print
  1169. out exhaustive debugging
  1170. information for if
  1171. OPTION_DEBUG_DUMP is set */
  1172. unsigned char debug_lun_limit[16]; /* If OPTION_DEBUG_TARGET_LIMIT
  1173. set, puke if commands are sent
  1174. to other target/lun combinations */
  1175. int debug_count_limit; /* Number of commands to execute
  1176. before puking to limit debugging
  1177. output */
  1178. volatile unsigned idle:1; /* set to 1 if idle */
  1179. /*
  1180. * Table of synchronous+wide transfer parameters set on a per-target
  1181. * basis.
  1182. */
  1183. volatile struct NCR53c7x0_synchronous sync[16]
  1184. __attribute__ ((aligned (4)));
  1185. volatile Scsi_Cmnd *issue_queue
  1186. __attribute__ ((aligned (4)));
  1187. /* waiting to be issued by
  1188. Linux driver */
  1189. volatile struct NCR53c7x0_cmd *running_list;
  1190. /* commands running, maintained
  1191. by Linux driver */
  1192. volatile struct NCR53c7x0_cmd *ncrcurrent; /* currently connected
  1193. nexus, ONLY valid for
  1194. NCR53c700/NCR53c700-66
  1195. */
  1196. volatile struct NCR53c7x0_cmd *spare; /* pointer to spare,
  1197. allocated at probe time,
  1198. which we can use for
  1199. initialization */
  1200. volatile struct NCR53c7x0_cmd *free;
  1201. int max_cmd_size; /* Maximum size of NCR53c7x0_cmd
  1202. based on number of
  1203. scatter/gather segments, etc.
  1204. */
  1205. volatile int num_cmds; /* Number of commands
  1206. allocated */
  1207. volatile int extra_allocate;
  1208. volatile unsigned char cmd_allocated[16]; /* Have we allocated commands
  1209. for this target yet? If not,
  1210. do so ASAP */
  1211. volatile unsigned char busy[16][8]; /* number of commands
  1212. executing on each target
  1213. */
  1214. /*
  1215. * Eventually, I'll switch to a coroutine for calling
  1216. * cmd->done(cmd), etc. so that we can overlap interrupt
  1217. * processing with this code for maximum performance.
  1218. */
  1219. volatile struct NCR53c7x0_cmd *finished_queue;
  1220. /* Shared variables between SCRIPT and host driver */
  1221. volatile u32 *schedule
  1222. __attribute__ ((aligned (4))); /* Array of JUMPs to dsa_begin
  1223. routines of various DSAs.
  1224. When not in use, replace
  1225. with jump to next slot */
  1226. volatile unsigned char msg_buf[16]; /* buffer for messages
  1227. other than the command
  1228. complete message */
  1229. /* Per-target default synchronous and WIDE messages */
  1230. volatile unsigned char synchronous_want[16][5];
  1231. volatile unsigned char wide_want[16][4];
  1232. /* Bit fielded set of targets we want to speak synchronously with */
  1233. volatile u16 initiate_sdtr;
  1234. /* Bit fielded set of targets we want to speak wide with */
  1235. volatile u16 initiate_wdtr;
  1236. /* Bit fielded list of targets we've talked to. */
  1237. volatile u16 talked_to;
  1238. /* Array of bit-fielded lun lists that we need to request_sense */
  1239. volatile unsigned char request_sense[16];
  1240. u32 addr_reconnect_dsa_head
  1241. __attribute__ ((aligned (4))); /* RISCy style constant,
  1242. address of following */
  1243. volatile u32 reconnect_dsa_head;
  1244. /* Data identifying nexus we are trying to match during reselection */
  1245. volatile unsigned char reselected_identify; /* IDENTIFY message */
  1246. volatile unsigned char reselected_tag; /* second byte of queue tag
  1247. message or 0 */
  1248. /* These were static variables before we moved them */
  1249. s32 NCR53c7xx_zero
  1250. __attribute__ ((aligned (4)));
  1251. s32 NCR53c7xx_sink;
  1252. u32 NOP_insn;
  1253. char NCR53c7xx_msg_reject;
  1254. char NCR53c7xx_msg_abort;
  1255. char NCR53c7xx_msg_nop;
  1256. /*
  1257. * Following item introduced by RGH to support NCRc710, which is
  1258. * VERY brain-dead when it come to memory moves
  1259. */
  1260. /* DSA save area used only by the NCR chip */
  1261. volatile unsigned long saved2_dsa
  1262. __attribute__ ((aligned (4)));
  1263. volatile unsigned long emulated_intfly
  1264. __attribute__ ((aligned (4)));
  1265. volatile int event_size, event_index;
  1266. volatile struct NCR53c7x0_event *events;
  1267. /* If we need to generate code to kill off the currently connected
  1268. command, this is where we do it. Should have a BMI instruction
  1269. to source or sink the current data, followed by a JUMP
  1270. to abort_connected */
  1271. u32 *abort_script;
  1272. int script_count; /* Size of script in words */
  1273. u32 script[0]; /* Relocated SCSI script */
  1274. };
  1275. #define SCSI_IRQ_NONE 255
  1276. #define DMA_NONE 255
  1277. #define IRQ_AUTO 254
  1278. #define DMA_AUTO 254
  1279. #define BOARD_GENERIC 0
  1280. #define NCR53c7x0_insn_size(insn) \
  1281. (((insn) & DCMD_TYPE_MASK) == DCMD_TYPE_MMI ? 3 : 2)
  1282. #define NCR53c7x0_local_declare() \
  1283. volatile unsigned char *NCR53c7x0_address_memory; \
  1284. unsigned int NCR53c7x0_address_io; \
  1285. int NCR53c7x0_memory_mapped
  1286. #define NCR53c7x0_local_setup(host) \
  1287. NCR53c7x0_address_memory = (void *) (host)->base; \
  1288. NCR53c7x0_address_io = (unsigned int) (host)->io_port; \
  1289. NCR53c7x0_memory_mapped = ((struct NCR53c7x0_hostdata *) \
  1290. host->hostdata[0])-> options & OPTION_MEMORY_MAPPED
  1291. #ifdef BIG_ENDIAN
  1292. /* These could be more efficient, given that we are always memory mapped,
  1293. * but they don't give the same problems as the write macros, so leave
  1294. * them. */
  1295. #ifdef __mc68000__
  1296. #define NCR53c7x0_read8(address) \
  1297. ((unsigned int)raw_inb((u32)NCR53c7x0_address_memory + ((u32)(address)^3)) )
  1298. #define NCR53c7x0_read16(address) \
  1299. ((unsigned int)raw_inw((u32)NCR53c7x0_address_memory + ((u32)(address)^2)))
  1300. #else
  1301. #define NCR53c7x0_read8(address) \
  1302. (NCR53c7x0_memory_mapped ? \
  1303. (unsigned int)readb((u32)NCR53c7x0_address_memory + ((u32)(address)^3)) : \
  1304. inb(NCR53c7x0_address_io + (address)))
  1305. #define NCR53c7x0_read16(address) \
  1306. (NCR53c7x0_memory_mapped ? \
  1307. (unsigned int)readw((u32)NCR53c7x0_address_memory + ((u32)(address)^2)) : \
  1308. inw(NCR53c7x0_address_io + (address)))
  1309. #endif /* mc68000 */
  1310. #else
  1311. #define NCR53c7x0_read8(address) \
  1312. (NCR53c7x0_memory_mapped ? \
  1313. (unsigned int)readb((u32)NCR53c7x0_address_memory + (u32)(address)) : \
  1314. inb(NCR53c7x0_address_io + (address)))
  1315. #define NCR53c7x0_read16(address) \
  1316. (NCR53c7x0_memory_mapped ? \
  1317. (unsigned int)readw((u32)NCR53c7x0_address_memory + (u32)(address)) : \
  1318. inw(NCR53c7x0_address_io + (address)))
  1319. #endif
  1320. #ifdef __mc68000__
  1321. #define NCR53c7x0_read32(address) \
  1322. ((unsigned int) raw_inl((u32)NCR53c7x0_address_memory + (u32)(address)))
  1323. #else
  1324. #define NCR53c7x0_read32(address) \
  1325. (NCR53c7x0_memory_mapped ? \
  1326. (unsigned int) readl((u32)NCR53c7x0_address_memory + (u32)(address)) : \
  1327. inl(NCR53c7x0_address_io + (address)))
  1328. #endif /* mc68000*/
  1329. #ifdef BIG_ENDIAN
  1330. /* If we are big-endian, then we are not Intel, so probably don't have
  1331. * an i/o map as well as a memory map. So, let's assume memory mapped.
  1332. * Also, I am having terrible problems trying to persuade the compiler
  1333. * not to lay down code which does a read after write for these macros.
  1334. * If you remove 'volatile' from writeb() and friends it is ok....
  1335. */
  1336. #define NCR53c7x0_write8(address,value) \
  1337. *(volatile unsigned char *) \
  1338. ((u32)NCR53c7x0_address_memory + ((u32)(address)^3)) = (value)
  1339. #define NCR53c7x0_write16(address,value) \
  1340. *(volatile unsigned short *) \
  1341. ((u32)NCR53c7x0_address_memory + ((u32)(address)^2)) = (value)
  1342. #define NCR53c7x0_write32(address,value) \
  1343. *(volatile unsigned long *) \
  1344. ((u32)NCR53c7x0_address_memory + ((u32)(address))) = (value)
  1345. #else
  1346. #define NCR53c7x0_write8(address,value) \
  1347. (NCR53c7x0_memory_mapped ? \
  1348. ({writeb((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
  1349. outb((value), NCR53c7x0_address_io + (address)))
  1350. #define NCR53c7x0_write16(address,value) \
  1351. (NCR53c7x0_memory_mapped ? \
  1352. ({writew((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
  1353. outw((value), NCR53c7x0_address_io + (address)))
  1354. #define NCR53c7x0_write32(address,value) \
  1355. (NCR53c7x0_memory_mapped ? \
  1356. ({writel((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
  1357. outl((value), NCR53c7x0_address_io + (address)))
  1358. #endif
  1359. /* Patch arbitrary 32 bit words in the script */
  1360. #define patch_abs_32(script, offset, symbol, value) \
  1361. for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
  1362. (u32)); ++i) { \
  1363. (script)[A_##symbol##_used[i] - (offset)] += (value); \
  1364. if (hostdata->options & OPTION_DEBUG_FIXUP) \
  1365. printk("scsi%d : %s reference %d at 0x%x in %s is now 0x%x\n",\
  1366. host->host_no, #symbol, i, A_##symbol##_used[i] - \
  1367. (int)(offset), #script, (script)[A_##symbol##_used[i] - \
  1368. (offset)]); \
  1369. }
  1370. /* Patch read/write instruction immediate field */
  1371. #define patch_abs_rwri_data(script, offset, symbol, value) \
  1372. for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
  1373. (u32)); ++i) \
  1374. (script)[A_##symbol##_used[i] - (offset)] = \
  1375. ((script)[A_##symbol##_used[i] - (offset)] & \
  1376. ~DBC_RWRI_IMMEDIATE_MASK) | \
  1377. (((value) << DBC_RWRI_IMMEDIATE_SHIFT) & \
  1378. DBC_RWRI_IMMEDIATE_MASK)
  1379. /* Patch transfer control instruction data field */
  1380. #define patch_abs_tci_data(script, offset, symbol, value) \
  1381. for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
  1382. (u32)); ++i) \
  1383. (script)[A_##symbol##_used[i] - (offset)] = \
  1384. ((script)[A_##symbol##_used[i] - (offset)] & \
  1385. ~DBC_TCI_DATA_MASK) | \
  1386. (((value) << DBC_TCI_DATA_SHIFT) & \
  1387. DBC_TCI_DATA_MASK)
  1388. /* Patch field in dsa structure (assignment should be +=?) */
  1389. #define patch_dsa_32(dsa, symbol, word, value) \
  1390. { \
  1391. (dsa)[(hostdata->##symbol - hostdata->dsa_start) / sizeof(u32) \
  1392. + (word)] = (value); \
  1393. if (hostdata->options & OPTION_DEBUG_DSA) \
  1394. printk("scsi : dsa %s symbol %s(%d) word %d now 0x%x\n", \
  1395. #dsa, #symbol, hostdata->##symbol, \
  1396. (word), (u32) (value)); \
  1397. }
  1398. /* Paranoid people could use panic() here. */
  1399. #define FATAL(host) shutdown((host));
  1400. extern int ncr53c7xx_init(struct scsi_host_template *tpnt, int board, int chip,
  1401. unsigned long base, int io_port, int irq, int dma,
  1402. long long options, int clock);
  1403. #endif /* NCR53c710_C */
  1404. #endif /* NCR53c710_H */