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