ncr53c8xx.h 40 KB

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