sun3_scsi.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. * Sun3 SCSI stuff by Erik Verbruggen (erik@bigmama.xtdnet.nl)
  3. *
  4. * Sun3 DMA additions by Sam Creasey (sammy@sammy.net)
  5. *
  6. * Adapted from mac_scsinew.h:
  7. */
  8. /*
  9. * Cumana Generic NCR5380 driver defines
  10. *
  11. * Copyright 1993, Drew Eckhardt
  12. * Visionary Computing
  13. * (Unix and Linux consulting and custom programming)
  14. * drew@colorado.edu
  15. * +1 (303) 440-4894
  16. *
  17. * ALPHA RELEASE 1.
  18. *
  19. * For more information, please consult
  20. *
  21. * NCR 5380 Family
  22. * SCSI Protocol Controller
  23. * Databook
  24. *
  25. * NCR Microelectronics
  26. * 1635 Aeroplaza Drive
  27. * Colorado Springs, CO 80916
  28. * 1+ (719) 578-3400
  29. * 1+ (800) 334-5454
  30. */
  31. /*
  32. * $Log: cumana_NCR5380.h,v $
  33. */
  34. #ifndef SUN3_NCR5380_H
  35. #define SUN3_NCR5380_H
  36. #define SUN3SCSI_PUBLIC_RELEASE 1
  37. /*
  38. * Int: level 2 autovector
  39. * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
  40. */
  41. #define IRQ_SUN3_SCSI 2
  42. #define IOBASE_SUN3_SCSI 0x00140000
  43. #define IOBASE_SUN3_VMESCSI 0xff200000
  44. static int sun3scsi_abort(struct scsi_cmnd *);
  45. static int sun3scsi_detect (struct scsi_host_template *);
  46. static const char *sun3scsi_info (struct Scsi_Host *);
  47. static int sun3scsi_bus_reset(struct scsi_cmnd *);
  48. static int sun3scsi_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
  49. static int sun3scsi_release (struct Scsi_Host *);
  50. #ifndef CMD_PER_LUN
  51. #define CMD_PER_LUN 2
  52. #endif
  53. #ifndef CAN_QUEUE
  54. #define CAN_QUEUE 16
  55. #endif
  56. #ifndef SG_TABLESIZE
  57. #define SG_TABLESIZE SG_NONE
  58. #endif
  59. #ifndef MAX_TAGS
  60. #define MAX_TAGS 32
  61. #endif
  62. #ifndef USE_TAGGED_QUEUING
  63. #define USE_TAGGED_QUEUING 1
  64. #endif
  65. #include <scsi/scsicam.h>
  66. #ifdef SUN3_SCSI_VME
  67. #define SUN3_SCSI_NAME "Sun3 NCR5380 VME SCSI"
  68. #else
  69. #define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI"
  70. #endif
  71. #ifndef HOSTS_C
  72. #define NCR5380_implementation_fields \
  73. int port, ctrl
  74. #define NCR5380_local_declare() \
  75. struct Scsi_Host *_instance
  76. #define NCR5380_setup(instance) \
  77. _instance = instance
  78. #define NCR5380_read(reg) sun3scsi_read(reg)
  79. #define NCR5380_write(reg, value) sun3scsi_write(reg, value)
  80. #define NCR5380_intr sun3scsi_intr
  81. #define NCR5380_queue_command sun3scsi_queue_command
  82. #define NCR5380_bus_reset sun3scsi_bus_reset
  83. #define NCR5380_abort sun3scsi_abort
  84. #define NCR5380_proc_info sun3scsi_proc_info
  85. #define NCR5380_dma_xfer_len(i, cmd, phase) \
  86. sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
  87. #define NCR5380_dma_write_setup(instance, data, count) sun3scsi_dma_setup(data, count, 1)
  88. #define NCR5380_dma_read_setup(instance, data, count) sun3scsi_dma_setup(data, count, 0)
  89. #define NCR5380_dma_residual sun3scsi_dma_residual
  90. #define BOARD_NORMAL 0
  91. #define BOARD_NCR53C400 1
  92. /* additional registers - mainly DMA control regs */
  93. /* these start at regbase + 8 -- directly after the NCR regs */
  94. struct sun3_dma_regs {
  95. unsigned short dma_addr_hi; /* vme only */
  96. unsigned short dma_addr_lo; /* vme only */
  97. unsigned short dma_count_hi; /* vme only */
  98. unsigned short dma_count_lo; /* vme only */
  99. unsigned short udc_data; /* udc dma data reg (obio only) */
  100. unsigned short udc_addr; /* uda dma addr reg (obio only) */
  101. unsigned short fifo_data; /* fifo data reg, holds extra byte on
  102. odd dma reads */
  103. unsigned short fifo_count;
  104. unsigned short csr; /* control/status reg */
  105. unsigned short bpack_hi; /* vme only */
  106. unsigned short bpack_lo; /* vme only */
  107. unsigned short ivect; /* vme only */
  108. unsigned short fifo_count_hi; /* vme only */
  109. };
  110. /* ucd chip specific regs - live in dvma space */
  111. struct sun3_udc_regs {
  112. unsigned short rsel; /* select regs to load */
  113. unsigned short addr_hi; /* high word of addr */
  114. unsigned short addr_lo; /* low word */
  115. unsigned short count; /* words to be xfer'd */
  116. unsigned short mode_hi; /* high word of channel mode */
  117. unsigned short mode_lo; /* low word of channel mode */
  118. };
  119. /* addresses of the udc registers */
  120. #define UDC_MODE 0x38
  121. #define UDC_CSR 0x2e /* command/status */
  122. #define UDC_CHN_HI 0x26 /* chain high word */
  123. #define UDC_CHN_LO 0x22 /* chain lo word */
  124. #define UDC_CURA_HI 0x1a /* cur reg A high */
  125. #define UDC_CURA_LO 0x0a /* cur reg A low */
  126. #define UDC_CURB_HI 0x12 /* cur reg B high */
  127. #define UDC_CURB_LO 0x02 /* cur reg B low */
  128. #define UDC_MODE_HI 0x56 /* mode reg high */
  129. #define UDC_MODE_LO 0x52 /* mode reg low */
  130. #define UDC_COUNT 0x32 /* words to xfer */
  131. /* some udc commands */
  132. #define UDC_RESET 0
  133. #define UDC_CHN_START 0xa0 /* start chain */
  134. #define UDC_INT_ENABLE 0x32 /* channel 1 int on */
  135. /* udc mode words */
  136. #define UDC_MODE_HIWORD 0x40
  137. #define UDC_MODE_LSEND 0xc2
  138. #define UDC_MODE_LRECV 0xd2
  139. /* udc reg selections */
  140. #define UDC_RSEL_SEND 0x282
  141. #define UDC_RSEL_RECV 0x182
  142. /* bits in csr reg */
  143. #define CSR_DMA_ACTIVE 0x8000
  144. #define CSR_DMA_CONFLICT 0x4000
  145. #define CSR_DMA_BUSERR 0x2000
  146. #define CSR_FIFO_EMPTY 0x400 /* fifo flushed? */
  147. #define CSR_SDB_INT 0x200 /* sbc interrupt pending */
  148. #define CSR_DMA_INT 0x100 /* dma interrupt pending */
  149. #define CSR_LEFT 0xc0
  150. #define CSR_LEFT_3 0xc0
  151. #define CSR_LEFT_2 0x80
  152. #define CSR_LEFT_1 0x40
  153. #define CSR_PACK_ENABLE 0x20
  154. #define CSR_DMA_ENABLE 0x10
  155. #define CSR_SEND 0x8 /* 1 = send 0 = recv */
  156. #define CSR_FIFO 0x2 /* reset fifo */
  157. #define CSR_INTR 0x4 /* interrupt enable */
  158. #define CSR_SCSI 0x1
  159. #define VME_DATA24 0x3d00
  160. // debugging printk's, taken from atari_scsi.h
  161. /* Debugging printk definitions:
  162. *
  163. * ARB -> arbitration
  164. * ASEN -> auto-sense
  165. * DMA -> DMA
  166. * HSH -> PIO handshake
  167. * INF -> information transfer
  168. * INI -> initialization
  169. * INT -> interrupt
  170. * LNK -> linked commands
  171. * MAIN -> NCR5380_main() control flow
  172. * NDAT -> no data-out phase
  173. * NWR -> no write commands
  174. * PIO -> PIO transfers
  175. * PDMA -> pseudo DMA (unused on Atari)
  176. * QU -> queues
  177. * RSL -> reselections
  178. * SEL -> selections
  179. * USL -> usleep cpde (unused on Atari)
  180. * LBS -> last byte sent (unused on Atari)
  181. * RSS -> restarting of selections
  182. * EXT -> extended messages
  183. * ABRT -> aborting and resetting
  184. * TAG -> queue tag handling
  185. * MER -> merging of consec. buffers
  186. *
  187. */
  188. #include "NCR5380.h"
  189. #if NDEBUG & NDEBUG_ARBITRATION
  190. #define ARB_PRINTK(format, args...) \
  191. printk(KERN_DEBUG format , ## args)
  192. #else
  193. #define ARB_PRINTK(format, args...)
  194. #endif
  195. #if NDEBUG & NDEBUG_AUTOSENSE
  196. #define ASEN_PRINTK(format, args...) \
  197. printk(KERN_DEBUG format , ## args)
  198. #else
  199. #define ASEN_PRINTK(format, args...)
  200. #endif
  201. #if NDEBUG & NDEBUG_DMA
  202. #define DMA_PRINTK(format, args...) \
  203. printk(KERN_DEBUG format , ## args)
  204. #else
  205. #define DMA_PRINTK(format, args...)
  206. #endif
  207. #if NDEBUG & NDEBUG_HANDSHAKE
  208. #define HSH_PRINTK(format, args...) \
  209. printk(KERN_DEBUG format , ## args)
  210. #else
  211. #define HSH_PRINTK(format, args...)
  212. #endif
  213. #if NDEBUG & NDEBUG_INFORMATION
  214. #define INF_PRINTK(format, args...) \
  215. printk(KERN_DEBUG format , ## args)
  216. #else
  217. #define INF_PRINTK(format, args...)
  218. #endif
  219. #if NDEBUG & NDEBUG_INIT
  220. #define INI_PRINTK(format, args...) \
  221. printk(KERN_DEBUG format , ## args)
  222. #else
  223. #define INI_PRINTK(format, args...)
  224. #endif
  225. #if NDEBUG & NDEBUG_INTR
  226. #define INT_PRINTK(format, args...) \
  227. printk(KERN_DEBUG format , ## args)
  228. #else
  229. #define INT_PRINTK(format, args...)
  230. #endif
  231. #if NDEBUG & NDEBUG_LINKED
  232. #define LNK_PRINTK(format, args...) \
  233. printk(KERN_DEBUG format , ## args)
  234. #else
  235. #define LNK_PRINTK(format, args...)
  236. #endif
  237. #if NDEBUG & NDEBUG_MAIN
  238. #define MAIN_PRINTK(format, args...) \
  239. printk(KERN_DEBUG format , ## args)
  240. #else
  241. #define MAIN_PRINTK(format, args...)
  242. #endif
  243. #if NDEBUG & NDEBUG_NO_DATAOUT
  244. #define NDAT_PRINTK(format, args...) \
  245. printk(KERN_DEBUG format , ## args)
  246. #else
  247. #define NDAT_PRINTK(format, args...)
  248. #endif
  249. #if NDEBUG & NDEBUG_NO_WRITE
  250. #define NWR_PRINTK(format, args...) \
  251. printk(KERN_DEBUG format , ## args)
  252. #else
  253. #define NWR_PRINTK(format, args...)
  254. #endif
  255. #if NDEBUG & NDEBUG_PIO
  256. #define PIO_PRINTK(format, args...) \
  257. printk(KERN_DEBUG format , ## args)
  258. #else
  259. #define PIO_PRINTK(format, args...)
  260. #endif
  261. #if NDEBUG & NDEBUG_PSEUDO_DMA
  262. #define PDMA_PRINTK(format, args...) \
  263. printk(KERN_DEBUG format , ## args)
  264. #else
  265. #define PDMA_PRINTK(format, args...)
  266. #endif
  267. #if NDEBUG & NDEBUG_QUEUES
  268. #define QU_PRINTK(format, args...) \
  269. printk(KERN_DEBUG format , ## args)
  270. #else
  271. #define QU_PRINTK(format, args...)
  272. #endif
  273. #if NDEBUG & NDEBUG_RESELECTION
  274. #define RSL_PRINTK(format, args...) \
  275. printk(KERN_DEBUG format , ## args)
  276. #else
  277. #define RSL_PRINTK(format, args...)
  278. #endif
  279. #if NDEBUG & NDEBUG_SELECTION
  280. #define SEL_PRINTK(format, args...) \
  281. printk(KERN_DEBUG format , ## args)
  282. #else
  283. #define SEL_PRINTK(format, args...)
  284. #endif
  285. #if NDEBUG & NDEBUG_USLEEP
  286. #define USL_PRINTK(format, args...) \
  287. printk(KERN_DEBUG format , ## args)
  288. #else
  289. #define USL_PRINTK(format, args...)
  290. #endif
  291. #if NDEBUG & NDEBUG_LAST_BYTE_SENT
  292. #define LBS_PRINTK(format, args...) \
  293. printk(KERN_DEBUG format , ## args)
  294. #else
  295. #define LBS_PRINTK(format, args...)
  296. #endif
  297. #if NDEBUG & NDEBUG_RESTART_SELECT
  298. #define RSS_PRINTK(format, args...) \
  299. printk(KERN_DEBUG format , ## args)
  300. #else
  301. #define RSS_PRINTK(format, args...)
  302. #endif
  303. #if NDEBUG & NDEBUG_EXTENDED
  304. #define EXT_PRINTK(format, args...) \
  305. printk(KERN_DEBUG format , ## args)
  306. #else
  307. #define EXT_PRINTK(format, args...)
  308. #endif
  309. #if NDEBUG & NDEBUG_ABORT
  310. #define ABRT_PRINTK(format, args...) \
  311. printk(KERN_DEBUG format , ## args)
  312. #else
  313. #define ABRT_PRINTK(format, args...)
  314. #endif
  315. #if NDEBUG & NDEBUG_TAGS
  316. #define TAG_PRINTK(format, args...) \
  317. printk(KERN_DEBUG format , ## args)
  318. #else
  319. #define TAG_PRINTK(format, args...)
  320. #endif
  321. #if NDEBUG & NDEBUG_MERGING
  322. #define MER_PRINTK(format, args...) \
  323. printk(KERN_DEBUG format , ## args)
  324. #else
  325. #define MER_PRINTK(format, args...)
  326. #endif
  327. /* conditional macros for NCR5380_print_{,phase,status} */
  328. #define NCR_PRINT(mask) \
  329. ((NDEBUG & (mask)) ? NCR5380_print(instance) : (void)0)
  330. #define NCR_PRINT_PHASE(mask) \
  331. ((NDEBUG & (mask)) ? NCR5380_print_phase(instance) : (void)0)
  332. #define NCR_PRINT_STATUS(mask) \
  333. ((NDEBUG & (mask)) ? NCR5380_print_status(instance) : (void)0)
  334. #endif /* ndef HOSTS_C */
  335. #endif /* SUN3_NCR5380_H */