firestream.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* drivers/atm/firestream.h - FireStream 155 (MB86697) and
  3. * FireStream 50 (MB86695) device driver
  4. */
  5. /* Written & (C) 2000 by R.E.Wolff@BitWizard.nl
  6. * Copied snippets from zatm.c by Werner Almesberger, EPFL LRC/ICA
  7. * and ambassador.c Copyright (C) 1995-1999 Madge Networks Ltd
  8. */
  9. /*
  10. */
  11. /***********************************************************************
  12. * first the defines for the chip. *
  13. ***********************************************************************/
  14. /********************* General chip parameters. ************************/
  15. #define FS_NR_FREE_POOLS 8
  16. #define FS_NR_RX_QUEUES 4
  17. /********************* queues and queue access macros ******************/
  18. /* A queue entry. */
  19. struct FS_QENTRY {
  20. u32 cmd;
  21. u32 p0, p1, p2;
  22. };
  23. /* A freepool entry. */
  24. struct FS_BPENTRY {
  25. u32 flags;
  26. u32 next;
  27. u32 bsa;
  28. u32 aal_bufsize;
  29. /* The hardware doesn't look at this, but we need the SKB somewhere... */
  30. struct sk_buff *skb;
  31. struct freepool *fp;
  32. struct fs_dev *dev;
  33. };
  34. #define STATUS_CODE(qe) ((qe->cmd >> 22) & 0x3f)
  35. /* OFFSETS against the base of a QUEUE... */
  36. #define QSA 0x00
  37. #define QEA 0x04
  38. #define QRP 0x08
  39. #define QWP 0x0c
  40. #define QCNF 0x10 /* Only for Release queues! */
  41. /* Not for the transmit pending queue. */
  42. /* OFFSETS against the base of a FREE POOL... */
  43. #define FPCNF 0x00
  44. #define FPSA 0x04
  45. #define FPEA 0x08
  46. #define FPCNT 0x0c
  47. #define FPCTU 0x10
  48. #define Q_SA(b) (b + QSA )
  49. #define Q_EA(b) (b + QEA )
  50. #define Q_RP(b) (b + QRP )
  51. #define Q_WP(b) (b + QWP )
  52. #define Q_CNF(b) (b + QCNF)
  53. #define FP_CNF(b) (b + FPCNF)
  54. #define FP_SA(b) (b + FPSA)
  55. #define FP_EA(b) (b + FPEA)
  56. #define FP_CNT(b) (b + FPCNT)
  57. #define FP_CTU(b) (b + FPCTU)
  58. /* bits in a queue register. */
  59. #define Q_FULL 0x1
  60. #define Q_EMPTY 0x2
  61. #define Q_INCWRAP 0x4
  62. #define Q_ADDR_MASK 0xfffffff0
  63. /* bits in a FreePool config register */
  64. #define RBFP_RBS (0x1 << 16)
  65. #define RBFP_RBSVAL (0x1 << 15)
  66. #define RBFP_CME (0x1 << 12)
  67. #define RBFP_DLP (0x1 << 11)
  68. #define RBFP_BFPWT (0x1 << 0)
  69. /* FireStream commands. */
  70. #define QE_CMD_NULL (0x00 << 22)
  71. #define QE_CMD_REG_RD (0x01 << 22)
  72. #define QE_CMD_REG_RDM (0x02 << 22)
  73. #define QE_CMD_REG_WR (0x03 << 22)
  74. #define QE_CMD_REG_WRM (0x04 << 22)
  75. #define QE_CMD_CONFIG_TX (0x05 << 22)
  76. #define QE_CMD_CONFIG_RX (0x06 << 22)
  77. #define QE_CMD_PRP_RD (0x07 << 22)
  78. #define QE_CMD_PRP_RDM (0x2a << 22)
  79. #define QE_CMD_PRP_WR (0x09 << 22)
  80. #define QE_CMD_PRP_WRM (0x2b << 22)
  81. #define QE_CMD_RX_EN (0x0a << 22)
  82. #define QE_CMD_RX_PURGE (0x0b << 22)
  83. #define QE_CMD_RX_PURGE_INH (0x0c << 22)
  84. #define QE_CMD_TX_EN (0x0d << 22)
  85. #define QE_CMD_TX_PURGE (0x0e << 22)
  86. #define QE_CMD_TX_PURGE_INH (0x0f << 22)
  87. #define QE_CMD_RST_CG (0x10 << 22)
  88. #define QE_CMD_SET_CG (0x11 << 22)
  89. #define QE_CMD_RST_CLP (0x12 << 22)
  90. #define QE_CMD_SET_CLP (0x13 << 22)
  91. #define QE_CMD_OVERRIDE (0x14 << 22)
  92. #define QE_CMD_ADD_BFP (0x15 << 22)
  93. #define QE_CMD_DUMP_TX (0x16 << 22)
  94. #define QE_CMD_DUMP_RX (0x17 << 22)
  95. #define QE_CMD_LRAM_RD (0x18 << 22)
  96. #define QE_CMD_LRAM_RDM (0x28 << 22)
  97. #define QE_CMD_LRAM_WR (0x19 << 22)
  98. #define QE_CMD_LRAM_WRM (0x29 << 22)
  99. #define QE_CMD_LRAM_BSET (0x1a << 22)
  100. #define QE_CMD_LRAM_BCLR (0x1b << 22)
  101. #define QE_CMD_CONFIG_SEGM (0x1c << 22)
  102. #define QE_CMD_READ_SEGM (0x1d << 22)
  103. #define QE_CMD_CONFIG_ROUT (0x1e << 22)
  104. #define QE_CMD_READ_ROUT (0x1f << 22)
  105. #define QE_CMD_CONFIG_TM (0x20 << 22)
  106. #define QE_CMD_READ_TM (0x21 << 22)
  107. #define QE_CMD_CONFIG_TXBM (0x22 << 22)
  108. #define QE_CMD_READ_TXBM (0x23 << 22)
  109. #define QE_CMD_CONFIG_RXBM (0x24 << 22)
  110. #define QE_CMD_READ_RXBM (0x25 << 22)
  111. #define QE_CMD_CONFIG_REAS (0x26 << 22)
  112. #define QE_CMD_READ_REAS (0x27 << 22)
  113. #define QE_TRANSMIT_DE (0x0 << 30)
  114. #define QE_CMD_LINKED (0x1 << 30)
  115. #define QE_CMD_IMM (0x2 << 30)
  116. #define QE_CMD_IMM_INQ (0x3 << 30)
  117. #define TD_EPI (0x1 << 27)
  118. #define TD_COMMAND (0x1 << 28)
  119. #define TD_DATA (0x0 << 29)
  120. #define TD_RM_CELL (0x1 << 29)
  121. #define TD_OAM_CELL (0x2 << 29)
  122. #define TD_OAM_CELL_SEGMENT (0x3 << 29)
  123. #define TD_BPI (0x1 << 20)
  124. #define FP_FLAGS_EPI (0x1 << 27)
  125. #define TX_PQ(i) (0x00 + (i) * 0x10)
  126. #define TXB_RQ (0x20)
  127. #define ST_Q (0x48)
  128. #define RXB_FP(i) (0x90 + (i) * 0x14)
  129. #define RXB_RQ(i) (0x134 + (i) * 0x14)
  130. #define TXQ_HP 0
  131. #define TXQ_LP 1
  132. /* Phew. You don't want to know how many revisions these simple queue
  133. * address macros went through before I got them nice and compact as
  134. * they are now. -- REW
  135. */
  136. /* And now for something completely different:
  137. * The rest of the registers... */
  138. #define CMDR0 0x34
  139. #define CMDR1 0x38
  140. #define CMDR2 0x3c
  141. #define CMDR3 0x40
  142. #define SARMODE0 0x5c
  143. #define SARMODE0_TXVCS_0 (0x0 << 0)
  144. #define SARMODE0_TXVCS_1k (0x1 << 0)
  145. #define SARMODE0_TXVCS_2k (0x2 << 0)
  146. #define SARMODE0_TXVCS_4k (0x3 << 0)
  147. #define SARMODE0_TXVCS_8k (0x4 << 0)
  148. #define SARMODE0_TXVCS_16k (0x5 << 0)
  149. #define SARMODE0_TXVCS_32k (0x6 << 0)
  150. #define SARMODE0_TXVCS_64k (0x7 << 0)
  151. #define SARMODE0_TXVCS_32 (0x8 << 0)
  152. #define SARMODE0_ABRVCS_0 (0x0 << 4)
  153. #define SARMODE0_ABRVCS_512 (0x1 << 4)
  154. #define SARMODE0_ABRVCS_1k (0x2 << 4)
  155. #define SARMODE0_ABRVCS_2k (0x3 << 4)
  156. #define SARMODE0_ABRVCS_4k (0x4 << 4)
  157. #define SARMODE0_ABRVCS_8k (0x5 << 4)
  158. #define SARMODE0_ABRVCS_16k (0x6 << 4)
  159. #define SARMODE0_ABRVCS_32k (0x7 << 4)
  160. #define SARMODE0_ABRVCS_32 (0x9 << 4) /* The others are "8", this one really has to
  161. be 9. Tell me you don't believe me. -- REW */
  162. #define SARMODE0_RXVCS_0 (0x0 << 8)
  163. #define SARMODE0_RXVCS_1k (0x1 << 8)
  164. #define SARMODE0_RXVCS_2k (0x2 << 8)
  165. #define SARMODE0_RXVCS_4k (0x3 << 8)
  166. #define SARMODE0_RXVCS_8k (0x4 << 8)
  167. #define SARMODE0_RXVCS_16k (0x5 << 8)
  168. #define SARMODE0_RXVCS_32k (0x6 << 8)
  169. #define SARMODE0_RXVCS_64k (0x7 << 8)
  170. #define SARMODE0_RXVCS_32 (0x8 << 8)
  171. #define SARMODE0_CALSUP_1 (0x0 << 12)
  172. #define SARMODE0_CALSUP_2 (0x1 << 12)
  173. #define SARMODE0_CALSUP_3 (0x2 << 12)
  174. #define SARMODE0_CALSUP_4 (0x3 << 12)
  175. #define SARMODE0_PRPWT_FS50_0 (0x0 << 14)
  176. #define SARMODE0_PRPWT_FS50_2 (0x1 << 14)
  177. #define SARMODE0_PRPWT_FS50_5 (0x2 << 14)
  178. #define SARMODE0_PRPWT_FS50_11 (0x3 << 14)
  179. #define SARMODE0_PRPWT_FS155_0 (0x0 << 14)
  180. #define SARMODE0_PRPWT_FS155_1 (0x1 << 14)
  181. #define SARMODE0_PRPWT_FS155_2 (0x2 << 14)
  182. #define SARMODE0_PRPWT_FS155_3 (0x3 << 14)
  183. #define SARMODE0_SRTS0 (0x1 << 23)
  184. #define SARMODE0_SRTS1 (0x1 << 24)
  185. #define SARMODE0_RUN (0x1 << 25)
  186. #define SARMODE0_UNLOCK (0x1 << 26)
  187. #define SARMODE0_CWRE (0x1 << 27)
  188. #define SARMODE0_INTMODE_READCLEAR (0x0 << 28)
  189. #define SARMODE0_INTMODE_READNOCLEAR (0x1 << 28)
  190. #define SARMODE0_INTMODE_READNOCLEARINHIBIT (0x2 << 28)
  191. #define SARMODE0_INTMODE_READCLEARINHIBIT (0x3 << 28) /* Tell me you don't believe me. */
  192. #define SARMODE0_GINT (0x1 << 30)
  193. #define SARMODE0_SHADEN (0x1 << 31)
  194. #define SARMODE1 0x60
  195. #define SARMODE1_TRTL_SHIFT 0 /* Program to 0 */
  196. #define SARMODE1_RRTL_SHIFT 4 /* Program to 0 */
  197. #define SARMODE1_TAGM (0x1 << 8) /* Program to 0 */
  198. #define SARMODE1_HECM0 (0x1 << 9)
  199. #define SARMODE1_HECM1 (0x1 << 10)
  200. #define SARMODE1_HECM2 (0x1 << 11)
  201. #define SARMODE1_GFCE (0x1 << 14)
  202. #define SARMODE1_GFCR (0x1 << 15)
  203. #define SARMODE1_PMS (0x1 << 18)
  204. #define SARMODE1_GPRI (0x1 << 19)
  205. #define SARMODE1_GPAS (0x1 << 20)
  206. #define SARMODE1_GVAS (0x1 << 21)
  207. #define SARMODE1_GNAM (0x1 << 22)
  208. #define SARMODE1_GPLEN (0x1 << 23)
  209. #define SARMODE1_DUMPE (0x1 << 24)
  210. #define SARMODE1_OAMCRC (0x1 << 25)
  211. #define SARMODE1_DCOAM (0x1 << 26)
  212. #define SARMODE1_DCRM (0x1 << 27)
  213. #define SARMODE1_TSTLP (0x1 << 28)
  214. #define SARMODE1_DEFHEC (0x1 << 29)
  215. #define ISR 0x64
  216. #define IUSR 0x68
  217. #define IMR 0x6c
  218. #define ISR_LPCO (0x1 << 0)
  219. #define ISR_DPCO (0x1 << 1)
  220. #define ISR_RBRQ0_W (0x1 << 2)
  221. #define ISR_RBRQ1_W (0x1 << 3)
  222. #define ISR_RBRQ2_W (0x1 << 4)
  223. #define ISR_RBRQ3_W (0x1 << 5)
  224. #define ISR_RBRQ0_NF (0x1 << 6)
  225. #define ISR_RBRQ1_NF (0x1 << 7)
  226. #define ISR_RBRQ2_NF (0x1 << 8)
  227. #define ISR_RBRQ3_NF (0x1 << 9)
  228. #define ISR_BFP_SC (0x1 << 10)
  229. #define ISR_INIT (0x1 << 11)
  230. #define ISR_INIT_ERR (0x1 << 12) /* Documented as "reserved" */
  231. #define ISR_USCEO (0x1 << 13)
  232. #define ISR_UPEC0 (0x1 << 14)
  233. #define ISR_VPFCO (0x1 << 15)
  234. #define ISR_CRCCO (0x1 << 16)
  235. #define ISR_HECO (0x1 << 17)
  236. #define ISR_TBRQ_W (0x1 << 18)
  237. #define ISR_TBRQ_NF (0x1 << 19)
  238. #define ISR_CTPQ_E (0x1 << 20)
  239. #define ISR_GFC_C0 (0x1 << 21)
  240. #define ISR_PCI_FTL (0x1 << 22)
  241. #define ISR_CSQ_W (0x1 << 23)
  242. #define ISR_CSQ_NF (0x1 << 24)
  243. #define ISR_EXT_INT (0x1 << 25)
  244. #define ISR_RXDMA_S (0x1 << 26)
  245. #define TMCONF 0x78
  246. /* Bits? */
  247. #define CALPRESCALE 0x7c
  248. /* Bits? */
  249. #define CELLOSCONF 0x84
  250. #define CELLOSCONF_COTS (0x1 << 28)
  251. #define CELLOSCONF_CEN (0x1 << 27)
  252. #define CELLOSCONF_SC8 (0x3 << 24)
  253. #define CELLOSCONF_SC4 (0x2 << 24)
  254. #define CELLOSCONF_SC2 (0x1 << 24)
  255. #define CELLOSCONF_SC1 (0x0 << 24)
  256. #define CELLOSCONF_COBS (0x1 << 16)
  257. #define CELLOSCONF_COPK (0x1 << 8)
  258. #define CELLOSCONF_COST (0x1 << 0)
  259. /* Bits? */
  260. #define RAS0 0x1bc
  261. #define RAS0_DCD_XHLT (0x1 << 31)
  262. #define RAS0_VPSEL (0x1 << 16)
  263. #define RAS0_VCSEL (0x1 << 0)
  264. #define RAS1 0x1c0
  265. #define RAS1_UTREG (0x1 << 5)
  266. #define DMAMR 0x1cc
  267. #define DMAMR_TX_MODE_FULL (0x0 << 0)
  268. #define DMAMR_TX_MODE_PART (0x1 << 0)
  269. #define DMAMR_TX_MODE_NONE (0x2 << 0) /* And 3 */
  270. #define RAS2 0x280
  271. #define RAS2_NNI (0x1 << 0)
  272. #define RAS2_USEL (0x1 << 1)
  273. #define RAS2_UBS (0x1 << 2)
  274. struct fs_transmit_config {
  275. u32 flags;
  276. u32 atm_hdr;
  277. u32 TMC[4];
  278. u32 spec;
  279. u32 rtag[3];
  280. };
  281. #define TC_FLAGS_AAL5 (0x0 << 29)
  282. #define TC_FLAGS_TRANSPARENT_PAYLOAD (0x1 << 29)
  283. #define TC_FLAGS_TRANSPARENT_CELL (0x2 << 29)
  284. #define TC_FLAGS_STREAMING (0x1 << 28)
  285. #define TC_FLAGS_PACKET (0x0)
  286. #define TC_FLAGS_TYPE_ABR (0x0 << 22)
  287. #define TC_FLAGS_TYPE_CBR (0x1 << 22)
  288. #define TC_FLAGS_TYPE_VBR (0x2 << 22)
  289. #define TC_FLAGS_TYPE_UBR (0x3 << 22)
  290. #define TC_FLAGS_CAL0 (0x0 << 20)
  291. #define TC_FLAGS_CAL1 (0x1 << 20)
  292. #define TC_FLAGS_CAL2 (0x2 << 20)
  293. #define TC_FLAGS_CAL3 (0x3 << 20)
  294. #define RC_FLAGS_NAM (0x1 << 13)
  295. #define RC_FLAGS_RXBM_PSB (0x0 << 14)
  296. #define RC_FLAGS_RXBM_CIF (0x1 << 14)
  297. #define RC_FLAGS_RXBM_PMB (0x2 << 14)
  298. #define RC_FLAGS_RXBM_STR (0x4 << 14)
  299. #define RC_FLAGS_RXBM_SAF (0x6 << 14)
  300. #define RC_FLAGS_RXBM_POS (0x6 << 14)
  301. #define RC_FLAGS_BFPS (0x1 << 17)
  302. #define RC_FLAGS_BFPS_BFP (0x1 << 17)
  303. #define RC_FLAGS_BFPS_BFP0 (0x0 << 17)
  304. #define RC_FLAGS_BFPS_BFP1 (0x1 << 17)
  305. #define RC_FLAGS_BFPS_BFP2 (0x2 << 17)
  306. #define RC_FLAGS_BFPS_BFP3 (0x3 << 17)
  307. #define RC_FLAGS_BFPS_BFP4 (0x4 << 17)
  308. #define RC_FLAGS_BFPS_BFP5 (0x5 << 17)
  309. #define RC_FLAGS_BFPS_BFP6 (0x6 << 17)
  310. #define RC_FLAGS_BFPS_BFP7 (0x7 << 17)
  311. #define RC_FLAGS_BFPS_BFP01 (0x8 << 17)
  312. #define RC_FLAGS_BFPS_BFP23 (0x9 << 17)
  313. #define RC_FLAGS_BFPS_BFP45 (0xa << 17)
  314. #define RC_FLAGS_BFPS_BFP67 (0xb << 17)
  315. #define RC_FLAGS_BFPS_BFP07 (0xc << 17)
  316. #define RC_FLAGS_BFPS_BFP27 (0xd << 17)
  317. #define RC_FLAGS_BFPS_BFP47 (0xe << 17)
  318. #define RC_FLAGS_BFPP (0x1 << 21)
  319. #define RC_FLAGS_TEVC (0x1 << 22)
  320. #define RC_FLAGS_TEP (0x1 << 23)
  321. #define RC_FLAGS_AAL5 (0x0 << 24)
  322. #define RC_FLAGS_TRANSP (0x1 << 24)
  323. #define RC_FLAGS_TRANSC (0x2 << 24)
  324. #define RC_FLAGS_ML (0x1 << 27)
  325. #define RC_FLAGS_TRBRM (0x1 << 28)
  326. #define RC_FLAGS_PRI (0x1 << 29)
  327. #define RC_FLAGS_HOAM (0x1 << 30)
  328. #define RC_FLAGS_CRC10 (0x1 << 31)
  329. #define RAC 0x1c8
  330. #define RAM 0x1c4
  331. /************************************************************************
  332. * Then the datastructures that the DRIVER uses. *
  333. ************************************************************************/
  334. #define TXQ_NENTRIES 32
  335. #define RXRQ_NENTRIES 1024
  336. struct fs_vcc {
  337. int channo;
  338. wait_queue_head_t close_wait;
  339. struct sk_buff *last_skb;
  340. };
  341. struct queue {
  342. struct FS_QENTRY *sa, *ea;
  343. int offset;
  344. };
  345. struct freepool {
  346. int offset;
  347. int bufsize;
  348. int nr_buffers;
  349. int n;
  350. };
  351. struct fs_dev {
  352. struct fs_dev *next; /* other FS devices */
  353. int flags;
  354. unsigned char irq; /* IRQ */
  355. struct pci_dev *pci_dev; /* PCI stuff */
  356. struct atm_dev *atm_dev;
  357. struct timer_list timer;
  358. unsigned long hw_base; /* mem base address */
  359. void __iomem *base; /* Mapping of base address */
  360. int channo;
  361. unsigned long channel_mask;
  362. struct queue hp_txq, lp_txq, tx_relq, st_q;
  363. struct freepool rx_fp[FS_NR_FREE_POOLS];
  364. struct queue rx_rq[FS_NR_RX_QUEUES];
  365. int nchannels;
  366. struct atm_vcc **atm_vccs;
  367. void *tx_inuse;
  368. int ntxpckts;
  369. };
  370. /* Number of channesl that the FS50 supports. */
  371. #define FS50_CHANNEL_BITS 5
  372. #define FS50_NR_CHANNELS (1 << FS50_CHANNEL_BITS)
  373. #define FS_DEV(atm_dev) ((struct fs_dev *) (atm_dev)->dev_data)
  374. #define FS_VCC(atm_vcc) ((struct fs_vcc *) (atm_vcc)->dev_data)
  375. #define FS_IS50 0x1
  376. #define FS_IS155 0x2
  377. #define IS_FS50(dev) (dev->flags & FS_IS50)
  378. #define IS_FS155(dev) (dev->flags & FS_IS155)
  379. /* Within limits this is user-configurable. */
  380. /* Note: Currently the sum (10 -> 1k channels) is hardcoded in the driver. */
  381. #define FS155_VPI_BITS 4
  382. #define FS155_VCI_BITS 6
  383. #define FS155_CHANNEL_BITS (FS155_VPI_BITS + FS155_VCI_BITS)
  384. #define FS155_NR_CHANNELS (1 << FS155_CHANNEL_BITS)