iphase.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. /******************************************************************************
  2. Device driver for Interphase ATM PCI adapter cards
  3. Author: Peter Wang <pwang@iphase.com>
  4. Interphase Corporation <www.iphase.com>
  5. Version: 1.0
  6. iphase.h: This is the header file for iphase.c.
  7. *******************************************************************************
  8. This software may be used and distributed according to the terms
  9. of the GNU General Public License (GPL), incorporated herein by reference.
  10. Drivers based on this skeleton fall under the GPL and must retain
  11. the authorship (implicit copyright) notice.
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. General Public License for more details.
  16. Modified from an incomplete driver for Interphase 5575 1KVC 1M card which
  17. was originally written by Monalisa Agrawal at UNH. Now this driver
  18. supports a variety of varients of Interphase ATM PCI (i)Chip adapter
  19. card family (See www.iphase.com/products/ClassSheet.cfm?ClassID=ATM)
  20. in terms of PHY type, the size of control memory and the size of
  21. packet memory. The following are the change log and history:
  22. Bugfix the Mona's UBR driver.
  23. Modify the basic memory allocation and dma logic.
  24. Port the driver to the latest kernel from 2.0.46.
  25. Complete the ABR logic of the driver, and added the ABR work-
  26. around for the hardware anormalies.
  27. Add the CBR support.
  28. Add the flow control logic to the driver to allow rate-limit VC.
  29. Add 4K VC support to the board with 512K control memory.
  30. Add the support of all the variants of the Interphase ATM PCI
  31. (i)Chip adapter cards including x575 (155M OC3 and UTP155), x525
  32. (25M UTP25) and x531 (DS3 and E3).
  33. Add SMP support.
  34. Support and updates available at: ftp://ftp.iphase.com/pub/atm
  35. *******************************************************************************/
  36. #ifndef IPHASE_H
  37. #define IPHASE_H
  38. /************************ IADBG DEFINE *********************************/
  39. /* IADebugFlag Bit Map */
  40. #define IF_IADBG_INIT_ADAPTER 0x00000001 // init adapter info
  41. #define IF_IADBG_TX 0x00000002 // debug TX
  42. #define IF_IADBG_RX 0x00000004 // debug RX
  43. #define IF_IADBG_QUERY_INFO 0x00000008 // debug Request call
  44. #define IF_IADBG_SHUTDOWN 0x00000010 // debug shutdown event
  45. #define IF_IADBG_INTR 0x00000020 // debug interrupt DPC
  46. #define IF_IADBG_TXPKT 0x00000040 // debug TX PKT
  47. #define IF_IADBG_RXPKT 0x00000080 // debug RX PKT
  48. #define IF_IADBG_ERR 0x00000100 // debug system error
  49. #define IF_IADBG_EVENT 0x00000200 // debug event
  50. #define IF_IADBG_DIS_INTR 0x00001000 // debug disable interrupt
  51. #define IF_IADBG_EN_INTR 0x00002000 // debug enable interrupt
  52. #define IF_IADBG_LOUD 0x00004000 // debugging info
  53. #define IF_IADBG_VERY_LOUD 0x00008000 // excessive debugging info
  54. #define IF_IADBG_CBR 0x00100000 //
  55. #define IF_IADBG_UBR 0x00200000 //
  56. #define IF_IADBG_ABR 0x00400000 //
  57. #define IF_IADBG_DESC 0x01000000 //
  58. #define IF_IADBG_SUNI_STAT 0x02000000 // suni statistics
  59. #define IF_IADBG_RESET 0x04000000
  60. #define IF_IADBG(f) if (IADebugFlag & (f))
  61. #ifdef CONFIG_ATM_IA_DEBUG /* Debug build */
  62. #define IF_LOUD(A) IF_IADBG(IF_IADBG_LOUD) { A }
  63. #define IF_ERR(A) IF_IADBG(IF_IADBG_ERR) { A }
  64. #define IF_VERY_LOUD(A) IF_IADBG( IF_IADBG_VERY_LOUD ) { A }
  65. #define IF_INIT_ADAPTER(A) IF_IADBG( IF_IADBG_INIT_ADAPTER ) { A }
  66. #define IF_INIT(A) IF_IADBG( IF_IADBG_INIT_ADAPTER ) { A }
  67. #define IF_SUNI_STAT(A) IF_IADBG( IF_IADBG_SUNI_STAT ) { A }
  68. #define IF_QUERY_INFO(A) IF_IADBG( IF_IADBG_QUERY_INFO ) { A }
  69. #define IF_COPY_OVER(A) IF_IADBG( IF_IADBG_COPY_OVER ) { A }
  70. #define IF_INTR(A) IF_IADBG( IF_IADBG_INTR ) { A }
  71. #define IF_DIS_INTR(A) IF_IADBG( IF_IADBG_DIS_INTR ) { A }
  72. #define IF_EN_INTR(A) IF_IADBG( IF_IADBG_EN_INTR ) { A }
  73. #define IF_TX(A) IF_IADBG( IF_IADBG_TX ) { A }
  74. #define IF_RX(A) IF_IADBG( IF_IADBG_RX ) { A }
  75. #define IF_TXPKT(A) IF_IADBG( IF_IADBG_TXPKT ) { A }
  76. #define IF_RXPKT(A) IF_IADBG( IF_IADBG_RXPKT ) { A }
  77. #define IF_SHUTDOWN(A) IF_IADBG(IF_IADBG_SHUTDOWN) { A }
  78. #define IF_CBR(A) IF_IADBG( IF_IADBG_CBR ) { A }
  79. #define IF_UBR(A) IF_IADBG( IF_IADBG_UBR ) { A }
  80. #define IF_ABR(A) IF_IADBG( IF_IADBG_ABR ) { A }
  81. #define IF_EVENT(A) IF_IADBG( IF_IADBG_EVENT) { A }
  82. #else /* free build */
  83. #define IF_LOUD(A)
  84. #define IF_VERY_LOUD(A)
  85. #define IF_INIT_ADAPTER(A)
  86. #define IF_INIT(A)
  87. #define IF_SUNI_STAT(A)
  88. #define IF_PVC_CHKPKT(A)
  89. #define IF_QUERY_INFO(A)
  90. #define IF_COPY_OVER(A)
  91. #define IF_HANG(A)
  92. #define IF_INTR(A)
  93. #define IF_DIS_INTR(A)
  94. #define IF_EN_INTR(A)
  95. #define IF_TX(A)
  96. #define IF_RX(A)
  97. #define IF_TXDEBUG(A)
  98. #define IF_VC(A)
  99. #define IF_ERR(A)
  100. #define IF_CBR(A)
  101. #define IF_UBR(A)
  102. #define IF_ABR(A)
  103. #define IF_SHUTDOWN(A)
  104. #define DbgPrint(A)
  105. #define IF_EVENT(A)
  106. #define IF_TXPKT(A)
  107. #define IF_RXPKT(A)
  108. #endif /* CONFIG_ATM_IA_DEBUG */
  109. #define isprint(a) ((a >=' ')&&(a <= '~'))
  110. #define ATM_DESC(skb) (skb->protocol)
  111. #define IA_SKB_STATE(skb) (skb->protocol)
  112. #define IA_DLED 1
  113. #define IA_TX_DONE 2
  114. /* iadbg defines */
  115. #define IA_CMD 0x7749
  116. typedef struct {
  117. int cmd;
  118. int sub_cmd;
  119. int len;
  120. u32 maddr;
  121. int status;
  122. void __user *buf;
  123. } IA_CMDBUF, *PIA_CMDBUF;
  124. /* cmds */
  125. #define MEMDUMP 0x01
  126. /* sub_cmds */
  127. #define MEMDUMP_SEGREG 0x2
  128. #define MEMDUMP_DEV 0x1
  129. #define MEMDUMP_REASSREG 0x3
  130. #define MEMDUMP_FFL 0x4
  131. #define READ_REG 0x5
  132. #define WAKE_DBG_WAIT 0x6
  133. /************************ IADBG DEFINE END ***************************/
  134. #define Boolean(x) ((x) ? 1 : 0)
  135. #define NR_VCI 1024 /* number of VCIs */
  136. #define NR_VCI_LD 10 /* log2(NR_VCI) */
  137. #define NR_VCI_4K 4096 /* number of VCIs */
  138. #define NR_VCI_4K_LD 12 /* log2(NR_VCI) */
  139. #define MEM_VALID 0xfffffff0 /* mask base address with this */
  140. #ifndef PCI_VENDOR_ID_IPHASE
  141. #define PCI_VENDOR_ID_IPHASE 0x107e
  142. #endif
  143. #ifndef PCI_DEVICE_ID_IPHASE_5575
  144. #define PCI_DEVICE_ID_IPHASE_5575 0x0008
  145. #endif
  146. #define DEV_LABEL "ia"
  147. #define PCR 207692
  148. #define ICR 100000
  149. #define MCR 0
  150. #define TBE 1000
  151. #define FRTT 1
  152. #define RIF 2
  153. #define RDF 4
  154. #define NRMCODE 5 /* 0 - 7 */
  155. #define TRMCODE 3 /* 0 - 7 */
  156. #define CDFCODE 6
  157. #define ATDFCODE 2 /* 0 - 15 */
  158. /*---------------------- Packet/Cell Memory ------------------------*/
  159. #define TX_PACKET_RAM 0x00000 /* start of Trasnmit Packet memory - 0 */
  160. #define DFL_TX_BUF_SZ 10240 /* 10 K buffers */
  161. #define DFL_TX_BUFFERS 50 /* number of packet buffers for Tx
  162. - descriptor 0 unused */
  163. #define REASS_RAM_SIZE 0x10000 /* for 64K 1K VC board */
  164. #define RX_PACKET_RAM 0x80000 /* start of Receive Packet memory - 512K */
  165. #define DFL_RX_BUF_SZ 10240 /* 10k buffers */
  166. #define DFL_RX_BUFFERS 50 /* number of packet buffers for Rx
  167. - descriptor 0 unused */
  168. struct cpcs_trailer
  169. {
  170. u_short control;
  171. u_short length;
  172. u_int crc32;
  173. };
  174. struct cpcs_trailer_desc
  175. {
  176. struct cpcs_trailer *cpcs;
  177. dma_addr_t dma_addr;
  178. };
  179. struct ia_vcc
  180. {
  181. int rxing;
  182. int txing;
  183. int NumCbrEntry;
  184. u32 pcr;
  185. u32 saved_tx_quota;
  186. int flow_inc;
  187. struct sk_buff_head txing_skb;
  188. int ltimeout;
  189. u8 vc_desc_cnt;
  190. };
  191. struct abr_vc_table
  192. {
  193. u_char status;
  194. u_char rdf;
  195. u_short air;
  196. u_int res[3];
  197. u_int req_rm_cell_data1;
  198. u_int req_rm_cell_data2;
  199. u_int add_rm_cell_data1;
  200. u_int add_rm_cell_data2;
  201. };
  202. /* 32 byte entries */
  203. struct main_vc
  204. {
  205. u_short type;
  206. #define ABR 0x8000
  207. #define UBR 0xc000
  208. #define CBR 0x0000
  209. /* ABR fields */
  210. u_short nrm;
  211. u_short trm;
  212. u_short rm_timestamp_hi;
  213. u_short rm_timestamp_lo:8,
  214. crm:8;
  215. u_short remainder; /* ABR and UBR fields - last 10 bits*/
  216. u_short next_vc_sched;
  217. u_short present_desc; /* all classes */
  218. u_short last_cell_slot; /* ABR and UBR */
  219. u_short pcr;
  220. u_short fraction;
  221. u_short icr;
  222. u_short atdf;
  223. u_short mcr;
  224. u_short acr;
  225. u_short unack:8,
  226. status:8; /* all classes */
  227. #define UIOLI 0x80
  228. #define CRC_APPEND 0x40 /* for status field - CRC-32 append */
  229. #define ABR_STATE 0x02
  230. };
  231. /* 8 byte entries */
  232. struct ext_vc
  233. {
  234. u_short atm_hdr1;
  235. u_short atm_hdr2;
  236. u_short last_desc;
  237. u_short out_of_rate_link; /* reserved for UBR and CBR */
  238. };
  239. #define DLE_ENTRIES 256
  240. #define DMA_INT_ENABLE 0x0002 /* use for both Tx and Rx */
  241. #define TX_DLE_PSI 0x0001
  242. #define DLE_TOTAL_SIZE (sizeof(struct dle)*DLE_ENTRIES)
  243. /* Descriptor List Entries (DLE) */
  244. struct dle
  245. {
  246. u32 sys_pkt_addr;
  247. u32 local_pkt_addr;
  248. u32 bytes;
  249. u16 prq_wr_ptr_data;
  250. u16 mode;
  251. };
  252. struct dle_q
  253. {
  254. struct dle *start;
  255. struct dle *end;
  256. struct dle *read;
  257. struct dle *write;
  258. };
  259. struct free_desc_q
  260. {
  261. int desc; /* Descriptor number */
  262. struct free_desc_q *next;
  263. };
  264. struct tx_buf_desc {
  265. unsigned short desc_mode;
  266. unsigned short vc_index;
  267. unsigned short res1; /* reserved field */
  268. unsigned short bytes;
  269. unsigned short buf_start_hi;
  270. unsigned short buf_start_lo;
  271. unsigned short res2[10]; /* reserved field */
  272. };
  273. struct rx_buf_desc {
  274. unsigned short desc_mode;
  275. unsigned short vc_index;
  276. unsigned short vpi;
  277. unsigned short bytes;
  278. unsigned short buf_start_hi;
  279. unsigned short buf_start_lo;
  280. unsigned short dma_start_hi;
  281. unsigned short dma_start_lo;
  282. unsigned short crc_upper;
  283. unsigned short crc_lower;
  284. unsigned short res:8, timeout:8;
  285. unsigned short res2[5]; /* reserved field */
  286. };
  287. /*--------SAR stuff ---------------------*/
  288. #define EPROM_SIZE 0x40000 /* says 64K in the docs ??? */
  289. #define MAC1_LEN 4
  290. #define MAC2_LEN 2
  291. /*------------ PCI Memory Space Map, 128K SAR memory ----------------*/
  292. #define IPHASE5575_PCI_CONFIG_REG_BASE 0x0000
  293. #define IPHASE5575_BUS_CONTROL_REG_BASE 0x1000 /* offsets 0x00 - 0x3c */
  294. #define IPHASE5575_FRAG_CONTROL_REG_BASE 0x2000
  295. #define IPHASE5575_REASS_CONTROL_REG_BASE 0x3000
  296. #define IPHASE5575_DMA_CONTROL_REG_BASE 0x4000
  297. #define IPHASE5575_FRONT_END_REG_BASE IPHASE5575_DMA_CONTROL_REG_BASE
  298. #define IPHASE5575_FRAG_CONTROL_RAM_BASE 0x10000
  299. #define IPHASE5575_REASS_CONTROL_RAM_BASE 0x20000
  300. /*------------ Bus interface control registers -----------------*/
  301. #define IPHASE5575_BUS_CONTROL_REG 0x00
  302. #define IPHASE5575_BUS_STATUS_REG 0x01 /* actual offset 0x04 */
  303. #define IPHASE5575_MAC1 0x02
  304. #define IPHASE5575_REV 0x03
  305. #define IPHASE5575_MAC2 0x03 /*actual offset 0x0e-reg 0x0c*/
  306. #define IPHASE5575_EXT_RESET 0x04
  307. #define IPHASE5575_INT_RESET 0x05 /* addr 1c ?? reg 0x06 */
  308. #define IPHASE5575_PCI_ADDR_PAGE 0x07 /* reg 0x08, 0x09 ?? */
  309. #define IPHASE5575_EEPROM_ACCESS 0x0a /* actual offset 0x28 */
  310. #define IPHASE5575_CELL_FIFO_QUEUE_SZ 0x0b
  311. #define IPHASE5575_CELL_FIFO_MARK_STATE 0x0c
  312. #define IPHASE5575_CELL_FIFO_READ_PTR 0x0d
  313. #define IPHASE5575_CELL_FIFO_WRITE_PTR 0x0e
  314. #define IPHASE5575_CELL_FIFO_CELLS_AVL 0x0f /* actual offset 0x3c */
  315. /* Bus Interface Control Register bits */
  316. #define CTRL_FE_RST 0x80000000
  317. #define CTRL_LED 0x40000000
  318. #define CTRL_25MBPHY 0x10000000
  319. #define CTRL_ENCMBMEM 0x08000000
  320. #define CTRL_ENOFFSEG 0x01000000
  321. #define CTRL_ERRMASK 0x00400000
  322. #define CTRL_DLETMASK 0x00100000
  323. #define CTRL_DLERMASK 0x00080000
  324. #define CTRL_FEMASK 0x00040000
  325. #define CTRL_SEGMASK 0x00020000
  326. #define CTRL_REASSMASK 0x00010000
  327. #define CTRL_CSPREEMPT 0x00002000
  328. #define CTRL_B128 0x00000200
  329. #define CTRL_B64 0x00000100
  330. #define CTRL_B48 0x00000080
  331. #define CTRL_B32 0x00000040
  332. #define CTRL_B16 0x00000020
  333. #define CTRL_B8 0x00000010
  334. /* Bus Interface Status Register bits */
  335. #define STAT_CMEMSIZ 0xc0000000
  336. #define STAT_ADPARCK 0x20000000
  337. #define STAT_RESVD 0x1fffff80
  338. #define STAT_ERRINT 0x00000040
  339. #define STAT_MARKINT 0x00000020
  340. #define STAT_DLETINT 0x00000010
  341. #define STAT_DLERINT 0x00000008
  342. #define STAT_FEINT 0x00000004
  343. #define STAT_SEGINT 0x00000002
  344. #define STAT_REASSINT 0x00000001
  345. /*--------------- Segmentation control registers -----------------*/
  346. /* The segmentation registers are 16 bits access and the addresses
  347. are defined as such so the addresses are the actual "offsets" */
  348. #define IDLEHEADHI 0x00
  349. #define IDLEHEADLO 0x01
  350. #define MAXRATE 0x02
  351. /* Values for MAXRATE register for 155Mbps and 25.6 Mbps operation */
  352. #define RATE155 0x64b1 // 16 bits float format
  353. #define MAX_ATM_155 352768 // Cells/second p.118
  354. #define RATE25 0x5f9d
  355. #define STPARMS 0x03
  356. #define STPARMS_1K 0x008c
  357. #define STPARMS_2K 0x0049
  358. #define STPARMS_4K 0x0026
  359. #define COMP_EN 0x4000
  360. #define CBR_EN 0x2000
  361. #define ABR_EN 0x0800
  362. #define UBR_EN 0x0400
  363. #define ABRUBR_ARB 0x04
  364. #define RM_TYPE 0x05
  365. /*Value for RM_TYPE register for ATM Forum Traffic Mangement4.0 support*/
  366. #define RM_TYPE_4_0 0x0100
  367. #define SEG_COMMAND_REG 0x17
  368. /* Values for the command register */
  369. #define RESET_SEG 0x0055
  370. #define RESET_SEG_STATE 0x00aa
  371. #define RESET_TX_CELL_CTR 0x00cc
  372. #define CBR_PTR_BASE 0x20
  373. #define ABR_SBPTR_BASE 0x22
  374. #define UBR_SBPTR_BASE 0x23
  375. #define ABRWQ_BASE 0x26
  376. #define UBRWQ_BASE 0x27
  377. #define VCT_BASE 0x28
  378. #define VCTE_BASE 0x29
  379. #define CBR_TAB_BEG 0x2c
  380. #define CBR_TAB_END 0x2d
  381. #define PRQ_ST_ADR 0x30
  382. #define PRQ_ED_ADR 0x31
  383. #define PRQ_RD_PTR 0x32
  384. #define PRQ_WR_PTR 0x33
  385. #define TCQ_ST_ADR 0x34
  386. #define TCQ_ED_ADR 0x35
  387. #define TCQ_RD_PTR 0x36
  388. #define TCQ_WR_PTR 0x37
  389. #define SEG_QUEUE_BASE 0x40
  390. #define SEG_DESC_BASE 0x41
  391. #define MODE_REG_0 0x45
  392. #define T_ONLINE 0x0002 /* (i)chipSAR is online */
  393. #define MODE_REG_1 0x46
  394. #define MODE_REG_1_VAL 0x0400 /*for propoer device operation*/
  395. #define SEG_INTR_STATUS_REG 0x47
  396. #define SEG_MASK_REG 0x48
  397. #define TRANSMIT_DONE 0x0200
  398. #define TCQ_NOT_EMPTY 0x1000 /* this can be used for both the interrupt
  399. status registers as well as the mask register */
  400. #define CELL_CTR_HIGH_AUTO 0x49
  401. #define CELL_CTR_HIGH_NOAUTO 0xc9
  402. #define CELL_CTR_LO_AUTO 0x4a
  403. #define CELL_CTR_LO_NOAUTO 0xca
  404. /* Diagnostic registers */
  405. #define NEXTDESC 0x59
  406. #define NEXTVC 0x5a
  407. #define PSLOTCNT 0x5d
  408. #define NEWDN 0x6a
  409. #define NEWVC 0x6b
  410. #define SBPTR 0x6c
  411. #define ABRWQ_WRPTR 0x6f
  412. #define ABRWQ_RDPTR 0x70
  413. #define UBRWQ_WRPTR 0x71
  414. #define UBRWQ_RDPTR 0x72
  415. #define CBR_VC 0x73
  416. #define ABR_SBVC 0x75
  417. #define UBR_SBVC 0x76
  418. #define ABRNEXTLINK 0x78
  419. #define UBRNEXTLINK 0x79
  420. /*----------------- Reassembly control registers ---------------------*/
  421. /* The reassembly registers are 16 bits access and the addresses
  422. are defined as such so the addresses are the actual "offsets" */
  423. #define MODE_REG 0x00
  424. #define R_ONLINE 0x0002 /* (i)chip is online */
  425. #define IGN_RAW_FL 0x0004
  426. #define PROTOCOL_ID 0x01
  427. #define REASS_MASK_REG 0x02
  428. #define REASS_INTR_STATUS_REG 0x03
  429. /* Interrupt Status register bits */
  430. #define RX_PKT_CTR_OF 0x8000
  431. #define RX_ERR_CTR_OF 0x4000
  432. #define RX_CELL_CTR_OF 0x1000
  433. #define RX_FREEQ_EMPT 0x0200
  434. #define RX_EXCPQ_FL 0x0080
  435. #define RX_RAWQ_FL 0x0010
  436. #define RX_EXCP_RCVD 0x0008
  437. #define RX_PKT_RCVD 0x0004
  438. #define RX_RAW_RCVD 0x0001
  439. #define DRP_PKT_CNTR 0x04
  440. #define ERR_CNTR 0x05
  441. #define RAW_BASE_ADR 0x08
  442. #define CELL_CTR0 0x0c
  443. #define CELL_CTR1 0x0d
  444. #define REASS_COMMAND_REG 0x0f
  445. /* Values for command register */
  446. #define RESET_REASS 0x0055
  447. #define RESET_REASS_STATE 0x00aa
  448. #define RESET_DRP_PKT_CNTR 0x00f1
  449. #define RESET_ERR_CNTR 0x00f2
  450. #define RESET_CELL_CNTR 0x00f8
  451. #define RESET_REASS_ALL_REGS 0x00ff
  452. #define REASS_DESC_BASE 0x10
  453. #define VC_LKUP_BASE 0x11
  454. #define REASS_TABLE_BASE 0x12
  455. #define REASS_QUEUE_BASE 0x13
  456. #define PKT_TM_CNT 0x16
  457. #define TMOUT_RANGE 0x17
  458. #define INTRVL_CNTR 0x18
  459. #define TMOUT_INDX 0x19
  460. #define VP_LKUP_BASE 0x1c
  461. #define VP_FILTER 0x1d
  462. #define ABR_LKUP_BASE 0x1e
  463. #define FREEQ_ST_ADR 0x24
  464. #define FREEQ_ED_ADR 0x25
  465. #define FREEQ_RD_PTR 0x26
  466. #define FREEQ_WR_PTR 0x27
  467. #define PCQ_ST_ADR 0x28
  468. #define PCQ_ED_ADR 0x29
  469. #define PCQ_RD_PTR 0x2a
  470. #define PCQ_WR_PTR 0x2b
  471. #define EXCP_Q_ST_ADR 0x2c
  472. #define EXCP_Q_ED_ADR 0x2d
  473. #define EXCP_Q_RD_PTR 0x2e
  474. #define EXCP_Q_WR_PTR 0x2f
  475. #define CC_FIFO_ST_ADR 0x34
  476. #define CC_FIFO_ED_ADR 0x35
  477. #define CC_FIFO_RD_PTR 0x36
  478. #define CC_FIFO_WR_PTR 0x37
  479. #define STATE_REG 0x38
  480. #define BUF_SIZE 0x42
  481. #define XTRA_RM_OFFSET 0x44
  482. #define DRP_PKT_CNTR_NC 0x84
  483. #define ERR_CNTR_NC 0x85
  484. #define CELL_CNTR0_NC 0x8c
  485. #define CELL_CNTR1_NC 0x8d
  486. /* State Register bits */
  487. #define EXCPQ_EMPTY 0x0040
  488. #define PCQ_EMPTY 0x0010
  489. #define FREEQ_EMPTY 0x0004
  490. /*----------------- Front End registers/ DMA control --------------*/
  491. /* There is a lot of documentation error regarding these offsets ???
  492. eg:- 2 offsets given 800, a00 for rx counter
  493. similarly many others
  494. Remember again that the offsets are to be 4*register number, so
  495. correct the #defines here
  496. */
  497. #define IPHASE5575_TX_COUNTER 0x200 /* offset - 0x800 */
  498. #define IPHASE5575_RX_COUNTER 0x280 /* offset - 0xa00 */
  499. #define IPHASE5575_TX_LIST_ADDR 0x300 /* offset - 0xc00 */
  500. #define IPHASE5575_RX_LIST_ADDR 0x380 /* offset - 0xe00 */
  501. /*--------------------------- RAM ---------------------------*/
  502. /* These memory maps are actually offsets from the segmentation and reassembly RAM base addresses */
  503. /* Segmentation Control Memory map */
  504. #define TX_DESC_BASE 0x0000 /* Buffer Decriptor Table */
  505. #define TX_COMP_Q 0x1000 /* Transmit Complete Queue */
  506. #define PKT_RDY_Q 0x1400 /* Packet Ready Queue */
  507. #define CBR_SCHED_TABLE 0x1800 /* CBR Table */
  508. #define UBR_SCHED_TABLE 0x3000 /* UBR Table */
  509. #define UBR_WAIT_Q 0x4000 /* UBR Wait Queue */
  510. #define ABR_SCHED_TABLE 0x5000 /* ABR Table */
  511. #define ABR_WAIT_Q 0x5800 /* ABR Wait Queue */
  512. #define EXT_VC_TABLE 0x6000 /* Extended VC Table */
  513. #define MAIN_VC_TABLE 0x8000 /* Main VC Table */
  514. #define SCHEDSZ 1024 /* ABR and UBR Scheduling Table size */
  515. #define TX_DESC_TABLE_SZ 128 /* Number of entries in the Transmit
  516. Buffer Descriptor Table */
  517. /* These are used as table offsets in Descriptor Table address generation */
  518. #define DESC_MODE 0x0
  519. #define VC_INDEX 0x1
  520. #define BYTE_CNT 0x3
  521. #define PKT_START_HI 0x4
  522. #define PKT_START_LO 0x5
  523. /* Descriptor Mode Word Bits */
  524. #define EOM_EN 0x0800
  525. #define AAL5 0x0100
  526. #define APP_CRC32 0x0400
  527. #define CMPL_INT 0x1000
  528. #define TABLE_ADDRESS(db, dn, to) \
  529. (((unsigned long)(db & 0x04)) << 16) | (dn << 5) | (to << 1)
  530. /* Reassembly Control Memory Map */
  531. #define RX_DESC_BASE 0x0000 /* Buffer Descriptor Table */
  532. #define VP_TABLE 0x5c00 /* VP Table */
  533. #define EXCEPTION_Q 0x5e00 /* Exception Queue */
  534. #define FREE_BUF_DESC_Q 0x6000 /* Free Buffer Descriptor Queue */
  535. #define PKT_COMP_Q 0x6800 /* Packet Complete Queue */
  536. #define REASS_TABLE 0x7000 /* Reassembly Table */
  537. #define RX_VC_TABLE 0x7800 /* VC Table */
  538. #define ABR_VC_TABLE 0x8000 /* ABR VC Table */
  539. #define RX_DESC_TABLE_SZ 736 /* Number of entries in the Receive
  540. Buffer Descriptor Table */
  541. #define VP_TABLE_SZ 256 /* Number of entries in VPTable */
  542. #define RX_VC_TABLE_SZ 1024 /* Number of entries in VC Table */
  543. #define REASS_TABLE_SZ 1024 /* Number of entries in Reassembly Table */
  544. /* Buffer Descriptor Table */
  545. #define RX_ACT 0x8000
  546. #define RX_VPVC 0x4000
  547. #define RX_CNG 0x0040
  548. #define RX_CER 0x0008
  549. #define RX_PTE 0x0004
  550. #define RX_OFL 0x0002
  551. #define NUM_RX_EXCP 32
  552. /* Reassembly Table */
  553. #define NO_AAL5_PKT 0x0000
  554. #define AAL5_PKT_REASSEMBLED 0x4000
  555. #define AAL5_PKT_TERMINATED 0x8000
  556. #define RAW_PKT 0xc000
  557. #define REASS_ABR 0x2000
  558. /*-------------------- Base Registers --------------------*/
  559. #define REG_BASE IPHASE5575_BUS_CONTROL_REG_BASE
  560. #define RAM_BASE IPHASE5575_FRAG_CONTROL_RAM_BASE
  561. #define PHY_BASE IPHASE5575_FRONT_END_REG_BASE
  562. #define SEG_BASE IPHASE5575_FRAG_CONTROL_REG_BASE
  563. #define REASS_BASE IPHASE5575_REASS_CONTROL_REG_BASE
  564. typedef volatile u_int ffreg_t;
  565. typedef u_int rreg_t;
  566. typedef struct _ffredn_t {
  567. ffreg_t idlehead_high; /* Idle cell header (high) */
  568. ffreg_t idlehead_low; /* Idle cell header (low) */
  569. ffreg_t maxrate; /* Maximum rate */
  570. ffreg_t stparms; /* Traffic Management Parameters */
  571. ffreg_t abrubr_abr; /* ABRUBR Priority Byte 1, TCR Byte 0 */
  572. ffreg_t rm_type; /* */
  573. u_int filler5[0x17 - 0x06];
  574. ffreg_t cmd_reg; /* Command register */
  575. u_int filler18[0x20 - 0x18];
  576. ffreg_t cbr_base; /* CBR Pointer Base */
  577. ffreg_t vbr_base; /* VBR Pointer Base */
  578. ffreg_t abr_base; /* ABR Pointer Base */
  579. ffreg_t ubr_base; /* UBR Pointer Base */
  580. u_int filler24;
  581. ffreg_t vbrwq_base; /* VBR Wait Queue Base */
  582. ffreg_t abrwq_base; /* ABR Wait Queue Base */
  583. ffreg_t ubrwq_base; /* UBR Wait Queue Base */
  584. ffreg_t vct_base; /* Main VC Table Base */
  585. ffreg_t vcte_base; /* Extended Main VC Table Base */
  586. u_int filler2a[0x2C - 0x2A];
  587. ffreg_t cbr_tab_beg; /* CBR Table Begin */
  588. ffreg_t cbr_tab_end; /* CBR Table End */
  589. ffreg_t cbr_pointer; /* CBR Pointer */
  590. u_int filler2f[0x30 - 0x2F];
  591. ffreg_t prq_st_adr; /* Packet Ready Queue Start Address */
  592. ffreg_t prq_ed_adr; /* Packet Ready Queue End Address */
  593. ffreg_t prq_rd_ptr; /* Packet Ready Queue read pointer */
  594. ffreg_t prq_wr_ptr; /* Packet Ready Queue write pointer */
  595. ffreg_t tcq_st_adr; /* Transmit Complete Queue Start Address*/
  596. ffreg_t tcq_ed_adr; /* Transmit Complete Queue End Address */
  597. ffreg_t tcq_rd_ptr; /* Transmit Complete Queue read pointer */
  598. ffreg_t tcq_wr_ptr; /* Transmit Complete Queue write pointer*/
  599. u_int filler38[0x40 - 0x38];
  600. ffreg_t queue_base; /* Base address for PRQ and TCQ */
  601. ffreg_t desc_base; /* Base address of descriptor table */
  602. u_int filler42[0x45 - 0x42];
  603. ffreg_t mode_reg_0; /* Mode register 0 */
  604. ffreg_t mode_reg_1; /* Mode register 1 */
  605. ffreg_t intr_status_reg;/* Interrupt Status register */
  606. ffreg_t mask_reg; /* Mask Register */
  607. ffreg_t cell_ctr_high1; /* Total cell transfer count (high) */
  608. ffreg_t cell_ctr_lo1; /* Total cell transfer count (low) */
  609. ffreg_t state_reg; /* Status register */
  610. u_int filler4c[0x58 - 0x4c];
  611. ffreg_t curr_desc_num; /* Contains the current descriptor num */
  612. ffreg_t next_desc; /* Next descriptor */
  613. ffreg_t next_vc; /* Next VC */
  614. u_int filler5b[0x5d - 0x5b];
  615. ffreg_t present_slot_cnt;/* Present slot count */
  616. u_int filler5e[0x6a - 0x5e];
  617. ffreg_t new_desc_num; /* New descriptor number */
  618. ffreg_t new_vc; /* New VC */
  619. ffreg_t sched_tbl_ptr; /* Schedule table pointer */
  620. ffreg_t vbrwq_wptr; /* VBR wait queue write pointer */
  621. ffreg_t vbrwq_rptr; /* VBR wait queue read pointer */
  622. ffreg_t abrwq_wptr; /* ABR wait queue write pointer */
  623. ffreg_t abrwq_rptr; /* ABR wait queue read pointer */
  624. ffreg_t ubrwq_wptr; /* UBR wait queue write pointer */
  625. ffreg_t ubrwq_rptr; /* UBR wait queue read pointer */
  626. ffreg_t cbr_vc; /* CBR VC */
  627. ffreg_t vbr_sb_vc; /* VBR SB VC */
  628. ffreg_t abr_sb_vc; /* ABR SB VC */
  629. ffreg_t ubr_sb_vc; /* UBR SB VC */
  630. ffreg_t vbr_next_link; /* VBR next link */
  631. ffreg_t abr_next_link; /* ABR next link */
  632. ffreg_t ubr_next_link; /* UBR next link */
  633. u_int filler7a[0x7c-0x7a];
  634. ffreg_t out_rate_head; /* Out of rate head */
  635. u_int filler7d[0xca-0x7d]; /* pad out to full address space */
  636. ffreg_t cell_ctr_high1_nc;/* Total cell transfer count (high) */
  637. ffreg_t cell_ctr_lo1_nc;/* Total cell transfer count (low) */
  638. u_int fillercc[0x100-0xcc]; /* pad out to full address space */
  639. } ffredn_t;
  640. typedef struct _rfredn_t {
  641. rreg_t mode_reg_0; /* Mode register 0 */
  642. rreg_t protocol_id; /* Protocol ID */
  643. rreg_t mask_reg; /* Mask Register */
  644. rreg_t intr_status_reg;/* Interrupt status register */
  645. rreg_t drp_pkt_cntr; /* Dropped packet cntr (clear on read) */
  646. rreg_t err_cntr; /* Error Counter (cleared on read) */
  647. u_int filler6[0x08 - 0x06];
  648. rreg_t raw_base_adr; /* Base addr for raw cell Q */
  649. u_int filler2[0x0c - 0x09];
  650. rreg_t cell_ctr0; /* Cell Counter 0 (cleared when read) */
  651. rreg_t cell_ctr1; /* Cell Counter 1 (cleared when read) */
  652. u_int filler3[0x0f - 0x0e];
  653. rreg_t cmd_reg; /* Command register */
  654. rreg_t desc_base; /* Base address for description table */
  655. rreg_t vc_lkup_base; /* Base address for VC lookup table */
  656. rreg_t reass_base; /* Base address for reassembler table */
  657. rreg_t queue_base; /* Base address for Communication queue */
  658. u_int filler14[0x16 - 0x14];
  659. rreg_t pkt_tm_cnt; /* Packet Timeout and count register */
  660. rreg_t tmout_range; /* Range of reassembley IDs for timeout */
  661. rreg_t intrvl_cntr; /* Packet aging interval counter */
  662. rreg_t tmout_indx; /* index of pkt being tested for aging */
  663. u_int filler1a[0x1c - 0x1a];
  664. rreg_t vp_lkup_base; /* Base address for VP lookup table */
  665. rreg_t vp_filter; /* VP filter register */
  666. rreg_t abr_lkup_base; /* Base address of ABR VC Table */
  667. u_int filler1f[0x24 - 0x1f];
  668. rreg_t fdq_st_adr; /* Free desc queue start address */
  669. rreg_t fdq_ed_adr; /* Free desc queue end address */
  670. rreg_t fdq_rd_ptr; /* Free desc queue read pointer */
  671. rreg_t fdq_wr_ptr; /* Free desc queue write pointer */
  672. rreg_t pcq_st_adr; /* Packet Complete queue start address */
  673. rreg_t pcq_ed_adr; /* Packet Complete queue end address */
  674. rreg_t pcq_rd_ptr; /* Packet Complete queue read pointer */
  675. rreg_t pcq_wr_ptr; /* Packet Complete queue write pointer */
  676. rreg_t excp_st_adr; /* Exception queue start address */
  677. rreg_t excp_ed_adr; /* Exception queue end address */
  678. rreg_t excp_rd_ptr; /* Exception queue read pointer */
  679. rreg_t excp_wr_ptr; /* Exception queue write pointer */
  680. u_int filler30[0x34 - 0x30];
  681. rreg_t raw_st_adr; /* Raw Cell start address */
  682. rreg_t raw_ed_adr; /* Raw Cell end address */
  683. rreg_t raw_rd_ptr; /* Raw Cell read pointer */
  684. rreg_t raw_wr_ptr; /* Raw Cell write pointer */
  685. rreg_t state_reg; /* State Register */
  686. u_int filler39[0x42 - 0x39];
  687. rreg_t buf_size; /* Buffer size */
  688. u_int filler43;
  689. rreg_t xtra_rm_offset; /* Offset of the additional turnaround RM */
  690. u_int filler45[0x84 - 0x45];
  691. rreg_t drp_pkt_cntr_nc;/* Dropped Packet cntr, Not clear on rd */
  692. rreg_t err_cntr_nc; /* Error Counter, Not clear on read */
  693. u_int filler86[0x8c - 0x86];
  694. rreg_t cell_ctr0_nc; /* Cell Counter 0, Not clear on read */
  695. rreg_t cell_ctr1_nc; /* Cell Counter 1, Not clear on read */
  696. u_int filler8e[0x100-0x8e]; /* pad out to full address space */
  697. } rfredn_t;
  698. typedef struct {
  699. /* Atlantic */
  700. ffredn_t ffredn; /* F FRED */
  701. rfredn_t rfredn; /* R FRED */
  702. } ia_regs_t;
  703. typedef struct {
  704. u_short f_vc_type; /* VC type */
  705. u_short f_nrm; /* Nrm */
  706. u_short f_nrmexp; /* Nrm Exp */
  707. u_short reserved6; /* */
  708. u_short f_crm; /* Crm */
  709. u_short reserved10; /* Reserved */
  710. u_short reserved12; /* Reserved */
  711. u_short reserved14; /* Reserved */
  712. u_short last_cell_slot; /* last_cell_slot_count */
  713. u_short f_pcr; /* Peak Cell Rate */
  714. u_short fraction; /* fraction */
  715. u_short f_icr; /* Initial Cell Rate */
  716. u_short f_cdf; /* */
  717. u_short f_mcr; /* Minimum Cell Rate */
  718. u_short f_acr; /* Allowed Cell Rate */
  719. u_short f_status; /* */
  720. } f_vc_abr_entry;
  721. typedef struct {
  722. u_short r_status_rdf; /* status + RDF */
  723. u_short r_air; /* AIR */
  724. u_short reserved4[14]; /* Reserved */
  725. } r_vc_abr_entry;
  726. #define MRM 3
  727. typedef struct srv_cls_param {
  728. u32 class_type; /* CBR/VBR/ABR/UBR; use the enum above */
  729. u32 pcr; /* Peak Cell Rate (24-bit) */
  730. /* VBR parameters */
  731. u32 scr; /* sustainable cell rate */
  732. u32 max_burst_size; /* ?? cell rate or data rate */
  733. /* ABR only UNI 4.0 Parameters */
  734. u32 mcr; /* Min Cell Rate (24-bit) */
  735. u32 icr; /* Initial Cell Rate (24-bit) */
  736. u32 tbe; /* Transient Buffer Exposure (24-bit) */
  737. u32 frtt; /* Fixed Round Trip Time (24-bit) */
  738. #if 0 /* Additional Parameters of TM 4.0 */
  739. bits 31 30 29 28 27-25 24-22 21-19 18-9
  740. -----------------------------------------------------------------------------
  741. | NRM present | TRM prsnt | CDF prsnt | ADTF prsnt | NRM | TRM | CDF | ADTF |
  742. -----------------------------------------------------------------------------
  743. #endif /* 0 */
  744. u8 nrm; /* Max # of Cells for each forward RM
  745. cell (3-bit) */
  746. u8 trm; /* Time between forward RM cells (3-bit) */
  747. u16 adtf; /* ACR Decrease Time Factor (10-bit) */
  748. u8 cdf; /* Cutoff Decrease Factor (3-bit) */
  749. u8 rif; /* Rate Increment Factor (4-bit) */
  750. u8 rdf; /* Rate Decrease Factor (4-bit) */
  751. u8 reserved; /* 8 bits to keep structure word aligned */
  752. } srv_cls_param_t;
  753. struct testTable_t {
  754. u16 lastTime;
  755. u16 fract;
  756. u8 vc_status;
  757. };
  758. typedef struct {
  759. u16 vci;
  760. u16 error;
  761. } RX_ERROR_Q;
  762. typedef struct {
  763. u8 active: 1;
  764. u8 abr: 1;
  765. u8 ubr: 1;
  766. u8 cnt: 5;
  767. #define VC_ACTIVE 0x01
  768. #define VC_ABR 0x02
  769. #define VC_UBR 0x04
  770. } vcstatus_t;
  771. struct ia_rfL_t {
  772. u32 fdq_st; /* Free desc queue start address */
  773. u32 fdq_ed; /* Free desc queue end address */
  774. u32 fdq_rd; /* Free desc queue read pointer */
  775. u32 fdq_wr; /* Free desc queue write pointer */
  776. u32 pcq_st; /* Packet Complete queue start address */
  777. u32 pcq_ed; /* Packet Complete queue end address */
  778. u32 pcq_rd; /* Packet Complete queue read pointer */
  779. u32 pcq_wr; /* Packet Complete queue write pointer */
  780. };
  781. struct ia_ffL_t {
  782. u32 prq_st; /* Packet Ready Queue Start Address */
  783. u32 prq_ed; /* Packet Ready Queue End Address */
  784. u32 prq_wr; /* Packet Ready Queue write pointer */
  785. u32 tcq_st; /* Transmit Complete Queue Start Address*/
  786. u32 tcq_ed; /* Transmit Complete Queue End Address */
  787. u32 tcq_rd; /* Transmit Complete Queue read pointer */
  788. };
  789. struct desc_tbl_t {
  790. u32 timestamp;
  791. struct ia_vcc *iavcc;
  792. struct sk_buff *txskb;
  793. };
  794. typedef struct ia_rtn_q {
  795. struct desc_tbl_t data;
  796. struct ia_rtn_q *next, *tail;
  797. } IARTN_Q;
  798. #define SUNI_LOSV 0x04
  799. enum ia_suni {
  800. SUNI_MASTER_RESET = 0x000, /* SUNI Master Reset and Identity */
  801. SUNI_MASTER_CONFIG = 0x004, /* SUNI Master Configuration */
  802. SUNI_MASTER_INTR_STAT = 0x008, /* SUNI Master Interrupt Status */
  803. SUNI_RESERVED1 = 0x00c, /* Reserved */
  804. SUNI_MASTER_CLK_MONITOR = 0x010, /* SUNI Master Clock Monitor */
  805. SUNI_MASTER_CONTROL = 0x014, /* SUNI Master Clock Monitor */
  806. /* Reserved (10) */
  807. SUNI_RSOP_CONTROL = 0x040, /* RSOP Control/Interrupt Enable */
  808. SUNI_RSOP_STATUS = 0x044, /* RSOP Status/Interrupt States */
  809. SUNI_RSOP_SECTION_BIP8L = 0x048, /* RSOP Section BIP-8 LSB */
  810. SUNI_RSOP_SECTION_BIP8M = 0x04c, /* RSOP Section BIP-8 MSB */
  811. SUNI_TSOP_CONTROL = 0x050, /* TSOP Control */
  812. SUNI_TSOP_DIAG = 0x054, /* TSOP Disgnostics */
  813. /* Reserved (2) */
  814. SUNI_RLOP_CS = 0x060, /* RLOP Control/Status */
  815. SUNI_RLOP_INTR = 0x064, /* RLOP Interrupt Enable/Status */
  816. SUNI_RLOP_LINE_BIP24L = 0x068, /* RLOP Line BIP-24 LSB */
  817. SUNI_RLOP_LINE_BIP24 = 0x06c, /* RLOP Line BIP-24 */
  818. SUNI_RLOP_LINE_BIP24M = 0x070, /* RLOP Line BIP-24 MSB */
  819. SUNI_RLOP_LINE_FEBEL = 0x074, /* RLOP Line FEBE LSB */
  820. SUNI_RLOP_LINE_FEBE = 0x078, /* RLOP Line FEBE */
  821. SUNI_RLOP_LINE_FEBEM = 0x07c, /* RLOP Line FEBE MSB */
  822. SUNI_TLOP_CONTROL = 0x080, /* TLOP Control */
  823. SUNI_TLOP_DISG = 0x084, /* TLOP Disgnostics */
  824. /* Reserved (14) */
  825. SUNI_RPOP_CS = 0x0c0, /* RPOP Status/Control */
  826. SUNI_RPOP_INTR = 0x0c4, /* RPOP Interrupt/Status */
  827. SUNI_RPOP_RESERVED = 0x0c8, /* RPOP Reserved */
  828. SUNI_RPOP_INTR_ENA = 0x0cc, /* RPOP Interrupt Enable */
  829. /* Reserved (3) */
  830. SUNI_RPOP_PATH_SIG = 0x0dc, /* RPOP Path Signal Label */
  831. SUNI_RPOP_BIP8L = 0x0e0, /* RPOP Path BIP-8 LSB */
  832. SUNI_RPOP_BIP8M = 0x0e4, /* RPOP Path BIP-8 MSB */
  833. SUNI_RPOP_FEBEL = 0x0e8, /* RPOP Path FEBE LSB */
  834. SUNI_RPOP_FEBEM = 0x0ec, /* RPOP Path FEBE MSB */
  835. /* Reserved (4) */
  836. SUNI_TPOP_CNTRL_DAIG = 0x100, /* TPOP Control/Disgnostics */
  837. SUNI_TPOP_POINTER_CTRL = 0x104, /* TPOP Pointer Control */
  838. SUNI_TPOP_SOURCER_CTRL = 0x108, /* TPOP Source Control */
  839. /* Reserved (2) */
  840. SUNI_TPOP_ARB_PRTL = 0x114, /* TPOP Arbitrary Pointer LSB */
  841. SUNI_TPOP_ARB_PRTM = 0x118, /* TPOP Arbitrary Pointer MSB */
  842. SUNI_TPOP_RESERVED2 = 0x11c, /* TPOP Reserved */
  843. SUNI_TPOP_PATH_SIG = 0x120, /* TPOP Path Signal Lable */
  844. SUNI_TPOP_PATH_STATUS = 0x124, /* TPOP Path Status */
  845. /* Reserved (6) */
  846. SUNI_RACP_CS = 0x140, /* RACP Control/Status */
  847. SUNI_RACP_INTR = 0x144, /* RACP Interrupt Enable/Status */
  848. SUNI_RACP_HDR_PATTERN = 0x148, /* RACP Match Header Pattern */
  849. SUNI_RACP_HDR_MASK = 0x14c, /* RACP Match Header Mask */
  850. SUNI_RACP_CORR_HCS = 0x150, /* RACP Correctable HCS Error Count */
  851. SUNI_RACP_UNCORR_HCS = 0x154, /* RACP Uncorrectable HCS Err Count */
  852. /* Reserved (10) */
  853. SUNI_TACP_CONTROL = 0x180, /* TACP Control */
  854. SUNI_TACP_IDLE_HDR_PAT = 0x184, /* TACP Idle Cell Header Pattern */
  855. SUNI_TACP_IDLE_PAY_PAY = 0x188, /* TACP Idle Cell Payld Octet Patrn */
  856. /* Reserved (5) */
  857. /* Reserved (24) */
  858. /* FIXME: unused but name conflicts.
  859. * SUNI_MASTER_TEST = 0x200, SUNI Master Test */
  860. SUNI_RESERVED_TEST = 0x204 /* SUNI Reserved for Test */
  861. };
  862. typedef struct _SUNI_STATS_
  863. {
  864. u32 valid; // 1 = oc3 PHY card
  865. u32 carrier_detect; // GPIN input
  866. // RSOP: receive section overhead processor
  867. u16 rsop_oof_state; // 1 = out of frame
  868. u16 rsop_lof_state; // 1 = loss of frame
  869. u16 rsop_los_state; // 1 = loss of signal
  870. u32 rsop_los_count; // loss of signal count
  871. u32 rsop_bse_count; // section BIP-8 error count
  872. // RLOP: receive line overhead processor
  873. u16 rlop_ferf_state; // 1 = far end receive failure
  874. u16 rlop_lais_state; // 1 = line AIS
  875. u32 rlop_lbe_count; // BIP-24 count
  876. u32 rlop_febe_count; // FEBE count;
  877. // RPOP: receive path overhead processor
  878. u16 rpop_lop_state; // 1 = LOP
  879. u16 rpop_pais_state; // 1 = path AIS
  880. u16 rpop_pyel_state; // 1 = path yellow alert
  881. u32 rpop_bip_count; // path BIP-8 error count
  882. u32 rpop_febe_count; // path FEBE error count
  883. u16 rpop_psig; // path signal label value
  884. // RACP: receive ATM cell processor
  885. u16 racp_hp_state; // hunt/presync state
  886. u32 racp_fu_count; // FIFO underrun count
  887. u32 racp_fo_count; // FIFO overrun count
  888. u32 racp_chcs_count; // correctable HCS error count
  889. u32 racp_uchcs_count; // uncorrectable HCS error count
  890. } IA_SUNI_STATS;
  891. typedef struct iadev_priv {
  892. /*-----base pointers into (i)chipSAR+ address space */
  893. u32 __iomem *phy; /* Base pointer into phy (SUNI). */
  894. u32 __iomem *dma; /* Base pointer into DMA control registers. */
  895. u32 __iomem *reg; /* Base pointer to SAR registers. */
  896. u32 __iomem *seg_reg; /* base pointer to segmentation engine
  897. internal registers */
  898. u32 __iomem *reass_reg; /* base pointer to reassemble engine
  899. internal registers */
  900. u32 __iomem *ram; /* base pointer to SAR RAM */
  901. void __iomem *seg_ram;
  902. void __iomem *reass_ram;
  903. struct dle_q tx_dle_q;
  904. struct free_desc_q *tx_free_desc_qhead;
  905. struct sk_buff_head tx_dma_q, tx_backlog;
  906. spinlock_t tx_lock;
  907. IARTN_Q tx_return_q;
  908. u32 close_pending;
  909. wait_queue_head_t close_wait;
  910. wait_queue_head_t timeout_wait;
  911. struct cpcs_trailer_desc *tx_buf;
  912. u16 num_tx_desc, tx_buf_sz, rate_limit;
  913. u32 tx_cell_cnt, tx_pkt_cnt;
  914. void __iomem *MAIN_VC_TABLE_ADDR, *EXT_VC_TABLE_ADDR, *ABR_SCHED_TABLE_ADDR;
  915. struct dle_q rx_dle_q;
  916. struct free_desc_q *rx_free_desc_qhead;
  917. struct sk_buff_head rx_dma_q;
  918. spinlock_t rx_lock;
  919. struct atm_vcc **rx_open; /* list of all open VCs */
  920. u16 num_rx_desc, rx_buf_sz, rxing;
  921. u32 rx_pkt_ram, rx_tmp_cnt;
  922. unsigned long rx_tmp_jif;
  923. void __iomem *RX_DESC_BASE_ADDR;
  924. u32 drop_rxpkt, drop_rxcell, rx_cell_cnt, rx_pkt_cnt;
  925. struct atm_dev *next_board; /* other iphase devices */
  926. struct pci_dev *pci;
  927. int mem;
  928. unsigned int real_base; /* real and virtual base address */
  929. void __iomem *base;
  930. unsigned int pci_map_size; /*pci map size of board */
  931. unsigned char irq;
  932. unsigned char bus;
  933. unsigned char dev_fn;
  934. u_short phy_type;
  935. u_short num_vc, memSize, memType;
  936. struct ia_ffL_t ffL;
  937. struct ia_rfL_t rfL;
  938. /* Suni stat */
  939. // IA_SUNI_STATS suni_stats;
  940. unsigned char carrier_detect;
  941. /* CBR related */
  942. // transmit DMA & Receive
  943. unsigned int tx_dma_cnt; // number of elements on dma queue
  944. unsigned int rx_dma_cnt; // number of elements on rx dma queue
  945. unsigned int NumEnabledCBR; // number of CBR VCI's enabled. CBR
  946. // receive MARK for Cell FIFO
  947. unsigned int rx_mark_cnt; // number of elements on mark queue
  948. unsigned int CbrTotEntries; // Total CBR Entries in Scheduling Table.
  949. unsigned int CbrRemEntries; // Remaining CBR Entries in Scheduling Table.
  950. unsigned int CbrEntryPt; // CBR Sched Table Entry Point.
  951. unsigned int Granularity; // CBR Granularity given Table Size.
  952. /* ABR related */
  953. unsigned int sum_mcr, sum_cbr, LineRate;
  954. unsigned int n_abr;
  955. struct desc_tbl_t *desc_tbl;
  956. u_short host_tcq_wr;
  957. struct testTable_t **testTable;
  958. dma_addr_t tx_dle_dma;
  959. dma_addr_t rx_dle_dma;
  960. } IADEV;
  961. #define INPH_IA_DEV(d) ((IADEV *) (d)->dev_data)
  962. #define INPH_IA_VCC(v) ((struct ia_vcc *) (v)->dev_data)
  963. /******************* IDT77105 25MB/s PHY DEFINE *****************************/
  964. enum ia_mb25 {
  965. MB25_MASTER_CTRL = 0x00, /* Master control */
  966. MB25_INTR_STATUS = 0x04, /* Interrupt status */
  967. MB25_DIAG_CONTROL = 0x08, /* Diagnostic control */
  968. MB25_LED_HEC = 0x0c, /* LED driver and HEC status/control */
  969. MB25_LOW_BYTE_COUNTER = 0x10,
  970. MB25_HIGH_BYTE_COUNTER = 0x14
  971. };
  972. /*
  973. * Master Control
  974. */
  975. #define MB25_MC_UPLO 0x80 /* UPLO */
  976. #define MB25_MC_DREC 0x40 /* Discard receive cell errors */
  977. #define MB25_MC_ECEIO 0x20 /* Enable Cell Error Interrupts Only */
  978. #define MB25_MC_TDPC 0x10 /* Transmit data parity check */
  979. #define MB25_MC_DRIC 0x08 /* Discard receive idle cells */
  980. #define MB25_MC_HALTTX 0x04 /* Halt Tx */
  981. #define MB25_MC_UMS 0x02 /* UTOPIA mode select */
  982. #define MB25_MC_ENABLED 0x01 /* Enable interrupt */
  983. /*
  984. * Interrupt Status
  985. */
  986. #define MB25_IS_GSB 0x40 /* GOOD Symbol Bit */
  987. #define MB25_IS_HECECR 0x20 /* HEC error cell received */
  988. #define MB25_IS_SCR 0x10 /* "Short Cell" Received */
  989. #define MB25_IS_TPE 0x08 /* Trnamsit Parity Error */
  990. #define MB25_IS_RSCC 0x04 /* Receive Signal Condition change */
  991. #define MB25_IS_RCSE 0x02 /* Received Cell Symbol Error */
  992. #define MB25_IS_RFIFOO 0x01 /* Received FIFO Overrun */
  993. /*
  994. * Diagnostic Control
  995. */
  996. #define MB25_DC_FTXCD 0x80 /* Force TxClav deassert */
  997. #define MB25_DC_RXCOS 0x40 /* RxClav operation select */
  998. #define MB25_DC_ECEIO 0x20 /* Single/Multi-PHY config select */
  999. #define MB25_DC_RLFLUSH 0x10 /* Clear receive FIFO */
  1000. #define MB25_DC_IXPE 0x08 /* Insert xmit payload error */
  1001. #define MB25_DC_IXHECE 0x04 /* Insert Xmit HEC Error */
  1002. #define MB25_DC_LB_MASK 0x03 /* Loopback control mask */
  1003. #define MB25_DC_LL 0x03 /* Line Loopback */
  1004. #define MB25_DC_PL 0x02 /* PHY Loopback */
  1005. #define MB25_DC_NM 0x00
  1006. #define FE_MASK 0x00F0
  1007. #define FE_MULTI_MODE 0x0000
  1008. #define FE_SINGLE_MODE 0x0010
  1009. #define FE_UTP_OPTION 0x0020
  1010. #define FE_25MBIT_PHY 0x0040
  1011. #define FE_DS3_PHY 0x0080 /* DS3 */
  1012. #define FE_E3_PHY 0x0090 /* E3 */
  1013. /*********************** SUNI_PM7345 PHY DEFINE HERE *********************/
  1014. enum suni_pm7345 {
  1015. SUNI_CONFIG = 0x000, /* SUNI Configuration */
  1016. SUNI_INTR_ENBL = 0x004, /* SUNI Interrupt Enable */
  1017. SUNI_INTR_STAT = 0x008, /* SUNI Interrupt Status */
  1018. SUNI_CONTROL = 0x00c, /* SUNI Control */
  1019. SUNI_ID_RESET = 0x010, /* SUNI Reset and Identity */
  1020. SUNI_DATA_LINK_CTRL = 0x014,
  1021. SUNI_RBOC_CONF_INTR_ENBL = 0x018,
  1022. SUNI_RBOC_STAT = 0x01c,
  1023. SUNI_DS3_FRM_CFG = 0x020,
  1024. SUNI_DS3_FRM_INTR_ENBL = 0x024,
  1025. SUNI_DS3_FRM_INTR_STAT = 0x028,
  1026. SUNI_DS3_FRM_STAT = 0x02c,
  1027. SUNI_RFDL_CFG = 0x030,
  1028. SUNI_RFDL_ENBL_STAT = 0x034,
  1029. SUNI_RFDL_STAT = 0x038,
  1030. SUNI_RFDL_DATA = 0x03c,
  1031. SUNI_PMON_CHNG = 0x040,
  1032. SUNI_PMON_INTR_ENBL_STAT = 0x044,
  1033. /* SUNI_RESERVED1 (0x13 - 0x11) */
  1034. SUNI_PMON_LCV_EVT_CNT_LSB = 0x050,
  1035. SUNI_PMON_LCV_EVT_CNT_MSB = 0x054,
  1036. SUNI_PMON_FBE_EVT_CNT_LSB = 0x058,
  1037. SUNI_PMON_FBE_EVT_CNT_MSB = 0x05c,
  1038. SUNI_PMON_SEZ_DET_CNT_LSB = 0x060,
  1039. SUNI_PMON_SEZ_DET_CNT_MSB = 0x064,
  1040. SUNI_PMON_PE_EVT_CNT_LSB = 0x068,
  1041. SUNI_PMON_PE_EVT_CNT_MSB = 0x06c,
  1042. SUNI_PMON_PPE_EVT_CNT_LSB = 0x070,
  1043. SUNI_PMON_PPE_EVT_CNT_MSB = 0x074,
  1044. SUNI_PMON_FEBE_EVT_CNT_LSB = 0x078,
  1045. SUNI_PMON_FEBE_EVT_CNT_MSB = 0x07c,
  1046. SUNI_DS3_TRAN_CFG = 0x080,
  1047. SUNI_DS3_TRAN_DIAG = 0x084,
  1048. /* SUNI_RESERVED2 (0x23 - 0x21) */
  1049. SUNI_XFDL_CFG = 0x090,
  1050. SUNI_XFDL_INTR_ST = 0x094,
  1051. SUNI_XFDL_XMIT_DATA = 0x098,
  1052. SUNI_XBOC_CODE = 0x09c,
  1053. SUNI_SPLR_CFG = 0x0a0,
  1054. SUNI_SPLR_INTR_EN = 0x0a4,
  1055. SUNI_SPLR_INTR_ST = 0x0a8,
  1056. SUNI_SPLR_STATUS = 0x0ac,
  1057. SUNI_SPLT_CFG = 0x0b0,
  1058. SUNI_SPLT_CNTL = 0x0b4,
  1059. SUNI_SPLT_DIAG_G1 = 0x0b8,
  1060. SUNI_SPLT_F1 = 0x0bc,
  1061. SUNI_CPPM_LOC_METERS = 0x0c0,
  1062. SUNI_CPPM_CHG_OF_CPPM_PERF_METR = 0x0c4,
  1063. SUNI_CPPM_B1_ERR_CNT_LSB = 0x0c8,
  1064. SUNI_CPPM_B1_ERR_CNT_MSB = 0x0cc,
  1065. SUNI_CPPM_FRAMING_ERR_CNT_LSB = 0x0d0,
  1066. SUNI_CPPM_FRAMING_ERR_CNT_MSB = 0x0d4,
  1067. SUNI_CPPM_FEBE_CNT_LSB = 0x0d8,
  1068. SUNI_CPPM_FEBE_CNT_MSB = 0x0dc,
  1069. SUNI_CPPM_HCS_ERR_CNT_LSB = 0x0e0,
  1070. SUNI_CPPM_HCS_ERR_CNT_MSB = 0x0e4,
  1071. SUNI_CPPM_IDLE_UN_CELL_CNT_LSB = 0x0e8,
  1072. SUNI_CPPM_IDLE_UN_CELL_CNT_MSB = 0x0ec,
  1073. SUNI_CPPM_RCV_CELL_CNT_LSB = 0x0f0,
  1074. SUNI_CPPM_RCV_CELL_CNT_MSB = 0x0f4,
  1075. SUNI_CPPM_XMIT_CELL_CNT_LSB = 0x0f8,
  1076. SUNI_CPPM_XMIT_CELL_CNT_MSB = 0x0fc,
  1077. SUNI_RXCP_CTRL = 0x100,
  1078. SUNI_RXCP_FCTRL = 0x104,
  1079. SUNI_RXCP_INTR_EN_STS = 0x108,
  1080. SUNI_RXCP_IDLE_PAT_H1 = 0x10c,
  1081. SUNI_RXCP_IDLE_PAT_H2 = 0x110,
  1082. SUNI_RXCP_IDLE_PAT_H3 = 0x114,
  1083. SUNI_RXCP_IDLE_PAT_H4 = 0x118,
  1084. SUNI_RXCP_IDLE_MASK_H1 = 0x11c,
  1085. SUNI_RXCP_IDLE_MASK_H2 = 0x120,
  1086. SUNI_RXCP_IDLE_MASK_H3 = 0x124,
  1087. SUNI_RXCP_IDLE_MASK_H4 = 0x128,
  1088. SUNI_RXCP_CELL_PAT_H1 = 0x12c,
  1089. SUNI_RXCP_CELL_PAT_H2 = 0x130,
  1090. SUNI_RXCP_CELL_PAT_H3 = 0x134,
  1091. SUNI_RXCP_CELL_PAT_H4 = 0x138,
  1092. SUNI_RXCP_CELL_MASK_H1 = 0x13c,
  1093. SUNI_RXCP_CELL_MASK_H2 = 0x140,
  1094. SUNI_RXCP_CELL_MASK_H3 = 0x144,
  1095. SUNI_RXCP_CELL_MASK_H4 = 0x148,
  1096. SUNI_RXCP_HCS_CS = 0x14c,
  1097. SUNI_RXCP_LCD_CNT_THRESHOLD = 0x150,
  1098. /* SUNI_RESERVED3 (0x57 - 0x54) */
  1099. SUNI_TXCP_CTRL = 0x160,
  1100. SUNI_TXCP_INTR_EN_STS = 0x164,
  1101. SUNI_TXCP_IDLE_PAT_H1 = 0x168,
  1102. SUNI_TXCP_IDLE_PAT_H2 = 0x16c,
  1103. SUNI_TXCP_IDLE_PAT_H3 = 0x170,
  1104. SUNI_TXCP_IDLE_PAT_H4 = 0x174,
  1105. SUNI_TXCP_IDLE_PAT_H5 = 0x178,
  1106. SUNI_TXCP_IDLE_PAYLOAD = 0x17c,
  1107. SUNI_E3_FRM_FRAM_OPTIONS = 0x180,
  1108. SUNI_E3_FRM_MAINT_OPTIONS = 0x184,
  1109. SUNI_E3_FRM_FRAM_INTR_ENBL = 0x188,
  1110. SUNI_E3_FRM_FRAM_INTR_IND_STAT = 0x18c,
  1111. SUNI_E3_FRM_MAINT_INTR_ENBL = 0x190,
  1112. SUNI_E3_FRM_MAINT_INTR_IND = 0x194,
  1113. SUNI_E3_FRM_MAINT_STAT = 0x198,
  1114. SUNI_RESERVED4 = 0x19c,
  1115. SUNI_E3_TRAN_FRAM_OPTIONS = 0x1a0,
  1116. SUNI_E3_TRAN_STAT_DIAG_OPTIONS = 0x1a4,
  1117. SUNI_E3_TRAN_BIP_8_ERR_MASK = 0x1a8,
  1118. SUNI_E3_TRAN_MAINT_ADAPT_OPTS = 0x1ac,
  1119. SUNI_TTB_CTRL = 0x1b0,
  1120. SUNI_TTB_TRAIL_TRACE_ID_STAT = 0x1b4,
  1121. SUNI_TTB_IND_ADDR = 0x1b8,
  1122. SUNI_TTB_IND_DATA = 0x1bc,
  1123. SUNI_TTB_EXP_PAYLOAD_TYPE = 0x1c0,
  1124. SUNI_TTB_PAYLOAD_TYPE_CTRL_STAT = 0x1c4,
  1125. /* SUNI_PAD5 (0x7f - 0x71) */
  1126. SUNI_MASTER_TEST = 0x200,
  1127. /* SUNI_PAD6 (0xff - 0x80) */
  1128. };
  1129. #define SUNI_PM7345_T suni_pm7345_t
  1130. #define SUNI_PM7345 0x20 /* Suni chip type */
  1131. #define SUNI_PM5346 0x30 /* Suni chip type */
  1132. /*
  1133. * SUNI_PM7345 Configuration
  1134. */
  1135. #define SUNI_PM7345_CLB 0x01 /* Cell loopback */
  1136. #define SUNI_PM7345_PLB 0x02 /* Payload loopback */
  1137. #define SUNI_PM7345_DLB 0x04 /* Diagnostic loopback */
  1138. #define SUNI_PM7345_LLB 0x80 /* Line loopback */
  1139. #define SUNI_PM7345_E3ENBL 0x40 /* E3 enable bit */
  1140. #define SUNI_PM7345_LOOPT 0x10 /* LOOPT enable bit */
  1141. #define SUNI_PM7345_FIFOBP 0x20 /* FIFO bypass */
  1142. #define SUNI_PM7345_FRMRBP 0x08 /* Framer bypass */
  1143. /*
  1144. * DS3 FRMR Interrupt Enable
  1145. */
  1146. #define SUNI_DS3_COFAE 0x80 /* Enable change of frame align */
  1147. #define SUNI_DS3_REDE 0x40 /* Enable DS3 RED state intr */
  1148. #define SUNI_DS3_CBITE 0x20 /* Enable Appl ID channel intr */
  1149. #define SUNI_DS3_FERFE 0x10 /* Enable Far End Receive Failure intr*/
  1150. #define SUNI_DS3_IDLE 0x08 /* Enable Idle signal intr */
  1151. #define SUNI_DS3_AISE 0x04 /* Enable Alarm Indication signal intr*/
  1152. #define SUNI_DS3_OOFE 0x02 /* Enable Out of frame intr */
  1153. #define SUNI_DS3_LOSE 0x01 /* Enable Loss of signal intr */
  1154. /*
  1155. * DS3 FRMR Status
  1156. */
  1157. #define SUNI_DS3_ACE 0x80 /* Additional Configuration Reg */
  1158. #define SUNI_DS3_REDV 0x40 /* DS3 RED state */
  1159. #define SUNI_DS3_CBITV 0x20 /* Application ID channel state */
  1160. #define SUNI_DS3_FERFV 0x10 /* Far End Receive Failure state*/
  1161. #define SUNI_DS3_IDLV 0x08 /* Idle signal state */
  1162. #define SUNI_DS3_AISV 0x04 /* Alarm Indication signal state*/
  1163. #define SUNI_DS3_OOFV 0x02 /* Out of frame state */
  1164. #define SUNI_DS3_LOSV 0x01 /* Loss of signal state */
  1165. /*
  1166. * E3 FRMR Interrupt/Status
  1167. */
  1168. #define SUNI_E3_CZDI 0x40 /* Consecutive Zeros indicator */
  1169. #define SUNI_E3_LOSI 0x20 /* Loss of signal intr status */
  1170. #define SUNI_E3_LCVI 0x10 /* Line code violation intr */
  1171. #define SUNI_E3_COFAI 0x08 /* Change of frame align intr */
  1172. #define SUNI_E3_OOFI 0x04 /* Out of frame intr status */
  1173. #define SUNI_E3_LOS 0x02 /* Loss of signal state */
  1174. #define SUNI_E3_OOF 0x01 /* Out of frame state */
  1175. /*
  1176. * E3 FRMR Maintenance Status
  1177. */
  1178. #define SUNI_E3_AISD 0x80 /* Alarm Indication signal state*/
  1179. #define SUNI_E3_FERF_RAI 0x40 /* FERF/RAI indicator */
  1180. #define SUNI_E3_FEBE 0x20 /* Far End Block Error indicator*/
  1181. /*
  1182. * RXCP Control/Status
  1183. */
  1184. #define SUNI_DS3_HCSPASS 0x80 /* Pass cell with HEC errors */
  1185. #define SUNI_DS3_HCSDQDB 0x40 /* Control octets in HCS calc */
  1186. #define SUNI_DS3_HCSADD 0x20 /* Add coset poly */
  1187. #define SUNI_DS3_HCK 0x10 /* Control FIFO data path integ chk*/
  1188. #define SUNI_DS3_BLOCK 0x08 /* Enable cell filtering */
  1189. #define SUNI_DS3_DSCR 0x04 /* Disable payload descrambling */
  1190. #define SUNI_DS3_OOCDV 0x02 /* Cell delineation state */
  1191. #define SUNI_DS3_FIFORST 0x01 /* Cell FIFO reset */
  1192. /*
  1193. * RXCP Interrupt Enable/Status
  1194. */
  1195. #define SUNI_DS3_OOCDE 0x80 /* Intr enable, change in CDS */
  1196. #define SUNI_DS3_HCSE 0x40 /* Intr enable, corr HCS errors */
  1197. #define SUNI_DS3_FIFOE 0x20 /* Intr enable, unco HCS errors */
  1198. #define SUNI_DS3_OOCDI 0x10 /* SYNC state */
  1199. #define SUNI_DS3_UHCSI 0x08 /* Uncorr. HCS errors detected */
  1200. #define SUNI_DS3_COCAI 0x04 /* Corr. HCS errors detected */
  1201. #define SUNI_DS3_FOVRI 0x02 /* FIFO overrun */
  1202. #define SUNI_DS3_FUDRI 0x01 /* FIFO underrun */
  1203. ///////////////////SUNI_PM7345 PHY DEFINE END /////////////////////////////
  1204. /* ia_eeprom define*/
  1205. #define MEM_SIZE_MASK 0x000F /* mask of 4 bits defining memory size*/
  1206. #define MEM_SIZE_128K 0x0000 /* board has 128k buffer */
  1207. #define MEM_SIZE_512K 0x0001 /* board has 512K of buffer */
  1208. #define MEM_SIZE_1M 0x0002 /* board has 1M of buffer */
  1209. /* 0x3 to 0xF are reserved for future */
  1210. #define FE_MASK 0x00F0 /* mask of 4 bits defining FE type */
  1211. #define FE_MULTI_MODE 0x0000 /* 155 MBit multimode fiber */
  1212. #define FE_SINGLE_MODE 0x0010 /* 155 MBit single mode laser */
  1213. #define FE_UTP_OPTION 0x0020 /* 155 MBit UTP front end */
  1214. #define NOVRAM_SIZE 64
  1215. #define CMD_LEN 10
  1216. /***********
  1217. *
  1218. * Switches and defines for header files.
  1219. *
  1220. * The following defines are used to turn on and off
  1221. * various options in the header files. Primarily useful
  1222. * for debugging.
  1223. *
  1224. ***********/
  1225. /*
  1226. * a list of the commands that can be sent to the NOVRAM
  1227. */
  1228. #define EXTEND 0x100
  1229. #define IAWRITE 0x140
  1230. #define IAREAD 0x180
  1231. #define ERASE 0x1c0
  1232. #define EWDS 0x00
  1233. #define WRAL 0x10
  1234. #define ERAL 0x20
  1235. #define EWEN 0x30
  1236. /*
  1237. * these bits duplicate the hw_flip.h register settings
  1238. * note: how the data in / out bits are defined in the flipper specification
  1239. */
  1240. #define NVCE 0x02
  1241. #define NVSK 0x01
  1242. #define NVDO 0x08
  1243. #define NVDI 0x04
  1244. /***********************
  1245. *
  1246. * This define ands the value and the current config register and puts
  1247. * the result in the config register
  1248. *
  1249. ***********************/
  1250. #define CFG_AND(val) { \
  1251. u32 t; \
  1252. t = readl(iadev->reg+IPHASE5575_EEPROM_ACCESS); \
  1253. t &= (val); \
  1254. writel(t, iadev->reg+IPHASE5575_EEPROM_ACCESS); \
  1255. }
  1256. /***********************
  1257. *
  1258. * This define ors the value and the current config register and puts
  1259. * the result in the config register
  1260. *
  1261. ***********************/
  1262. #define CFG_OR(val) { \
  1263. u32 t; \
  1264. t = readl(iadev->reg+IPHASE5575_EEPROM_ACCESS); \
  1265. t |= (val); \
  1266. writel(t, iadev->reg+IPHASE5575_EEPROM_ACCESS); \
  1267. }
  1268. /***********************
  1269. *
  1270. * Send a command to the NOVRAM, the command is in cmd.
  1271. *
  1272. * clear CE and SK. Then assert CE.
  1273. * Clock each of the command bits out in the correct order with SK
  1274. * exit with CE still asserted
  1275. *
  1276. ***********************/
  1277. #define NVRAM_CMD(cmd) { \
  1278. int i; \
  1279. u_short c = cmd; \
  1280. CFG_AND(~(NVCE|NVSK)); \
  1281. CFG_OR(NVCE); \
  1282. for (i=0; i<CMD_LEN; i++) { \
  1283. NVRAM_CLKOUT((c & (1 << (CMD_LEN - 1))) ? 1 : 0); \
  1284. c <<= 1; \
  1285. } \
  1286. }
  1287. /***********************
  1288. *
  1289. * clear the CE, this must be used after each command is complete
  1290. *
  1291. ***********************/
  1292. #define NVRAM_CLR_CE {CFG_AND(~NVCE)}
  1293. /***********************
  1294. *
  1295. * clock the data bit in bitval out to the NOVRAM. The bitval must be
  1296. * a 1 or 0, or the clockout operation is undefined
  1297. *
  1298. ***********************/
  1299. #define NVRAM_CLKOUT(bitval) { \
  1300. CFG_AND(~NVDI); \
  1301. CFG_OR((bitval) ? NVDI : 0); \
  1302. CFG_OR(NVSK); \
  1303. CFG_AND( ~NVSK); \
  1304. }
  1305. /***********************
  1306. *
  1307. * clock the data bit in and return a 1 or 0, depending on the value
  1308. * that was received from the NOVRAM
  1309. *
  1310. ***********************/
  1311. #define NVRAM_CLKIN(value) { \
  1312. u32 _t; \
  1313. CFG_OR(NVSK); \
  1314. CFG_AND(~NVSK); \
  1315. _t = readl(iadev->reg+IPHASE5575_EEPROM_ACCESS); \
  1316. value = (_t & NVDO) ? 1 : 0; \
  1317. }
  1318. #endif /* IPHASE_H */