ncr53c8xx.h 41 KB

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