ncr53c8xx.h 39 KB

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