mite.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Hardware driver for NI Mite PCI interface chip
  4. *
  5. * Copyright (C) 1999 David A. Schleef <ds@stm.lbl.gov>
  6. */
  7. #ifndef _MITE_H_
  8. #define _MITE_H_
  9. #include <linux/pci.h>
  10. #define PCI_VENDOR_ID_NATINST 0x1093
  11. //#define DEBUG_MITE
  12. #ifdef DEBUG_MITE
  13. #define MDPRINTK(format, args...) pr_debug(format, ## args)
  14. #else
  15. #define MDPRINTK(args...)
  16. #endif
  17. #define MITE_RING_SIZE 3000
  18. struct mite_dma_chain {
  19. u32 count;
  20. u32 addr;
  21. u32 next;
  22. };
  23. struct mite_struct {
  24. struct mite_struct *next;
  25. int used;
  26. struct pci_dev *pcidev;
  27. unsigned long mite_phys_addr;
  28. void __iomem *mite_io_addr;
  29. unsigned long daq_phys_addr;
  30. void __iomem *daq_io_addr;
  31. int DMA_CheckNearEnd;
  32. struct mite_dma_chain ring[MITE_RING_SIZE];
  33. };
  34. extern struct mite_struct *mite_devices;
  35. extern inline unsigned int mite_irq(struct mite_struct *mite)
  36. {
  37. return mite->pcidev->irq;
  38. };
  39. extern inline unsigned int mite_device_id(struct mite_struct *mite)
  40. {
  41. return mite->pcidev->device;
  42. };
  43. void mite_init(void);
  44. void mite_cleanup(void);
  45. int mite_setup(struct mite_struct *mite);
  46. void mite_unsetup(struct mite_struct *mite);
  47. void mite_list_devices(void);
  48. #define CHAN_OFFSET(x) (0x100 * (x))
  49. /* DMA base for chan 0 is 0x500, chan 1 is 0x600 */
  50. #define MITE_CHOR 0x500
  51. #define CHOR_DMARESET BIT(31)
  52. #define CHOR_SET_SEND_TC BIT(11)
  53. #define CHOR_CLR_SEND_TC BIT(10)
  54. #define CHOR_SET_LPAUSE BIT(9)
  55. #define CHOR_CLR_LPAUSE BIT(8)
  56. #define CHOR_CLRDONE BIT(7)
  57. #define CHOR_CLRRB BIT(6)
  58. #define CHOR_CLRLC BIT(5)
  59. #define CHOR_FRESET BIT(4)
  60. #define CHOR_ABORT BIT(3)
  61. #define CHOR_STOP BIT(2)
  62. #define CHOR_CONT BIT(1)
  63. #define CHOR_START BIT(0)
  64. #define CHOR_PON (CHOR_CLR_SEND_TC | CHOR_CLR_LPAUSE)
  65. #define MITE_CHCR 0x504
  66. #define CHCR_SET_DMA_IE BIT(31)
  67. #define CHCR_CLR_DMA_IE BIT(30)
  68. #define CHCR_SET_LINKP_IE BIT(29)
  69. #define CHCR_CLR_LINKP_IE BIT(28)
  70. #define CHCR_SET_SAR_IE BIT(27)
  71. #define CHCR_CLR_SAR_IE BIT(26)
  72. #define CHCR_SET_DONE_IE BIT(25)
  73. #define CHCR_CLR_DONE_IE BIT(24)
  74. #define CHCR_SET_MRDY_IE BIT(23)
  75. #define CHCR_CLR_MRDY_IE BIT(22)
  76. #define CHCR_SET_DRDY_IE BIT(21)
  77. #define CHCR_CLR_DRDY_IE BIT(20)
  78. #define CHCR_SET_LC_IE BIT(19)
  79. #define CHCR_CLR_LC_IE BIT(18)
  80. #define CHCR_SET_CONT_RB_IE BIT(17)
  81. #define CHCR_CLR_CONT_RB_IE BIT(16)
  82. #define CHCR_FIFODIS BIT(15)
  83. #define CHCR_FIFO_ON 0
  84. #define CHCR_BURSTEN BIT(14)
  85. #define CHCR_NO_BURSTEN 0
  86. #define CHCR_NFTP(x) ((x) << 11)
  87. #define CHCR_NFTP0 CHCR_NFTP(0)
  88. #define CHCR_NFTP1 CHCR_NFTP(1)
  89. #define CHCR_NFTP2 CHCR_NFTP(2)
  90. #define CHCR_NFTP4 CHCR_NFTP(3)
  91. #define CHCR_NFTP8 CHCR_NFTP(4)
  92. #define CHCR_NFTP16 CHCR_NFTP(5)
  93. #define CHCR_NETP(x) ((x) << 11)
  94. #define CHCR_NETP0 CHCR_NETP(0)
  95. #define CHCR_NETP1 CHCR_NETP(1)
  96. #define CHCR_NETP2 CHCR_NETP(2)
  97. #define CHCR_NETP4 CHCR_NETP(3)
  98. #define CHCR_NETP8 CHCR_NETP(4)
  99. #define CHCR_CHEND1 BIT(5)
  100. #define CHCR_CHEND0 BIT(4)
  101. #define CHCR_DIR BIT(3)
  102. #define CHCR_DEV_TO_MEM CHCR_DIR
  103. #define CHCR_MEM_TO_DEV 0
  104. #define CHCR_NORMAL ((0) << 0)
  105. #define CHCR_CONTINUE ((1) << 0)
  106. #define CHCR_RINGBUFF ((2) << 0)
  107. #define CHCR_LINKSHORT ((4) << 0)
  108. #define CHCR_LINKLONG ((5) << 0)
  109. #define CHCRPON (CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | \
  110. CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | \
  111. CHCR_CLR_LC_IE | CHCR_CLR_CONT_IE)
  112. #define MITE_TCR 0x508
  113. /* CR bits */
  114. #define CR_RL(x) ((x) << 21)
  115. #define CR_RL0 CR_RL(0)
  116. #define CR_RL1 CR_RL(1)
  117. #define CR_RL2 CR_RL(2)
  118. #define CR_RL4 CR_RL(3)
  119. #define CR_RL8 CR_RL(4)
  120. #define CR_RL16 CR_RL(5)
  121. #define CR_RL32 CR_RL(6)
  122. #define CR_RL64 CR_RL(7)
  123. #define CR_RD(x) ((x) << 19)
  124. #define CR_RD0 CR_RD(0)
  125. #define CR_RD32 CR_RD(1)
  126. #define CR_RD512 CR_RD(2)
  127. #define CR_RD8192 CR_RD(3)
  128. #define CR_REQS(x) ((x) << 16)
  129. #define CR_REQSDRQ0 CR_REQS(4)
  130. #define CR_REQSDRQ1 CR_REQS(5)
  131. #define CR_REQSDRQ2 CR_REQS(6)
  132. #define CR_REQSDRQ3 CR_REQS(7)
  133. #define CR_ASEQX(x) ((x) << 10)
  134. #define CR_ASEQX0 CR_ASEQX(0)
  135. #define CR_ASEQDONT CR_ASEQX0
  136. #define CR_ASEQXP1 CR_ASEQX(1)
  137. #define CR_ASEQUP CR_ASEQXP1
  138. #define CR_ASEQXP2 CR_ASEQX(2)
  139. #define CR_ASEQDOWN CR_ASEQXP2
  140. #define CR_ASEQXP4 CR_ASEQX(3)
  141. #define CR_ASEQXP8 CR_ASEQX(4)
  142. #define CR_ASEQXP16 CR_ASEQX(5)
  143. #define CR_ASEQXP32 CR_ASEQX(6)
  144. #define CR_ASEQXP64 CR_ASEQX(7)
  145. #define CR_ASEQXM1 CR_ASEQX(9)
  146. #define CR_ASEQXM2 CR_ASEQX(10)
  147. #define CR_ASEQXM4 CR_ASEQX(11)
  148. #define CR_ASEQXM8 CR_ASEQX(12)
  149. #define CR_ASEQXM16 CR_ASEQX(13)
  150. #define CR_ASEQXM32 CR_ASEQX(14)
  151. #define CR_ASEQXM64 CR_ASEQX(15)
  152. #define CR_PSIZEBYTE BIT(8)
  153. #define CR_PSIZEHALF (2 << 8)
  154. #define CR_PSIZEWORD (3 << 8)
  155. #define CR_PORTCPU (0 << 6)
  156. #define CR_PORTIO BIT(6)
  157. #define CR_PORTVXI (2 << 6)
  158. #define CR_PORTMXI (3 << 6)
  159. #define CR_AMDEVICE BIT(0)
  160. #define CHSR_INT 0x80000000
  161. #define CHSR_DONE 0x02000000
  162. #define CHSR_LINKC 0x00080000
  163. #define MITE_MCR 0x50c
  164. #define MCRPON 0
  165. #define MITE_MAR 0x510
  166. #define MITE_DCR 0x514
  167. #define DCR_NORMAL BIT(29)
  168. #define DCRPON 0
  169. #define MITE_DAR 0x518
  170. #define MITE_LKCR 0x51c
  171. #define MITE_LKAR 0x520
  172. #define MITE_LLKAR 0x524
  173. #define MITE_BAR 0x528
  174. #define MITE_BCR 0x52c
  175. #define MITE_SAR 0x530
  176. #define MITE_WSCR 0x534
  177. #define MITE_WSER 0x538
  178. #define MITE_CHSR 0x53c
  179. #define MITE_FCR 0x540
  180. #define MITE_FIFO 0x80
  181. #define MITE_FIFOEND 0xff
  182. #define MITE_AMRAM 0x00
  183. #define MITE_AMDEVICE 0x01
  184. #define MITE_AMHOST_A32_SINGLE 0x09
  185. #define MITE_AMHOST_A24_SINGLE 0x39
  186. #define MITE_AMHOST_A16_SINGLE 0x29
  187. #define MITE_AMHOST_A32_BLOCK 0x0b
  188. #define MITE_AMHOST_A32D64_BLOCK 0x08
  189. #define MITE_AMHOST_A24_BLOCK 0x3b
  190. enum mite_registers {
  191. MITE_IODWBSR = 0xc0, // IO Device Window Base Size Register
  192. MITE_CSIGR = 0x460, // chip signature
  193. MITE_IODWBSR_1 = 0xc4, // IO Device Window Base Size Register 1 (used by 6602 boards)
  194. MITE_IODWCR_1 = 0xf4
  195. };
  196. enum MITE_IODWBSR_bits {
  197. WENAB = 0x80, // window enable
  198. WENAB_6602 = 0x8c // window enable for 6602 boards
  199. };
  200. #endif