sym53c8xx_defs.h 40 KB

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