via-velocity.h 40 KB

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