sym53c8xx_defs.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:53k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /******************************************************************************
  2. **  High Performance device driver for the Symbios 53C896 controller.
  3. **
  4. **  Copyright (C) 1998-2001  Gerard Roudier <groudier@free.fr>
  5. **
  6. **  This driver also supports all the Symbios 53C8XX controller family, 
  7. **  except 53C810 revisions < 16, 53C825 revisions < 16 and all 
  8. **  revisions of 53C815 controllers.
  9. **
  10. **  This driver is based on the Linux port of the FreeBSD ncr driver.
  11. ** 
  12. **  Copyright (C) 1994  Wolfgang Stanglmeier
  13. **  
  14. **-----------------------------------------------------------------------------
  15. **  
  16. **  This program is free software; you can redistribute it and/or modify
  17. **  it under the terms of the GNU General Public License as published by
  18. **  the Free Software Foundation; either version 2 of the License, or
  19. **  (at your option) any later version.
  20. **
  21. **  This program is distributed in the hope that it will be useful,
  22. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24. **  GNU General Public License for more details.
  25. **
  26. **  You should have received a copy of the GNU General Public License
  27. **  along with this program; if not, write to the Free Software
  28. **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. **
  30. **-----------------------------------------------------------------------------
  31. **
  32. **  The Linux port of the FreeBSD ncr driver has been achieved in 
  33. **  november 1995 by:
  34. **
  35. **          Gerard Roudier              <groudier@free.fr>
  36. **
  37. **  Being given that this driver originates from the FreeBSD version, and
  38. **  in order to keep synergy on both, any suggested enhancements and corrections
  39. **  received on Linux are automatically a potential candidate for the FreeBSD 
  40. **  version.
  41. **
  42. **  The original driver has been written for 386bsd and FreeBSD by
  43. **          Wolfgang Stanglmeier        <wolf@cologne.de>
  44. **          Stefan Esser                <se@mi.Uni-Koeln.de>
  45. **
  46. **-----------------------------------------------------------------------------
  47. **
  48. **  Major contributions:
  49. **  --------------------
  50. **
  51. **  NVRAM detection and reading.
  52. **    Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  53. **
  54. **  Added support for MIPS big endian systems.
  55. **  Carsten Langgaard, carstenl@mips.com
  56. **  Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
  57. **
  58. *******************************************************************************
  59. */
  60. #ifndef SYM53C8XX_DEFS_H
  61. #define SYM53C8XX_DEFS_H
  62. /*
  63. ** Check supported Linux versions
  64. */
  65. #if !defined(LINUX_VERSION_CODE)
  66. #include <linux/version.h>
  67. #endif
  68. #include <linux/config.h>
  69. #define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
  70. /*
  71.  * NCR PQS/PDS special device support.
  72.  */
  73. #ifdef CONFIG_SCSI_NCR53C8XX_PQS_PDS
  74. #define SCSI_NCR_PQS_PDS_SUPPORT
  75. #endif
  76. /*
  77.  * No more an option, enabled by default.
  78.  */
  79. #ifndef CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT
  80. #define CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT
  81. #endif
  82. /*
  83. ** These options are not tunable from 'make config'
  84. */
  85. #define SCSI_NCR_PROC_INFO_SUPPORT
  86. /*
  87. ** If you want a driver as small as possible, donnot define the 
  88. ** following options.
  89. */
  90. #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
  91. #define SCSI_NCR_DEBUG_INFO_SUPPORT
  92. #define SCSI_NCR_PCI_FIX_UP_SUPPORT
  93. #ifdef SCSI_NCR_PROC_INFO_SUPPORT
  94. # define SCSI_NCR_USER_COMMAND_SUPPORT
  95. # define SCSI_NCR_USER_INFO_SUPPORT
  96. #endif
  97. /*
  98. ** To disable integrity checking, do not define the 
  99. ** following option.
  100. */
  101. #ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
  102. # define SCSI_NCR_ENABLE_INTEGRITY_CHECK
  103. #endif
  104. /*==========================================================
  105. **
  106. ** nvram settings - #define SCSI_NCR_NVRAM_SUPPORT to enable
  107. **
  108. **==========================================================
  109. */
  110. #ifdef CONFIG_SCSI_NCR53C8XX_NVRAM_DETECT
  111. #define SCSI_NCR_NVRAM_SUPPORT
  112. /* #define SCSI_NCR_DEBUG_NVRAM */
  113. #endif
  114. /* ---------------------------------------------------------------------
  115. ** Take into account kernel configured parameters.
  116. ** Most of these options can be overridden at startup by a command line.
  117. ** ---------------------------------------------------------------------
  118. */
  119. /*
  120.  * For Ultra2 and Ultra3 SCSI support option, use special features. 
  121.  *
  122.  * Value (default) means:
  123.  * bit 0 : all features enabled, except:
  124.  * bit 1 : PCI Write And Invalidate.
  125.  * bit 2 : Data Phase Mismatch handling from SCRIPTS.
  126.  *
  127.  * Use boot options ncr53c8xx=specf:1 if you want all chip features to be 
  128.  * enabled by the driver.
  129.  */
  130. #define SCSI_NCR_SETUP_SPECIAL_FEATURES (3)
  131. #define SCSI_NCR_MAX_SYNC (80)
  132. /*
  133.  * Allow tags from 2 to 256, default 8
  134.  */
  135. #ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS
  136. #if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
  137. #define SCSI_NCR_MAX_TAGS (2)
  138. #elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
  139. #define SCSI_NCR_MAX_TAGS (256)
  140. #else
  141. #define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS
  142. #endif
  143. #else
  144. #define SCSI_NCR_MAX_TAGS (8)
  145. #endif
  146. /*
  147.  * Allow tagged command queuing support if configured with default number 
  148.  * of tags set to max (see above).
  149.  */
  150. #ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
  151. #define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
  152. #elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
  153. #define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS
  154. #else
  155. #define SCSI_NCR_SETUP_DEFAULT_TAGS (0)
  156. #endif
  157. /*
  158.  * Use normal IO if configured. Forced for alpha.
  159.  */
  160. #if defined(CONFIG_SCSI_NCR53C8XX_IOMAPPED)
  161. #define SCSI_NCR_IOMAPPED
  162. #elif defined(__alpha__)
  163. #define SCSI_NCR_IOMAPPED
  164. #elif defined(__powerpc__)
  165. #if LINUX_VERSION_CODE <= LinuxVersionCode(2,4,3)
  166. #define SCSI_NCR_IOMAPPED
  167. #define SCSI_NCR_PCI_MEM_NOT_SUPPORTED
  168. #endif
  169. #elif defined(__sparc__)
  170. #undef SCSI_NCR_IOMAPPED
  171. #endif
  172. /*
  173.  * Immediate arbitration
  174.  */
  175. #if defined(CONFIG_SCSI_NCR53C8XX_IARB)
  176. #define SCSI_NCR_IARB_SUPPORT
  177. #endif
  178. /*
  179.  * Sync transfer frequency at startup.
  180.  * Allow from 5Mhz to 80Mhz default 20 Mhz.
  181.  */
  182. #ifndef CONFIG_SCSI_NCR53C8XX_SYNC
  183. #define CONFIG_SCSI_NCR53C8XX_SYNC (20)
  184. #elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
  185. #undef CONFIG_SCSI_NCR53C8XX_SYNC
  186. #define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC
  187. #endif
  188. #if CONFIG_SCSI_NCR53C8XX_SYNC == 0
  189. #define SCSI_NCR_SETUP_DEFAULT_SYNC (255)
  190. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5
  191. #define SCSI_NCR_SETUP_DEFAULT_SYNC (50)
  192. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20
  193. #define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC))
  194. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33
  195. #define SCSI_NCR_SETUP_DEFAULT_SYNC (11)
  196. #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40
  197. #define SCSI_NCR_SETUP_DEFAULT_SYNC (10)
  198. #else
  199. #define SCSI_NCR_SETUP_DEFAULT_SYNC  (9)
  200. #endif
  201. /*
  202.  * Disallow disconnections at boot-up
  203.  */
  204. #ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
  205. #define SCSI_NCR_SETUP_DISCONNECTION (0)
  206. #else
  207. #define SCSI_NCR_SETUP_DISCONNECTION (1)
  208. #endif
  209. /*
  210.  * Force synchronous negotiation for all targets
  211.  */
  212. #ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
  213. #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1)
  214. #else
  215. #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0)
  216. #endif
  217. /*
  218.  * Disable master parity checking (flawed hardwares need that)
  219.  */
  220. #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
  221. #define SCSI_NCR_SETUP_MASTER_PARITY (0)
  222. #else
  223. #define SCSI_NCR_SETUP_MASTER_PARITY (1)
  224. #endif
  225. /*
  226.  * Disable scsi parity checking (flawed devices may need that)
  227.  */
  228. #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
  229. #define SCSI_NCR_SETUP_SCSI_PARITY (0)
  230. #else
  231. #define SCSI_NCR_SETUP_SCSI_PARITY (1)
  232. #endif
  233. /*
  234.  * Vendor specific stuff
  235.  */
  236. #ifdef CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT
  237. #define SCSI_NCR_SETUP_LED_PIN (1)
  238. #define SCSI_NCR_SETUP_DIFF_SUPPORT (4)
  239. #else
  240. #define SCSI_NCR_SETUP_LED_PIN (0)
  241. #define SCSI_NCR_SETUP_DIFF_SUPPORT (0)
  242. #endif
  243. /*
  244.  * Settle time after reset at boot-up
  245.  */
  246. #define SCSI_NCR_SETUP_SETTLE_TIME (2)
  247. /*
  248. ** Bridge quirks work-around option defaulted to 1.
  249. */
  250. #ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT
  251. #define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1
  252. #endif
  253. /*
  254. ** Work-around common bridge misbehaviour.
  255. **
  256. ** - Do not flush posted writes in the opposite 
  257. **   direction on read.
  258. ** - May reorder DMA writes to memory.
  259. **
  260. ** This option should not affect performances 
  261. ** significantly, so it is the default.
  262. */
  263. #if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
  264. #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
  265. #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
  266. #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
  267. /*
  268. ** Same as option 1, but also deal with 
  269. ** misconfigured interrupts.
  270. **
  271. ** - Edge triggerred instead of level sensitive.
  272. ** - No interrupt line connected.
  273. ** - IRQ number misconfigured.
  274. **
  275. ** If no interrupt is delivered, the driver will 
  276. ** catch the interrupt conditions 10 times per 
  277. ** second. No need to say that this option is 
  278. ** not recommended.
  279. */
  280. #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
  281. #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
  282. #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
  283. #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
  284. #define SCSI_NCR_PCIQ_BROKEN_INTR
  285. /*
  286. ** Some bridge designers decided to flush 
  287. ** everything prior to deliver the interrupt.
  288. ** This option tries to deal with such a 
  289. ** behaviour.
  290. */
  291. #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
  292. #define SCSI_NCR_PCIQ_SYNC_ON_INTR
  293. #endif
  294. /*
  295. ** Other parameters not configurable with "make config"
  296. ** Avoid to change these constants, unless you know what you are doing.
  297. */
  298. #define SCSI_NCR_ALWAYS_SIMPLE_TAG
  299. #define SCSI_NCR_MAX_SCATTER (127)
  300. #define SCSI_NCR_MAX_TARGET (16)
  301. /*
  302. **   Compute some desirable value for CAN_QUEUE 
  303. **   and CMD_PER_LUN.
  304. **   The driver will use lower values if these 
  305. **   ones appear to be too large.
  306. */
  307. #define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
  308. #define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS)
  309. #define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER)
  310. #define SCSI_NCR_TIMER_INTERVAL (HZ)
  311. #if 1 /* defined CONFIG_SCSI_MULTI_LUN */
  312. #define SCSI_NCR_MAX_LUN (16)
  313. #else
  314. #define SCSI_NCR_MAX_LUN (1)
  315. #endif
  316. #ifndef HOSTS_C
  317. /*
  318. ** These simple macros limit expression involving 
  319. ** kernel time values (jiffies) to some that have 
  320. ** chance not to be too much incorrect. :-)
  321. */
  322. #define ktime_get(o) (jiffies + (u_long) o)
  323. #define ktime_exp(b) ((long)(jiffies) - (long)(b) >= 0)
  324. #define ktime_dif(a, b) ((long)(a) - (long)(b))
  325. /* These ones are not used in this driver */
  326. #define ktime_add(a, o) ((a) + (u_long)(o))
  327. #define ktime_sub(a, o) ((a) - (u_long)(o))
  328. /*
  329.  *  IO functions definition for big/little endian CPU support.
  330.  *  For now, the NCR is only supported in little endian addressing mode, 
  331.  */
  332. #ifdef __BIG_ENDIAN
  333. #if LINUX_VERSION_CODE < LinuxVersionCode(2,1,0)
  334. #error "BIG ENDIAN byte ordering needs kernel version >= 2.1.0"
  335. #endif
  336. #define inw_l2b inw
  337. #define inl_l2b inl
  338. #define outw_b2l outw
  339. #define outl_b2l outl
  340. #define readb_raw readb
  341. #define writeb_raw writeb
  342. #if defined(__hppa__)
  343. #define readw_l2b(a) le16_to_cpu(readw(a))
  344. #define readl_l2b(a) le32_to_cpu(readl(a))
  345. #define writew_b2l(v,a) writew(cpu_to_le16(v),a)
  346. #define writel_b2l(v,a) writel(cpu_to_le32(v),a)
  347. #elif defined(__mips__)
  348. #define readw_l2b readw
  349. #define readl_l2b readl
  350. #define writew_b2l writew
  351. #define writel_b2l writel
  352. #define inw_l2b  inw
  353. #define inl_l2b  inl
  354. #define outw_b2l outw
  355. #define outl_b2l outl
  356. #else /* Other big-endian */
  357. #define readw_l2b readw
  358. #define readl_l2b readl
  359. #define writew_b2l writew
  360. #define writel_b2l writel
  361. #endif
  362. #else /* little endian */
  363. #define inw_raw inw
  364. #define inl_raw inl
  365. #define outw_raw outw
  366. #define outl_raw outl
  367. #if defined(__i386__) /* i386 implements full FLAT memory/MMIO model */
  368. #define readb_raw(a) (*(volatile unsigned char *) (a))
  369. #define readw_raw(a) (*(volatile unsigned short *) (a))
  370. #define readl_raw(a) (*(volatile unsigned int *) (a))
  371. #define writeb_raw(b,a) ((*(volatile unsigned char *) (a)) = (b))
  372. #define writew_raw(b,a) ((*(volatile unsigned short *) (a)) = (b))
  373. #define writel_raw(b,a) ((*(volatile unsigned int *) (a)) = (b))
  374. #else /* Other little-endian */
  375. #define readb_raw readb
  376. #define readw_raw readw
  377. #define readl_raw readl
  378. #define writeb_raw writeb
  379. #define writew_raw writew
  380. #define writel_raw writel
  381. #endif
  382. #endif
  383. #ifdef SCSI_NCR_BIG_ENDIAN
  384. #error "The NCR in BIG ENDIAN addressing mode is not (yet) supported"
  385. #endif
  386. /*
  387.  *  IA32 architecture does not reorder STORES and prevents
  388.  *  LOADS from passing STORES. It is called `program order' 
  389.  *  by Intel and allows device drivers to deal with memory 
  390.  *  ordering by only ensuring that the code is not reordered  
  391.  *  by the compiler when ordering is required.
  392.  *  Other architectures implement a weaker ordering that 
  393.  *  requires memory barriers (and also IO barriers when they 
  394.  *  make sense) to be used.
  395.  *  We want to be paranoid for ppc and ia64. :)
  396.  */
  397. #if defined(__i386__) || defined(__x86_64__)
  398. #define MEMORY_BARRIER() do { ; } while(0)
  399. #elif defined __powerpc__
  400. #define MEMORY_BARRIER() __asm__ volatile("eieio; sync" : : : "memory")
  401. #elif defined __ia64__
  402. #define MEMORY_BARRIER() __asm__ volatile("mf.a; mf" : : : "memory")
  403. #else
  404. #define MEMORY_BARRIER() mb()
  405. #endif
  406. /*
  407.  *  If the NCR uses big endian addressing mode over the 
  408.  *  PCI, actual io register addresses for byte and word 
  409.  *  accesses must be changed according to lane routing.
  410.  *  Btw, ncr_offb() and ncr_offw() macros only apply to 
  411.  *  constants and so donnot generate bloated code.
  412.  */
  413. #if defined(SCSI_NCR_BIG_ENDIAN)
  414. #define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))
  415. #define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))
  416. #else
  417. #define ncr_offb(o) (o)
  418. #define ncr_offw(o) (o)
  419. #endif
  420. /*
  421.  *  If the CPU and the NCR use same endian-ness adressing,
  422.  *  no byte reordering is needed for script patching.
  423.  *  Macro cpu_to_scr() is to be used for script patching.
  424.  *  Macro scr_to_cpu() is to be used for getting a DWORD 
  425.  *  from the script.
  426.  */
  427. #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
  428. #define cpu_to_scr(dw) cpu_to_le32(dw)
  429. #define scr_to_cpu(dw) le32_to_cpu(dw)
  430. #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
  431. #define cpu_to_scr(dw) cpu_to_be32(dw)
  432. #define scr_to_cpu(dw) be32_to_cpu(dw)
  433. #else
  434. #define cpu_to_scr(dw) (dw)
  435. #define scr_to_cpu(dw) (dw)
  436. #endif
  437. /*
  438.  *  Access to the controller chip.
  439.  *
  440.  *  If SCSI_NCR_IOMAPPED is defined, the driver will use 
  441.  *  normal IOs instead of the MEMORY MAPPED IO method  
  442.  *  recommended by PCI specifications.
  443.  *  If all PCI bridges, host brigdes and architectures 
  444.  *  would have been correctly designed for PCI, this 
  445.  *  option would be useless.
  446.  *
  447.  *  If the CPU and the NCR use same endian-ness adressing,
  448.  *  no byte reordering is needed for accessing chip io 
  449.  *  registers. Functions suffixed by '_raw' are assumed 
  450.  *  to access the chip over the PCI without doing byte 
  451.  *  reordering. Functions suffixed by '_l2b' are 
  452.  *  assumed to perform little-endian to big-endian byte 
  453.  *  reordering, those suffixed by '_b2l' blah, blah,
  454.  *  blah, ...
  455.  */
  456. #if defined(SCSI_NCR_IOMAPPED)
  457. /*
  458.  *  IO mapped only input / ouput
  459.  */
  460. #define INB_OFF(o) inb (np->base_io + ncr_offb(o))
  461. #define OUTB_OFF(o, val) outb ((val), np->base_io + ncr_offb(o))
  462. #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
  463. #define INW_OFF(o) inw_l2b (np->base_io + ncr_offw(o))
  464. #define INL_OFF(o) inl_l2b (np->base_io + (o))
  465. #define OUTW_OFF(o, val) outw_b2l ((val), np->base_io + ncr_offw(o))
  466. #define OUTL_OFF(o, val) outl_b2l ((val), np->base_io + (o))
  467. #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
  468. #define INW_OFF(o) inw_b2l (np->base_io + ncr_offw(o))
  469. #define INL_OFF(o) inl_b2l (np->base_io + (o))
  470. #define OUTW_OFF(o, val) outw_l2b ((val), np->base_io + ncr_offw(o))
  471. #define OUTL_OFF(o, val) outl_l2b ((val), np->base_io + (o))
  472. #else
  473. #define INW_OFF(o) inw_raw (np->base_io + ncr_offw(o))
  474. #define INL_OFF(o) inl_raw (np->base_io + (o))
  475. #define OUTW_OFF(o, val) outw_raw ((val), np->base_io + ncr_offw(o))
  476. #define OUTL_OFF(o, val) outl_raw ((val), np->base_io + (o))
  477. #endif /* ENDIANs */
  478. #else /* defined SCSI_NCR_IOMAPPED */
  479. /*
  480.  *  MEMORY mapped IO input / output
  481.  */
  482. #define INB_OFF(o) readb_raw((char *)np->reg + ncr_offb(o))
  483. #define OUTB_OFF(o, val) writeb_raw((val), (char *)np->reg + ncr_offb(o))
  484. #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
  485. #define INW_OFF(o) readw_l2b((char *)np->reg + ncr_offw(o))
  486. #define INL_OFF(o) readl_l2b((char *)np->reg + (o))
  487. #define OUTW_OFF(o, val) writew_b2l((val), (char *)np->reg + ncr_offw(o))
  488. #define OUTL_OFF(o, val) writel_b2l((val), (char *)np->reg + (o))
  489. #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
  490. #define INW_OFF(o) readw_b2l((char *)np->reg + ncr_offw(o))
  491. #define INL_OFF(o) readl_b2l((char *)np->reg + (o))
  492. #define OUTW_OFF(o, val) writew_l2b((val), (char *)np->reg + ncr_offw(o))
  493. #define OUTL_OFF(o, val) writel_l2b((val), (char *)np->reg + (o))
  494. #else
  495. #define INW_OFF(o) readw_raw((char *)np->reg + ncr_offw(o))
  496. #define INL_OFF(o) readl_raw((char *)np->reg + (o))
  497. #define OUTW_OFF(o, val) writew_raw((val), (char *)np->reg + ncr_offw(o))
  498. #define OUTL_OFF(o, val) writel_raw((val), (char *)np->reg + (o))
  499. #endif
  500. #endif /* defined SCSI_NCR_IOMAPPED */
  501. #define INB(r) INB_OFF (offsetof(struct ncr_reg,r))
  502. #define INW(r) INW_OFF (offsetof(struct ncr_reg,r))
  503. #define INL(r) INL_OFF (offsetof(struct ncr_reg,r))
  504. #define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))
  505. #define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))
  506. #define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))
  507. /*
  508.  *  Set bit field ON, OFF 
  509.  */
  510. #define OUTONB(r, m) OUTB(r, INB(r) | (m))
  511. #define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))
  512. #define OUTONW(r, m) OUTW(r, INW(r) | (m))
  513. #define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))
  514. #define OUTONL(r, m) OUTL(r, INL(r) | (m))
  515. #define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))
  516. /*
  517.  *  We normally want the chip to have a consistent view
  518.  *  of driver internal data structures when we restart it.
  519.  *  Thus these macros.
  520.  */
  521. #define OUTL_DSP(v)
  522. do {
  523. MEMORY_BARRIER();
  524. OUTL (nc_dsp, (v));
  525. } while (0)
  526. #define OUTONB_STD()
  527. do {
  528. MEMORY_BARRIER();
  529. OUTONB (nc_dcntl, (STD|NOCOM));
  530. } while (0)
  531. /*
  532. ** NCR53C8XX Device Ids
  533. */
  534. #ifndef PCI_DEVICE_ID_NCR_53C810
  535. #define PCI_DEVICE_ID_NCR_53C810 1
  536. #endif
  537. #ifndef PCI_DEVICE_ID_NCR_53C810AP
  538. #define PCI_DEVICE_ID_NCR_53C810AP 5
  539. #endif
  540. #ifndef PCI_DEVICE_ID_NCR_53C815
  541. #define PCI_DEVICE_ID_NCR_53C815 4
  542. #endif
  543. #ifndef PCI_DEVICE_ID_NCR_53C820
  544. #define PCI_DEVICE_ID_NCR_53C820 2
  545. #endif
  546. #ifndef PCI_DEVICE_ID_NCR_53C825
  547. #define PCI_DEVICE_ID_NCR_53C825 3
  548. #endif
  549. #ifndef PCI_DEVICE_ID_NCR_53C860
  550. #define PCI_DEVICE_ID_NCR_53C860 6
  551. #endif
  552. #ifndef PCI_DEVICE_ID_NCR_53C875
  553. #define PCI_DEVICE_ID_NCR_53C875 0xf
  554. #endif
  555. #ifndef PCI_DEVICE_ID_NCR_53C875J
  556. #define PCI_DEVICE_ID_NCR_53C875J 0x8f
  557. #endif
  558. #ifndef PCI_DEVICE_ID_NCR_53C885
  559. #define PCI_DEVICE_ID_NCR_53C885 0xd
  560. #endif
  561. #ifndef PCI_DEVICE_ID_NCR_53C895
  562. #define PCI_DEVICE_ID_NCR_53C895 0xc
  563. #endif
  564. #ifndef PCI_DEVICE_ID_NCR_53C896
  565. #define PCI_DEVICE_ID_NCR_53C896 0xb
  566. #endif
  567. #ifndef PCI_DEVICE_ID_NCR_53C895A
  568. #define PCI_DEVICE_ID_NCR_53C895A 0x12
  569. #endif
  570. #ifndef PCI_DEVICE_ID_NCR_53C875A
  571. #define PCI_DEVICE_ID_NCR_53C875A 0x13
  572. #endif
  573. #ifndef PCI_DEVICE_ID_NCR_53C1510D
  574. #define PCI_DEVICE_ID_NCR_53C1510D 0xa
  575. #endif
  576. #ifndef PCI_DEVICE_ID_LSI_53C1010
  577. #define PCI_DEVICE_ID_LSI_53C1010 0x20
  578. #endif
  579. #ifndef PCI_DEVICE_ID_LSI_53C1010_66
  580. #define PCI_DEVICE_ID_LSI_53C1010_66 0x21
  581. #endif
  582. /*
  583. **   NCR53C8XX devices features table.
  584. */
  585. typedef struct {
  586. unsigned short device_id;
  587. unsigned short revision_id;
  588. char *name;
  589. unsigned char burst_max; /* log-base-2 of max burst */
  590. unsigned char offset_max;
  591. unsigned char nr_divisor;
  592. unsigned int features;
  593. #define FE_LED0 (1<<0)
  594. #define FE_WIDE (1<<1)    /* Wide data transfers */
  595. #define FE_ULTRA (1<<2)   /* Ultra speed 20Mtrans/sec */
  596. #define FE_ULTRA2 (1<<3)   /* Ultra 2 - 40 Mtrans/sec */
  597. #define FE_DBLR (1<<4)   /* Clock doubler present */
  598. #define FE_QUAD (1<<5)   /* Clock quadrupler present */
  599. #define FE_ERL (1<<6)    /* Enable read line */
  600. #define FE_CLSE (1<<7)    /* Cache line size enable */
  601. #define FE_WRIE (1<<8)    /* Write & Invalidate enable */
  602. #define FE_ERMP (1<<9)    /* Enable read multiple */
  603. #define FE_BOF (1<<10)   /* Burst opcode fetch */
  604. #define FE_DFS (1<<11)   /* DMA fifo size */
  605. #define FE_PFEN (1<<12)   /* Prefetch enable */
  606. #define FE_LDSTR (1<<13)   /* Load/Store supported */
  607. #define FE_RAM (1<<14)   /* On chip RAM present */
  608. #define FE_VARCLK (1<<15)   /* SCSI clock may vary */
  609. #define FE_RAM8K (1<<16)   /* On chip RAM sized 8Kb */
  610. #define FE_64BIT (1<<17)   /* Have a 64-bit PCI interface */
  611. #define FE_IO256 (1<<18)   /* Requires full 256 bytes in PCI space */
  612. #define FE_NOPM (1<<19)   /* Scripts handles phase mismatch */
  613. #define FE_LEDC (1<<20)   /* Hardware control of LED */
  614. #define FE_DIFF (1<<21)   /* Support Differential SCSI */
  615. #define FE_ULTRA3 (1<<22)   /* Ultra-3 80Mtrans/sec */
  616. #define FE_66MHZ  (1<<23)   /* 66MHz PCI Support */
  617. #define FE_DAC   (1<<24)   /* Support DAC cycles (64 bit addressing) */
  618. #define FE_ISTAT1  (1<<25)   /* Have ISTAT1, MBOX0, MBOX1 registers */
  619. #define FE_DAC_IN_USE (1<<26)   /* Platform does DAC cycles */
  620. #define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
  621. #define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_ULTRA2|FE_DBLR|FE_QUAD|F_CLK80)
  622. #define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
  623. } ncr_chip;
  624. /*
  625. ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 3.
  626. ** Memory Read transaction terminated by a retry followed by 
  627. ** Memory Read Line command.
  628. */
  629. #define FE_CACHE0_SET (FE_CACHE_SET & ~FE_ERL)
  630. /*
  631. ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 5.
  632. ** On paper, this errata is harmless. But it is a good reason for 
  633. ** using a shorter programmed burst length (64 DWORDS instead of 128).
  634. */
  635. #define SCSI_NCR_CHIP_TABLE
  636. {
  637.  {PCI_DEVICE_ID_NCR_53C810, 0x0f, "810",  4,  8, 4,
  638.  FE_ERL}
  639.  ,
  640.  {PCI_DEVICE_ID_NCR_53C810, 0xff, "810a", 4,  8, 4,
  641.  FE_CACHE_SET|FE_LDSTR|FE_PFEN|FE_BOF}
  642.  ,
  643.  {PCI_DEVICE_ID_NCR_53C815, 0xff, "815",  4,  8, 4,
  644.  FE_ERL|FE_BOF}
  645.  ,
  646.  {PCI_DEVICE_ID_NCR_53C820, 0xff, "820",  4,  8, 4,
  647.  FE_WIDE|FE_ERL}
  648.  ,
  649.  {PCI_DEVICE_ID_NCR_53C825, 0x0f, "825",  4,  8, 4,
  650.  FE_WIDE|FE_ERL|FE_BOF|FE_DIFF}
  651.  ,
  652.  {PCI_DEVICE_ID_NCR_53C825, 0xff, "825a", 6,  8, 4,
  653.  FE_WIDE|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM|FE_DIFF}
  654.  ,
  655.  {PCI_DEVICE_ID_NCR_53C860, 0xff, "860",  4,  8, 5,
  656.  FE_ULTRA|FE_CACHE_SET|FE_BOF|FE_LDSTR|FE_PFEN}
  657.  ,
  658.  {PCI_DEVICE_ID_NCR_53C875, 0x01, "875",  6, 16, 5,
  659.  FE_WIDE|FE_ULTRA|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  660.  FE_RAM|FE_DIFF|FE_VARCLK}
  661.  ,
  662.  {PCI_DEVICE_ID_NCR_53C875, 0xff, "875",  6, 16, 5,
  663.  FE_WIDE|FE_ULTRA|FE_DBLR|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  664.  FE_RAM|FE_DIFF|FE_VARCLK}
  665.  ,
  666.  {PCI_DEVICE_ID_NCR_53C875J,0xff, "875J", 6, 16, 5,
  667.  FE_WIDE|FE_ULTRA|FE_DBLR|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  668.  FE_RAM|FE_VARCLK}
  669.  ,
  670.  {PCI_DEVICE_ID_NCR_53C885, 0xff, "885",  6, 16, 5,
  671.  FE_WIDE|FE_ULTRA|FE_DBLR|FE_CACHE0_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  672.  FE_RAM|FE_DIFF|FE_VARCLK}
  673.  ,
  674.  {PCI_DEVICE_ID_NCR_53C895, 0xff, "895",  6, 31, 7,
  675.  FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  676.  FE_RAM}
  677.  ,
  678.  {PCI_DEVICE_ID_NCR_53C896, 0xff, "896",  6, 31, 7,
  679.  FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  680.  FE_RAM|FE_RAM8K|FE_64BIT|FE_DAC|FE_IO256|FE_NOPM|FE_LEDC|FE_ISTAT1}
  681.  ,
  682.  {PCI_DEVICE_ID_NCR_53C895A, 0xff, "895a",  6, 31, 7,
  683.  FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  684.  FE_RAM|FE_RAM8K|FE_DAC|FE_IO256|FE_NOPM|FE_LEDC}
  685.  ,
  686.  {PCI_DEVICE_ID_NCR_53C875A, 0xff, "875a",  6, 31, 7,
  687.  FE_WIDE|FE_ULTRA|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  688.  FE_RAM|FE_DAC|FE_IO256|FE_NOPM|FE_LEDC}
  689.  ,
  690.  {PCI_DEVICE_ID_NCR_53C1510D, 0xff, "1510D",  7, 31, 7,
  691.  FE_WIDE|FE_ULTRA2|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|
  692.  FE_RAM|FE_IO256}
  693.  ,
  694.  {PCI_DEVICE_ID_LSI_53C1010, 0xff, "1010-33",  6, 62, 7,
  695.  FE_WIDE|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_ISTAT1|
  696.  FE_RAM|FE_RAM8K|FE_64BIT|FE_DAC|FE_IO256|FE_NOPM|FE_LEDC|FE_ULTRA3}
  697.  ,
  698.  {PCI_DEVICE_ID_LSI_53C1010_66, 0xff, "1010-66",  6, 62, 7,
  699.  FE_WIDE|FE_QUAD|FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_ISTAT1|
  700.  FE_RAM|FE_RAM8K|FE_64BIT|FE_DAC|FE_IO256|FE_NOPM|FE_LEDC|FE_ULTRA3|
  701.  FE_66MHZ}
  702. }
  703. /*
  704.  * List of supported NCR chip ids
  705.  */
  706. #define SCSI_NCR_CHIP_IDS
  707. {
  708. PCI_DEVICE_ID_NCR_53C810,
  709. PCI_DEVICE_ID_NCR_53C815,
  710. PCI_DEVICE_ID_NCR_53C820,
  711. PCI_DEVICE_ID_NCR_53C825,
  712. PCI_DEVICE_ID_NCR_53C860,
  713. PCI_DEVICE_ID_NCR_53C875,
  714. PCI_DEVICE_ID_NCR_53C875J,
  715. PCI_DEVICE_ID_NCR_53C885,
  716. PCI_DEVICE_ID_NCR_53C895,
  717. PCI_DEVICE_ID_NCR_53C896,
  718. PCI_DEVICE_ID_NCR_53C895A,
  719. PCI_DEVICE_ID_NCR_53C1510D,
  720.   PCI_DEVICE_ID_LSI_53C1010,
  721.   PCI_DEVICE_ID_LSI_53C1010_66
  722. }
  723. /*
  724. ** Driver setup structure.
  725. **
  726. ** This structure is initialized from linux config options.
  727. ** It can be overridden at boot-up by the boot command line.
  728. */
  729. #define SCSI_NCR_MAX_EXCLUDES 8
  730. struct ncr_driver_setup {
  731. u_char master_parity;
  732. u_char scsi_parity;
  733. u_char disconnection;
  734. u_char special_features;
  735. u_char force_sync_nego;
  736. u_char reverse_probe;
  737. u_char pci_fix_up;
  738. u_char use_nvram;
  739. u_char verbose;
  740. u_char default_tags;
  741. u_short default_sync;
  742. u_short debug;
  743. u_char burst_max;
  744. u_char led_pin;
  745. u_char max_wide;
  746. u_char settle_delay;
  747. u_char diff_support;
  748. u_char irqm;
  749. u_char bus_check;
  750. u_char optimize;
  751. u_char recovery;
  752. u_char host_id;
  753. u_short iarb;
  754. u_long excludes[SCSI_NCR_MAX_EXCLUDES];
  755. char tag_ctrl[100];
  756. };
  757. /*
  758. ** Initial setup.
  759. ** Can be overriden at startup by a command line.
  760. */
  761. #define SCSI_NCR_DRIVER_SETUP
  762. {
  763. SCSI_NCR_SETUP_MASTER_PARITY,
  764. SCSI_NCR_SETUP_SCSI_PARITY,
  765. SCSI_NCR_SETUP_DISCONNECTION,
  766. SCSI_NCR_SETUP_SPECIAL_FEATURES,
  767. SCSI_NCR_SETUP_FORCE_SYNC_NEGO,
  768. 0,
  769. 0,
  770. 1,
  771. 0,
  772. SCSI_NCR_SETUP_DEFAULT_TAGS,
  773. SCSI_NCR_SETUP_DEFAULT_SYNC,
  774. 0x00,
  775. 7,
  776. SCSI_NCR_SETUP_LED_PIN,
  777. 1,
  778. SCSI_NCR_SETUP_SETTLE_TIME,
  779. SCSI_NCR_SETUP_DIFF_SUPPORT,
  780. 0,
  781. 1,
  782. 0,
  783. 0,
  784. 255,
  785. 0x00
  786. }
  787. /*
  788. ** Boot fail safe setup.
  789. ** Override initial setup from boot command line:
  790. ** ncr53c8xx=safe:y
  791. */
  792. #define SCSI_NCR_DRIVER_SAFE_SETUP
  793. {
  794. 0,
  795. 1,
  796. 0,
  797. 0,
  798. 0,
  799. 0,
  800. 0,
  801. 1,
  802. 2,
  803. 0,
  804. 255,
  805. 0x00,
  806. 255,
  807. 0,
  808. 0,
  809. 10,
  810. 1,
  811. 1,
  812. 1,
  813. 0,
  814. 0,
  815. 255
  816. }
  817. #ifdef SCSI_NCR_NVRAM_SUPPORT
  818. /*
  819. ** Symbios NvRAM data format
  820. */
  821. #define SYMBIOS_NVRAM_SIZE 368
  822. #define SYMBIOS_NVRAM_ADDRESS 0x100
  823. struct Symbios_nvram {
  824. /* Header 6 bytes */
  825. u_short type; /* 0x0000 */
  826. u_short byte_count; /* excluding header/trailer */
  827. u_short checksum;
  828. /* Controller set up 20 bytes */
  829. u_char v_major; /* 0x00 */
  830. u_char v_minor; /* 0x30 */
  831. u_int32 boot_crc;
  832. u_short flags;
  833. #define SYMBIOS_SCAM_ENABLE (1)
  834. #define SYMBIOS_PARITY_ENABLE (1<<1)
  835. #define SYMBIOS_VERBOSE_MSGS (1<<2)
  836. #define SYMBIOS_CHS_MAPPING (1<<3)
  837. #define SYMBIOS_NO_NVRAM (1<<3) /* ??? */
  838. u_short flags1;
  839. #define SYMBIOS_SCAN_HI_LO (1)
  840. u_short term_state;
  841. #define SYMBIOS_TERM_CANT_PROGRAM (0)
  842. #define SYMBIOS_TERM_ENABLED (1)
  843. #define SYMBIOS_TERM_DISABLED (2)
  844. u_short rmvbl_flags;
  845. #define SYMBIOS_RMVBL_NO_SUPPORT (0)
  846. #define SYMBIOS_RMVBL_BOOT_DEVICE (1)
  847. #define SYMBIOS_RMVBL_MEDIA_INSTALLED (2)
  848. u_char host_id;
  849. u_char num_hba; /* 0x04 */
  850. u_char num_devices; /* 0x10 */
  851. u_char max_scam_devices; /* 0x04 */
  852. u_char num_valid_scam_devives; /* 0x00 */
  853. u_char rsvd;
  854. /* Boot order 14 bytes * 4 */
  855. struct Symbios_host{
  856. u_short type; /* 4:8xx / 0:nok */
  857. u_short device_id; /* PCI device id */
  858. u_short vendor_id; /* PCI vendor id */
  859. u_char bus_nr; /* PCI bus number */
  860. u_char device_fn; /* PCI device/function number << 3*/
  861. u_short word8;
  862. u_short flags;
  863. #define SYMBIOS_INIT_SCAN_AT_BOOT (1)
  864. u_short io_port; /* PCI io_port address */
  865. } host[4];
  866. /* Targets 8 bytes * 16 */
  867. struct Symbios_target {
  868. u_char flags;
  869. #define SYMBIOS_DISCONNECT_ENABLE (1)
  870. #define SYMBIOS_SCAN_AT_BOOT_TIME (1<<1)
  871. #define SYMBIOS_SCAN_LUNS (1<<2)
  872. #define SYMBIOS_QUEUE_TAGS_ENABLED (1<<3)
  873. u_char rsvd;
  874. u_char bus_width; /* 0x08/0x10 */
  875. u_char sync_offset;
  876. u_short sync_period; /* 4*period factor */
  877. u_short timeout;
  878. } target[16];
  879. /* Scam table 8 bytes * 4 */
  880. struct Symbios_scam {
  881. u_short id;
  882. u_short method;
  883. #define SYMBIOS_SCAM_DEFAULT_METHOD (0)
  884. #define SYMBIOS_SCAM_DONT_ASSIGN (1)
  885. #define SYMBIOS_SCAM_SET_SPECIFIC_ID (2)
  886. #define SYMBIOS_SCAM_USE_ORDER_GIVEN (3)
  887. u_short status;
  888. #define SYMBIOS_SCAM_UNKNOWN (0)
  889. #define SYMBIOS_SCAM_DEVICE_NOT_FOUND (1)
  890. #define SYMBIOS_SCAM_ID_NOT_SET (2)
  891. #define SYMBIOS_SCAM_ID_VALID (3)
  892. u_char target_id;
  893. u_char rsvd;
  894. } scam[4];
  895. u_char spare_devices[15*8];
  896. u_char trailer[6]; /* 0xfe 0xfe 0x00 0x00 0x00 0x00 */
  897. };
  898. typedef struct Symbios_nvram Symbios_nvram;
  899. typedef struct Symbios_host Symbios_host;
  900. typedef struct Symbios_target Symbios_target;
  901. typedef struct Symbios_scam Symbios_scam;
  902. /*
  903. ** Tekram NvRAM data format.
  904. */
  905. #define TEKRAM_NVRAM_SIZE 64
  906. #define TEKRAM_93C46_NVRAM_ADDRESS 0
  907. #define TEKRAM_24C16_NVRAM_ADDRESS 0x40
  908. struct Tekram_nvram {
  909. struct Tekram_target {
  910. u_char flags;
  911. #define TEKRAM_PARITY_CHECK (1)
  912. #define TEKRAM_SYNC_NEGO (1<<1)
  913. #define TEKRAM_DISCONNECT_ENABLE (1<<2)
  914. #define TEKRAM_START_CMD (1<<3)
  915. #define TEKRAM_TAGGED_COMMANDS (1<<4)
  916. #define TEKRAM_WIDE_NEGO (1<<5)
  917. u_char sync_index;
  918. u_short word2;
  919. } target[16];
  920. u_char host_id;
  921. u_char flags;
  922. #define TEKRAM_MORE_THAN_2_DRIVES (1)
  923. #define TEKRAM_DRIVES_SUP_1GB (1<<1)
  924. #define TEKRAM_RESET_ON_POWER_ON (1<<2)
  925. #define TEKRAM_ACTIVE_NEGATION (1<<3)
  926. #define TEKRAM_IMMEDIATE_SEEK (1<<4)
  927. #define TEKRAM_SCAN_LUNS (1<<5)
  928. #define TEKRAM_REMOVABLE_FLAGS (3<<6) /* 0: disable; 1: boot device; 2:all */
  929. u_char boot_delay_index;
  930. u_char max_tags_index;
  931. u_short flags1;
  932. #define TEKRAM_F2_F6_ENABLED (1)
  933. u_short spare[29];
  934. };
  935. typedef struct Tekram_nvram Tekram_nvram;
  936. typedef struct Tekram_target Tekram_target;
  937. #endif /* SCSI_NCR_NVRAM_SUPPORT */
  938. /**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
  939. /*-----------------------------------------------------------------
  940. **
  941. ** The ncr 53c810 register structure.
  942. **
  943. **-----------------------------------------------------------------
  944. */
  945. struct ncr_reg {
  946. /*00*/  u_char    nc_scntl0;    /* full arb., ena parity, par->ATN  */
  947. /*01*/  u_char    nc_scntl1;    /* no reset                         */
  948.         #define   ISCON   0x10  /* connected to scsi     */
  949.         #define   CRST    0x08  /* force reset                      */
  950.         #define   IARB    0x02  /* immediate arbitration            */
  951. /*02*/  u_char    nc_scntl2;    /* no disconnect expected           */
  952. #define   SDU     0x80  /* cmd: disconnect will raise error */
  953. #define   CHM     0x40  /* sta: chained mode                */
  954. #define   WSS     0x08  /* sta: wide scsi send           [W]*/
  955. #define   WSR     0x01  /* sta: wide scsi received       [W]*/
  956. /*03*/  u_char    nc_scntl3;    /* cnf system clock dependent       */
  957. #define   EWS     0x08  /* cmd: enable wide scsi         [W]*/
  958. #define   ULTRA   0x80  /* cmd: ULTRA enable                */
  959. /* bits 0-2, 7 rsvd for C1010       */
  960. /*04*/  u_char    nc_scid; /* cnf host adapter scsi address    */
  961. #define   RRE     0x40  /* r/w:e enable response to resel.  */
  962. #define   SRE     0x20  /* r/w:e enable response to select  */
  963. /*05*/  u_char    nc_sxfer; /* ### Sync speed and count         */
  964. /* bits 6-7 rsvd for C1010          */
  965. /*06*/  u_char    nc_sdid; /* ### Destination-ID               */
  966. /*07*/  u_char    nc_gpreg; /* ??? IO-Pins                      */
  967. /*08*/  u_char    nc_sfbr; /* ### First byte in phase          */
  968. /*09*/  u_char    nc_socl;
  969. #define   CREQ   0x80 /* r/w: SCSI-REQ                    */
  970. #define   CACK   0x40 /* r/w: SCSI-ACK                    */
  971. #define   CBSY   0x20 /* r/w: SCSI-BSY                    */
  972. #define   CSEL   0x10 /* r/w: SCSI-SEL                    */
  973. #define   CATN   0x08 /* r/w: SCSI-ATN                    */
  974. #define   CMSG   0x04 /* r/w: SCSI-MSG                    */
  975. #define   CC_D   0x02 /* r/w: SCSI-C_D                    */
  976. #define   CI_O   0x01 /* r/w: SCSI-I_O                    */
  977. /*0a*/  u_char    nc_ssid;
  978. /*0b*/  u_char    nc_sbcl;
  979. /*0c*/  u_char    nc_dstat;
  980.         #define   DFE     0x80  /* sta: dma fifo empty              */
  981.         #define   MDPE    0x40  /* int: master data parity error    */
  982.         #define   BF      0x20  /* int: script: bus fault           */
  983.         #define   ABRT    0x10  /* int: script: command aborted     */
  984.         #define   SSI     0x08  /* int: script: single step         */
  985.         #define   SIR     0x04  /* int: script: interrupt instruct. */
  986.         #define   IID     0x01  /* int: script: illegal instruct.   */
  987. /*0d*/  u_char    nc_sstat0;
  988.         #define   ILF     0x80  /* sta: data in SIDL register lsb   */
  989.         #define   ORF     0x40  /* sta: data in SODR register lsb   */
  990.         #define   OLF     0x20  /* sta: data in SODL register lsb   */
  991.         #define   AIP     0x10  /* sta: arbitration in progress     */
  992.         #define   LOA     0x08  /* sta: arbitration lost            */
  993.         #define   WOA     0x04  /* sta: arbitration won             */
  994.         #define   IRST    0x02  /* sta: scsi reset signal           */
  995.         #define   SDP     0x01  /* sta: scsi parity signal          */
  996. /*0e*/  u_char    nc_sstat1;
  997. #define   FF3210  0xf0 /* sta: bytes in the scsi fifo      */
  998. /*0f*/  u_char    nc_sstat2;
  999.         #define   ILF1    0x80  /* sta: data in SIDL register msb[W]*/
  1000.         #define   ORF1    0x40  /* sta: data in SODR register msb[W]*/
  1001.         #define   OLF1    0x20  /* sta: data in SODL register msb[W]*/
  1002.         #define   DM      0x04  /* sta: DIFFSENS mismatch (895/6 only) */
  1003.         #define   LDSC    0x02  /* sta: disconnect & reconnect      */
  1004. /*10*/  u_char    nc_dsa; /* --> Base page                    */
  1005. /*11*/  u_char    nc_dsa1;
  1006. /*12*/  u_char    nc_dsa2;
  1007. /*13*/  u_char    nc_dsa3;
  1008. /*14*/  u_char    nc_istat; /* --> Main Command and status      */
  1009.         #define   CABRT   0x80  /* cmd: abort current operation     */
  1010.         #define   SRST    0x40  /* mod: reset chip                  */
  1011.         #define   SIGP    0x20  /* r/w: message from host to ncr    */
  1012.         #define   SEM     0x10  /* r/w: message between host + ncr  */
  1013.         #define   CON     0x08  /* sta: connected to scsi           */
  1014.         #define   INTF    0x04  /* sta: int on the fly (reset by wr)*/
  1015.         #define   SIP     0x02  /* sta: scsi-interrupt              */
  1016.         #define   DIP     0x01  /* sta: host/script interrupt       */
  1017. /*15*/  u_char    nc_istat1; /* 896 and later cores only */
  1018.         #define   FLSH    0x04  /* sta: chip is flushing            */
  1019.         #define   SRUN    0x02  /* sta: scripts are running         */
  1020.         #define   SIRQD   0x01  /* r/w: disable INT pin             */
  1021. /*16*/  u_char    nc_mbox0; /* 896 and later cores only */
  1022. /*17*/  u_char    nc_mbox1; /* 896 and later cores only */
  1023. /*18*/ u_char   nc_ctest0;
  1024. /*19*/  u_char    nc_ctest1;
  1025. /*1a*/  u_char    nc_ctest2;
  1026. #define   CSIGP   0x40
  1027. /* bits 0-2,7 rsvd for C1010        */
  1028. /*1b*/  u_char    nc_ctest3;
  1029. #define   FLF     0x08  /* cmd: flush dma fifo              */
  1030. #define   CLF   0x04 /* cmd: clear dma fifo     */
  1031. #define   FM      0x02  /* mod: fetch pin mode              */
  1032. #define   WRIE    0x01  /* mod: write and invalidate enable */
  1033. /* bits 4-7 rsvd for C1010          */
  1034. /*1c*/  u_int32    nc_temp; /* ### Temporary stack              */
  1035. /*20*/ u_char   nc_dfifo;
  1036. /*21*/  u_char    nc_ctest4;
  1037. #define   BDIS    0x80  /* mod: burst disable               */
  1038. #define   MPEE    0x08  /* mod: master parity error enable  */
  1039. /*22*/  u_char    nc_ctest5;
  1040. #define   DFS     0x20  /* mod: dma fifo size               */
  1041. /* bits 0-1, 3-7 rsvd for C1010          */
  1042. /*23*/  u_char    nc_ctest6;
  1043. /*24*/  u_int32    nc_dbc; /* ### Byte count and command       */
  1044. /*28*/  u_int32    nc_dnad; /* ### Next command register        */
  1045. /*2c*/  u_int32    nc_dsp; /* --> Script Pointer               */
  1046. /*30*/  u_int32    nc_dsps; /* --> Script pointer save/opcode#2 */
  1047. /*34*/  u_char     nc_scratcha;  /* Temporary register a            */
  1048. /*35*/  u_char     nc_scratcha1;
  1049. /*36*/  u_char     nc_scratcha2;
  1050. /*37*/  u_char     nc_scratcha3;
  1051. /*38*/  u_char    nc_dmode;
  1052. #define   BL_2    0x80  /* mod: burst length shift value +2 */
  1053. #define   BL_1    0x40  /* mod: burst length shift value +1 */
  1054. #define   ERL     0x08  /* mod: enable read line            */
  1055. #define   ERMP    0x04  /* mod: enable read multiple        */
  1056. #define   BOF     0x02  /* mod: burst op code fetch         */
  1057. /*39*/  u_char    nc_dien;
  1058. /*3a*/  u_char    nc_sbr;
  1059. /*3b*/  u_char    nc_dcntl; /* --> Script execution control     */
  1060. #define   CLSE    0x80  /* mod: cache line size enable      */
  1061. #define   PFF     0x40  /* cmd: pre-fetch flush             */
  1062. #define   PFEN    0x20  /* mod: pre-fetch enable            */
  1063. #define   SSM     0x10  /* mod: single step mode            */
  1064. #define   IRQM    0x08  /* mod: irq mode (1 = totem pole !) */
  1065. #define   STD     0x04  /* cmd: start dma mode              */
  1066. #define   IRQD    0x02  /* mod: irq disable                 */
  1067.   #define   NOCOM   0x01 /* cmd: protect sfbr while reselect */
  1068. /* bits 0-1 rsvd for C1010          */
  1069. /*3c*/  u_int32    nc_adder;
  1070. /*40*/  u_short   nc_sien; /* -->: interrupt enable            */
  1071. /*42*/  u_short   nc_sist; /* <--: interrupt status            */
  1072.         #define   SBMC    0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
  1073.         #define   STO     0x0400/* sta: timeout (select)            */
  1074.         #define   GEN     0x0200/* sta: timeout (general)           */
  1075.         #define   HTH     0x0100/* sta: timeout (handshake)         */
  1076.         #define   MA      0x80  /* sta: phase mismatch              */
  1077.         #define   CMP     0x40  /* sta: arbitration complete        */
  1078.         #define   SEL     0x20  /* sta: selected by another device  */
  1079.         #define   RSL     0x10  /* sta: reselected by another device*/
  1080.         #define   SGE     0x08  /* sta: gross error (over/underflow)*/
  1081.         #define   UDC     0x04  /* sta: unexpected disconnect       */
  1082.         #define   RST     0x02  /* sta: scsi bus reset detected     */
  1083.         #define   PAR     0x01  /* sta: scsi parity error           */
  1084. /*44*/  u_char    nc_slpar;
  1085. /*45*/  u_char    nc_swide;
  1086. /*46*/  u_char    nc_macntl;
  1087. /*47*/  u_char    nc_gpcntl;
  1088. /*48*/  u_char    nc_stime0;    /* cmd: timeout for select&handshake*/
  1089. /*49*/  u_char    nc_stime1;    /* cmd: timeout user defined        */
  1090. /*4a*/  u_short   nc_respid;    /* sta: Reselect-IDs                */
  1091. /*4c*/  u_char    nc_stest0;
  1092. /*4d*/  u_char    nc_stest1;
  1093. #define   SCLK    0x80 /* Use the PCI clock as SCSI clock */
  1094. #define   DBLEN   0x08 /* clock doubler running */
  1095. #define   DBLSEL  0x04 /* clock doubler selected */
  1096.   
  1097. /*4e*/  u_char    nc_stest2;
  1098. #define   ROF     0x40 /* reset scsi offset (after gross error!) */
  1099. #define   EXT     0x02  /* extended filtering                     */
  1100. /*4f*/  u_char    nc_stest3;
  1101. #define   TE     0x80 /* c: tolerAnt enable */
  1102. #define   HSC    0x20 /* c: Halt SCSI Clock */
  1103. #define   CSF    0x02 /* c: clear scsi fifo */
  1104. /*50*/  u_short   nc_sidl; /* Lowlevel: latched from scsi data */
  1105. /*52*/  u_char    nc_stest4;
  1106. #define   SMODE  0xc0 /* SCSI bus mode      (895/6 only) */
  1107. #define    SMODE_HVD 0x40 /* High Voltage Differential       */
  1108. #define    SMODE_SE  0x80 /* Single Ended                    */
  1109. #define    SMODE_LVD 0xc0 /* Low Voltage Differential        */
  1110. #define   LCKFRQ 0x20 /* Frequency Lock (895/6 only)     */
  1111. /* bits 0-5 rsvd for C1010          */
  1112. /*53*/  u_char    nc_53_;
  1113. /*54*/  u_short   nc_sodl; /* Lowlevel: data out to scsi data  */
  1114. /*56*/ u_char    nc_ccntl0; /* Chip Control 0 (896)             */
  1115. #define   ENPMJ  0x80 /* Enable Phase Mismatch Jump       */
  1116. #define   PMJCTL 0x40 /* Phase Mismatch Jump Control      */
  1117. #define   ENNDJ  0x20 /* Enable Non Data PM Jump          */
  1118. #define   DISFC  0x10 /* Disable Auto FIFO Clear          */
  1119. #define   DILS   0x02 /* Disable Internal Load/Store      */
  1120. #define   DPR    0x01 /* Disable Pipe Req                 */
  1121. /*57*/ u_char    nc_ccntl1; /* Chip Control 1 (896)             */
  1122. #define   ZMOD   0x80 /* High Impedance Mode              */
  1123. #define   DIC  0x10 /* Disable Internal Cycles     */
  1124. #define   DDAC   0x08 /* Disable Dual Address Cycle       */
  1125. #define   XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode  */
  1126. #define   EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV    */
  1127. #define   EXDBMV 0x01 /* Enable 64-bit Direct BMOV        */
  1128. /*58*/  u_short   nc_sbdl; /* Lowlevel: data from scsi data    */
  1129. /*5a*/  u_short   nc_5a_;
  1130. /*5c*/  u_char    nc_scr0; /* Working register B               */
  1131. /*5d*/  u_char    nc_scr1; /*                                  */
  1132. /*5e*/  u_char    nc_scr2; /*                                  */
  1133. /*5f*/  u_char    nc_scr3; /*                                  */
  1134. /*60*/  u_char    nc_scrx[64]; /* Working register C-R             */
  1135. /*a0*/ u_int32   nc_mmrs; /* Memory Move Read Selector        */
  1136. /*a4*/ u_int32   nc_mmws; /* Memory Move Write Selector       */
  1137. /*a8*/ u_int32   nc_sfs; /* Script Fetch Selector            */
  1138. /*ac*/ u_int32   nc_drs; /* DSA Relative Selector            */
  1139. /*b0*/ u_int32   nc_sbms; /* Static Block Move Selector       */
  1140. /*b4*/ u_int32   nc_dbms; /* Dynamic Block Move Selector      */
  1141. /*b8*/ u_int32   nc_dnad64; /* DMA Next Address 64              */
  1142. /*bc*/ u_short   nc_scntl4;    /* C1010 only                       */
  1143. #define   U3EN   0x80 /* Enable Ultra 3                   */
  1144. #define   AIPEN  0x40   /* Allow check upper byte lanes     */
  1145. #define   XCLKH_DT 0x08 /* Extra clock of data hold on DT
  1146. transfer edge             */
  1147. #define   XCLKH_ST 0x04 /* Extra clock of data hold on ST
  1148. transfer edge             */
  1149. /*be*/  u_char   nc_aipcntl0; /* Epat Control 1 C1010 only        */
  1150. /*bf*/  u_char   nc_aipcntl1; /* AIP Control C1010_66 Only        */
  1151. /*c0*/ u_int32   nc_pmjad1; /* Phase Mismatch Jump Address 1    */
  1152. /*c4*/ u_int32   nc_pmjad2; /* Phase Mismatch Jump Address 2    */
  1153. /*c8*/ u_char    nc_rbc; /* Remaining Byte Count             */
  1154. /*c9*/ u_char    nc_rbc1; /*                                  */
  1155. /*ca*/ u_char    nc_rbc2; /*                                  */
  1156. /*cb*/ u_char    nc_rbc3; /*                                  */
  1157. /*cc*/ u_char    nc_ua; /* Updated Address                  */
  1158. /*cd*/ u_char    nc_ua1; /*                                  */
  1159. /*ce*/ u_char    nc_ua2; /*                                  */
  1160. /*cf*/ u_char    nc_ua3; /*                                  */
  1161. /*d0*/ u_int32   nc_esa; /* Entry Storage Address            */
  1162. /*d4*/ u_char    nc_ia; /* Instruction Address              */
  1163. /*d5*/ u_char    nc_ia1;
  1164. /*d6*/ u_char    nc_ia2;
  1165. /*d7*/ u_char    nc_ia3;
  1166. /*d8*/ u_int32   nc_sbc; /* SCSI Byte Count (3 bytes only)   */
  1167. /*dc*/ u_int32   nc_csbc; /* Cumulative SCSI Byte Count       */
  1168.                                 /* Following for C1010 only         */
  1169. /*e0*/ u_short    nc_crcpad;    /* CRC Value                        */
  1170. /*e2*/ u_char     nc_crccntl0;  /* CRC control register             */
  1171. #define   SNDCRC  0x10 /* Send CRC Request                 */
  1172. /*e3*/ u_char     nc_crccntl1;  /* CRC control register             */
  1173. /*e4*/ u_int32    nc_crcdata;   /* CRC data register                */ 
  1174. /*e8*/ u_int32   nc_e8_; /* rsvd      */
  1175. /*ec*/ u_int32   nc_ec_; /* rsvd      */
  1176. /*f0*/ u_short    nc_dfbc;      /* DMA FIFO byte count              */ 
  1177. };
  1178. /*-----------------------------------------------------------
  1179. **
  1180. ** Utility macros for the script.
  1181. **
  1182. **-----------------------------------------------------------
  1183. */
  1184. #define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
  1185. #define REG(r) REGJ (nc_, r)
  1186. typedef u_int32 ncrcmd;
  1187. /*-----------------------------------------------------------
  1188. **
  1189. ** SCSI phases
  1190. **
  1191. ** DT phases illegal for ncr driver.
  1192. **
  1193. **-----------------------------------------------------------
  1194. */
  1195. #define SCR_DATA_OUT 0x00000000
  1196. #define SCR_DATA_IN 0x01000000
  1197. #define SCR_COMMAND 0x02000000
  1198. #define SCR_STATUS 0x03000000
  1199. #define SCR_DT_DATA_OUT 0x04000000
  1200. #define SCR_DT_DATA_IN 0x05000000
  1201. #define SCR_MSG_OUT 0x06000000
  1202. #define SCR_MSG_IN      0x07000000
  1203. #define SCR_ILG_OUT 0x04000000
  1204. #define SCR_ILG_IN 0x05000000
  1205. /*-----------------------------------------------------------
  1206. **
  1207. ** Data transfer via SCSI.
  1208. **
  1209. **-----------------------------------------------------------
  1210. **
  1211. ** MOVE_ABS (LEN)
  1212. ** <<start address>>
  1213. **
  1214. ** MOVE_IND (LEN)
  1215. ** <<dnad_offset>>
  1216. **
  1217. ** MOVE_TBL
  1218. ** <<dnad_offset>>
  1219. **
  1220. **-----------------------------------------------------------
  1221. */
  1222. #define OPC_MOVE          0x08000000
  1223. #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
  1224. #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
  1225. #define SCR_MOVE_TBL     (0x10000000 | OPC_MOVE)
  1226. #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
  1227. #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
  1228. #define SCR_CHMOV_TBL     (0x10000000)
  1229. struct scr_tblmove {
  1230.         u_int32  size;
  1231.         u_int32  addr;
  1232. };
  1233. /*-----------------------------------------------------------
  1234. **
  1235. ** Selection
  1236. **
  1237. **-----------------------------------------------------------
  1238. **
  1239. ** SEL_ABS | SCR_ID (0..15)    [ | REL_JMP]
  1240. ** <<alternate_address>>
  1241. **
  1242. ** SEL_TBL | << dnad_offset>>  [ | REL_JMP]
  1243. ** <<alternate_address>>
  1244. **
  1245. **-----------------------------------------------------------
  1246. */
  1247. #define SCR_SEL_ABS 0x40000000
  1248. #define SCR_SEL_ABS_ATN 0x41000000
  1249. #define SCR_SEL_TBL 0x42000000
  1250. #define SCR_SEL_TBL_ATN 0x43000000
  1251. struct scr_tblsel {
  1252.         u_char  sel_scntl4;
  1253.         u_char  sel_sxfer;
  1254.         u_char  sel_id;
  1255.         u_char  sel_scntl3;
  1256. };
  1257. #define SCR_JMP_REL     0x04000000
  1258. #define SCR_ID(id) (((u_int32)(id)) << 16)
  1259. /*-----------------------------------------------------------
  1260. **
  1261. ** Waiting for Disconnect or Reselect
  1262. **
  1263. **-----------------------------------------------------------
  1264. **
  1265. ** WAIT_DISC
  1266. ** dummy: <<alternate_address>>
  1267. **
  1268. ** WAIT_RESEL
  1269. ** <<alternate_address>>
  1270. **
  1271. **-----------------------------------------------------------
  1272. */
  1273. #define SCR_WAIT_DISC 0x48000000
  1274. #define SCR_WAIT_RESEL  0x50000000
  1275. /*-----------------------------------------------------------
  1276. **
  1277. ** Bit Set / Reset
  1278. **
  1279. **-----------------------------------------------------------
  1280. **
  1281. ** SET (flags {|.. })
  1282. **
  1283. ** CLR (flags {|.. })
  1284. **
  1285. **-----------------------------------------------------------
  1286. */
  1287. #define SCR_SET(f)     (0x58000000 | (f))
  1288. #define SCR_CLR(f)     (0x60000000 | (f))
  1289. #define SCR_CARRY 0x00000400
  1290. #define SCR_TRG 0x00000200
  1291. #define SCR_ACK 0x00000040
  1292. #define SCR_ATN 0x00000008
  1293. /*-----------------------------------------------------------
  1294. **
  1295. ** Memory to memory move
  1296. **
  1297. **-----------------------------------------------------------
  1298. **
  1299. ** COPY (bytecount)
  1300. ** << source_address >>
  1301. ** << destination_address >>
  1302. **
  1303. ** SCR_COPY   sets the NO FLUSH option by default.
  1304. ** SCR_COPY_F does not set this option.
  1305. **
  1306. ** For chips which do not support this option,
  1307. ** ncr_copy_and_bind() will remove this bit.
  1308. **-----------------------------------------------------------
  1309. */
  1310. #define SCR_NO_FLUSH 0x01000000
  1311. #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
  1312. #define SCR_COPY_F(n) (0xc0000000 | (n))
  1313. /*-----------------------------------------------------------
  1314. **
  1315. ** Register move and binary operations
  1316. **
  1317. **-----------------------------------------------------------
  1318. **
  1319. ** SFBR_REG (reg, op, data)        reg  = SFBR op data
  1320. ** << 0 >>
  1321. **
  1322. ** REG_SFBR (reg, op, data)        SFBR = reg op data
  1323. ** << 0 >>
  1324. **
  1325. ** REG_REG  (reg, op, data)        reg  = reg op data
  1326. ** << 0 >>
  1327. **
  1328. **-----------------------------------------------------------
  1329. ** On 810A, 860, 825A, 875, 895 and 896 chips the content 
  1330. ** of SFBR register can be used as data (SCR_SFBR_DATA).
  1331. ** The 896 has additionnal IO registers starting at 
  1332. ** offset 0x80. Bit 7 of register offset is stored in 
  1333. ** bit 7 of the SCRIPTS instruction first DWORD.
  1334. **-----------------------------------------------------------
  1335. */
  1336. #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80)) 
  1337. #define SCR_SFBR_REG(reg,op,data) 
  1338.         (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  1339. #define SCR_REG_SFBR(reg,op,data) 
  1340.         (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  1341. #define SCR_REG_REG(reg,op,data) 
  1342.         (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
  1343. #define      SCR_LOAD   0x00000000
  1344. #define      SCR_SHL    0x01000000
  1345. #define      SCR_OR     0x02000000
  1346. #define      SCR_XOR    0x03000000
  1347. #define      SCR_AND    0x04000000
  1348. #define      SCR_SHR    0x05000000
  1349. #define      SCR_ADD    0x06000000
  1350. #define      SCR_ADDC   0x07000000
  1351. #define      SCR_SFBR_DATA   (0x00800000>>8ul) /* Use SFBR as data */
  1352. /*-----------------------------------------------------------
  1353. **
  1354. ** FROM_REG (reg)   SFBR = reg
  1355. ** << 0 >>
  1356. **
  1357. ** TO_REG  (reg)   reg  = SFBR
  1358. ** << 0 >>
  1359. **
  1360. ** LOAD_REG (reg, data)   reg  = <data>
  1361. ** << 0 >>
  1362. **
  1363. ** LOAD_SFBR(data)    SFBR = <data>
  1364. ** << 0 >>
  1365. **
  1366. **-----------------------------------------------------------
  1367. */
  1368. #define SCR_FROM_REG(reg) 
  1369. SCR_REG_SFBR(reg,SCR_OR,0)
  1370. #define SCR_TO_REG(reg) 
  1371. SCR_SFBR_REG(reg,SCR_OR,0)
  1372. #define SCR_LOAD_REG(reg,data) 
  1373. SCR_REG_REG(reg,SCR_LOAD,data)
  1374. #define SCR_LOAD_SFBR(data) 
  1375.         (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
  1376. /*-----------------------------------------------------------
  1377. **
  1378. ** LOAD  from memory   to register.
  1379. ** STORE from register to memory.
  1380. **
  1381. ** Only supported by 810A, 860, 825A, 875, 895 and 896.
  1382. **
  1383. **-----------------------------------------------------------
  1384. **
  1385. ** LOAD_ABS (LEN)
  1386. ** <<start address>>
  1387. **
  1388. ** LOAD_REL (LEN)        (DSA relative)
  1389. ** <<dsa_offset>>
  1390. **
  1391. **-----------------------------------------------------------
  1392. */
  1393. #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
  1394. #define SCR_NO_FLUSH2 0x02000000
  1395. #define SCR_DSA_REL2 0x10000000
  1396. #define SCR_LOAD_R(reg, how, n) 
  1397.         (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  1398. #define SCR_STORE_R(reg, how, n) 
  1399.         (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
  1400. #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
  1401. #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
  1402. #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
  1403. #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
  1404. #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
  1405. #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
  1406. #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
  1407. #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
  1408. /*-----------------------------------------------------------
  1409. **
  1410. ** Waiting for Disconnect or Reselect
  1411. **
  1412. **-----------------------------------------------------------
  1413. **
  1414. ** JUMP            [ | IFTRUE/IFFALSE ( ... ) ]
  1415. ** <<address>>
  1416. **
  1417. ** JUMPR           [ | IFTRUE/IFFALSE ( ... ) ]
  1418. ** <<distance>>
  1419. **
  1420. ** CALL            [ | IFTRUE/IFFALSE ( ... ) ]
  1421. ** <<address>>
  1422. **
  1423. ** CALLR           [ | IFTRUE/IFFALSE ( ... ) ]
  1424. ** <<distance>>
  1425. **
  1426. ** RETURN          [ | IFTRUE/IFFALSE ( ... ) ]
  1427. ** <<dummy>>
  1428. **
  1429. ** INT             [ | IFTRUE/IFFALSE ( ... ) ]
  1430. ** <<ident>>
  1431. **
  1432. ** INT_FLY         [ | IFTRUE/IFFALSE ( ... ) ]
  1433. ** <<ident>>
  1434. **
  1435. ** Conditions:
  1436. **      WHEN (phase)
  1437. **      IF   (phase)
  1438. **      CARRYSET
  1439. **      DATA (data, mask)
  1440. **
  1441. **-----------------------------------------------------------
  1442. */
  1443. #define SCR_NO_OP       0x80000000
  1444. #define SCR_JUMP        0x80080000
  1445. #define SCR_JUMP64      0x80480000
  1446. #define SCR_JUMPR       0x80880000
  1447. #define SCR_CALL        0x88080000
  1448. #define SCR_CALLR       0x88880000
  1449. #define SCR_RETURN      0x90080000
  1450. #define SCR_INT         0x98080000
  1451. #define SCR_INT_FLY     0x98180000
  1452. #define IFFALSE(arg)   (0x00080000 | (arg))
  1453. #define IFTRUE(arg)    (0x00000000 | (arg))
  1454. #define WHEN(phase)    (0x00030000 | (phase))
  1455. #define IF(phase)      (0x00020000 | (phase))
  1456. #define DATA(D)        (0x00040000 | ((D) & 0xff))
  1457. #define MASK(D,M)      (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
  1458. #define CARRYSET       (0x00200000)
  1459. /*-----------------------------------------------------------
  1460. **
  1461. ** SCSI  constants.
  1462. **
  1463. **-----------------------------------------------------------
  1464. */
  1465. /*
  1466. ** Messages
  1467. */
  1468. #define M_COMPLETE (0x00)
  1469. #define M_EXTENDED (0x01)
  1470. #define M_SAVE_DP (0x02)
  1471. #define M_RESTORE_DP (0x03)
  1472. #define M_DISCONNECT (0x04)
  1473. #define M_ID_ERROR (0x05)
  1474. #define M_ABORT (0x06)
  1475. #define M_REJECT (0x07)
  1476. #define M_NOOP (0x08)
  1477. #define M_PARITY (0x09)
  1478. #define M_LCOMPLETE (0x0a)
  1479. #define M_FCOMPLETE (0x0b)
  1480. #define M_RESET (0x0c)
  1481. #define M_ABORT_TAG (0x0d)
  1482. #define M_CLEAR_QUEUE (0x0e)
  1483. #define M_INIT_REC (0x0f)
  1484. #define M_REL_REC (0x10)
  1485. #define M_TERMINATE (0x11)
  1486. #define M_SIMPLE_TAG (0x20)
  1487. #define M_HEAD_TAG (0x21)
  1488. #define M_ORDERED_TAG (0x22)
  1489. #define M_IGN_RESIDUE (0x23)
  1490. #define M_IDENTIFY    (0x80)
  1491. #define M_X_MODIFY_DP (0x00)
  1492. #define M_X_SYNC_REQ (0x01)
  1493. #define M_X_WIDE_REQ (0x03)
  1494. #define M_X_PPR_REQ (0x04)
  1495. /*
  1496. ** Status
  1497. */
  1498. #define S_GOOD (0x00)
  1499. #define S_CHECK_COND (0x02)
  1500. #define S_COND_MET (0x04)
  1501. #define S_BUSY (0x08)
  1502. #define S_INT (0x10)
  1503. #define S_INT_COND_MET (0x14)
  1504. #define S_CONFLICT (0x18)
  1505. #define S_TERMINATED (0x20)
  1506. #define S_QUEUE_FULL (0x28)
  1507. #define S_ILLEGAL (0xff)
  1508. #define S_SENSE (0x80)
  1509. /*
  1510.  * End of ncrreg from FreeBSD
  1511.  */
  1512. #endif /* !defined HOSTS_C */
  1513. #endif /* defined SYM53C8XX_DEFS_H */