atm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. typedef unsigned char uint8;
  2. typedef unsigned short uint16;
  3. typedef unsigned int uint32;
  4. typedef volatile unsigned char vuint8;
  5. typedef volatile unsigned short vuint16;
  6. typedef volatile unsigned int vuint32;
  7. #define DPRAM_ATM CFG_IMMR + 0x3000
  8. #define ATM_DPRAM_BEGIN (DPRAM_ATM - CFG_IMMR - 0x2000)
  9. #define NUM_CONNECTIONS 1
  10. #define SAR_RXB_SIZE 1584
  11. #define AM_HMASK 0x0FFFFFF0
  12. #define NUM_CT_ENTRIES (NUM_CONNECTIONS)
  13. #define NUM_TCTE_ENTRIES (NUM_CONNECTIONS)
  14. #define NUM_AM_ENTRIES (NUM_CONNECTIONS+1)
  15. #define NUM_AP_ENTRIES (NUM_CONNECTIONS+1)
  16. #define NUM_MPHYPT_ENTRIES 1
  17. #define NUM_APCP_ENTRIES 1
  18. #define NUM_APCT_PRIO_1_ENTRIES 146 /* Determines minimum rate */
  19. #define NUM_TQ_ENTRIES 12
  20. #define SIZE_OF_CT_ENTRY 64
  21. #define SIZE_OF_TCTE_ENTRY 32
  22. #define SIZE_OF_AM_ENTRY 4
  23. #define SIZE_OF_AP_ENTRY 2
  24. #define SIZE_OF_MPHYPT_ENTRY 2
  25. #define SIZE_OF_APCP_ENTRY 32
  26. #define SIZE_OF_APCT_ENTRY 2
  27. #define SIZE_OF_TQ_ENTRY 2
  28. #define CT_BASE ((ATM_DPRAM_BEGIN + 63) & 0xFFC0) /*64*/
  29. #define TCTE_BASE (CT_BASE + NUM_CT_ENTRIES * SIZE_OF_CT_ENTRY) /*32*/
  30. #define APCP_BASE (TCTE_BASE + NUM_TCTE_ENTRIES * SIZE_OF_TCTE_ENTRY) /*32*/
  31. #define AM_BEGIN (APCP_BASE + NUM_APCP_ENTRIES * SIZE_OF_APCP_ENTRY) /*4*/
  32. #define AM_BASE (AM_BEGIN + (NUM_AM_ENTRIES - 1) * SIZE_OF_AM_ENTRY)
  33. #define AP_BEGIN (AM_BEGIN + NUM_AM_ENTRIES * SIZE_OF_AM_ENTRY) /*2*/
  34. #define AP_BASE (AP_BEGIN + (NUM_AP_ENTRIES - 1) * SIZE_OF_AP_ENTRY)
  35. #define MPHYPT_BASE (AP_BEGIN + NUM_AP_ENTRIES * SIZE_OF_AP_ENTRY) /*2*/
  36. #define APCT_PRIO_1_BASE (MPHYPT_BASE + NUM_MPHYPT_ENTRIES * SIZE_OF_MPHYPT_ENTRY) /*2*/
  37. #define TQ_BASE (APCT_PRIO_1_BASE + NUM_APCT_PRIO_1_ENTRIES * SIZE_OF_APCT_ENTRY) /*2*/
  38. #define ATM_DPRAM_SIZE ((TQ_BASE + NUM_TQ_ENTRIES * SIZE_OF_TQ_ENTRY) - ATM_DPRAM_BEGIN)
  39. #define CT_PTR(base) ((struct ct_entry_t *)((char *)(base) + 0x2000 + CT_BASE))
  40. #define TCTE_PTR(base) ((struct tcte_entry_t *)((char *)(base) + 0x2000 + TCTE_BASE))
  41. #define AM_PTR(base) ((uint32 *)((char *)(base) + 0x2000 + AM_BASE))
  42. #define AP_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + AP_BASE))
  43. #define MPHYPT_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + MPHYPT_BASE))
  44. #define APCP_PTR(base) ((struct apc_params_t *)((char*)(base) + 0x2000 + APCP_BASE))
  45. #define APCT1_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + APCT_PRIO_1_BASE))
  46. #define APCT2_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + APCT_PRIO_2_BASE))
  47. #define APCT3_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + APCT_PRIO_3_BASE))
  48. #define TQ_PTR(base) ((uint16 *)((char *)(base) + 0x2000 + TQ_BASE))
  49. /* SAR registers */
  50. #define RBDBASE(base) ((vuint32 *)(base + 0x3F00)) /* Base address of RxBD-List */
  51. #define SRFCR(base) ((vuint8 *)(base + 0x3F04)) /* DMA Receive function code */
  52. #define SRSTATE(base) ((vuint8 *)(base + 0x3F05)) /* DMA Receive status */
  53. #define MRBLR(base) ((vuint16 *)(base + 0x3F06)) /* Init to 0 for ATM */
  54. #define RSTATE(base) ((vuint32 *)(base + 0x3F08)) /* Do not write to */
  55. #define R_CNT(base) ((vuint16 *)(base + 0x3F10)) /* Do not write to */
  56. #define STFCR(base) ((vuint8 *)(base + 0x3F12)) /* DMA Transmit function code */
  57. #define STSTATE(base) ((vuint8 *)(base + 0x3F13)) /* DMA Transmit status */
  58. #define TBDBASE(base) ((vuint32 *)(base + 0x3F14)) /* Base address of TxBD-List */
  59. #define TSTATE(base) ((vuint32 *)(base + 0x3F18)) /* Do not write to */
  60. #define COMM_CH(base) ((vuint16 *)(base + 0x3F1C)) /* Command channel */
  61. #define STCHNUM(base) ((vuint16 *)(base + 0x3F1E)) /* Do not write to */
  62. #define T_CNT(base) ((vuint16 *)(base + 0x3F20)) /* Do not write to */
  63. #define CTBASE(base) ((vuint16 *)(base + 0x3F22)) /* Base address of Connection-table */
  64. #define ECTBASE(base) ((vuint32 *)(base + 0x3F24)) /* Valid only for external Conn.-table */
  65. #define INTBASE(base) ((vuint32 *)(base + 0x3F28)) /* Base address of Interrupt-table */
  66. #define INTPTR(base) ((vuint32 *)(base + 0x3F2C)) /* Pointer to Interrupt-queue */
  67. #define C_MASK(base) ((vuint32 *)(base + 0x3F30)) /* CRC-mask */
  68. #define SRCHNUM(base) ((vuint16 *)(base + 0x3F34)) /* Do not write to */
  69. #define INT_CNT(base) ((vuint16 *)(base + 0x3F36)) /* Interrupt-Counter */
  70. #define INT_ICNT(base) ((vuint16 *)(base + 0x3F38)) /* Interrupt threshold */
  71. #define TSTA(base) ((vuint16 *)(base + 0x3F3A)) /* Time-stamp-address */
  72. #define OLDLEN(base) ((vuint16 *)(base + 0x3F3C)) /* Do not write to */
  73. #define SMRBLR(base) ((vuint16 *)(base + 0x3F3E)) /* SAR max RXBuffer length */
  74. #define EHEAD(base) ((vuint32 *)(base + 0x3F40)) /* Valid for serial mode */
  75. #define EPAYLOAD(base) ((vuint32 *)(base + 0x3F44)) /* Valid for serial mode */
  76. #define TQBASE(base) ((vuint16 *)(base + 0x3F48)) /* Base address of Tx queue */
  77. #define TQEND(base) ((vuint16 *)(base + 0x3F4A)) /* End address of Tx queue */
  78. #define TQAPTR(base) ((vuint16 *)(base + 0x3F4C)) /* TQ APC pointer */
  79. #define TQTPTR(base) ((vuint16 *)(base + 0x3F4E)) /* TQ Tx pointer */
  80. #define APCST(base) ((vuint16 *)(base + 0x3F50)) /* APC status */
  81. #define APCPTR(base) ((vuint16 *)(base + 0x3F52)) /* APC parameter pointer */
  82. #define HMASK(base) ((vuint32 *)(base + 0x3F54)) /* Header mask */
  83. #define AMBASE(base) ((vuint16 *)(base + 0x3F58)) /* Address match table base */
  84. #define AMEND(base) ((vuint16 *)(base + 0x3F5A)) /* Address match table end */
  85. #define APBASE(base) ((vuint16 *)(base + 0x3F5C)) /* Address match parameter */
  86. #define FLBASE(base) ((vuint32 *)(base + 0x3F54)) /* First-level table base */
  87. #define SLBASE(base) ((vuint32 *)(base + 0x3F58)) /* Second-level table base */
  88. #define FLMASK(base) ((vuint16 *)(base + 0x3F5C)) /* First-level mask */
  89. #define ECSIZE(base) ((vuint16 *)(base + 0x3F5E)) /* Valid for extended mode */
  90. #define APCT_REAL(base) ((vuint32 *)(base + 0x3F60)) /* APC 32 bit counter */
  91. #define R_PTR(base) ((vuint32 *)(base + 0x3F64)) /* Do not write to */
  92. #define RTEMP(base) ((vuint32 *)(base + 0x3F68)) /* Do not write to */
  93. #define T_PTR(base) ((vuint32 *)(base + 0x3F6C)) /* Do not write to */
  94. #define TTEMP(base) ((vuint32 *)(base + 0x3F70)) /* Do not write to */
  95. /* ESAR registers */
  96. #define FMCTIMESTMP(base) ((vuint32 *)(base + 0x3F80)) /* Perf.Mon.Timestamp */
  97. #define FMCTEMPLATE(base) ((vuint32 *)(base + 0x3F84)) /* Perf.Mon.Template */
  98. #define PMPTR(base) ((vuint16 *)(base + 0x3F88)) /* Perf.Mon.Table */
  99. #define PMCHANNEL(base) ((vuint16 *)(base + 0x3F8A)) /* Perf.Mon.Channel */
  100. #define MPHYST(base) ((vuint16 *)(base + 0x3F90)) /* Multi-PHY Status */
  101. #define TCTEBASE(base) ((vuint16 *)(base + 0x3F92)) /* Internal TCT Extension Base */
  102. #define ETCTEBASE(base) ((vuint32 *)(base + 0x3F94)) /* External TCT Extension Base */
  103. #define COMM_CH2(base) ((vuint32 *)(base + 0x3F98)) /* 2nd command channel word */
  104. #define STATBASE(base) ((vuint16 *)(base + 0x3F9C)) /* Statistics table pointer */
  105. /* UTOPIA Mode Register */
  106. #define UTMODE(base) (CAST(vuint32 *)(base + 0x0978))
  107. /* SAR commands */
  108. #define TRANSMIT_CHANNEL_ACTIVATE_CMD 0x0FC1
  109. #define TRANSMIT_CHANNEL_DEACTIVATE_CMD 0x1FC1
  110. #define STOP_TRANSMIT_CMD 0x2FC1
  111. #define RESTART_TRANSMIT_CMD 0x3FC1
  112. #define STOP_RECEIVE_CMD 0x4FC1
  113. #define RESTART_RECEIVE_CMD 0x5FC1
  114. #define APC_BYPASS_CMD 0x6FC1
  115. #define MEM_WRITE_CMD 0x7FC1
  116. #define CPCR_FLG 0x0001
  117. /* INT flags */
  118. #define INT_VALID 0x80000000
  119. #define INT_WRAP 0x40000000
  120. #define INT_APCO 0x00800000
  121. #define INT_TQF 0x00200000
  122. #define INT_RXF 0x00080000
  123. #define INT_BSY 0x00040000
  124. #define INT_TXB 0x00020000
  125. #define INT_RXB 0x00010000
  126. #define NUM_INT_ENTRIES 80
  127. #define SIZE_OF_INT_ENTRY 4
  128. struct apc_params_t
  129. {
  130. vuint16 apct_base1; /* APC Table - First Priority Base pointer */
  131. vuint16 apct_end1; /* First APC Table - Length */
  132. vuint16 apct_ptr1; /* First APC Table Pointer */
  133. vuint16 apct_sptr1; /* APC Table First Priority Service pointer */
  134. vuint16 etqbase; /* Enhanced Transmit Queue Base pointer */
  135. vuint16 etqend; /* Enhanced Transmit Queue End pointer */
  136. vuint16 etqaptr; /* Enhanced Transmit Queue APC pointer */
  137. vuint16 etqtptr; /* Enhanced Transmit Queue Transmitter pointer */
  138. vuint16 apc_mi; /* APC - Max Iteration */
  139. vuint16 ncits; /* Number of Cells In TimeSlot */
  140. vuint16 apcnt; /* APC - N Timer */
  141. vuint16 reserved1; /* reserved */
  142. vuint16 eapcst; /* APC status */
  143. vuint16 ptp_counter; /* PTP queue length */
  144. vuint16 ptp_txch; /* PTP channel */
  145. vuint16 reserved2; /* reserved */
  146. };
  147. struct ct_entry_t
  148. {
  149. /* RCT */
  150. unsigned fhnt : 1;
  151. unsigned pm_rct : 1;
  152. unsigned reserved0 : 6;
  153. unsigned hec : 1;
  154. unsigned clp : 1;
  155. unsigned cng_ncrc : 1;
  156. unsigned inf_rct : 1;
  157. unsigned cngi_ptp : 1;
  158. unsigned cdis_rct : 1;
  159. unsigned aal_rct : 2;
  160. uint16 rbalen;
  161. uint32 rcrc;
  162. uint32 rb_ptr;
  163. uint16 rtmlen;
  164. uint16 rbd_ptr;
  165. uint16 rbase;
  166. uint16 tstamp;
  167. uint16 imask;
  168. unsigned ft : 2;
  169. unsigned nim : 1;
  170. unsigned reserved1 : 2;
  171. unsigned rpmt : 6;
  172. unsigned reserved2 : 5;
  173. uint8 reserved3[8];
  174. /* TCT */
  175. unsigned reserved4 : 1;
  176. unsigned pm_tct : 1;
  177. unsigned reserved5 : 6;
  178. unsigned pc : 1;
  179. unsigned reserved6 : 2;
  180. unsigned inf_tct : 1;
  181. unsigned cr10 : 1;
  182. unsigned cdis_tct : 1;
  183. unsigned aal_tct : 2;
  184. uint16 tbalen;
  185. uint32 tcrc;
  186. uint32 tb_ptr;
  187. uint16 ttmlen;
  188. uint16 tbd_ptr;
  189. uint16 tbase;
  190. unsigned reserved7 : 5;
  191. unsigned tpmt : 6;
  192. unsigned reserved8 : 3;
  193. unsigned avcf : 1;
  194. unsigned act : 1;
  195. uint32 chead;
  196. uint16 apcl;
  197. uint16 apcpr;
  198. unsigned out : 1;
  199. unsigned bnr : 1;
  200. unsigned tservice : 2;
  201. unsigned apcp : 12;
  202. uint16 apcpf;
  203. };
  204. struct tcte_entry_t
  205. {
  206. unsigned res1 : 4;
  207. unsigned scr : 12;
  208. uint16 scrf;
  209. uint16 bt;
  210. uint16 buptrh;
  211. uint32 buptrl;
  212. unsigned vbr2 : 1;
  213. unsigned res2 : 15;
  214. uint16 oobr;
  215. uint16 res3[8];
  216. };
  217. #define SIZE_OF_RBD 12
  218. #define SIZE_OF_TBD 12
  219. struct atm_bd_t
  220. {
  221. vuint16 flags;
  222. vuint16 length;
  223. unsigned char * buffer_ptr;
  224. vuint16 cpcs_uu_cpi;
  225. vuint16 reserved;
  226. };
  227. /* BD flags */
  228. #define EMPTY 0x8000
  229. #define READY 0x8000
  230. #define WRAP 0x2000
  231. #define INTERRUPT 0x1000
  232. #define LAST 0x0800
  233. #define FIRST 0x0400
  234. #define OAM 0x0400
  235. #define CONTINUOUS 0x0200
  236. #define HEC_ERROR 0x0080
  237. #define CELL_LOSS 0x0040
  238. #define CONGESTION 0x0020
  239. #define ABORT 0x0010
  240. #define LEN_ERROR 0x0002
  241. #define CRC_ERROR 0x0001
  242. struct atm_connection_t
  243. {
  244. struct atm_bd_t * rbd_ptr;
  245. int num_rbd;
  246. struct atm_bd_t * tbd_ptr;
  247. int num_tbd;
  248. struct ct_entry_t * ct_ptr;
  249. struct tcte_entry_t * tcte_ptr;
  250. void * drv;
  251. void (* notify)(void * drv, int event);
  252. };
  253. struct atm_driver_t
  254. {
  255. int loaded;
  256. int started;
  257. char * csram;
  258. int csram_size;
  259. uint32 * am_top;
  260. uint16 * ap_top;
  261. uint32 * int_reload_ptr;
  262. uint32 * int_serv_ptr;
  263. struct atm_bd_t * rbd_base_ptr;
  264. struct atm_bd_t * tbd_base_ptr;
  265. unsigned linerate_in_bps;
  266. };
  267. extern struct atm_connection_t g_conn[NUM_CONNECTIONS];
  268. extern struct atm_driver_t g_atm;
  269. extern int atmLoad(void);
  270. extern void atmUnload(void);