firestream.h 15 KB

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