sym53c8xx_defs.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. /******************************************************************************
  2. ** High Performance device driver for the Symbios 53C896 controller.
  3. **
  4. ** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
  5. **
  6. ** This driver also supports all the Symbios 53C8XX controller family,
  7. ** except 53C810 revisions < 16, 53C825 revisions < 16 and all
  8. ** revisions of 53C815 controllers.
  9. **
  10. ** This driver is based on the Linux port of the FreeBSD ncr driver.
  11. **
  12. ** Copyright (C) 1994 Wolfgang Stanglmeier
  13. **
  14. **-----------------------------------------------------------------------------
  15. **
  16. ** This program is free software; you can redistribute it and/or modify
  17. ** it under the terms of the GNU General Public License as published by
  18. ** the Free Software Foundation; either version 2 of the License, or
  19. ** (at your option) any later version.
  20. **
  21. ** This program is distributed in the hope that it will be useful,
  22. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. ** GNU General Public License for more details.
  25. **
  26. ** You should have received a copy of the GNU General Public License
  27. ** along with this program; if not, write to the Free Software
  28. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. **
  30. **-----------------------------------------------------------------------------
  31. **
  32. ** The Linux port of the FreeBSD ncr driver has been achieved in
  33. ** november 1995 by:
  34. **
  35. ** Gerard Roudier <groudier@free.fr>
  36. **
  37. ** Being given that this driver originates from the FreeBSD version, and
  38. ** in order to keep synergy on both, any suggested enhancements and corrections
  39. ** received on Linux are automatically a potential candidate for the FreeBSD
  40. ** version.
  41. **
  42. ** The original driver has been written for 386bsd and FreeBSD by
  43. ** Wolfgang Stanglmeier <wolf@cologne.de>
  44. ** Stefan Esser <se@mi.Uni-Koeln.de>
  45. **
  46. **-----------------------------------------------------------------------------
  47. **
  48. ** Major contributions:
  49. ** --------------------
  50. **
  51. ** NVRAM detection and reading.
  52. ** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  53. **
  54. ** Added support for MIPS big endian systems.
  55. ** Carsten Langgaard, carstenl@mips.com
  56. ** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  57. **
  58. ** Added support for HP PARISC big endian systems.
  59. ** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  60. **
  61. *******************************************************************************
  62. */
  63. #ifndef SYM53C8XX_DEFS_H
  64. #define SYM53C8XX_DEFS_H
  65. #include <linux/config.h>
  66. /*
  67. ** If you want a driver as small as possible, donnot define the
  68. ** following options.
  69. */
  70. #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
  71. #define SCSI_NCR_DEBUG_INFO_SUPPORT
  72. /*
  73. ** To disable integrity checking, do not define the
  74. ** following option.
  75. */
  76. #ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
  77. # define SCSI_NCR_ENABLE_INTEGRITY_CHECK
  78. #endif
  79. /* ---------------------------------------------------------------------
  80. ** Take into account kernel configured parameters.
  81. ** Most of these options can be overridden at startup by a command line.
  82. ** ---------------------------------------------------------------------
  83. */
  84. /*
  85. * For Ultra2 and Ultra3 SCSI support option, use special features.
  86. *
  87. * Value (default) means:
  88. * bit 0 : all features enabled, except:
  89. * bit 1 : PCI Write And Invalidate.
  90. * bit 2 : Data Phase Mismatch handling from SCRIPTS.
  91. *
  92. * Use boot options ncr53c8xx=specf:1 if you want all chip features to be
  93. * enabled by the driver.
  94. */
  95. #define SCSI_NCR_SETUP_SPECIAL_FEATURES (3)
  96. #define SCSI_NCR_MAX_SYNC (80)
  97. /*
  98. * Allow tags from 2 to 256, default 8
  99. */
  100. #ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS
  101. #if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
  102. #define SCSI_NCR_MAX_TAGS (2)
  103. #elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
  104. #define SCSI_NCR_MAX_TAGS (256)
  105. #else
  106. #define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS
  107. #endif
  108. #else
  109. #define SCSI_NCR_MAX_TAGS (8)
  110. #endif
  111. /*
  112. * Allow tagged command queuing support if configured with default number
  113. * of tags set to max (see above).
  114. */
  115. #ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
  116. #define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
  117. #elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
  118. #define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS
  119. #else
  120. #define SCSI_NCR_SETUP_DEFAULT_TAGS (0)
  121. #endif
  122. /*
  123. * Immediate arbitration
  124. */
  125. #if defined(CONFIG_SCSI_NCR53C8XX_IARB)
  126. #define SCSI_NCR_IARB_SUPPORT
  127. #endif
  128. /*
  129. * Sync transfer frequency at startup.
  130. * Allow from 5Mhz to 80Mhz default 20 Mhz.
  131. */
  132. #ifndef CONFIG_SCSI_NCR53C8XX_SYNC
  133. #define CONFIG_SCSI_NCR53C8XX_SYNC (20)
  134. #elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
  135. #undef CONFIG_SCSI_NCR53C8XX_SYNC
  136. #define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC
  137. #endif
  138. #if CONFIG_SCSI_NCR53C8XX_SYNC == 0
  139. #define SCSI_NCR_SETUP_DEFAULT_SYNC (255)
  140. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5
  141. #define SCSI_NCR_SETUP_DEFAULT_SYNC (50)
  142. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20
  143. #define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC))
  144. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33
  145. #define SCSI_NCR_SETUP_DEFAULT_SYNC (11)
  146. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40
  147. #define SCSI_NCR_SETUP_DEFAULT_SYNC (10)
  148. #else
  149. #define SCSI_NCR_SETUP_DEFAULT_SYNC (9)
  150. #endif
  151. /*
  152. * Disallow disconnections at boot-up
  153. */
  154. #ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
  155. #define SCSI_NCR_SETUP_DISCONNECTION (0)
  156. #else
  157. #define SCSI_NCR_SETUP_DISCONNECTION (1)
  158. #endif
  159. /*
  160. * Force synchronous negotiation for all targets
  161. */
  162. #ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
  163. #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1)
  164. #else
  165. #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0)
  166. #endif
  167. /*
  168. * Disable master parity checking (flawed hardwares need that)
  169. */
  170. #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
  171. #define SCSI_NCR_SETUP_MASTER_PARITY (0)
  172. #else
  173. #define SCSI_NCR_SETUP_MASTER_PARITY (1)
  174. #endif
  175. /*
  176. * Disable scsi parity checking (flawed devices may need that)
  177. */
  178. #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
  179. #define SCSI_NCR_SETUP_SCSI_PARITY (0)
  180. #else
  181. #define SCSI_NCR_SETUP_SCSI_PARITY (1)
  182. #endif
  183. /*
  184. * Settle time after reset at boot-up
  185. */
  186. #define SCSI_NCR_SETUP_SETTLE_TIME (2)
  187. /*
  188. ** Bridge quirks work-around option defaulted to 1.
  189. */
  190. #ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT
  191. #define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1
  192. #endif
  193. /*
  194. ** Work-around common bridge misbehaviour.
  195. **
  196. ** - Do not flush posted writes in the opposite
  197. ** direction on read.
  198. ** - May reorder DMA writes to memory.
  199. **
  200. ** This option should not affect performances
  201. ** significantly, so it is the default.
  202. */
  203. #if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
  204. #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
  205. #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
  206. #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
  207. /*
  208. ** Same as option 1, but also deal with
  209. ** misconfigured interrupts.
  210. **
  211. ** - Edge triggerred instead of level sensitive.
  212. ** - No interrupt line connected.
  213. ** - IRQ number misconfigured.
  214. **
  215. ** If no interrupt is delivered, the driver will
  216. ** catch the interrupt conditions 10 times per
  217. ** second. No need to say that this option is
  218. ** not recommended.
  219. */
  220. #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
  221. #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
  222. #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
  223. #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
  224. #define SCSI_NCR_PCIQ_BROKEN_INTR
  225. /*
  226. ** Some bridge designers decided to flush
  227. ** everything prior to deliver the interrupt.
  228. ** This option tries to deal with such a
  229. ** behaviour.
  230. */
  231. #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
  232. #define SCSI_NCR_PCIQ_SYNC_ON_INTR
  233. #endif
  234. /*
  235. ** Other parameters not configurable with "make config"
  236. ** Avoid to change these constants, unless you know what you are doing.
  237. */
  238. #define SCSI_NCR_ALWAYS_SIMPLE_TAG
  239. #define SCSI_NCR_MAX_SCATTER (127)
  240. #define SCSI_NCR_MAX_TARGET (16)
  241. /*
  242. ** Compute some desirable value for CAN_QUEUE
  243. ** and CMD_PER_LUN.
  244. ** The driver will use lower values if these
  245. ** ones appear to be too large.
  246. */
  247. #define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
  248. #define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS)
  249. #define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER)
  250. #define SCSI_NCR_TIMER_INTERVAL (HZ)
  251. #if 1 /* defined CONFIG_SCSI_MULTI_LUN */
  252. #define SCSI_NCR_MAX_LUN (16)
  253. #else
  254. #define SCSI_NCR_MAX_LUN (1)
  255. #endif
  256. /*
  257. * IO functions definition for big/little endian CPU support.
  258. * For now, the NCR is only supported in little endian addressing mode,
  259. */
  260. #ifdef __BIG_ENDIAN
  261. #define inw_l2b inw
  262. #define inl_l2b inl
  263. #define outw_b2l outw
  264. #define outl_b2l outl
  265. #define readb_raw readb
  266. #define writeb_raw writeb
  267. #if defined(SCSI_NCR_BIG_ENDIAN)
  268. #define readw_l2b __raw_readw
  269. #define readl_l2b __raw_readl
  270. #define writew_b2l __raw_writew
  271. #define writel_b2l __raw_writel
  272. #define readw_raw __raw_readw
  273. #define readl_raw __raw_readl
  274. #define writew_raw __raw_writew
  275. #define writel_raw __raw_writel
  276. #else /* Other big-endian */
  277. #define readw_l2b readw
  278. #define readl_l2b readl
  279. #define writew_b2l writew
  280. #define writel_b2l writel
  281. #define readw_raw readw
  282. #define readl_raw readl
  283. #define writew_raw writew
  284. #define writel_raw writel
  285. #endif
  286. #else /* little endian */
  287. #define inw_raw inw
  288. #define inl_raw inl
  289. #define outw_raw outw
  290. #define outl_raw outl
  291. #define readb_raw readb
  292. #define readw_raw readw
  293. #define readl_raw readl
  294. #define writeb_raw writeb
  295. #define writew_raw writew
  296. #define writel_raw writel
  297. #endif
  298. #if !defined(__hppa__) && !defined(__mips__)
  299. #ifdef SCSI_NCR_BIG_ENDIAN
  300. #error "The NCR in BIG ENDIAN addressing mode is not (yet) supported"
  301. #endif
  302. #endif
  303. #define MEMORY_BARRIER() mb()
  304. /*
  305. * If the NCR uses big endian addressing mode over the
  306. * PCI, actual io register addresses for byte and word
  307. * accesses must be changed according to lane routing.
  308. * Btw, ncr_offb() and ncr_offw() macros only apply to
  309. * constants and so donnot generate bloated code.
  310. */
  311. #if defined(SCSI_NCR_BIG_ENDIAN)
  312. #define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))
  313. #define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))
  314. #else
  315. #define ncr_offb(o) (o)
  316. #define ncr_offw(o) (o)
  317. #endif
  318. /*
  319. * If the CPU and the NCR use same endian-ness addressing,
  320. * no byte reordering is needed for script patching.
  321. * Macro cpu_to_scr() is to be used for script patching.
  322. * Macro scr_to_cpu() is to be used for getting a DWORD
  323. * from the script.
  324. */
  325. #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
  326. #define cpu_to_scr(dw) cpu_to_le32(dw)
  327. #define scr_to_cpu(dw) le32_to_cpu(dw)
  328. #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
  329. #define cpu_to_scr(dw) cpu_to_be32(dw)
  330. #define scr_to_cpu(dw) be32_to_cpu(dw)
  331. #else
  332. #define cpu_to_scr(dw) (dw)
  333. #define scr_to_cpu(dw) (dw)
  334. #endif
  335. /*
  336. * Access to the controller chip.
  337. *
  338. * If the CPU and the NCR use same endian-ness addressing,
  339. * no byte reordering is needed for accessing chip io
  340. * registers. Functions suffixed by '_raw' are assumed
  341. * to access the chip over the PCI without doing byte
  342. * reordering. Functions suffixed by '_l2b' are
  343. * assumed to perform little-endian to big-endian byte
  344. * reordering, those suffixed by '_b2l' blah, blah,
  345. * blah, ...
  346. */
  347. /*
  348. * MEMORY mapped IO input / output
  349. */
  350. #define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o))
  351. #define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
  352. #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
  353. #define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o))
  354. #define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o))
  355. #define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
  356. #define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o))
  357. #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
  358. #define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o))
  359. #define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o))
  360. #define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
  361. #define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o))
  362. #else
  363. #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
  364. /* Only 8 or 32 bit transfers allowed */
  365. #define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
  366. #else
  367. #define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o))
  368. #endif
  369. #define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o))
  370. #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
  371. /* Only 8 or 32 bit transfers allowed */
  372. #define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
  373. #else
  374. #define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
  375. #endif
  376. #define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o))
  377. #endif
  378. #define INB(r) INB_OFF (offsetof(struct ncr_reg,r))
  379. #define INW(r) INW_OFF (offsetof(struct ncr_reg,r))
  380. #define INL(r) INL_OFF (offsetof(struct ncr_reg,r))
  381. #define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))
  382. #define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))
  383. #define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))
  384. /*
  385. * Set bit field ON, OFF
  386. */
  387. #define OUTONB(r, m) OUTB(r, INB(r) | (m))
  388. #define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))
  389. #define OUTONW(r, m) OUTW(r, INW(r) | (m))
  390. #define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))
  391. #define OUTONL(r, m) OUTL(r, INL(r) | (m))
  392. #define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))
  393. /*
  394. * We normally want the chip to have a consistent view
  395. * of driver internal data structures when we restart it.
  396. * Thus these macros.
  397. */
  398. #define OUTL_DSP(v) \
  399. do { \
  400. MEMORY_BARRIER(); \
  401. OUTL (nc_dsp, (v)); \
  402. } while (0)
  403. #define OUTONB_STD() \
  404. do { \
  405. MEMORY_BARRIER(); \
  406. OUTONB (nc_dcntl, (STD|NOCOM)); \
  407. } while (0)
  408. /*
  409. ** NCR53C8XX devices features table.
  410. */
  411. struct ncr_chip {
  412. unsigned short revision_id;
  413. unsigned char burst_max; /* log-base-2 of max burst */
  414. unsigned char offset_max;
  415. unsigned char nr_divisor;
  416. unsigned int features;
  417. #define FE_LED0 (1<<0)
  418. #define FE_WIDE (1<<1) /* Wide data transfers */
  419. #define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */
  420. #define FE_DBLR (1<<4) /* Clock doubler present */
  421. #define FE_QUAD (1<<5) /* Clock quadrupler present */
  422. #define FE_ERL (1<<6) /* Enable read line */
  423. #define FE_CLSE (1<<7) /* Cache line size enable */
  424. #define FE_WRIE (1<<8) /* Write & Invalidate enable */
  425. #define FE_ERMP (1<<9) /* Enable read multiple */
  426. #define FE_BOF (1<<10) /* Burst opcode fetch */
  427. #define FE_DFS (1<<11) /* DMA fifo size */
  428. #define FE_PFEN (1<<12) /* Prefetch enable */
  429. #define FE_LDSTR (1<<13) /* Load/Store supported */
  430. #define FE_RAM (1<<14) /* On chip RAM present */
  431. #define FE_VARCLK (1<<15) /* SCSI clock may vary */
  432. #define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */
  433. #define FE_64BIT (1<<17) /* Have a 64-bit PCI interface */
  434. #define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */
  435. #define FE_NOPM (1<<19) /* Scripts handles phase mismatch */
  436. #define FE_LEDC (1<<20) /* Hardware control of LED */
  437. #define FE_DIFF (1<<21) /* Support Differential SCSI */
  438. #define FE_66MHZ (1<<23) /* 66MHz PCI Support */
  439. #define FE_DAC (1<<24) /* Support DAC cycles (64 bit addressing) */
  440. #define FE_ISTAT1 (1<<25) /* Have ISTAT1, MBOX0, MBOX1 registers */
  441. #define FE_DAC_IN_USE (1<<26) /* Platform does DAC cycles */
  442. #define FE_EHP (1<<27) /* 720: Even host parity */
  443. #define FE_MUX (1<<28) /* 720: Multiplexed bus */
  444. #define FE_EA (1<<29) /* 720: Enable Ack */
  445. #define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
  446. #define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
  447. #define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
  448. };
  449. /*
  450. ** Driver setup structure.
  451. **
  452. ** This structure is initialized from linux config options.
  453. ** It can be overridden at boot-up by the boot command line.
  454. */
  455. #define SCSI_NCR_MAX_EXCLUDES 8
  456. struct ncr_driver_setup {
  457. u8 master_parity;
  458. u8 scsi_parity;
  459. u8 disconnection;
  460. u8 special_features;
  461. u8 force_sync_nego;
  462. u8 reverse_probe;
  463. u8 pci_fix_up;
  464. u8 use_nvram;
  465. u8 verbose;
  466. u8 default_tags;
  467. u16 default_sync;
  468. u16 debug;
  469. u8 burst_max;
  470. u8 led_pin;
  471. u8 max_wide;
  472. u8 settle_delay;
  473. u8 diff_support;
  474. u8 irqm;
  475. u8 bus_check;
  476. u8 optimize;
  477. u8 recovery;
  478. u8 host_id;
  479. u16 iarb;
  480. u32 excludes[SCSI_NCR_MAX_EXCLUDES];
  481. char tag_ctrl[100];
  482. };
  483. /*
  484. ** Initial setup.
  485. ** Can be overriden at startup by a command line.
  486. */
  487. #define SCSI_NCR_DRIVER_SETUP \
  488. { \
  489. SCSI_NCR_SETUP_MASTER_PARITY, \
  490. SCSI_NCR_SETUP_SCSI_PARITY, \
  491. SCSI_NCR_SETUP_DISCONNECTION, \
  492. SCSI_NCR_SETUP_SPECIAL_FEATURES, \
  493. SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \
  494. 0, \
  495. 0, \
  496. 1, \
  497. 0, \
  498. SCSI_NCR_SETUP_DEFAULT_TAGS, \
  499. SCSI_NCR_SETUP_DEFAULT_SYNC, \
  500. 0x00, \
  501. 7, \
  502. 0, \
  503. 1, \
  504. SCSI_NCR_SETUP_SETTLE_TIME, \
  505. 0, \
  506. 0, \
  507. 1, \
  508. 0, \
  509. 0, \
  510. 255, \
  511. 0x00 \
  512. }
  513. /*
  514. ** Boot fail safe setup.
  515. ** Override initial setup from boot command line:
  516. ** ncr53c8xx=safe:y
  517. */
  518. #define SCSI_NCR_DRIVER_SAFE_SETUP \
  519. { \
  520. 0, \
  521. 1, \
  522. 0, \
  523. 0, \
  524. 0, \
  525. 0, \
  526. 0, \
  527. 1, \
  528. 2, \
  529. 0, \
  530. 255, \
  531. 0x00, \
  532. 255, \
  533. 0, \
  534. 0, \
  535. 10, \
  536. 1, \
  537. 1, \
  538. 1, \
  539. 0, \
  540. 0, \
  541. 255 \
  542. }
  543. /**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
  544. /*-----------------------------------------------------------------
  545. **
  546. ** The ncr 53c810 register structure.
  547. **
  548. **-----------------------------------------------------------------
  549. */
  550. struct ncr_reg {
  551. /*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */
  552. /*01*/ u8 nc_scntl1; /* no reset */
  553. #define ISCON 0x10 /* connected to scsi */
  554. #define CRST 0x08 /* force reset */
  555. #define IARB 0x02 /* immediate arbitration */
  556. /*02*/ u8 nc_scntl2; /* no disconnect expected */
  557. #define SDU 0x80 /* cmd: disconnect will raise error */
  558. #define CHM 0x40 /* sta: chained mode */
  559. #define WSS 0x08 /* sta: wide scsi send [W]*/
  560. #define WSR 0x01 /* sta: wide scsi received [W]*/
  561. /*03*/ u8 nc_scntl3; /* cnf system clock dependent */
  562. #define EWS 0x08 /* cmd: enable wide scsi [W]*/
  563. #define ULTRA 0x80 /* cmd: ULTRA enable */
  564. /* bits 0-2, 7 rsvd for C1010 */
  565. /*04*/ u8 nc_scid; /* cnf host adapter scsi address */
  566. #define RRE 0x40 /* r/w:e enable response to resel. */
  567. #define SRE 0x20 /* r/w:e enable response to select */
  568. /*05*/ u8 nc_sxfer; /* ### Sync speed and count */
  569. /* bits 6-7 rsvd for C1010 */
  570. /*06*/ u8 nc_sdid; /* ### Destination-ID */
  571. /*07*/ u8 nc_gpreg; /* ??? IO-Pins */
  572. /*08*/ u8 nc_sfbr; /* ### First byte in phase */
  573. /*09*/ u8 nc_socl;
  574. #define CREQ 0x80 /* r/w: SCSI-REQ */
  575. #define CACK 0x40 /* r/w: SCSI-ACK */
  576. #define CBSY 0x20 /* r/w: SCSI-BSY */
  577. #define CSEL 0x10 /* r/w: SCSI-SEL */
  578. #define CATN 0x08 /* r/w: SCSI-ATN */
  579. #define CMSG 0x04 /* r/w: SCSI-MSG */
  580. #define CC_D 0x02 /* r/w: SCSI-C_D */
  581. #define CI_O 0x01 /* r/w: SCSI-I_O */
  582. /*0a*/ u8 nc_ssid;
  583. /*0b*/ u8 nc_sbcl;
  584. /*0c*/ u8 nc_dstat;
  585. #define DFE 0x80 /* sta: dma fifo empty */
  586. #define MDPE 0x40 /* int: master data parity error */
  587. #define BF 0x20 /* int: script: bus fault */
  588. #define ABRT 0x10 /* int: script: command aborted */
  589. #define SSI 0x08 /* int: script: single step */
  590. #define SIR 0x04 /* int: script: interrupt instruct. */
  591. #define IID 0x01 /* int: script: illegal instruct. */
  592. /*0d*/ u8 nc_sstat0;
  593. #define ILF 0x80 /* sta: data in SIDL register lsb */
  594. #define ORF 0x40 /* sta: data in SODR register lsb */
  595. #define OLF 0x20 /* sta: data in SODL register lsb */
  596. #define AIP 0x10 /* sta: arbitration in progress */
  597. #define LOA 0x08 /* sta: arbitration lost */
  598. #define WOA 0x04 /* sta: arbitration won */
  599. #define IRST 0x02 /* sta: scsi reset signal */
  600. #define SDP 0x01 /* sta: scsi parity signal */
  601. /*0e*/ u8 nc_sstat1;
  602. #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
  603. /*0f*/ u8 nc_sstat2;
  604. #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
  605. #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
  606. #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
  607. #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
  608. #define LDSC 0x02 /* sta: disconnect & reconnect */
  609. /*10*/ u8 nc_dsa; /* --> Base page */
  610. /*11*/ u8 nc_dsa1;
  611. /*12*/ u8 nc_dsa2;
  612. /*13*/ u8 nc_dsa3;
  613. /*14*/ u8 nc_istat; /* --> Main Command and status */
  614. #define CABRT 0x80 /* cmd: abort current operation */
  615. #define SRST 0x40 /* mod: reset chip */
  616. #define SIGP 0x20 /* r/w: message from host to ncr */
  617. #define SEM 0x10 /* r/w: message between host + ncr */
  618. #define CON 0x08 /* sta: connected to scsi */
  619. #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
  620. #define SIP 0x02 /* sta: scsi-interrupt */
  621. #define DIP 0x01 /* sta: host/script interrupt */
  622. /*15*/ u8 nc_istat1; /* 896 and later cores only */
  623. #define FLSH 0x04 /* sta: chip is flushing */
  624. #define SRUN 0x02 /* sta: scripts are running */
  625. #define SIRQD 0x01 /* r/w: disable INT pin */
  626. /*16*/ u8 nc_mbox0; /* 896 and later cores only */
  627. /*17*/ u8 nc_mbox1; /* 896 and later cores only */
  628. /*18*/ u8 nc_ctest0;
  629. #define EHP 0x04 /* 720 even host parity */
  630. /*19*/ u8 nc_ctest1;
  631. /*1a*/ u8 nc_ctest2;
  632. #define CSIGP 0x40
  633. /* bits 0-2,7 rsvd for C1010 */
  634. /*1b*/ u8 nc_ctest3;
  635. #define FLF 0x08 /* cmd: flush dma fifo */
  636. #define CLF 0x04 /* cmd: clear dma fifo */
  637. #define FM 0x02 /* mod: fetch pin mode */
  638. #define WRIE 0x01 /* mod: write and invalidate enable */
  639. /* bits 4-7 rsvd for C1010 */
  640. /*1c*/ u32 nc_temp; /* ### Temporary stack */
  641. /*20*/ u8 nc_dfifo;
  642. /*21*/ u8 nc_ctest4;
  643. #define MUX 0x80 /* 720 host bus multiplex mode */
  644. #define BDIS 0x80 /* mod: burst disable */
  645. #define MPEE 0x08 /* mod: master parity error enable */
  646. /*22*/ u8 nc_ctest5;
  647. #define DFS 0x20 /* mod: dma fifo size */
  648. /* bits 0-1, 3-7 rsvd for C1010 */
  649. /*23*/ u8 nc_ctest6;
  650. /*24*/ u32 nc_dbc; /* ### Byte count and command */
  651. /*28*/ u32 nc_dnad; /* ### Next command register */
  652. /*2c*/ u32 nc_dsp; /* --> Script Pointer */
  653. /*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */
  654. /*34*/ u8 nc_scratcha; /* Temporary register a */
  655. /*35*/ u8 nc_scratcha1;
  656. /*36*/ u8 nc_scratcha2;
  657. /*37*/ u8 nc_scratcha3;
  658. /*38*/ u8 nc_dmode;
  659. #define BL_2 0x80 /* mod: burst length shift value +2 */
  660. #define BL_1 0x40 /* mod: burst length shift value +1 */
  661. #define ERL 0x08 /* mod: enable read line */
  662. #define ERMP 0x04 /* mod: enable read multiple */
  663. #define BOF 0x02 /* mod: burst op code fetch */
  664. /*39*/ u8 nc_dien;
  665. /*3a*/ u8 nc_sbr;
  666. /*3b*/ u8 nc_dcntl; /* --> Script execution control */
  667. #define CLSE 0x80 /* mod: cache line size enable */
  668. #define PFF 0x40 /* cmd: pre-fetch flush */
  669. #define PFEN 0x20 /* mod: pre-fetch enable */
  670. #define EA 0x20 /* mod: 720 enable-ack */
  671. #define SSM 0x10 /* mod: single step mode */
  672. #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
  673. #define STD 0x04 /* cmd: start dma mode */
  674. #define IRQD 0x02 /* mod: irq disable */
  675. #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
  676. /* bits 0-1 rsvd for C1010 */
  677. /*3c*/ u32 nc_adder;
  678. /*40*/ u16 nc_sien; /* -->: interrupt enable */
  679. /*42*/ u16 nc_sist; /* <--: interrupt status */
  680. #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
  681. #define STO 0x0400/* sta: timeout (select) */
  682. #define GEN 0x0200/* sta: timeout (general) */
  683. #define HTH 0x0100/* sta: timeout (handshake) */
  684. #define MA 0x80 /* sta: phase mismatch */
  685. #define CMP 0x40 /* sta: arbitration complete */
  686. #define SEL 0x20 /* sta: selected by another device */
  687. #define RSL 0x10 /* sta: reselected by another device*/
  688. #define SGE 0x08 /* sta: gross error (over/underflow)*/
  689. #define UDC 0x04 /* sta: unexpected disconnect */
  690. #define RST 0x02 /* sta: scsi bus reset detected */
  691. #define PAR 0x01 /* sta: scsi parity error */
  692. /*44*/ u8 nc_slpar;
  693. /*45*/ u8 nc_swide;
  694. /*46*/ u8 nc_macntl;
  695. /*47*/ u8 nc_gpcntl;
  696. /*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/
  697. /*49*/ u8 nc_stime1; /* cmd: timeout user defined */
  698. /*4a*/ u16 nc_respid; /* sta: Reselect-IDs */
  699. /*4c*/ u8 nc_stest0;
  700. /*4d*/ u8 nc_stest1;
  701. #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
  702. #define DBLEN 0x08 /* clock doubler running */
  703. #define DBLSEL 0x04 /* clock doubler selected */
  704. /*4e*/ u8 nc_stest2;
  705. #define ROF 0x40 /* reset scsi offset (after gross error!) */
  706. #define DIF 0x20 /* 720 SCSI differential mode */
  707. #define EXT 0x02 /* extended filtering */
  708. /*4f*/ u8 nc_stest3;
  709. #define TE 0x80 /* c: tolerAnt enable */
  710. #define HSC 0x20 /* c: Halt SCSI Clock */
  711. #define CSF 0x02 /* c: clear scsi fifo */
  712. /*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */
  713. /*52*/ u8 nc_stest4;
  714. #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
  715. #define SMODE_HVD 0x40 /* High Voltage Differential */
  716. #define SMODE_SE 0x80 /* Single Ended */
  717. #define SMODE_LVD 0xc0 /* Low Voltage Differential */
  718. #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
  719. /* bits 0-5 rsvd for C1010 */
  720. /*53*/ u8 nc_53_;
  721. /*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */
  722. /*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */
  723. #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */
  724. #define PMJCTL 0x40 /* Phase Mismatch Jump Control */
  725. #define ENNDJ 0x20 /* Enable Non Data PM Jump */
  726. #define DISFC 0x10 /* Disable Auto FIFO Clear */
  727. #define DILS 0x02 /* Disable Internal Load/Store */
  728. #define DPR 0x01 /* Disable Pipe Req */
  729. /*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */
  730. #define ZMOD 0x80 /* High Impedance Mode */
  731. #define DIC 0x10 /* Disable Internal Cycles */
  732. #define DDAC 0x08 /* Disable Dual Address Cycle */
  733. #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */
  734. #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */
  735. #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */
  736. /*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */
  737. /*5a*/ u16 nc_5a_;
  738. /*5c*/ u8 nc_scr0; /* Working register B */
  739. /*5d*/ u8 nc_scr1; /* */
  740. /*5e*/ u8 nc_scr2; /* */
  741. /*5f*/ u8 nc_scr3; /* */
  742. /*60*/ u8 nc_scrx[64]; /* Working register C-R */
  743. /*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */
  744. /*a4*/ u32 nc_mmws; /* Memory Move Write Selector */
  745. /*a8*/ u32 nc_sfs; /* Script Fetch Selector */
  746. /*ac*/ u32 nc_drs; /* DSA Relative Selector */
  747. /*b0*/ u32 nc_sbms; /* Static Block Move Selector */
  748. /*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */
  749. /*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */
  750. /*bc*/ u16 nc_scntl4; /* C1010 only */
  751. #define U3EN 0x80 /* Enable Ultra 3 */
  752. #define AIPEN 0x40 /* Allow check upper byte lanes */
  753. #define XCLKH_DT 0x08 /* Extra clock of data hold on DT
  754. transfer edge */
  755. #define XCLKH_ST 0x04 /* Extra clock of data hold on ST
  756. transfer edge */
  757. /*be*/ u8 nc_aipcntl0; /* Epat Control 1 C1010 only */
  758. /*bf*/ u8 nc_aipcntl1; /* AIP Control C1010_66 Only */
  759. /*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */
  760. /*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */
  761. /*c8*/ u8 nc_rbc; /* Remaining Byte Count */
  762. /*c9*/ u8 nc_rbc1; /* */
  763. /*ca*/ u8 nc_rbc2; /* */
  764. /*cb*/ u8 nc_rbc3; /* */
  765. /*cc*/ u8 nc_ua; /* Updated Address */
  766. /*cd*/ u8 nc_ua1; /* */
  767. /*ce*/ u8 nc_ua2; /* */
  768. /*cf*/ u8 nc_ua3; /* */
  769. /*d0*/ u32 nc_esa; /* Entry Storage Address */
  770. /*d4*/ u8 nc_ia; /* Instruction Address */
  771. /*d5*/ u8 nc_ia1;
  772. /*d6*/ u8 nc_ia2;
  773. /*d7*/ u8 nc_ia3;
  774. /*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */
  775. /*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */
  776. /* Following for C1010 only */
  777. /*e0*/ u16 nc_crcpad; /* CRC Value */
  778. /*e2*/ u8 nc_crccntl0; /* CRC control register */
  779. #define SNDCRC 0x10 /* Send CRC Request */
  780. /*e3*/ u8 nc_crccntl1; /* CRC control register */
  781. /*e4*/ u32 nc_crcdata; /* CRC data register */
  782. /*e8*/ u32 nc_e8_; /* rsvd */
  783. /*ec*/ u32 nc_ec_; /* rsvd */
  784. /*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */
  785. };
  786. /*-----------------------------------------------------------
  787. **
  788. ** Utility macros for the script.
  789. **
  790. **-----------------------------------------------------------
  791. */
  792. #define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
  793. #define REG(r) REGJ (nc_, r)
  794. typedef u32 ncrcmd;
  795. /*-----------------------------------------------------------
  796. **
  797. ** SCSI phases
  798. **
  799. ** DT phases illegal for ncr driver.
  800. **
  801. **-----------------------------------------------------------
  802. */
  803. #define SCR_DATA_OUT 0x00000000
  804. #define SCR_DATA_IN 0x01000000
  805. #define SCR_COMMAND 0x02000000
  806. #define SCR_STATUS 0x03000000
  807. #define SCR_DT_DATA_OUT 0x04000000
  808. #define SCR_DT_DATA_IN 0x05000000
  809. #define SCR_MSG_OUT 0x06000000
  810. #define SCR_MSG_IN 0x07000000
  811. #define SCR_ILG_OUT 0x04000000
  812. #define SCR_ILG_IN 0x05000000
  813. /*-----------------------------------------------------------
  814. **
  815. ** Data transfer via SCSI.
  816. **
  817. **-----------------------------------------------------------
  818. **
  819. ** MOVE_ABS (LEN)
  820. ** <<start address>>
  821. **
  822. ** MOVE_IND (LEN)
  823. ** <<dnad_offset>>
  824. **
  825. ** MOVE_TBL
  826. ** <<dnad_offset>>
  827. **
  828. **-----------------------------------------------------------
  829. */
  830. #define OPC_MOVE 0x08000000
  831. #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
  832. #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
  833. #define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
  834. #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
  835. #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
  836. #define SCR_CHMOV_TBL (0x10000000)
  837. struct scr_tblmove {
  838. u32 size;
  839. u32 addr;
  840. };
  841. /*-----------------------------------------------------------
  842. **
  843. ** Selection
  844. **
  845. **-----------------------------------------------------------
  846. **
  847. ** SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
  848. ** <<alternate_address>>
  849. **
  850. ** SEL_TBL | << dnad_offset>> [ | REL_JMP]
  851. ** <<alternate_address>>
  852. **
  853. **-----------------------------------------------------------
  854. */
  855. #define SCR_SEL_ABS 0x40000000
  856. #define SCR_SEL_ABS_ATN 0x41000000
  857. #define SCR_SEL_TBL 0x42000000
  858. #define SCR_SEL_TBL_ATN 0x43000000
  859. #ifdef SCSI_NCR_BIG_ENDIAN
  860. struct scr_tblsel {
  861. u8 sel_scntl3;
  862. u8 sel_id;
  863. u8 sel_sxfer;
  864. u8 sel_scntl4;
  865. };
  866. #else
  867. struct scr_tblsel {
  868. u8 sel_scntl4;
  869. u8 sel_sxfer;
  870. u8 sel_id;
  871. u8 sel_scntl3;
  872. };
  873. #endif
  874. #define SCR_JMP_REL 0x04000000
  875. #define SCR_ID(id) (((u32)(id)) << 16)
  876. /*-----------------------------------------------------------
  877. **
  878. ** Waiting for Disconnect or Reselect
  879. **
  880. **-----------------------------------------------------------
  881. **
  882. ** WAIT_DISC
  883. ** dummy: <<alternate_address>>
  884. **
  885. ** WAIT_RESEL
  886. ** <<alternate_address>>
  887. **
  888. **-----------------------------------------------------------
  889. */
  890. #define SCR_WAIT_DISC 0x48000000
  891. #define SCR_WAIT_RESEL 0x50000000
  892. /*-----------------------------------------------------------
  893. **
  894. ** Bit Set / Reset
  895. **
  896. **-----------------------------------------------------------
  897. **
  898. ** SET (flags {|.. })
  899. **
  900. ** CLR (flags {|.. })
  901. **
  902. **-----------------------------------------------------------
  903. */
  904. #define SCR_SET(f) (0x58000000 | (f))
  905. #define SCR_CLR(f) (0x60000000 | (f))
  906. #define SCR_CARRY 0x00000400
  907. #define SCR_TRG 0x00000200
  908. #define SCR_ACK 0x00000040
  909. #define SCR_ATN 0x00000008
  910. /*-----------------------------------------------------------
  911. **
  912. ** Memory to memory move
  913. **
  914. **-----------------------------------------------------------
  915. **
  916. ** COPY (bytecount)
  917. ** << source_address >>
  918. ** << destination_address >>
  919. **
  920. ** SCR_COPY sets the NO FLUSH option by default.
  921. ** SCR_COPY_F does not set this option.
  922. **
  923. ** For chips which do not support this option,
  924. ** ncr_copy_and_bind() will remove this bit.
  925. **-----------------------------------------------------------
  926. */
  927. #define SCR_NO_FLUSH 0x01000000
  928. #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
  929. #define SCR_COPY_F(n) (0xc0000000 | (n))
  930. /*-----------------------------------------------------------
  931. **
  932. ** Register move and binary operations
  933. **
  934. **-----------------------------------------------------------
  935. **
  936. ** SFBR_REG (reg, op, data) reg = SFBR op data
  937. ** << 0 >>
  938. **
  939. ** REG_SFBR (reg, op, data) SFBR = reg op data
  940. ** << 0 >>
  941. **
  942. ** REG_REG (reg, op, data) reg = reg op data
  943. ** << 0 >>
  944. **
  945. **-----------------------------------------------------------
  946. ** On 810A, 860, 825A, 875, 895 and 896 chips the content
  947. ** of SFBR register can be used as data (SCR_SFBR_DATA).
  948. ** The 896 has additionnal IO registers starting at
  949. ** offset 0x80. Bit 7 of register offset is stored in
  950. ** bit 7 of the SCRIPTS instruction first DWORD.
  951. **-----------------------------------------------------------
  952. */
  953. #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
  954. #define SCR_SFBR_REG(reg,op,data) \
  955. (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  956. #define SCR_REG_SFBR(reg,op,data) \
  957. (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  958. #define SCR_REG_REG(reg,op,data) \
  959. (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  960. #define SCR_LOAD 0x00000000
  961. #define SCR_SHL 0x01000000
  962. #define SCR_OR 0x02000000
  963. #define SCR_XOR 0x03000000
  964. #define SCR_AND 0x04000000
  965. #define SCR_SHR 0x05000000
  966. #define SCR_ADD 0x06000000
  967. #define SCR_ADDC 0x07000000
  968. #define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
  969. /*-----------------------------------------------------------
  970. **
  971. ** FROM_REG (reg) SFBR = reg
  972. ** << 0 >>
  973. **
  974. ** TO_REG (reg) reg = SFBR
  975. ** << 0 >>
  976. **
  977. ** LOAD_REG (reg, data) reg = <data>
  978. ** << 0 >>
  979. **
  980. ** LOAD_SFBR(data) SFBR = <data>
  981. ** << 0 >>
  982. **
  983. **-----------------------------------------------------------
  984. */
  985. #define SCR_FROM_REG(reg) \
  986. SCR_REG_SFBR(reg,SCR_OR,0)
  987. #define SCR_TO_REG(reg) \
  988. SCR_SFBR_REG(reg,SCR_OR,0)
  989. #define SCR_LOAD_REG(reg,data) \
  990. SCR_REG_REG(reg,SCR_LOAD,data)
  991. #define SCR_LOAD_SFBR(data) \
  992. (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
  993. /*-----------------------------------------------------------
  994. **
  995. ** LOAD from memory to register.
  996. ** STORE from register to memory.
  997. **
  998. ** Only supported by 810A, 860, 825A, 875, 895 and 896.
  999. **
  1000. **-----------------------------------------------------------
  1001. **
  1002. ** LOAD_ABS (LEN)
  1003. ** <<start address>>
  1004. **
  1005. ** LOAD_REL (LEN) (DSA relative)
  1006. ** <<dsa_offset>>
  1007. **
  1008. **-----------------------------------------------------------
  1009. */
  1010. #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
  1011. #define SCR_NO_FLUSH2 0x02000000
  1012. #define SCR_DSA_REL2 0x10000000
  1013. #define SCR_LOAD_R(reg, how, n) \
  1014. (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  1015. #define SCR_STORE_R(reg, how, n) \
  1016. (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  1017. #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
  1018. #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
  1019. #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
  1020. #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
  1021. #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
  1022. #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
  1023. #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
  1024. #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
  1025. /*-----------------------------------------------------------
  1026. **
  1027. ** Waiting for Disconnect or Reselect
  1028. **
  1029. **-----------------------------------------------------------
  1030. **
  1031. ** JUMP [ | IFTRUE/IFFALSE ( ... ) ]
  1032. ** <<address>>
  1033. **
  1034. ** JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
  1035. ** <<distance>>
  1036. **
  1037. ** CALL [ | IFTRUE/IFFALSE ( ... ) ]
  1038. ** <<address>>
  1039. **
  1040. ** CALLR [ | IFTRUE/IFFALSE ( ... ) ]
  1041. ** <<distance>>
  1042. **
  1043. ** RETURN [ | IFTRUE/IFFALSE ( ... ) ]
  1044. ** <<dummy>>
  1045. **
  1046. ** INT [ | IFTRUE/IFFALSE ( ... ) ]
  1047. ** <<ident>>
  1048. **
  1049. ** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
  1050. ** <<ident>>
  1051. **
  1052. ** Conditions:
  1053. ** WHEN (phase)
  1054. ** IF (phase)
  1055. ** CARRYSET
  1056. ** DATA (data, mask)
  1057. **
  1058. **-----------------------------------------------------------
  1059. */
  1060. #define SCR_NO_OP 0x80000000
  1061. #define SCR_JUMP 0x80080000
  1062. #define SCR_JUMP64 0x80480000
  1063. #define SCR_JUMPR 0x80880000
  1064. #define SCR_CALL 0x88080000
  1065. #define SCR_CALLR 0x88880000
  1066. #define SCR_RETURN 0x90080000
  1067. #define SCR_INT 0x98080000
  1068. #define SCR_INT_FLY 0x98180000
  1069. #define IFFALSE(arg) (0x00080000 | (arg))
  1070. #define IFTRUE(arg) (0x00000000 | (arg))
  1071. #define WHEN(phase) (0x00030000 | (phase))
  1072. #define IF(phase) (0x00020000 | (phase))
  1073. #define DATA(D) (0x00040000 | ((D) & 0xff))
  1074. #define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
  1075. #define CARRYSET (0x00200000)
  1076. /*-----------------------------------------------------------
  1077. **
  1078. ** SCSI constants.
  1079. **
  1080. **-----------------------------------------------------------
  1081. */
  1082. /*
  1083. ** Messages
  1084. */
  1085. #define M_COMPLETE COMMAND_COMPLETE
  1086. #define M_EXTENDED EXTENDED_MESSAGE
  1087. #define M_SAVE_DP SAVE_POINTERS
  1088. #define M_RESTORE_DP RESTORE_POINTERS
  1089. #define M_DISCONNECT DISCONNECT
  1090. #define M_ID_ERROR INITIATOR_ERROR
  1091. #define M_ABORT ABORT_TASK_SET
  1092. #define M_REJECT MESSAGE_REJECT
  1093. #define M_NOOP NOP
  1094. #define M_PARITY MSG_PARITY_ERROR
  1095. #define M_LCOMPLETE LINKED_CMD_COMPLETE
  1096. #define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE
  1097. #define M_RESET TARGET_RESET
  1098. #define M_ABORT_TAG ABORT_TASK
  1099. #define M_CLEAR_QUEUE CLEAR_TASK_SET
  1100. #define M_INIT_REC INITIATE_RECOVERY
  1101. #define M_REL_REC RELEASE_RECOVERY
  1102. #define M_TERMINATE (0x11)
  1103. #define M_SIMPLE_TAG SIMPLE_QUEUE_TAG
  1104. #define M_HEAD_TAG HEAD_OF_QUEUE_TAG
  1105. #define M_ORDERED_TAG ORDERED_QUEUE_TAG
  1106. #define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE
  1107. #define M_IDENTIFY (0x80)
  1108. #define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER
  1109. #define M_X_SYNC_REQ EXTENDED_SDTR
  1110. #define M_X_WIDE_REQ EXTENDED_WDTR
  1111. #define M_X_PPR_REQ EXTENDED_PPR
  1112. /*
  1113. ** Status
  1114. */
  1115. #define S_GOOD (0x00)
  1116. #define S_CHECK_COND (0x02)
  1117. #define S_COND_MET (0x04)
  1118. #define S_BUSY (0x08)
  1119. #define S_INT (0x10)
  1120. #define S_INT_COND_MET (0x14)
  1121. #define S_CONFLICT (0x18)
  1122. #define S_TERMINATED (0x20)
  1123. #define S_QUEUE_FULL (0x28)
  1124. #define S_ILLEGAL (0xff)
  1125. #define S_SENSE (0x80)
  1126. /*
  1127. * End of ncrreg from FreeBSD
  1128. */
  1129. #endif /* defined SYM53C8XX_DEFS_H */