via-velocity.h 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This software may be redistributed and/or modified under
  6. * the terms of the GNU General Public License as published by the Free
  7. * Software Foundation; either version 2 of the License, or
  8. * any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. *
  15. * File: via-velocity.h
  16. *
  17. * Purpose: Header file to define driver's private structures.
  18. *
  19. * Author: Chuang Liang-Shing, AJ Jiang
  20. *
  21. * Date: Jan 24, 2003
  22. */
  23. #ifndef VELOCITY_H
  24. #define VELOCITY_H
  25. #define VELOCITY_TX_CSUM_SUPPORT
  26. #define VELOCITY_NAME "via-velocity"
  27. #define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
  28. #define VELOCITY_VERSION "1.15"
  29. #define VELOCITY_IO_SIZE 256
  30. #define VELOCITY_NAPI_WEIGHT 64
  31. #define PKT_BUF_SZ 1540
  32. #define MAX_UNITS 8
  33. #define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
  34. #define REV_ID_VT6110 (0)
  35. #define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
  36. #define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
  37. #define DWORD_REG_BITS_ON(x,p) do { writel(readl((p))|(x),(p));} while (0)
  38. #define BYTE_REG_BITS_IS_ON(x,p) (readb((p)) & (x))
  39. #define WORD_REG_BITS_IS_ON(x,p) (readw((p)) & (x))
  40. #define DWORD_REG_BITS_IS_ON(x,p) (readl((p)) & (x))
  41. #define BYTE_REG_BITS_OFF(x,p) do { writeb(readb((p)) & (~(x)),(p));} while (0)
  42. #define WORD_REG_BITS_OFF(x,p) do { writew(readw((p)) & (~(x)),(p));} while (0)
  43. #define DWORD_REG_BITS_OFF(x,p) do { writel(readl((p)) & (~(x)),(p));} while (0)
  44. #define BYTE_REG_BITS_SET(x,m,p) do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
  45. #define WORD_REG_BITS_SET(x,m,p) do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
  46. #define DWORD_REG_BITS_SET(x,m,p) do { writel( (readl((p)) & (~(m)))|(x),(p));} while (0)
  47. #define VAR_USED(p) do {(p)=(p);} while (0)
  48. /*
  49. * Purpose: Structures for MAX RX/TX descriptors.
  50. */
  51. #define B_OWNED_BY_CHIP 1
  52. #define B_OWNED_BY_HOST 0
  53. /*
  54. * Bits in the RSR0 register
  55. */
  56. #define RSR_DETAG cpu_to_le16(0x0080)
  57. #define RSR_SNTAG cpu_to_le16(0x0040)
  58. #define RSR_RXER cpu_to_le16(0x0020)
  59. #define RSR_RL cpu_to_le16(0x0010)
  60. #define RSR_CE cpu_to_le16(0x0008)
  61. #define RSR_FAE cpu_to_le16(0x0004)
  62. #define RSR_CRC cpu_to_le16(0x0002)
  63. #define RSR_VIDM cpu_to_le16(0x0001)
  64. /*
  65. * Bits in the RSR1 register
  66. */
  67. #define RSR_RXOK cpu_to_le16(0x8000) // rx OK
  68. #define RSR_PFT cpu_to_le16(0x4000) // Perfect filtering address match
  69. #define RSR_MAR cpu_to_le16(0x2000) // MAC accept multicast address packet
  70. #define RSR_BAR cpu_to_le16(0x1000) // MAC accept broadcast address packet
  71. #define RSR_PHY cpu_to_le16(0x0800) // MAC accept physical address packet
  72. #define RSR_VTAG cpu_to_le16(0x0400) // 802.1p/1q tagging packet indicator
  73. #define RSR_STP cpu_to_le16(0x0200) // start of packet
  74. #define RSR_EDP cpu_to_le16(0x0100) // end of packet
  75. /*
  76. * Bits in the CSM register
  77. */
  78. #define CSM_IPOK 0x40 //IP Checksum validation ok
  79. #define CSM_TUPOK 0x20 //TCP/UDP Checksum validation ok
  80. #define CSM_FRAG 0x10 //Fragment IP datagram
  81. #define CSM_IPKT 0x04 //Received an IP packet
  82. #define CSM_TCPKT 0x02 //Received a TCP packet
  83. #define CSM_UDPKT 0x01 //Received a UDP packet
  84. /*
  85. * Bits in the TSR0 register
  86. */
  87. #define TSR0_ABT cpu_to_le16(0x0080) // Tx abort because of excessive collision
  88. #define TSR0_OWT cpu_to_le16(0x0040) // Jumbo frame Tx abort
  89. #define TSR0_OWC cpu_to_le16(0x0020) // Out of window collision
  90. #define TSR0_COLS cpu_to_le16(0x0010) // experience collision in this transmit event
  91. #define TSR0_NCR3 cpu_to_le16(0x0008) // collision retry counter[3]
  92. #define TSR0_NCR2 cpu_to_le16(0x0004) // collision retry counter[2]
  93. #define TSR0_NCR1 cpu_to_le16(0x0002) // collision retry counter[1]
  94. #define TSR0_NCR0 cpu_to_le16(0x0001) // collision retry counter[0]
  95. #define TSR0_TERR cpu_to_le16(0x8000) //
  96. #define TSR0_FDX cpu_to_le16(0x4000) // current transaction is serviced by full duplex mode
  97. #define TSR0_GMII cpu_to_le16(0x2000) // current transaction is serviced by GMII mode
  98. #define TSR0_LNKFL cpu_to_le16(0x1000) // packet serviced during link down
  99. #define TSR0_SHDN cpu_to_le16(0x0400) // shutdown case
  100. #define TSR0_CRS cpu_to_le16(0x0200) // carrier sense lost
  101. #define TSR0_CDH cpu_to_le16(0x0100) // AQE test fail (CD heartbeat)
  102. //
  103. // Bits in the TCR0 register
  104. //
  105. #define TCR0_TIC 0x80 // assert interrupt immediately while descriptor has been send complete
  106. #define TCR0_PIC 0x40 // priority interrupt request, INA# is issued over adaptive interrupt scheme
  107. #define TCR0_VETAG 0x20 // enable VLAN tag
  108. #define TCR0_IPCK 0x10 // request IP checksum calculation.
  109. #define TCR0_UDPCK 0x08 // request UDP checksum calculation.
  110. #define TCR0_TCPCK 0x04 // request TCP checksum calculation.
  111. #define TCR0_JMBO 0x02 // indicate a jumbo packet in GMAC side
  112. #define TCR0_CRC 0x01 // disable CRC generation
  113. #define TCPLS_NORMAL 3
  114. #define TCPLS_START 2
  115. #define TCPLS_END 1
  116. #define TCPLS_MED 0
  117. // max transmit or receive buffer size
  118. #define CB_RX_BUF_SIZE 2048UL // max buffer size
  119. // NOTE: must be multiple of 4
  120. #define CB_MAX_RD_NUM 512 // MAX # of RD
  121. #define CB_MAX_TD_NUM 256 // MAX # of TD
  122. #define CB_INIT_RD_NUM_3119 128 // init # of RD, for setup VT3119
  123. #define CB_INIT_TD_NUM_3119 64 // init # of TD, for setup VT3119
  124. #define CB_INIT_RD_NUM 128 // init # of RD, for setup default
  125. #define CB_INIT_TD_NUM 64 // init # of TD, for setup default
  126. // for 3119
  127. #define CB_TD_RING_NUM 4 // # of TD rings.
  128. #define CB_MAX_SEG_PER_PKT 7 // max data seg per packet (Tx)
  129. /*
  130. * If collisions excess 15 times , tx will abort, and
  131. * if tx fifo underflow, tx will fail
  132. * we should try to resend it
  133. */
  134. #define CB_MAX_TX_ABORT_RETRY 3
  135. /*
  136. * Receive descriptor
  137. */
  138. struct rdesc0 {
  139. __le16 RSR; /* Receive status */
  140. __le16 len; /* bits 0--13; bit 15 - owner */
  141. };
  142. struct rdesc1 {
  143. __le16 PQTAG;
  144. u8 CSM;
  145. u8 IPKT;
  146. };
  147. enum {
  148. RX_INTEN = cpu_to_le16(0x8000)
  149. };
  150. struct rx_desc {
  151. struct rdesc0 rdesc0;
  152. struct rdesc1 rdesc1;
  153. __le32 pa_low; /* Low 32 bit PCI address */
  154. __le16 pa_high; /* Next 16 bit PCI address (48 total) */
  155. __le16 size; /* bits 0--14 - frame size, bit 15 - enable int. */
  156. } __packed;
  157. /*
  158. * Transmit descriptor
  159. */
  160. struct tdesc0 {
  161. __le16 TSR; /* Transmit status register */
  162. __le16 len; /* bits 0--13 - size of frame, bit 15 - owner */
  163. };
  164. struct tdesc1 {
  165. __le16 vlan;
  166. u8 TCR;
  167. u8 cmd; /* bits 0--1 - TCPLS, bits 4--7 - CMDZ */
  168. } __packed;
  169. enum {
  170. TD_QUEUE = cpu_to_le16(0x8000)
  171. };
  172. struct td_buf {
  173. __le32 pa_low;
  174. __le16 pa_high;
  175. __le16 size; /* bits 0--13 - size, bit 15 - queue */
  176. } __packed;
  177. struct tx_desc {
  178. struct tdesc0 tdesc0;
  179. struct tdesc1 tdesc1;
  180. struct td_buf td_buf[7];
  181. };
  182. struct velocity_rd_info {
  183. struct sk_buff *skb;
  184. dma_addr_t skb_dma;
  185. };
  186. /*
  187. * Used to track transmit side buffers.
  188. */
  189. struct velocity_td_info {
  190. struct sk_buff *skb;
  191. int nskb_dma;
  192. dma_addr_t skb_dma[7];
  193. };
  194. enum velocity_owner {
  195. OWNED_BY_HOST = 0,
  196. OWNED_BY_NIC = cpu_to_le16(0x8000)
  197. };
  198. /*
  199. * MAC registers and macros.
  200. */
  201. #define MCAM_SIZE 64
  202. #define VCAM_SIZE 64
  203. #define TX_QUEUE_NO 4
  204. #define MAX_HW_MIB_COUNTER 32
  205. #define VELOCITY_MIN_MTU (64)
  206. #define VELOCITY_MAX_MTU (9000)
  207. /*
  208. * Registers in the MAC
  209. */
  210. #define MAC_REG_PAR 0x00 // physical address
  211. #define MAC_REG_RCR 0x06
  212. #define MAC_REG_TCR 0x07
  213. #define MAC_REG_CR0_SET 0x08
  214. #define MAC_REG_CR1_SET 0x09
  215. #define MAC_REG_CR2_SET 0x0A
  216. #define MAC_REG_CR3_SET 0x0B
  217. #define MAC_REG_CR0_CLR 0x0C
  218. #define MAC_REG_CR1_CLR 0x0D
  219. #define MAC_REG_CR2_CLR 0x0E
  220. #define MAC_REG_CR3_CLR 0x0F
  221. #define MAC_REG_MAR 0x10
  222. #define MAC_REG_CAM 0x10
  223. #define MAC_REG_DEC_BASE_HI 0x18
  224. #define MAC_REG_DBF_BASE_HI 0x1C
  225. #define MAC_REG_ISR_CTL 0x20
  226. #define MAC_REG_ISR_HOTMR 0x20
  227. #define MAC_REG_ISR_TSUPTHR 0x20
  228. #define MAC_REG_ISR_RSUPTHR 0x20
  229. #define MAC_REG_ISR_CTL1 0x21
  230. #define MAC_REG_TXE_SR 0x22
  231. #define MAC_REG_RXE_SR 0x23
  232. #define MAC_REG_ISR 0x24
  233. #define MAC_REG_ISR0 0x24
  234. #define MAC_REG_ISR1 0x25
  235. #define MAC_REG_ISR2 0x26
  236. #define MAC_REG_ISR3 0x27
  237. #define MAC_REG_IMR 0x28
  238. #define MAC_REG_IMR0 0x28
  239. #define MAC_REG_IMR1 0x29
  240. #define MAC_REG_IMR2 0x2A
  241. #define MAC_REG_IMR3 0x2B
  242. #define MAC_REG_TDCSR_SET 0x30
  243. #define MAC_REG_RDCSR_SET 0x32
  244. #define MAC_REG_TDCSR_CLR 0x34
  245. #define MAC_REG_RDCSR_CLR 0x36
  246. #define MAC_REG_RDBASE_LO 0x38
  247. #define MAC_REG_RDINDX 0x3C
  248. #define MAC_REG_TDBASE_LO 0x40
  249. #define MAC_REG_RDCSIZE 0x50
  250. #define MAC_REG_TDCSIZE 0x52
  251. #define MAC_REG_TDINDX 0x54
  252. #define MAC_REG_TDIDX0 0x54
  253. #define MAC_REG_TDIDX1 0x56
  254. #define MAC_REG_TDIDX2 0x58
  255. #define MAC_REG_TDIDX3 0x5A
  256. #define MAC_REG_PAUSE_TIMER 0x5C
  257. #define MAC_REG_RBRDU 0x5E
  258. #define MAC_REG_FIFO_TEST0 0x60
  259. #define MAC_REG_FIFO_TEST1 0x64
  260. #define MAC_REG_CAMADDR 0x68
  261. #define MAC_REG_CAMCR 0x69
  262. #define MAC_REG_GFTEST 0x6A
  263. #define MAC_REG_FTSTCMD 0x6B
  264. #define MAC_REG_MIICFG 0x6C
  265. #define MAC_REG_MIISR 0x6D
  266. #define MAC_REG_PHYSR0 0x6E
  267. #define MAC_REG_PHYSR1 0x6F
  268. #define MAC_REG_MIICR 0x70
  269. #define MAC_REG_MIIADR 0x71
  270. #define MAC_REG_MIIDATA 0x72
  271. #define MAC_REG_SOFT_TIMER0 0x74
  272. #define MAC_REG_SOFT_TIMER1 0x76
  273. #define MAC_REG_CFGA 0x78
  274. #define MAC_REG_CFGB 0x79
  275. #define MAC_REG_CFGC 0x7A
  276. #define MAC_REG_CFGD 0x7B
  277. #define MAC_REG_DCFG0 0x7C
  278. #define MAC_REG_DCFG1 0x7D
  279. #define MAC_REG_MCFG0 0x7E
  280. #define MAC_REG_MCFG1 0x7F
  281. #define MAC_REG_TBIST 0x80
  282. #define MAC_REG_RBIST 0x81
  283. #define MAC_REG_PMCC 0x82
  284. #define MAC_REG_STICKHW 0x83
  285. #define MAC_REG_MIBCR 0x84
  286. #define MAC_REG_EERSV 0x85
  287. #define MAC_REG_REVID 0x86
  288. #define MAC_REG_MIBREAD 0x88
  289. #define MAC_REG_BPMA 0x8C
  290. #define MAC_REG_EEWR_DATA 0x8C
  291. #define MAC_REG_BPMD_WR 0x8F
  292. #define MAC_REG_BPCMD 0x90
  293. #define MAC_REG_BPMD_RD 0x91
  294. #define MAC_REG_EECHKSUM 0x92
  295. #define MAC_REG_EECSR 0x93
  296. #define MAC_REG_EERD_DATA 0x94
  297. #define MAC_REG_EADDR 0x96
  298. #define MAC_REG_EMBCMD 0x97
  299. #define MAC_REG_JMPSR0 0x98
  300. #define MAC_REG_JMPSR1 0x99
  301. #define MAC_REG_JMPSR2 0x9A
  302. #define MAC_REG_JMPSR3 0x9B
  303. #define MAC_REG_CHIPGSR 0x9C
  304. #define MAC_REG_TESTCFG 0x9D
  305. #define MAC_REG_DEBUG 0x9E
  306. #define MAC_REG_CHIPGCR 0x9F /* Chip Operation and Diagnostic Control */
  307. #define MAC_REG_WOLCR0_SET 0xA0
  308. #define MAC_REG_WOLCR1_SET 0xA1
  309. #define MAC_REG_PWCFG_SET 0xA2
  310. #define MAC_REG_WOLCFG_SET 0xA3
  311. #define MAC_REG_WOLCR0_CLR 0xA4
  312. #define MAC_REG_WOLCR1_CLR 0xA5
  313. #define MAC_REG_PWCFG_CLR 0xA6
  314. #define MAC_REG_WOLCFG_CLR 0xA7
  315. #define MAC_REG_WOLSR0_SET 0xA8
  316. #define MAC_REG_WOLSR1_SET 0xA9
  317. #define MAC_REG_WOLSR0_CLR 0xAC
  318. #define MAC_REG_WOLSR1_CLR 0xAD
  319. #define MAC_REG_PATRN_CRC0 0xB0
  320. #define MAC_REG_PATRN_CRC1 0xB2
  321. #define MAC_REG_PATRN_CRC2 0xB4
  322. #define MAC_REG_PATRN_CRC3 0xB6
  323. #define MAC_REG_PATRN_CRC4 0xB8
  324. #define MAC_REG_PATRN_CRC5 0xBA
  325. #define MAC_REG_PATRN_CRC6 0xBC
  326. #define MAC_REG_PATRN_CRC7 0xBE
  327. #define MAC_REG_BYTEMSK0_0 0xC0
  328. #define MAC_REG_BYTEMSK0_1 0xC4
  329. #define MAC_REG_BYTEMSK0_2 0xC8
  330. #define MAC_REG_BYTEMSK0_3 0xCC
  331. #define MAC_REG_BYTEMSK1_0 0xD0
  332. #define MAC_REG_BYTEMSK1_1 0xD4
  333. #define MAC_REG_BYTEMSK1_2 0xD8
  334. #define MAC_REG_BYTEMSK1_3 0xDC
  335. #define MAC_REG_BYTEMSK2_0 0xE0
  336. #define MAC_REG_BYTEMSK2_1 0xE4
  337. #define MAC_REG_BYTEMSK2_2 0xE8
  338. #define MAC_REG_BYTEMSK2_3 0xEC
  339. #define MAC_REG_BYTEMSK3_0 0xF0
  340. #define MAC_REG_BYTEMSK3_1 0xF4
  341. #define MAC_REG_BYTEMSK3_2 0xF8
  342. #define MAC_REG_BYTEMSK3_3 0xFC
  343. /*
  344. * Bits in the RCR register
  345. */
  346. #define RCR_AS 0x80
  347. #define RCR_AP 0x40
  348. #define RCR_AL 0x20
  349. #define RCR_PROM 0x10
  350. #define RCR_AB 0x08
  351. #define RCR_AM 0x04
  352. #define RCR_AR 0x02
  353. #define RCR_SEP 0x01
  354. /*
  355. * Bits in the TCR register
  356. */
  357. #define TCR_TB2BDIS 0x80
  358. #define TCR_COLTMC1 0x08
  359. #define TCR_COLTMC0 0x04
  360. #define TCR_LB1 0x02 /* loopback[1] */
  361. #define TCR_LB0 0x01 /* loopback[0] */
  362. /*
  363. * Bits in the CR0 register
  364. */
  365. #define CR0_TXON 0x00000008UL
  366. #define CR0_RXON 0x00000004UL
  367. #define CR0_STOP 0x00000002UL /* stop MAC, default = 1 */
  368. #define CR0_STRT 0x00000001UL /* start MAC */
  369. #define CR0_SFRST 0x00008000UL /* software reset */
  370. #define CR0_TM1EN 0x00004000UL
  371. #define CR0_TM0EN 0x00002000UL
  372. #define CR0_DPOLL 0x00000800UL /* disable rx/tx auto polling */
  373. #define CR0_DISAU 0x00000100UL
  374. #define CR0_XONEN 0x00800000UL
  375. #define CR0_FDXTFCEN 0x00400000UL /* full-duplex TX flow control enable */
  376. #define CR0_FDXRFCEN 0x00200000UL /* full-duplex RX flow control enable */
  377. #define CR0_HDXFCEN 0x00100000UL /* half-duplex flow control enable */
  378. #define CR0_XHITH1 0x00080000UL /* TX XON high threshold 1 */
  379. #define CR0_XHITH0 0x00040000UL /* TX XON high threshold 0 */
  380. #define CR0_XLTH1 0x00020000UL /* TX pause frame low threshold 1 */
  381. #define CR0_XLTH0 0x00010000UL /* TX pause frame low threshold 0 */
  382. #define CR0_GSPRST 0x80000000UL
  383. #define CR0_FORSRST 0x40000000UL
  384. #define CR0_FPHYRST 0x20000000UL
  385. #define CR0_DIAG 0x10000000UL
  386. #define CR0_INTPCTL 0x04000000UL
  387. #define CR0_GINTMSK1 0x02000000UL
  388. #define CR0_GINTMSK0 0x01000000UL
  389. /*
  390. * Bits in the CR1 register
  391. */
  392. #define CR1_SFRST 0x80 /* software reset */
  393. #define CR1_TM1EN 0x40
  394. #define CR1_TM0EN 0x20
  395. #define CR1_DPOLL 0x08 /* disable rx/tx auto polling */
  396. #define CR1_DISAU 0x01
  397. /*
  398. * Bits in the CR2 register
  399. */
  400. #define CR2_XONEN 0x80
  401. #define CR2_FDXTFCEN 0x40 /* full-duplex TX flow control enable */
  402. #define CR2_FDXRFCEN 0x20 /* full-duplex RX flow control enable */
  403. #define CR2_HDXFCEN 0x10 /* half-duplex flow control enable */
  404. #define CR2_XHITH1 0x08 /* TX XON high threshold 1 */
  405. #define CR2_XHITH0 0x04 /* TX XON high threshold 0 */
  406. #define CR2_XLTH1 0x02 /* TX pause frame low threshold 1 */
  407. #define CR2_XLTH0 0x01 /* TX pause frame low threshold 0 */
  408. /*
  409. * Bits in the CR3 register
  410. */
  411. #define CR3_GSPRST 0x80
  412. #define CR3_FORSRST 0x40
  413. #define CR3_FPHYRST 0x20
  414. #define CR3_DIAG 0x10
  415. #define CR3_INTPCTL 0x04
  416. #define CR3_GINTMSK1 0x02
  417. #define CR3_GINTMSK0 0x01
  418. #define ISRCTL_UDPINT 0x8000
  419. #define ISRCTL_TSUPDIS 0x4000
  420. #define ISRCTL_RSUPDIS 0x2000
  421. #define ISRCTL_PMSK1 0x1000
  422. #define ISRCTL_PMSK0 0x0800
  423. #define ISRCTL_INTPD 0x0400
  424. #define ISRCTL_HCRLD 0x0200
  425. #define ISRCTL_SCRLD 0x0100
  426. /*
  427. * Bits in the ISR_CTL1 register
  428. */
  429. #define ISRCTL1_UDPINT 0x80
  430. #define ISRCTL1_TSUPDIS 0x40
  431. #define ISRCTL1_RSUPDIS 0x20
  432. #define ISRCTL1_PMSK1 0x10
  433. #define ISRCTL1_PMSK0 0x08
  434. #define ISRCTL1_INTPD 0x04
  435. #define ISRCTL1_HCRLD 0x02
  436. #define ISRCTL1_SCRLD 0x01
  437. /*
  438. * Bits in the TXE_SR register
  439. */
  440. #define TXESR_TFDBS 0x08
  441. #define TXESR_TDWBS 0x04
  442. #define TXESR_TDRBS 0x02
  443. #define TXESR_TDSTR 0x01
  444. /*
  445. * Bits in the RXE_SR register
  446. */
  447. #define RXESR_RFDBS 0x08
  448. #define RXESR_RDWBS 0x04
  449. #define RXESR_RDRBS 0x02
  450. #define RXESR_RDSTR 0x01
  451. /*
  452. * Bits in the ISR register
  453. */
  454. #define ISR_ISR3 0x80000000UL
  455. #define ISR_ISR2 0x40000000UL
  456. #define ISR_ISR1 0x20000000UL
  457. #define ISR_ISR0 0x10000000UL
  458. #define ISR_TXSTLI 0x02000000UL
  459. #define ISR_RXSTLI 0x01000000UL
  460. #define ISR_HFLD 0x00800000UL
  461. #define ISR_UDPI 0x00400000UL
  462. #define ISR_MIBFI 0x00200000UL
  463. #define ISR_SHDNI 0x00100000UL
  464. #define ISR_PHYI 0x00080000UL
  465. #define ISR_PWEI 0x00040000UL
  466. #define ISR_TMR1I 0x00020000UL
  467. #define ISR_TMR0I 0x00010000UL
  468. #define ISR_SRCI 0x00008000UL
  469. #define ISR_LSTPEI 0x00004000UL
  470. #define ISR_LSTEI 0x00002000UL
  471. #define ISR_OVFI 0x00001000UL
  472. #define ISR_FLONI 0x00000800UL
  473. #define ISR_RACEI 0x00000400UL
  474. #define ISR_TXWB1I 0x00000200UL
  475. #define ISR_TXWB0I 0x00000100UL
  476. #define ISR_PTX3I 0x00000080UL
  477. #define ISR_PTX2I 0x00000040UL
  478. #define ISR_PTX1I 0x00000020UL
  479. #define ISR_PTX0I 0x00000010UL
  480. #define ISR_PTXI 0x00000008UL
  481. #define ISR_PRXI 0x00000004UL
  482. #define ISR_PPTXI 0x00000002UL
  483. #define ISR_PPRXI 0x00000001UL
  484. /*
  485. * Bits in the IMR register
  486. */
  487. #define IMR_TXSTLM 0x02000000UL
  488. #define IMR_UDPIM 0x00400000UL
  489. #define IMR_MIBFIM 0x00200000UL
  490. #define IMR_SHDNIM 0x00100000UL
  491. #define IMR_PHYIM 0x00080000UL
  492. #define IMR_PWEIM 0x00040000UL
  493. #define IMR_TMR1IM 0x00020000UL
  494. #define IMR_TMR0IM 0x00010000UL
  495. #define IMR_SRCIM 0x00008000UL
  496. #define IMR_LSTPEIM 0x00004000UL
  497. #define IMR_LSTEIM 0x00002000UL
  498. #define IMR_OVFIM 0x00001000UL
  499. #define IMR_FLONIM 0x00000800UL
  500. #define IMR_RACEIM 0x00000400UL
  501. #define IMR_TXWB1IM 0x00000200UL
  502. #define IMR_TXWB0IM 0x00000100UL
  503. #define IMR_PTX3IM 0x00000080UL
  504. #define IMR_PTX2IM 0x00000040UL
  505. #define IMR_PTX1IM 0x00000020UL
  506. #define IMR_PTX0IM 0x00000010UL
  507. #define IMR_PTXIM 0x00000008UL
  508. #define IMR_PRXIM 0x00000004UL
  509. #define IMR_PPTXIM 0x00000002UL
  510. #define IMR_PPRXIM 0x00000001UL
  511. /* 0x0013FB0FUL = initial value of IMR */
  512. #define INT_MASK_DEF (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\
  513. IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\
  514. IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
  515. IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM)
  516. /*
  517. * Bits in the TDCSR0/1, RDCSR0 register
  518. */
  519. #define TRDCSR_DEAD 0x0008
  520. #define TRDCSR_WAK 0x0004
  521. #define TRDCSR_ACT 0x0002
  522. #define TRDCSR_RUN 0x0001
  523. /*
  524. * Bits in the CAMADDR register
  525. */
  526. #define CAMADDR_CAMEN 0x80
  527. #define CAMADDR_VCAMSL 0x40
  528. /*
  529. * Bits in the CAMCR register
  530. */
  531. #define CAMCR_PS1 0x80
  532. #define CAMCR_PS0 0x40
  533. #define CAMCR_AITRPKT 0x20
  534. #define CAMCR_AITR16 0x10
  535. #define CAMCR_CAMRD 0x08
  536. #define CAMCR_CAMWR 0x04
  537. #define CAMCR_PS_CAM_MASK 0x40
  538. #define CAMCR_PS_CAM_DATA 0x80
  539. #define CAMCR_PS_MAR 0x00
  540. /*
  541. * Bits in the MIICFG register
  542. */
  543. #define MIICFG_MPO1 0x80
  544. #define MIICFG_MPO0 0x40
  545. #define MIICFG_MFDC 0x20
  546. /*
  547. * Bits in the MIISR register
  548. */
  549. #define MIISR_MIDLE 0x80
  550. /*
  551. * Bits in the PHYSR0 register
  552. */
  553. #define PHYSR0_PHYRST 0x80
  554. #define PHYSR0_LINKGD 0x40
  555. #define PHYSR0_FDPX 0x10
  556. #define PHYSR0_SPDG 0x08
  557. #define PHYSR0_SPD10 0x04
  558. #define PHYSR0_RXFLC 0x02
  559. #define PHYSR0_TXFLC 0x01
  560. /*
  561. * Bits in the PHYSR1 register
  562. */
  563. #define PHYSR1_PHYTBI 0x01
  564. /*
  565. * Bits in the MIICR register
  566. */
  567. #define MIICR_MAUTO 0x80
  568. #define MIICR_RCMD 0x40
  569. #define MIICR_WCMD 0x20
  570. #define MIICR_MDPM 0x10
  571. #define MIICR_MOUT 0x08
  572. #define MIICR_MDO 0x04
  573. #define MIICR_MDI 0x02
  574. #define MIICR_MDC 0x01
  575. /*
  576. * Bits in the MIIADR register
  577. */
  578. #define MIIADR_SWMPL 0x80
  579. /*
  580. * Bits in the CFGA register
  581. */
  582. #define CFGA_PMHCTG 0x08
  583. #define CFGA_GPIO1PD 0x04
  584. #define CFGA_ABSHDN 0x02
  585. #define CFGA_PACPI 0x01
  586. /*
  587. * Bits in the CFGB register
  588. */
  589. #define CFGB_GTCKOPT 0x80
  590. #define CFGB_MIIOPT 0x40
  591. #define CFGB_CRSEOPT 0x20
  592. #define CFGB_OFSET 0x10
  593. #define CFGB_CRANDOM 0x08
  594. #define CFGB_CAP 0x04
  595. #define CFGB_MBA 0x02
  596. #define CFGB_BAKOPT 0x01
  597. /*
  598. * Bits in the CFGC register
  599. */
  600. #define CFGC_EELOAD 0x80
  601. #define CFGC_BROPT 0x40
  602. #define CFGC_DLYEN 0x20
  603. #define CFGC_DTSEL 0x10
  604. #define CFGC_BTSEL 0x08
  605. #define CFGC_BPS2 0x04 /* bootrom select[2] */
  606. #define CFGC_BPS1 0x02 /* bootrom select[1] */
  607. #define CFGC_BPS0 0x01 /* bootrom select[0] */
  608. /*
  609. * Bits in the CFGD register
  610. */
  611. #define CFGD_IODIS 0x80
  612. #define CFGD_MSLVDACEN 0x40
  613. #define CFGD_CFGDACEN 0x20
  614. #define CFGD_PCI64EN 0x10
  615. #define CFGD_HTMRL4 0x08
  616. /*
  617. * Bits in the DCFG1 register
  618. */
  619. #define DCFG_XMWI 0x8000
  620. #define DCFG_XMRM 0x4000
  621. #define DCFG_XMRL 0x2000
  622. #define DCFG_PERDIS 0x1000
  623. #define DCFG_MRWAIT 0x0400
  624. #define DCFG_MWWAIT 0x0200
  625. #define DCFG_LATMEN 0x0100
  626. /*
  627. * Bits in the MCFG0 register
  628. */
  629. #define MCFG_RXARB 0x0080
  630. #define MCFG_RFT1 0x0020
  631. #define MCFG_RFT0 0x0010
  632. #define MCFG_LOWTHOPT 0x0008
  633. #define MCFG_PQEN 0x0004
  634. #define MCFG_RTGOPT 0x0002
  635. #define MCFG_VIDFR 0x0001
  636. /*
  637. * Bits in the MCFG1 register
  638. */
  639. #define MCFG_TXARB 0x8000
  640. #define MCFG_TXQBK1 0x0800
  641. #define MCFG_TXQBK0 0x0400
  642. #define MCFG_TXQNOBK 0x0200
  643. #define MCFG_SNAPOPT 0x0100
  644. /*
  645. * Bits in the PMCC register
  646. */
  647. #define PMCC_DSI 0x80
  648. #define PMCC_D2_DIS 0x40
  649. #define PMCC_D1_DIS 0x20
  650. #define PMCC_D3C_EN 0x10
  651. #define PMCC_D3H_EN 0x08
  652. #define PMCC_D2_EN 0x04
  653. #define PMCC_D1_EN 0x02
  654. #define PMCC_D0_EN 0x01
  655. /*
  656. * Bits in STICKHW
  657. */
  658. #define STICKHW_SWPTAG 0x10
  659. #define STICKHW_WOLSR 0x08
  660. #define STICKHW_WOLEN 0x04
  661. #define STICKHW_DS1 0x02 /* R/W by software/cfg cycle */
  662. #define STICKHW_DS0 0x01 /* suspend well DS write port */
  663. /*
  664. * Bits in the MIBCR register
  665. */
  666. #define MIBCR_MIBISTOK 0x80
  667. #define MIBCR_MIBISTGO 0x40
  668. #define MIBCR_MIBINC 0x20
  669. #define MIBCR_MIBHI 0x10
  670. #define MIBCR_MIBFRZ 0x08
  671. #define MIBCR_MIBFLSH 0x04
  672. #define MIBCR_MPTRINI 0x02
  673. #define MIBCR_MIBCLR 0x01
  674. /*
  675. * Bits in the EERSV register
  676. */
  677. #define EERSV_BOOT_RPL ((u8) 0x01) /* Boot method selection for VT6110 */
  678. #define EERSV_BOOT_MASK ((u8) 0x06)
  679. #define EERSV_BOOT_INT19 ((u8) 0x00)
  680. #define EERSV_BOOT_INT18 ((u8) 0x02)
  681. #define EERSV_BOOT_LOCAL ((u8) 0x04)
  682. #define EERSV_BOOT_BEV ((u8) 0x06)
  683. /*
  684. * Bits in BPCMD
  685. */
  686. #define BPCMD_BPDNE 0x80
  687. #define BPCMD_EBPWR 0x02
  688. #define BPCMD_EBPRD 0x01
  689. /*
  690. * Bits in the EECSR register
  691. */
  692. #define EECSR_EMBP 0x40 /* eeprom embedded programming */
  693. #define EECSR_RELOAD 0x20 /* eeprom content reload */
  694. #define EECSR_DPM 0x10 /* eeprom direct programming */
  695. #define EECSR_ECS 0x08 /* eeprom CS pin */
  696. #define EECSR_ECK 0x04 /* eeprom CK pin */
  697. #define EECSR_EDI 0x02 /* eeprom DI pin */
  698. #define EECSR_EDO 0x01 /* eeprom DO pin */
  699. /*
  700. * Bits in the EMBCMD register
  701. */
  702. #define EMBCMD_EDONE 0x80
  703. #define EMBCMD_EWDIS 0x08
  704. #define EMBCMD_EWEN 0x04
  705. #define EMBCMD_EWR 0x02
  706. #define EMBCMD_ERD 0x01
  707. /*
  708. * Bits in TESTCFG register
  709. */
  710. #define TESTCFG_HBDIS 0x80
  711. /*
  712. * Bits in CHIPGCR register
  713. */
  714. #define CHIPGCR_FCGMII 0x80 /* force GMII (else MII only) */
  715. #define CHIPGCR_FCFDX 0x40 /* force full duplex */
  716. #define CHIPGCR_FCRESV 0x20
  717. #define CHIPGCR_FCMODE 0x10 /* enable MAC forced mode */
  718. #define CHIPGCR_LPSOPT 0x08
  719. #define CHIPGCR_TM1US 0x04
  720. #define CHIPGCR_TM0US 0x02
  721. #define CHIPGCR_PHYINTEN 0x01
  722. /*
  723. * Bits in WOLCR0
  724. */
  725. #define WOLCR_MSWOLEN7 0x0080 /* enable pattern match filtering */
  726. #define WOLCR_MSWOLEN6 0x0040
  727. #define WOLCR_MSWOLEN5 0x0020
  728. #define WOLCR_MSWOLEN4 0x0010
  729. #define WOLCR_MSWOLEN3 0x0008
  730. #define WOLCR_MSWOLEN2 0x0004
  731. #define WOLCR_MSWOLEN1 0x0002
  732. #define WOLCR_MSWOLEN0 0x0001
  733. #define WOLCR_ARP_EN 0x0001
  734. /*
  735. * Bits in WOLCR1
  736. */
  737. #define WOLCR_LINKOFF_EN 0x0800 /* link off detected enable */
  738. #define WOLCR_LINKON_EN 0x0400 /* link on detected enable */
  739. #define WOLCR_MAGIC_EN 0x0200 /* magic packet filter enable */
  740. #define WOLCR_UNICAST_EN 0x0100 /* unicast filter enable */
  741. /*
  742. * Bits in PWCFG
  743. */
  744. #define PWCFG_PHYPWOPT 0x80 /* internal MII I/F timing */
  745. #define PWCFG_PCISTICK 0x40 /* PCI sticky R/W enable */
  746. #define PWCFG_WOLTYPE 0x20 /* pulse(1) or button (0) */
  747. #define PWCFG_LEGCY_WOL 0x10
  748. #define PWCFG_PMCSR_PME_SR 0x08
  749. #define PWCFG_PMCSR_PME_EN 0x04 /* control by PCISTICK */
  750. #define PWCFG_LEGACY_WOLSR 0x02 /* Legacy WOL_SR shadow */
  751. #define PWCFG_LEGACY_WOLEN 0x01 /* Legacy WOL_EN shadow */
  752. /*
  753. * Bits in WOLCFG
  754. */
  755. #define WOLCFG_PMEOVR 0x80 /* for legacy use, force PMEEN always */
  756. #define WOLCFG_SAM 0x20 /* accept multicast case reset, default=0 */
  757. #define WOLCFG_SAB 0x10 /* accept broadcast case reset, default=0 */
  758. #define WOLCFG_SMIIACC 0x08 /* ?? */
  759. #define WOLCFG_SGENWH 0x02
  760. #define WOLCFG_PHYINTEN 0x01 /* 0:PHYINT trigger enable, 1:use internal MII
  761. to report status change */
  762. /*
  763. * Bits in WOLSR1
  764. */
  765. #define WOLSR_LINKOFF_INT 0x0800
  766. #define WOLSR_LINKON_INT 0x0400
  767. #define WOLSR_MAGIC_INT 0x0200
  768. #define WOLSR_UNICAST_INT 0x0100
  769. /*
  770. * Ethernet address filter type
  771. */
  772. #define PKT_TYPE_NONE 0x0000 /* Turn off receiver */
  773. #define PKT_TYPE_DIRECTED 0x0001 /* obselete, directed address is always accepted */
  774. #define PKT_TYPE_MULTICAST 0x0002
  775. #define PKT_TYPE_ALL_MULTICAST 0x0004
  776. #define PKT_TYPE_BROADCAST 0x0008
  777. #define PKT_TYPE_PROMISCUOUS 0x0020
  778. #define PKT_TYPE_LONG 0x2000 /* NOTE.... the definition of LONG is >2048 bytes in our chip */
  779. #define PKT_TYPE_RUNT 0x4000
  780. #define PKT_TYPE_ERROR 0x8000 /* Accept error packets, e.g. CRC error */
  781. /*
  782. * Loopback mode
  783. */
  784. #define MAC_LB_NONE 0x00
  785. #define MAC_LB_INTERNAL 0x01
  786. #define MAC_LB_EXTERNAL 0x02
  787. /*
  788. * Enabled mask value of irq
  789. */
  790. #if defined(_SIM)
  791. #define IMR_MASK_VALUE 0x0033FF0FUL /* initial value of IMR
  792. set IMR0 to 0x0F according to spec */
  793. #else
  794. #define IMR_MASK_VALUE 0x0013FB0FUL /* initial value of IMR
  795. ignore MIBFI,RACEI to
  796. reduce intr. frequency
  797. NOTE.... do not enable NoBuf int mask at driver driver
  798. when (1) NoBuf -> RxThreshold = SF
  799. (2) OK -> RxThreshold = original value
  800. */
  801. #endif
  802. /*
  803. * Revision id
  804. */
  805. #define REV_ID_VT3119_A0 0x00
  806. #define REV_ID_VT3119_A1 0x01
  807. #define REV_ID_VT3216_A0 0x10
  808. /*
  809. * Max time out delay time
  810. */
  811. #define W_MAX_TIMEOUT 0x0FFFU
  812. /*
  813. * MAC registers as a structure. Cannot be directly accessed this
  814. * way but generates offsets for readl/writel() calls
  815. */
  816. struct mac_regs {
  817. volatile u8 PAR[6]; /* 0x00 */
  818. volatile u8 RCR;
  819. volatile u8 TCR;
  820. volatile __le32 CR0Set; /* 0x08 */
  821. volatile __le32 CR0Clr; /* 0x0C */
  822. volatile u8 MARCAM[8]; /* 0x10 */
  823. volatile __le32 DecBaseHi; /* 0x18 */
  824. volatile __le16 DbfBaseHi; /* 0x1C */
  825. volatile __le16 reserved_1E;
  826. volatile __le16 ISRCTL; /* 0x20 */
  827. volatile u8 TXESR;
  828. volatile u8 RXESR;
  829. volatile __le32 ISR; /* 0x24 */
  830. volatile __le32 IMR;
  831. volatile __le32 TDStatusPort; /* 0x2C */
  832. volatile __le16 TDCSRSet; /* 0x30 */
  833. volatile u8 RDCSRSet;
  834. volatile u8 reserved_33;
  835. volatile __le16 TDCSRClr;
  836. volatile u8 RDCSRClr;
  837. volatile u8 reserved_37;
  838. volatile __le32 RDBaseLo; /* 0x38 */
  839. volatile __le16 RDIdx; /* 0x3C */
  840. volatile u8 TQETMR; /* 0x3E, VT3216 and above only */
  841. volatile u8 RQETMR; /* 0x3F, VT3216 and above only */
  842. volatile __le32 TDBaseLo[4]; /* 0x40 */
  843. volatile __le16 RDCSize; /* 0x50 */
  844. volatile __le16 TDCSize; /* 0x52 */
  845. volatile __le16 TDIdx[4]; /* 0x54 */
  846. volatile __le16 tx_pause_timer; /* 0x5C */
  847. volatile __le16 RBRDU; /* 0x5E */
  848. volatile __le32 FIFOTest0; /* 0x60 */
  849. volatile __le32 FIFOTest1; /* 0x64 */
  850. volatile u8 CAMADDR; /* 0x68 */
  851. volatile u8 CAMCR; /* 0x69 */
  852. volatile u8 GFTEST; /* 0x6A */
  853. volatile u8 FTSTCMD; /* 0x6B */
  854. volatile u8 MIICFG; /* 0x6C */
  855. volatile u8 MIISR;
  856. volatile u8 PHYSR0;
  857. volatile u8 PHYSR1;
  858. volatile u8 MIICR;
  859. volatile u8 MIIADR;
  860. volatile __le16 MIIDATA;
  861. volatile __le16 SoftTimer0; /* 0x74 */
  862. volatile __le16 SoftTimer1;
  863. volatile u8 CFGA; /* 0x78 */
  864. volatile u8 CFGB;
  865. volatile u8 CFGC;
  866. volatile u8 CFGD;
  867. volatile __le16 DCFG; /* 0x7C */
  868. volatile __le16 MCFG;
  869. volatile u8 TBIST; /* 0x80 */
  870. volatile u8 RBIST;
  871. volatile u8 PMCPORT;
  872. volatile u8 STICKHW;
  873. volatile u8 MIBCR; /* 0x84 */
  874. volatile u8 reserved_85;
  875. volatile u8 rev_id;
  876. volatile u8 PORSTS;
  877. volatile __le32 MIBData; /* 0x88 */
  878. volatile __le16 EEWrData;
  879. volatile u8 reserved_8E;
  880. volatile u8 BPMDWr;
  881. volatile u8 BPCMD;
  882. volatile u8 BPMDRd;
  883. volatile u8 EECHKSUM; /* 0x92 */
  884. volatile u8 EECSR;
  885. volatile __le16 EERdData; /* 0x94 */
  886. volatile u8 EADDR;
  887. volatile u8 EMBCMD;
  888. volatile u8 JMPSR0; /* 0x98 */
  889. volatile u8 JMPSR1;
  890. volatile u8 JMPSR2;
  891. volatile u8 JMPSR3;
  892. volatile u8 CHIPGSR; /* 0x9C */
  893. volatile u8 TESTCFG;
  894. volatile u8 DEBUG;
  895. volatile u8 CHIPGCR;
  896. volatile __le16 WOLCRSet; /* 0xA0 */
  897. volatile u8 PWCFGSet;
  898. volatile u8 WOLCFGSet;
  899. volatile __le16 WOLCRClr; /* 0xA4 */
  900. volatile u8 PWCFGCLR;
  901. volatile u8 WOLCFGClr;
  902. volatile __le16 WOLSRSet; /* 0xA8 */
  903. volatile __le16 reserved_AA;
  904. volatile __le16 WOLSRClr; /* 0xAC */
  905. volatile __le16 reserved_AE;
  906. volatile __le16 PatternCRC[8]; /* 0xB0 */
  907. volatile __le32 ByteMask[4][4]; /* 0xC0 */
  908. };
  909. enum hw_mib {
  910. HW_MIB_ifRxAllPkts = 0,
  911. HW_MIB_ifRxOkPkts,
  912. HW_MIB_ifTxOkPkts,
  913. HW_MIB_ifRxErrorPkts,
  914. HW_MIB_ifRxRuntOkPkt,
  915. HW_MIB_ifRxRuntErrPkt,
  916. HW_MIB_ifRx64Pkts,
  917. HW_MIB_ifTx64Pkts,
  918. HW_MIB_ifRx65To127Pkts,
  919. HW_MIB_ifTx65To127Pkts,
  920. HW_MIB_ifRx128To255Pkts,
  921. HW_MIB_ifTx128To255Pkts,
  922. HW_MIB_ifRx256To511Pkts,
  923. HW_MIB_ifTx256To511Pkts,
  924. HW_MIB_ifRx512To1023Pkts,
  925. HW_MIB_ifTx512To1023Pkts,
  926. HW_MIB_ifRx1024To1518Pkts,
  927. HW_MIB_ifTx1024To1518Pkts,
  928. HW_MIB_ifTxEtherCollisions,
  929. HW_MIB_ifRxPktCRCE,
  930. HW_MIB_ifRxJumboPkts,
  931. HW_MIB_ifTxJumboPkts,
  932. HW_MIB_ifRxMacControlFrames,
  933. HW_MIB_ifTxMacControlFrames,
  934. HW_MIB_ifRxPktFAE,
  935. HW_MIB_ifRxLongOkPkt,
  936. HW_MIB_ifRxLongPktErrPkt,
  937. HW_MIB_ifTXSQEErrors,
  938. HW_MIB_ifRxNobuf,
  939. HW_MIB_ifRxSymbolErrors,
  940. HW_MIB_ifInRangeLengthErrors,
  941. HW_MIB_ifLateCollisions,
  942. HW_MIB_SIZE
  943. };
  944. enum chip_type {
  945. CHIP_TYPE_VT6110 = 1,
  946. };
  947. struct velocity_info_tbl {
  948. enum chip_type chip_id;
  949. const char *name;
  950. int txqueue;
  951. u32 flags;
  952. };
  953. #define mac_hw_mibs_init(regs) {\
  954. BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
  955. BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
  956. do {}\
  957. while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
  958. BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
  959. }
  960. #define mac_read_isr(regs) readl(&((regs)->ISR))
  961. #define mac_write_isr(regs, x) writel((x),&((regs)->ISR))
  962. #define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR))
  963. #define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR));
  964. #define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr))
  965. #define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set))
  966. #define mac_set_dma_length(regs, n) {\
  967. BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
  968. }
  969. #define mac_set_rx_thresh(regs, n) {\
  970. BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
  971. }
  972. #define mac_rx_queue_run(regs) {\
  973. writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
  974. }
  975. #define mac_rx_queue_wake(regs) {\
  976. writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
  977. }
  978. #define mac_tx_queue_run(regs, n) {\
  979. writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
  980. }
  981. #define mac_tx_queue_wake(regs, n) {\
  982. writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
  983. }
  984. static inline void mac_eeprom_reload(struct mac_regs __iomem * regs) {
  985. int i=0;
  986. BYTE_REG_BITS_ON(EECSR_RELOAD,&(regs->EECSR));
  987. do {
  988. udelay(10);
  989. if (i++>0x1000)
  990. break;
  991. } while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&(regs->EECSR)));
  992. }
  993. /*
  994. * Header for WOL definitions. Used to compute hashes
  995. */
  996. typedef u8 MCAM_ADDR[ETH_ALEN];
  997. struct arp_packet {
  998. u8 dest_mac[ETH_ALEN];
  999. u8 src_mac[ETH_ALEN];
  1000. __be16 type;
  1001. __be16 ar_hrd;
  1002. __be16 ar_pro;
  1003. u8 ar_hln;
  1004. u8 ar_pln;
  1005. __be16 ar_op;
  1006. u8 ar_sha[ETH_ALEN];
  1007. u8 ar_sip[4];
  1008. u8 ar_tha[ETH_ALEN];
  1009. u8 ar_tip[4];
  1010. } __packed;
  1011. struct _magic_packet {
  1012. u8 dest_mac[6];
  1013. u8 src_mac[6];
  1014. __be16 type;
  1015. u8 MAC[16][6];
  1016. u8 password[6];
  1017. } __packed;
  1018. /*
  1019. * Store for chip context when saving and restoring status. Not
  1020. * all fields are saved/restored currently.
  1021. */
  1022. struct velocity_context {
  1023. u8 mac_reg[256];
  1024. MCAM_ADDR cam_addr[MCAM_SIZE];
  1025. u16 vcam[VCAM_SIZE];
  1026. u32 cammask[2];
  1027. u32 patcrc[2];
  1028. u32 pattern[8];
  1029. };
  1030. /*
  1031. * Registers in the MII (offset unit is WORD)
  1032. */
  1033. // Marvell 88E1000/88E1000S
  1034. #define MII_REG_PSCR 0x10 // PHY specific control register
  1035. //
  1036. // Bits in the Silicon revision register
  1037. //
  1038. #define TCSR_ECHODIS 0x2000 //
  1039. #define AUXCR_MDPPS 0x0004 //
  1040. // Bits in the PLED register
  1041. #define PLED_LALBE 0x0004 //
  1042. // Marvell 88E1000/88E1000S Bits in the PHY specific control register (10h)
  1043. #define PSCR_ACRSTX 0x0800 // Assert CRS on Transmit
  1044. #define PHYID_CICADA_CS8201 0x000FC410UL
  1045. #define PHYID_VT3216_32BIT 0x000FC610UL
  1046. #define PHYID_VT3216_64BIT 0x000FC600UL
  1047. #define PHYID_MARVELL_1000 0x01410C50UL
  1048. #define PHYID_MARVELL_1000S 0x01410C40UL
  1049. #define PHYID_REV_ID_MASK 0x0000000FUL
  1050. #define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK)
  1051. #define MII_REG_BITS_ON(x,i,p) do {\
  1052. u16 w;\
  1053. velocity_mii_read((p),(i),&(w));\
  1054. (w)|=(x);\
  1055. velocity_mii_write((p),(i),(w));\
  1056. } while (0)
  1057. #define MII_REG_BITS_OFF(x,i,p) do {\
  1058. u16 w;\
  1059. velocity_mii_read((p),(i),&(w));\
  1060. (w)&=(~(x));\
  1061. velocity_mii_write((p),(i),(w));\
  1062. } while (0)
  1063. #define MII_REG_BITS_IS_ON(x,i,p) ({\
  1064. u16 w;\
  1065. velocity_mii_read((p),(i),&(w));\
  1066. ((int) ((w) & (x)));})
  1067. #define MII_GET_PHY_ID(p) ({\
  1068. u32 id;\
  1069. velocity_mii_read((p),MII_PHYSID2,(u16 *) &id);\
  1070. velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\
  1071. (id);})
  1072. /*
  1073. * Inline debug routine
  1074. */
  1075. enum velocity_msg_level {
  1076. MSG_LEVEL_ERR = 0, //Errors that will cause abnormal operation.
  1077. MSG_LEVEL_NOTICE = 1, //Some errors need users to be notified.
  1078. MSG_LEVEL_INFO = 2, //Normal message.
  1079. MSG_LEVEL_VERBOSE = 3, //Will report all trival errors.
  1080. MSG_LEVEL_DEBUG = 4 //Only for debug purpose.
  1081. };
  1082. #ifdef VELOCITY_DEBUG
  1083. #define ASSERT(x) { \
  1084. if (!(x)) { \
  1085. printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\
  1086. __func__, __LINE__);\
  1087. BUG(); \
  1088. }\
  1089. }
  1090. #define VELOCITY_DBG(p,args...) printk(p, ##args)
  1091. #else
  1092. #define ASSERT(x)
  1093. #define VELOCITY_DBG(x)
  1094. #endif
  1095. #define VELOCITY_PRT(l, p, args...) do {if (l<=msglevel) printk( p ,##args);} while (0)
  1096. #define VELOCITY_PRT_CAMMASK(p,t) {\
  1097. int i;\
  1098. if ((t)==VELOCITY_MULTICAST_CAM) {\
  1099. for (i=0;i<(MCAM_SIZE/8);i++)\
  1100. printk("%02X",(p)->mCAMmask[i]);\
  1101. }\
  1102. else {\
  1103. for (i=0;i<(VCAM_SIZE/8);i++)\
  1104. printk("%02X",(p)->vCAMmask[i]);\
  1105. }\
  1106. printk("\n");\
  1107. }
  1108. #define VELOCITY_WOL_MAGIC 0x00000000UL
  1109. #define VELOCITY_WOL_PHY 0x00000001UL
  1110. #define VELOCITY_WOL_ARP 0x00000002UL
  1111. #define VELOCITY_WOL_UCAST 0x00000004UL
  1112. #define VELOCITY_WOL_BCAST 0x00000010UL
  1113. #define VELOCITY_WOL_MCAST 0x00000020UL
  1114. #define VELOCITY_WOL_MAGIC_SEC 0x00000040UL
  1115. /*
  1116. * Flags for options
  1117. */
  1118. #define VELOCITY_FLAGS_TAGGING 0x00000001UL
  1119. #define VELOCITY_FLAGS_RX_CSUM 0x00000004UL
  1120. #define VELOCITY_FLAGS_IP_ALIGN 0x00000008UL
  1121. #define VELOCITY_FLAGS_VAL_PKT_LEN 0x00000010UL
  1122. #define VELOCITY_FLAGS_FLOW_CTRL 0x01000000UL
  1123. /*
  1124. * Flags for driver status
  1125. */
  1126. #define VELOCITY_FLAGS_OPENED 0x00010000UL
  1127. #define VELOCITY_FLAGS_VMNS_CONNECTED 0x00020000UL
  1128. #define VELOCITY_FLAGS_VMNS_COMMITTED 0x00040000UL
  1129. #define VELOCITY_FLAGS_WOL_ENABLED 0x00080000UL
  1130. /*
  1131. * Flags for MII status
  1132. */
  1133. #define VELOCITY_LINK_FAIL 0x00000001UL
  1134. #define VELOCITY_SPEED_10 0x00000002UL
  1135. #define VELOCITY_SPEED_100 0x00000004UL
  1136. #define VELOCITY_SPEED_1000 0x00000008UL
  1137. #define VELOCITY_DUPLEX_FULL 0x00000010UL
  1138. #define VELOCITY_AUTONEG_ENABLE 0x00000020UL
  1139. #define VELOCITY_FORCED_BY_EEPROM 0x00000040UL
  1140. /*
  1141. * For velocity_set_media_duplex
  1142. */
  1143. #define VELOCITY_LINK_CHANGE 0x00000001UL
  1144. enum speed_opt {
  1145. SPD_DPX_AUTO = 0,
  1146. SPD_DPX_100_HALF = 1,
  1147. SPD_DPX_100_FULL = 2,
  1148. SPD_DPX_10_HALF = 3,
  1149. SPD_DPX_10_FULL = 4,
  1150. SPD_DPX_1000_FULL = 5
  1151. };
  1152. enum velocity_init_type {
  1153. VELOCITY_INIT_COLD = 0,
  1154. VELOCITY_INIT_RESET,
  1155. VELOCITY_INIT_WOL
  1156. };
  1157. enum velocity_flow_cntl_type {
  1158. FLOW_CNTL_DEFAULT = 1,
  1159. FLOW_CNTL_TX,
  1160. FLOW_CNTL_RX,
  1161. FLOW_CNTL_TX_RX,
  1162. FLOW_CNTL_DISABLE,
  1163. };
  1164. struct velocity_opt {
  1165. int numrx; /* Number of RX descriptors */
  1166. int numtx; /* Number of TX descriptors */
  1167. enum speed_opt spd_dpx; /* Media link mode */
  1168. int DMA_length; /* DMA length */
  1169. int rx_thresh; /* RX_THRESH */
  1170. int flow_cntl;
  1171. int wol_opts; /* Wake on lan options */
  1172. int td_int_count;
  1173. int int_works;
  1174. int rx_bandwidth_hi;
  1175. int rx_bandwidth_lo;
  1176. int rx_bandwidth_en;
  1177. int rxqueue_timer;
  1178. int txqueue_timer;
  1179. int tx_intsup;
  1180. int rx_intsup;
  1181. u32 flags;
  1182. };
  1183. #define AVAIL_TD(p,q) ((p)->options.numtx-((p)->tx.used[(q)]))
  1184. #define GET_RD_BY_IDX(vptr, idx) (vptr->rd_ring[idx])
  1185. struct velocity_info {
  1186. struct pci_dev *pdev;
  1187. struct net_device *dev;
  1188. struct vlan_group *vlgrp;
  1189. u8 ip_addr[4];
  1190. enum chip_type chip_id;
  1191. struct mac_regs __iomem * mac_regs;
  1192. unsigned long memaddr;
  1193. unsigned long ioaddr;
  1194. struct tx_info {
  1195. int numq;
  1196. /* FIXME: the locality of the data seems rather poor. */
  1197. int used[TX_QUEUE_NO];
  1198. int curr[TX_QUEUE_NO];
  1199. int tail[TX_QUEUE_NO];
  1200. struct tx_desc *rings[TX_QUEUE_NO];
  1201. struct velocity_td_info *infos[TX_QUEUE_NO];
  1202. dma_addr_t pool_dma[TX_QUEUE_NO];
  1203. } tx;
  1204. struct rx_info {
  1205. int buf_sz;
  1206. int dirty;
  1207. int curr;
  1208. u32 filled;
  1209. struct rx_desc *ring;
  1210. struct velocity_rd_info *info; /* It's an array */
  1211. dma_addr_t pool_dma;
  1212. } rx;
  1213. u32 mib_counter[MAX_HW_MIB_COUNTER];
  1214. struct velocity_opt options;
  1215. u32 int_mask;
  1216. u32 flags;
  1217. u32 mii_status;
  1218. u32 phy_id;
  1219. int multicast_limit;
  1220. u8 vCAMmask[(VCAM_SIZE / 8)];
  1221. u8 mCAMmask[(MCAM_SIZE / 8)];
  1222. spinlock_t lock;
  1223. int wol_opts;
  1224. u8 wol_passwd[6];
  1225. struct velocity_context context;
  1226. u32 ticks;
  1227. u8 rev_id;
  1228. struct napi_struct napi;
  1229. };
  1230. /**
  1231. * velocity_get_ip - find an IP address for the device
  1232. * @vptr: Velocity to query
  1233. *
  1234. * Dig out an IP address for this interface so that we can
  1235. * configure wakeup with WOL for ARP. If there are multiple IP
  1236. * addresses on this chain then we use the first - multi-IP WOL is not
  1237. * supported.
  1238. *
  1239. */
  1240. static inline int velocity_get_ip(struct velocity_info *vptr)
  1241. {
  1242. struct in_device *in_dev;
  1243. struct in_ifaddr *ifa;
  1244. int res = -ENOENT;
  1245. rcu_read_lock();
  1246. in_dev = __in_dev_get_rcu(vptr->dev);
  1247. if (in_dev != NULL) {
  1248. ifa = (struct in_ifaddr *) in_dev->ifa_list;
  1249. if (ifa != NULL) {
  1250. memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
  1251. res = 0;
  1252. }
  1253. }
  1254. rcu_read_unlock();
  1255. return res;
  1256. }
  1257. /**
  1258. * velocity_update_hw_mibs - fetch MIB counters from chip
  1259. * @vptr: velocity to update
  1260. *
  1261. * The velocity hardware keeps certain counters in the hardware
  1262. * side. We need to read these when the user asks for statistics
  1263. * or when they overflow (causing an interrupt). The read of the
  1264. * statistic clears it, so we keep running master counters in user
  1265. * space.
  1266. */
  1267. static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
  1268. {
  1269. u32 tmp;
  1270. int i;
  1271. BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
  1272. while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
  1273. BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
  1274. for (i = 0; i < HW_MIB_SIZE; i++) {
  1275. tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
  1276. vptr->mib_counter[i] += tmp;
  1277. }
  1278. }
  1279. /**
  1280. * init_flow_control_register - set up flow control
  1281. * @vptr: velocity to configure
  1282. *
  1283. * Configure the flow control registers for this velocity device.
  1284. */
  1285. static inline void init_flow_control_register(struct velocity_info *vptr)
  1286. {
  1287. struct mac_regs __iomem * regs = vptr->mac_regs;
  1288. /* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1}
  1289. depend on RD=64, and Turn on XNOEN in FlowCR1 */
  1290. writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), &regs->CR0Set);
  1291. writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), &regs->CR0Clr);
  1292. /* Set TxPauseTimer to 0xFFFF */
  1293. writew(0xFFFF, &regs->tx_pause_timer);
  1294. /* Initialize RBRDU to Rx buffer count. */
  1295. writew(vptr->options.numrx, &regs->RBRDU);
  1296. }
  1297. #endif