ncr53c8xx.h 40 KB

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