sungem.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. /* $Id: sungem.h,v 1.10.2.4 2002/03/11 08:54:48 davem Exp $
  2. * sungem.h: Definitions for Sun GEM ethernet driver.
  3. *
  4. * Copyright (C) 2000 David S. Miller (davem@redhat.com)
  5. */
  6. #ifndef _SUNGEM_H
  7. #define _SUNGEM_H
  8. /* Global Registers */
  9. #define GREG_SEBSTATE 0x0000UL /* SEB State Register */
  10. #define GREG_CFG 0x0004UL /* Configuration Register */
  11. #define GREG_STAT 0x000CUL /* Status Register */
  12. #define GREG_IMASK 0x0010UL /* Interrupt Mask Register */
  13. #define GREG_IACK 0x0014UL /* Interrupt ACK Register */
  14. #define GREG_STAT2 0x001CUL /* Alias of GREG_STAT */
  15. #define GREG_PCIESTAT 0x1000UL /* PCI Error Status Register */
  16. #define GREG_PCIEMASK 0x1004UL /* PCI Error Mask Register */
  17. #define GREG_BIFCFG 0x1008UL /* BIF Configuration Register */
  18. #define GREG_BIFDIAG 0x100CUL /* BIF Diagnostics Register */
  19. #define GREG_SWRST 0x1010UL /* Software Reset Register */
  20. /* Global SEB State Register */
  21. #define GREG_SEBSTATE_ARB 0x00000003 /* State of Arbiter */
  22. #define GREG_SEBSTATE_RXWON 0x00000004 /* RX won internal arbitration */
  23. /* Global Configuration Register */
  24. #define GREG_CFG_IBURST 0x00000001 /* Infinite Burst */
  25. #define GREG_CFG_TXDMALIM 0x0000003e /* TX DMA grant limit */
  26. #define GREG_CFG_RXDMALIM 0x000007c0 /* RX DMA grant limit */
  27. #define GREG_CFG_RONPAULBIT 0x00000800 /* Use mem read multiple for PCI read
  28. * after infinite burst (Apple) */
  29. #define GREG_CFG_ENBUG2FIX 0x00001000 /* Fix Rx hang after overflow */
  30. /* Global Interrupt Status Register.
  31. *
  32. * Reading this register automatically clears bits 0 through 6.
  33. * This auto-clearing does not occur when the alias at GREG_STAT2
  34. * is read instead. The rest of the interrupt bits only clear when
  35. * the secondary interrupt status register corresponding to that
  36. * bit is read (ie. if GREG_STAT_PCS is set, it will be cleared by
  37. * reading PCS_ISTAT).
  38. */
  39. #define GREG_STAT_TXINTME 0x00000001 /* TX INTME frame transferred */
  40. #define GREG_STAT_TXALL 0x00000002 /* All TX frames transferred */
  41. #define GREG_STAT_TXDONE 0x00000004 /* One TX frame transferred */
  42. #define GREG_STAT_RXDONE 0x00000010 /* One RX frame arrived */
  43. #define GREG_STAT_RXNOBUF 0x00000020 /* No free RX buffers available */
  44. #define GREG_STAT_RXTAGERR 0x00000040 /* RX tag framing is corrupt */
  45. #define GREG_STAT_PCS 0x00002000 /* PCS signalled interrupt */
  46. #define GREG_STAT_TXMAC 0x00004000 /* TX MAC signalled interrupt */
  47. #define GREG_STAT_RXMAC 0x00008000 /* RX MAC signalled interrupt */
  48. #define GREG_STAT_MAC 0x00010000 /* MAC Control signalled irq */
  49. #define GREG_STAT_MIF 0x00020000 /* MIF signalled interrupt */
  50. #define GREG_STAT_PCIERR 0x00040000 /* PCI Error interrupt */
  51. #define GREG_STAT_TXNR 0xfff80000 /* == TXDMA_TXDONE reg val */
  52. #define GREG_STAT_TXNR_SHIFT 19
  53. #define GREG_STAT_ABNORMAL (GREG_STAT_RXNOBUF | GREG_STAT_RXTAGERR | \
  54. GREG_STAT_PCS | GREG_STAT_TXMAC | GREG_STAT_RXMAC | \
  55. GREG_STAT_MAC | GREG_STAT_MIF | GREG_STAT_PCIERR)
  56. #define GREG_STAT_NAPI (GREG_STAT_TXALL | GREG_STAT_TXINTME | \
  57. GREG_STAT_RXDONE | GREG_STAT_ABNORMAL)
  58. /* The layout of GREG_IMASK and GREG_IACK is identical to GREG_STAT.
  59. * Bits set in GREG_IMASK will prevent that interrupt type from being
  60. * signalled to the cpu. GREG_IACK can be used to clear specific top-level
  61. * interrupt conditions in GREG_STAT, ie. it only works for bits 0 through 6.
  62. * Setting the bit will clear that interrupt, clear bits will have no effect
  63. * on GREG_STAT.
  64. */
  65. /* Global PCI Error Status Register */
  66. #define GREG_PCIESTAT_BADACK 0x00000001 /* No ACK64# during ABS64 cycle */
  67. #define GREG_PCIESTAT_DTRTO 0x00000002 /* Delayed transaction timeout */
  68. #define GREG_PCIESTAT_OTHER 0x00000004 /* Other PCI error, check cfg space */
  69. /* The layout of the GREG_PCIEMASK is identical to that of GREG_PCIESTAT.
  70. * Bits set in GREG_PCIEMASK will prevent that interrupt type from being
  71. * signalled to the cpu.
  72. */
  73. /* Global BIF Configuration Register */
  74. #define GREG_BIFCFG_SLOWCLK 0x00000001 /* Set if PCI runs < 25Mhz */
  75. #define GREG_BIFCFG_B64DIS 0x00000002 /* Disable 64bit wide data cycle*/
  76. #define GREG_BIFCFG_M66EN 0x00000004 /* Set if on 66Mhz PCI segment */
  77. /* Global BIF Diagnostics Register */
  78. #define GREG_BIFDIAG_BURSTSM 0x007f0000 /* PCI Burst state machine */
  79. #define GREG_BIFDIAG_BIFSM 0xff000000 /* BIF state machine */
  80. /* Global Software Reset Register.
  81. *
  82. * This register is used to perform a global reset of the RX and TX portions
  83. * of the GEM asic. Setting the RX or TX reset bit will start the reset.
  84. * The driver _MUST_ poll these bits until they clear. One may not attempt
  85. * to program any other part of GEM until the bits clear.
  86. */
  87. #define GREG_SWRST_TXRST 0x00000001 /* TX Software Reset */
  88. #define GREG_SWRST_RXRST 0x00000002 /* RX Software Reset */
  89. #define GREG_SWRST_RSTOUT 0x00000004 /* Force RST# pin active */
  90. #define GREG_SWRST_CACHESIZE 0x00ff0000 /* RIO only: cache line size */
  91. #define GREG_SWRST_CACHE_SHIFT 16
  92. /* TX DMA Registers */
  93. #define TXDMA_KICK 0x2000UL /* TX Kick Register */
  94. #define TXDMA_CFG 0x2004UL /* TX Configuration Register */
  95. #define TXDMA_DBLOW 0x2008UL /* TX Desc. Base Low */
  96. #define TXDMA_DBHI 0x200CUL /* TX Desc. Base High */
  97. #define TXDMA_FWPTR 0x2014UL /* TX FIFO Write Pointer */
  98. #define TXDMA_FSWPTR 0x2018UL /* TX FIFO Shadow Write Pointer */
  99. #define TXDMA_FRPTR 0x201CUL /* TX FIFO Read Pointer */
  100. #define TXDMA_FSRPTR 0x2020UL /* TX FIFO Shadow Read Pointer */
  101. #define TXDMA_PCNT 0x2024UL /* TX FIFO Packet Counter */
  102. #define TXDMA_SMACHINE 0x2028UL /* TX State Machine Register */
  103. #define TXDMA_DPLOW 0x2030UL /* TX Data Pointer Low */
  104. #define TXDMA_DPHI 0x2034UL /* TX Data Pointer High */
  105. #define TXDMA_TXDONE 0x2100UL /* TX Completion Register */
  106. #define TXDMA_FADDR 0x2104UL /* TX FIFO Address */
  107. #define TXDMA_FTAG 0x2108UL /* TX FIFO Tag */
  108. #define TXDMA_DLOW 0x210CUL /* TX FIFO Data Low */
  109. #define TXDMA_DHIT1 0x2110UL /* TX FIFO Data HighT1 */
  110. #define TXDMA_DHIT0 0x2114UL /* TX FIFO Data HighT0 */
  111. #define TXDMA_FSZ 0x2118UL /* TX FIFO Size */
  112. /* TX Kick Register.
  113. *
  114. * This 13-bit register is programmed by the driver to hold the descriptor
  115. * entry index which follows the last valid transmit descriptor.
  116. */
  117. /* TX Completion Register.
  118. *
  119. * This 13-bit register is updated by GEM to hold to descriptor entry index
  120. * which follows the last descriptor already processed by GEM. Note that
  121. * this value is mirrored in GREG_STAT which eliminates the need to even
  122. * access this register in the driver during interrupt processing.
  123. */
  124. /* TX Configuration Register.
  125. *
  126. * Note that TXDMA_CFG_FTHRESH, the TX FIFO Threshold, is an obsolete feature
  127. * that was meant to be used with jumbo packets. It should be set to the
  128. * maximum value of 0x4ff, else one risks getting TX MAC Underrun errors.
  129. */
  130. #define TXDMA_CFG_ENABLE 0x00000001 /* Enable TX DMA channel */
  131. #define TXDMA_CFG_RINGSZ 0x0000001e /* TX descriptor ring size */
  132. #define TXDMA_CFG_RINGSZ_32 0x00000000 /* 32 TX descriptors */
  133. #define TXDMA_CFG_RINGSZ_64 0x00000002 /* 64 TX descriptors */
  134. #define TXDMA_CFG_RINGSZ_128 0x00000004 /* 128 TX descriptors */
  135. #define TXDMA_CFG_RINGSZ_256 0x00000006 /* 256 TX descriptors */
  136. #define TXDMA_CFG_RINGSZ_512 0x00000008 /* 512 TX descriptors */
  137. #define TXDMA_CFG_RINGSZ_1K 0x0000000a /* 1024 TX descriptors */
  138. #define TXDMA_CFG_RINGSZ_2K 0x0000000c /* 2048 TX descriptors */
  139. #define TXDMA_CFG_RINGSZ_4K 0x0000000e /* 4096 TX descriptors */
  140. #define TXDMA_CFG_RINGSZ_8K 0x00000010 /* 8192 TX descriptors */
  141. #define TXDMA_CFG_PIOSEL 0x00000020 /* Enable TX FIFO PIO from cpu */
  142. #define TXDMA_CFG_FTHRESH 0x001ffc00 /* TX FIFO Threshold, obsolete */
  143. #define TXDMA_CFG_PMODE 0x00200000 /* TXALL irq means TX FIFO empty*/
  144. /* TX Descriptor Base Low/High.
  145. *
  146. * These two registers store the 53 most significant bits of the base address
  147. * of the TX descriptor table. The 11 least significant bits are always
  148. * zero. As a result, the TX descriptor table must be 2K aligned.
  149. */
  150. /* The rest of the TXDMA_* registers are for diagnostics and debug, I will document
  151. * them later. -DaveM
  152. */
  153. /* WakeOnLan Registers */
  154. #define WOL_MATCH0 0x3000UL
  155. #define WOL_MATCH1 0x3004UL
  156. #define WOL_MATCH2 0x3008UL
  157. #define WOL_MCOUNT 0x300CUL
  158. #define WOL_WAKECSR 0x3010UL
  159. /* WOL Match count register
  160. */
  161. #define WOL_MCOUNT_N 0x00000010
  162. #define WOL_MCOUNT_M 0x00000000 /* 0 << 8 */
  163. #define WOL_WAKECSR_ENABLE 0x00000001
  164. #define WOL_WAKECSR_MII 0x00000002
  165. #define WOL_WAKECSR_SEEN 0x00000004
  166. #define WOL_WAKECSR_FILT_UCAST 0x00000008
  167. #define WOL_WAKECSR_FILT_MCAST 0x00000010
  168. #define WOL_WAKECSR_FILT_BCAST 0x00000020
  169. #define WOL_WAKECSR_FILT_SEEN 0x00000040
  170. /* Receive DMA Registers */
  171. #define RXDMA_CFG 0x4000UL /* RX Configuration Register */
  172. #define RXDMA_DBLOW 0x4004UL /* RX Descriptor Base Low */
  173. #define RXDMA_DBHI 0x4008UL /* RX Descriptor Base High */
  174. #define RXDMA_FWPTR 0x400CUL /* RX FIFO Write Pointer */
  175. #define RXDMA_FSWPTR 0x4010UL /* RX FIFO Shadow Write Pointer */
  176. #define RXDMA_FRPTR 0x4014UL /* RX FIFO Read Pointer */
  177. #define RXDMA_PCNT 0x4018UL /* RX FIFO Packet Counter */
  178. #define RXDMA_SMACHINE 0x401CUL /* RX State Machine Register */
  179. #define RXDMA_PTHRESH 0x4020UL /* Pause Thresholds */
  180. #define RXDMA_DPLOW 0x4024UL /* RX Data Pointer Low */
  181. #define RXDMA_DPHI 0x4028UL /* RX Data Pointer High */
  182. #define RXDMA_KICK 0x4100UL /* RX Kick Register */
  183. #define RXDMA_DONE 0x4104UL /* RX Completion Register */
  184. #define RXDMA_BLANK 0x4108UL /* RX Blanking Register */
  185. #define RXDMA_FADDR 0x410CUL /* RX FIFO Address */
  186. #define RXDMA_FTAG 0x4110UL /* RX FIFO Tag */
  187. #define RXDMA_DLOW 0x4114UL /* RX FIFO Data Low */
  188. #define RXDMA_DHIT1 0x4118UL /* RX FIFO Data HighT0 */
  189. #define RXDMA_DHIT0 0x411CUL /* RX FIFO Data HighT1 */
  190. #define RXDMA_FSZ 0x4120UL /* RX FIFO Size */
  191. /* RX Configuration Register. */
  192. #define RXDMA_CFG_ENABLE 0x00000001 /* Enable RX DMA channel */
  193. #define RXDMA_CFG_RINGSZ 0x0000001e /* RX descriptor ring size */
  194. #define RXDMA_CFG_RINGSZ_32 0x00000000 /* - 32 entries */
  195. #define RXDMA_CFG_RINGSZ_64 0x00000002 /* - 64 entries */
  196. #define RXDMA_CFG_RINGSZ_128 0x00000004 /* - 128 entries */
  197. #define RXDMA_CFG_RINGSZ_256 0x00000006 /* - 256 entries */
  198. #define RXDMA_CFG_RINGSZ_512 0x00000008 /* - 512 entries */
  199. #define RXDMA_CFG_RINGSZ_1K 0x0000000a /* - 1024 entries */
  200. #define RXDMA_CFG_RINGSZ_2K 0x0000000c /* - 2048 entries */
  201. #define RXDMA_CFG_RINGSZ_4K 0x0000000e /* - 4096 entries */
  202. #define RXDMA_CFG_RINGSZ_8K 0x00000010 /* - 8192 entries */
  203. #define RXDMA_CFG_RINGSZ_BDISAB 0x00000020 /* Disable RX desc batching */
  204. #define RXDMA_CFG_FBOFF 0x00001c00 /* Offset of first data byte */
  205. #define RXDMA_CFG_CSUMOFF 0x000fe000 /* Skip bytes before csum calc */
  206. #define RXDMA_CFG_FTHRESH 0x07000000 /* RX FIFO dma start threshold */
  207. #define RXDMA_CFG_FTHRESH_64 0x00000000 /* - 64 bytes */
  208. #define RXDMA_CFG_FTHRESH_128 0x01000000 /* - 128 bytes */
  209. #define RXDMA_CFG_FTHRESH_256 0x02000000 /* - 256 bytes */
  210. #define RXDMA_CFG_FTHRESH_512 0x03000000 /* - 512 bytes */
  211. #define RXDMA_CFG_FTHRESH_1K 0x04000000 /* - 1024 bytes */
  212. #define RXDMA_CFG_FTHRESH_2K 0x05000000 /* - 2048 bytes */
  213. /* RX Descriptor Base Low/High.
  214. *
  215. * These two registers store the 53 most significant bits of the base address
  216. * of the RX descriptor table. The 11 least significant bits are always
  217. * zero. As a result, the RX descriptor table must be 2K aligned.
  218. */
  219. /* RX PAUSE Thresholds.
  220. *
  221. * These values determine when XOFF and XON PAUSE frames are emitted by
  222. * GEM. The thresholds measure RX FIFO occupancy in units of 64 bytes.
  223. */
  224. #define RXDMA_PTHRESH_OFF 0x000001ff /* XOFF emitted w/FIFO > this */
  225. #define RXDMA_PTHRESH_ON 0x001ff000 /* XON emitted w/FIFO < this */
  226. /* RX Kick Register.
  227. *
  228. * This 13-bit register is written by the host CPU and holds the last
  229. * valid RX descriptor number plus one. This is, if 'N' is written to
  230. * this register, it means that all RX descriptors up to but excluding
  231. * 'N' are valid.
  232. *
  233. * The hardware requires that RX descriptors are posted in increments
  234. * of 4. This means 'N' must be a multiple of four. For the best
  235. * performance, the first new descriptor being posted should be (PCI)
  236. * cache line aligned.
  237. */
  238. /* RX Completion Register.
  239. *
  240. * This 13-bit register is updated by GEM to indicate which RX descriptors
  241. * have already been used for receive frames. All descriptors up to but
  242. * excluding the value in this register are ready to be processed. GEM
  243. * updates this register value after the RX FIFO empties completely into
  244. * the RX descriptor's buffer, but before the RX_DONE bit is set in the
  245. * interrupt status register.
  246. */
  247. /* RX Blanking Register. */
  248. #define RXDMA_BLANK_IPKTS 0x000001ff /* RX_DONE asserted after this
  249. * many packets received since
  250. * previous RX_DONE.
  251. */
  252. #define RXDMA_BLANK_ITIME 0x000ff000 /* RX_DONE asserted after this
  253. * many clocks (measured in 2048
  254. * PCI clocks) were counted since
  255. * the previous RX_DONE.
  256. */
  257. /* RX FIFO Size.
  258. *
  259. * This 11-bit read-only register indicates how large, in units of 64-bytes,
  260. * the RX FIFO is. The driver uses this to properly configure the RX PAUSE
  261. * thresholds.
  262. */
  263. /* The rest of the RXDMA_* registers are for diagnostics and debug, I will document
  264. * them later. -DaveM
  265. */
  266. /* MAC Registers */
  267. #define MAC_TXRST 0x6000UL /* TX MAC Software Reset Command*/
  268. #define MAC_RXRST 0x6004UL /* RX MAC Software Reset Command*/
  269. #define MAC_SNDPAUSE 0x6008UL /* Send Pause Command Register */
  270. #define MAC_TXSTAT 0x6010UL /* TX MAC Status Register */
  271. #define MAC_RXSTAT 0x6014UL /* RX MAC Status Register */
  272. #define MAC_CSTAT 0x6018UL /* MAC Control Status Register */
  273. #define MAC_TXMASK 0x6020UL /* TX MAC Mask Register */
  274. #define MAC_RXMASK 0x6024UL /* RX MAC Mask Register */
  275. #define MAC_MCMASK 0x6028UL /* MAC Control Mask Register */
  276. #define MAC_TXCFG 0x6030UL /* TX MAC Configuration Register*/
  277. #define MAC_RXCFG 0x6034UL /* RX MAC Configuration Register*/
  278. #define MAC_MCCFG 0x6038UL /* MAC Control Config Register */
  279. #define MAC_XIFCFG 0x603CUL /* XIF Configuration Register */
  280. #define MAC_IPG0 0x6040UL /* InterPacketGap0 Register */
  281. #define MAC_IPG1 0x6044UL /* InterPacketGap1 Register */
  282. #define MAC_IPG2 0x6048UL /* InterPacketGap2 Register */
  283. #define MAC_STIME 0x604CUL /* SlotTime Register */
  284. #define MAC_MINFSZ 0x6050UL /* MinFrameSize Register */
  285. #define MAC_MAXFSZ 0x6054UL /* MaxFrameSize Register */
  286. #define MAC_PASIZE 0x6058UL /* PA Size Register */
  287. #define MAC_JAMSIZE 0x605CUL /* JamSize Register */
  288. #define MAC_ATTLIM 0x6060UL /* Attempt Limit Register */
  289. #define MAC_MCTYPE 0x6064UL /* MAC Control Type Register */
  290. #define MAC_ADDR0 0x6080UL /* MAC Address 0 Register */
  291. #define MAC_ADDR1 0x6084UL /* MAC Address 1 Register */
  292. #define MAC_ADDR2 0x6088UL /* MAC Address 2 Register */
  293. #define MAC_ADDR3 0x608CUL /* MAC Address 3 Register */
  294. #define MAC_ADDR4 0x6090UL /* MAC Address 4 Register */
  295. #define MAC_ADDR5 0x6094UL /* MAC Address 5 Register */
  296. #define MAC_ADDR6 0x6098UL /* MAC Address 6 Register */
  297. #define MAC_ADDR7 0x609CUL /* MAC Address 7 Register */
  298. #define MAC_ADDR8 0x60A0UL /* MAC Address 8 Register */
  299. #define MAC_AFILT0 0x60A4UL /* Address Filter 0 Register */
  300. #define MAC_AFILT1 0x60A8UL /* Address Filter 1 Register */
  301. #define MAC_AFILT2 0x60ACUL /* Address Filter 2 Register */
  302. #define MAC_AF21MSK 0x60B0UL /* Address Filter 2&1 Mask Reg */
  303. #define MAC_AF0MSK 0x60B4UL /* Address Filter 0 Mask Reg */
  304. #define MAC_HASH0 0x60C0UL /* Hash Table 0 Register */
  305. #define MAC_HASH1 0x60C4UL /* Hash Table 1 Register */
  306. #define MAC_HASH2 0x60C8UL /* Hash Table 2 Register */
  307. #define MAC_HASH3 0x60CCUL /* Hash Table 3 Register */
  308. #define MAC_HASH4 0x60D0UL /* Hash Table 4 Register */
  309. #define MAC_HASH5 0x60D4UL /* Hash Table 5 Register */
  310. #define MAC_HASH6 0x60D8UL /* Hash Table 6 Register */
  311. #define MAC_HASH7 0x60DCUL /* Hash Table 7 Register */
  312. #define MAC_HASH8 0x60E0UL /* Hash Table 8 Register */
  313. #define MAC_HASH9 0x60E4UL /* Hash Table 9 Register */
  314. #define MAC_HASH10 0x60E8UL /* Hash Table 10 Register */
  315. #define MAC_HASH11 0x60ECUL /* Hash Table 11 Register */
  316. #define MAC_HASH12 0x60F0UL /* Hash Table 12 Register */
  317. #define MAC_HASH13 0x60F4UL /* Hash Table 13 Register */
  318. #define MAC_HASH14 0x60F8UL /* Hash Table 14 Register */
  319. #define MAC_HASH15 0x60FCUL /* Hash Table 15 Register */
  320. #define MAC_NCOLL 0x6100UL /* Normal Collision Counter */
  321. #define MAC_FASUCC 0x6104UL /* First Attmpt. Succ Coll Ctr. */
  322. #define MAC_ECOLL 0x6108UL /* Excessive Collision Counter */
  323. #define MAC_LCOLL 0x610CUL /* Late Collision Counter */
  324. #define MAC_DTIMER 0x6110UL /* Defer Timer */
  325. #define MAC_PATMPS 0x6114UL /* Peak Attempts Register */
  326. #define MAC_RFCTR 0x6118UL /* Receive Frame Counter */
  327. #define MAC_LERR 0x611CUL /* Length Error Counter */
  328. #define MAC_AERR 0x6120UL /* Alignment Error Counter */
  329. #define MAC_FCSERR 0x6124UL /* FCS Error Counter */
  330. #define MAC_RXCVERR 0x6128UL /* RX code Violation Error Ctr */
  331. #define MAC_RANDSEED 0x6130UL /* Random Number Seed Register */
  332. #define MAC_SMACHINE 0x6134UL /* State Machine Register */
  333. /* TX MAC Software Reset Command. */
  334. #define MAC_TXRST_CMD 0x00000001 /* Start sw reset, self-clears */
  335. /* RX MAC Software Reset Command. */
  336. #define MAC_RXRST_CMD 0x00000001 /* Start sw reset, self-clears */
  337. /* Send Pause Command. */
  338. #define MAC_SNDPAUSE_TS 0x0000ffff /* The pause_time operand used in
  339. * Send_Pause and flow-control
  340. * handshakes.
  341. */
  342. #define MAC_SNDPAUSE_SP 0x00010000 /* Setting this bit instructs the MAC
  343. * to send a Pause Flow Control
  344. * frame onto the network.
  345. */
  346. /* TX MAC Status Register. */
  347. #define MAC_TXSTAT_XMIT 0x00000001 /* Frame Transmitted */
  348. #define MAC_TXSTAT_URUN 0x00000002 /* TX Underrun */
  349. #define MAC_TXSTAT_MPE 0x00000004 /* Max Packet Size Error */
  350. #define MAC_TXSTAT_NCE 0x00000008 /* Normal Collision Cntr Expire */
  351. #define MAC_TXSTAT_ECE 0x00000010 /* Excess Collision Cntr Expire */
  352. #define MAC_TXSTAT_LCE 0x00000020 /* Late Collision Cntr Expire */
  353. #define MAC_TXSTAT_FCE 0x00000040 /* First Collision Cntr Expire */
  354. #define MAC_TXSTAT_DTE 0x00000080 /* Defer Timer Expire */
  355. #define MAC_TXSTAT_PCE 0x00000100 /* Peak Attempts Cntr Expire */
  356. /* RX MAC Status Register. */
  357. #define MAC_RXSTAT_RCV 0x00000001 /* Frame Received */
  358. #define MAC_RXSTAT_OFLW 0x00000002 /* Receive Overflow */
  359. #define MAC_RXSTAT_FCE 0x00000004 /* Frame Cntr Expire */
  360. #define MAC_RXSTAT_ACE 0x00000008 /* Align Error Cntr Expire */
  361. #define MAC_RXSTAT_CCE 0x00000010 /* CRC Error Cntr Expire */
  362. #define MAC_RXSTAT_LCE 0x00000020 /* Length Error Cntr Expire */
  363. #define MAC_RXSTAT_VCE 0x00000040 /* Code Violation Cntr Expire */
  364. /* MAC Control Status Register. */
  365. #define MAC_CSTAT_PRCV 0x00000001 /* Pause Received */
  366. #define MAC_CSTAT_PS 0x00000002 /* Paused State */
  367. #define MAC_CSTAT_NPS 0x00000004 /* Not Paused State */
  368. #define MAC_CSTAT_PTR 0xffff0000 /* Pause Time Received */
  369. /* The layout of the MAC_{TX,RX,C}MASK registers is identical to that
  370. * of MAC_{TX,RX,C}STAT. Bits set in MAC_{TX,RX,C}MASK will prevent
  371. * that interrupt type from being signalled to front end of GEM. For
  372. * the interrupt to actually get sent to the cpu, it is necessary to
  373. * properly set the appropriate GREG_IMASK_{TX,RX,}MAC bits as well.
  374. */
  375. /* TX MAC Configuration Register.
  376. *
  377. * NOTE: The TX MAC Enable bit must be cleared and polled until
  378. * zero before any other bits in this register are changed.
  379. *
  380. * Also, enabling the Carrier Extension feature of GEM is
  381. * a 3 step process 1) Set TX Carrier Extension 2) Set
  382. * RX Carrier Extension 3) Set Slot Time to 0x200. This
  383. * mode must be enabled when in half-duplex at 1Gbps, else
  384. * it must be disabled.
  385. */
  386. #define MAC_TXCFG_ENAB 0x00000001 /* TX MAC Enable */
  387. #define MAC_TXCFG_ICS 0x00000002 /* Ignore Carrier Sense */
  388. #define MAC_TXCFG_ICOLL 0x00000004 /* Ignore Collisions */
  389. #define MAC_TXCFG_EIPG0 0x00000008 /* Enable IPG0 */
  390. #define MAC_TXCFG_NGU 0x00000010 /* Never Give Up */
  391. #define MAC_TXCFG_NGUL 0x00000020 /* Never Give Up Limit */
  392. #define MAC_TXCFG_NBO 0x00000040 /* No Backoff */
  393. #define MAC_TXCFG_SD 0x00000080 /* Slow Down */
  394. #define MAC_TXCFG_NFCS 0x00000100 /* No FCS */
  395. #define MAC_TXCFG_TCE 0x00000200 /* TX Carrier Extension */
  396. /* RX MAC Configuration Register.
  397. *
  398. * NOTE: The RX MAC Enable bit must be cleared and polled until
  399. * zero before any other bits in this register are changed.
  400. *
  401. * Similar rules apply to the Hash Filter Enable bit when
  402. * programming the hash table registers, and the Address Filter
  403. * Enable bit when programming the address filter registers.
  404. */
  405. #define MAC_RXCFG_ENAB 0x00000001 /* RX MAC Enable */
  406. #define MAC_RXCFG_SPAD 0x00000002 /* Strip Pad */
  407. #define MAC_RXCFG_SFCS 0x00000004 /* Strip FCS */
  408. #define MAC_RXCFG_PROM 0x00000008 /* Promiscuous Mode */
  409. #define MAC_RXCFG_PGRP 0x00000010 /* Promiscuous Group */
  410. #define MAC_RXCFG_HFE 0x00000020 /* Hash Filter Enable */
  411. #define MAC_RXCFG_AFE 0x00000040 /* Address Filter Enable */
  412. #define MAC_RXCFG_DDE 0x00000080 /* Disable Discard on Error */
  413. #define MAC_RXCFG_RCE 0x00000100 /* RX Carrier Extension */
  414. /* MAC Control Config Register. */
  415. #define MAC_MCCFG_SPE 0x00000001 /* Send Pause Enable */
  416. #define MAC_MCCFG_RPE 0x00000002 /* Receive Pause Enable */
  417. #define MAC_MCCFG_PMC 0x00000004 /* Pass MAC Control */
  418. /* XIF Configuration Register.
  419. *
  420. * NOTE: When leaving or entering loopback mode, a global hardware
  421. * init of GEM should be performed.
  422. */
  423. #define MAC_XIFCFG_OE 0x00000001 /* MII TX Output Driver Enable */
  424. #define MAC_XIFCFG_LBCK 0x00000002 /* Loopback TX to RX */
  425. #define MAC_XIFCFG_DISE 0x00000004 /* Disable RX path during TX */
  426. #define MAC_XIFCFG_GMII 0x00000008 /* Use GMII clocks + datapath */
  427. #define MAC_XIFCFG_MBOE 0x00000010 /* Controls MII_BUF_EN pin */
  428. #define MAC_XIFCFG_LLED 0x00000020 /* Force LINKLED# active (low) */
  429. #define MAC_XIFCFG_FLED 0x00000040 /* Force FDPLXLED# active (low) */
  430. /* InterPacketGap0 Register. This 8-bit value is used as an extension
  431. * to the InterPacketGap1 Register. Specifically it contributes to the
  432. * timing of the RX-to-TX IPG. This value is ignored and presumed to
  433. * be zero for TX-to-TX IPG calculations and/or when the Enable IPG0 bit
  434. * is cleared in the TX MAC Configuration Register.
  435. *
  436. * This value in this register in terms of media byte time.
  437. *
  438. * Recommended value: 0x00
  439. */
  440. /* InterPacketGap1 Register. This 8-bit value defines the first 2/3
  441. * portion of the Inter Packet Gap.
  442. *
  443. * This value in this register in terms of media byte time.
  444. *
  445. * Recommended value: 0x08
  446. */
  447. /* InterPacketGap2 Register. This 8-bit value defines the second 1/3
  448. * portion of the Inter Packet Gap.
  449. *
  450. * This value in this register in terms of media byte time.
  451. *
  452. * Recommended value: 0x04
  453. */
  454. /* Slot Time Register. This 10-bit value specifies the slot time
  455. * parameter in units of media byte time. It determines the physical
  456. * span of the network.
  457. *
  458. * Recommended value: 0x40
  459. */
  460. /* Minimum Frame Size Register. This 10-bit register specifies the
  461. * smallest sized frame the TXMAC will send onto the medium, and the
  462. * RXMAC will receive from the medium.
  463. *
  464. * Recommended value: 0x40
  465. */
  466. /* Maximum Frame and Burst Size Register.
  467. *
  468. * This register specifies two things. First it specifies the maximum
  469. * sized frame the TXMAC will send and the RXMAC will recognize as
  470. * valid. Second, it specifies the maximum run length of a burst of
  471. * packets sent in half-duplex gigabit modes.
  472. *
  473. * Recommended value: 0x200005ee
  474. */
  475. #define MAC_MAXFSZ_MFS 0x00007fff /* Max Frame Size */
  476. #define MAC_MAXFSZ_MBS 0x7fff0000 /* Max Burst Size */
  477. /* PA Size Register. This 10-bit register specifies the number of preamble
  478. * bytes which will be transmitted at the beginning of each frame. A
  479. * value of two or greater should be programmed here.
  480. *
  481. * Recommended value: 0x07
  482. */
  483. /* Jam Size Register. This 4-bit register specifies the duration of
  484. * the jam in units of media byte time.
  485. *
  486. * Recommended value: 0x04
  487. */
  488. /* Attempts Limit Register. This 8-bit register specifies the number
  489. * of attempts that the TXMAC will make to transmit a frame, before it
  490. * resets its Attempts Counter. After reaching the Attempts Limit the
  491. * TXMAC may or may not drop the frame, as determined by the NGU
  492. * (Never Give Up) and NGUL (Never Give Up Limit) bits in the TXMAC
  493. * Configuration Register.
  494. *
  495. * Recommended value: 0x10
  496. */
  497. /* MAX Control Type Register. This 16-bit register specifies the
  498. * "type" field of a MAC Control frame. The TXMAC uses this field to
  499. * encapsulate the MAC Control frame for transmission, and the RXMAC
  500. * uses it for decoding valid MAC Control frames received from the
  501. * network.
  502. *
  503. * Recommended value: 0x8808
  504. */
  505. /* MAC Address Registers. Each of these registers specify the
  506. * ethernet MAC of the interface, 16-bits at a time. Register
  507. * 0 specifies bits [47:32], register 1 bits [31:16], and register
  508. * 2 bits [15:0].
  509. *
  510. * Registers 3 through and including 5 specify an alternate
  511. * MAC address for the interface.
  512. *
  513. * Registers 6 through and including 8 specify the MAC Control
  514. * Address, which must be the reserved multicast address for MAC
  515. * Control frames.
  516. *
  517. * Example: To program primary station address a:b:c:d:e:f into
  518. * the chip.
  519. * MAC_Address_2 = (a << 8) | b
  520. * MAC_Address_1 = (c << 8) | d
  521. * MAC_Address_0 = (e << 8) | f
  522. */
  523. /* Address Filter Registers. Registers 0 through 2 specify bit
  524. * fields [47:32] through [15:0], respectively, of the address
  525. * filter. The Address Filter 2&1 Mask Register denotes the 8-bit
  526. * nibble mask for Address Filter Registers 2 and 1. The Address
  527. * Filter 0 Mask Register denotes the 16-bit mask for the Address
  528. * Filter Register 0.
  529. */
  530. /* Hash Table Registers. Registers 0 through 15 specify bit fields
  531. * [255:240] through [15:0], respectively, of the hash table.
  532. */
  533. /* Statistics Registers. All of these registers are 16-bits and
  534. * track occurrences of a specific event. GEM can be configured
  535. * to interrupt the host cpu when any of these counters overflow.
  536. * They should all be explicitly initialized to zero when the interface
  537. * is brought up.
  538. */
  539. /* Random Number Seed Register. This 10-bit value is used as the
  540. * RNG seed inside GEM for the CSMA/CD backoff algorithm. It is
  541. * recommended to program this register to the 10 LSB of the
  542. * interfaces MAC address.
  543. */
  544. /* Pause Timer, read-only. This 16-bit timer is used to time the pause
  545. * interval as indicated by a received pause flow control frame.
  546. * A non-zero value in this timer indicates that the MAC is currently in
  547. * the paused state.
  548. */
  549. /* MIF Registers */
  550. #define MIF_BBCLK 0x6200UL /* MIF Bit-Bang Clock */
  551. #define MIF_BBDATA 0x6204UL /* MIF Bit-Band Data */
  552. #define MIF_BBOENAB 0x6208UL /* MIF Bit-Bang Output Enable */
  553. #define MIF_FRAME 0x620CUL /* MIF Frame/Output Register */
  554. #define MIF_CFG 0x6210UL /* MIF Configuration Register */
  555. #define MIF_MASK 0x6214UL /* MIF Mask Register */
  556. #define MIF_STATUS 0x6218UL /* MIF Status Register */
  557. #define MIF_SMACHINE 0x621CUL /* MIF State Machine Register */
  558. /* MIF Bit-Bang Clock. This 1-bit register is used to generate the
  559. * MDC clock waveform on the MII Management Interface when the MIF is
  560. * programmed in the "Bit-Bang" mode. Writing a '1' after a '0' into
  561. * this register will create a rising edge on the MDC, while writing
  562. * a '0' after a '1' will create a falling edge. For every bit that
  563. * is transferred on the management interface, both edges have to be
  564. * generated.
  565. */
  566. /* MIF Bit-Bang Data. This 1-bit register is used to generate the
  567. * outgoing data (MDO) on the MII Management Interface when the MIF
  568. * is programmed in the "Bit-Bang" mode. The daa will be steered to the
  569. * appropriate MDIO based on the state of the PHY_Select bit in the MIF
  570. * Configuration Register.
  571. */
  572. /* MIF Big-Band Output Enable. THis 1-bit register is used to enable
  573. * ('1') or disable ('0') the I-directional driver on the MII when the
  574. * MIF is programmed in the "Bit-Bang" mode. The MDIO should be enabled
  575. * when data bits are transferred from the MIF to the transceiver, and it
  576. * should be disabled when the interface is idle or when data bits are
  577. * transferred from the transceiver to the MIF (data portion of a read
  578. * instruction). Only one MDIO will be enabled at a given time, depending
  579. * on the state of the PHY_Select bit in the MIF Configuration Register.
  580. */
  581. /* MIF Configuration Register. This 15-bit register controls the operation
  582. * of the MIF.
  583. */
  584. #define MIF_CFG_PSELECT 0x00000001 /* Xcvr slct: 0=mdio0 1=mdio1 */
  585. #define MIF_CFG_POLL 0x00000002 /* Enable polling mechanism */
  586. #define MIF_CFG_BBMODE 0x00000004 /* 1=bit-bang 0=frame mode */
  587. #define MIF_CFG_PRADDR 0x000000f8 /* Xcvr poll register address */
  588. #define MIF_CFG_MDI0 0x00000100 /* MDIO_0 present or read-bit */
  589. #define MIF_CFG_MDI1 0x00000200 /* MDIO_1 present or read-bit */
  590. #define MIF_CFG_PPADDR 0x00007c00 /* Xcvr poll PHY address */
  591. /* MIF Frame/Output Register. This 32-bit register allows the host to
  592. * communicate with a transceiver in frame mode (as opposed to big-bang
  593. * mode). Writes by the host specify an instrution. After being issued
  594. * the host must poll this register for completion. Also, after
  595. * completion this register holds the data returned by the transceiver
  596. * if applicable.
  597. */
  598. #define MIF_FRAME_ST 0xc0000000 /* STart of frame */
  599. #define MIF_FRAME_OP 0x30000000 /* OPcode */
  600. #define MIF_FRAME_PHYAD 0x0f800000 /* PHY ADdress */
  601. #define MIF_FRAME_REGAD 0x007c0000 /* REGister ADdress */
  602. #define MIF_FRAME_TAMSB 0x00020000 /* Turn Around MSB */
  603. #define MIF_FRAME_TALSB 0x00010000 /* Turn Around LSB */
  604. #define MIF_FRAME_DATA 0x0000ffff /* Instruction Payload */
  605. /* MIF Status Register. This register reports status when the MIF is
  606. * operating in the poll mode. The poll status field is auto-clearing
  607. * on read.
  608. */
  609. #define MIF_STATUS_DATA 0xffff0000 /* Live image of XCVR reg */
  610. #define MIF_STATUS_STAT 0x0000ffff /* Which bits have changed */
  611. /* MIF Mask Register. This 16-bit register is used when in poll mode
  612. * to say which bits of the polled register will cause an interrupt
  613. * when changed.
  614. */
  615. /* PCS/Serialink Registers */
  616. #define PCS_MIICTRL 0x9000UL /* PCS MII Control Register */
  617. #define PCS_MIISTAT 0x9004UL /* PCS MII Status Register */
  618. #define PCS_MIIADV 0x9008UL /* PCS MII Advertisement Reg */
  619. #define PCS_MIILP 0x900CUL /* PCS MII Link Partner Ability */
  620. #define PCS_CFG 0x9010UL /* PCS Configuration Register */
  621. #define PCS_SMACHINE 0x9014UL /* PCS State Machine Register */
  622. #define PCS_ISTAT 0x9018UL /* PCS Interrupt Status Reg */
  623. #define PCS_DMODE 0x9050UL /* Datapath Mode Register */
  624. #define PCS_SCTRL 0x9054UL /* Serialink Control Register */
  625. #define PCS_SOS 0x9058UL /* Shared Output Select Reg */
  626. #define PCS_SSTATE 0x905CUL /* Serialink State Register */
  627. /* PCD MII Control Register. */
  628. #define PCS_MIICTRL_SPD 0x00000040 /* Read as one, writes ignored */
  629. #define PCS_MIICTRL_CT 0x00000080 /* Force COL signal active */
  630. #define PCS_MIICTRL_DM 0x00000100 /* Duplex mode, forced low */
  631. #define PCS_MIICTRL_RAN 0x00000200 /* Restart auto-neg, self clear */
  632. #define PCS_MIICTRL_ISO 0x00000400 /* Read as zero, writes ignored */
  633. #define PCS_MIICTRL_PD 0x00000800 /* Read as zero, writes ignored */
  634. #define PCS_MIICTRL_ANE 0x00001000 /* Auto-neg enable */
  635. #define PCS_MIICTRL_SS 0x00002000 /* Read as zero, writes ignored */
  636. #define PCS_MIICTRL_WB 0x00004000 /* Wrapback, loopback at 10-bit
  637. * input side of Serialink
  638. */
  639. #define PCS_MIICTRL_RST 0x00008000 /* Resets PCS, self clearing */
  640. /* PCS MII Status Register. */
  641. #define PCS_MIISTAT_EC 0x00000001 /* Ext Capability: Read as zero */
  642. #define PCS_MIISTAT_JD 0x00000002 /* Jabber Detect: Read as zero */
  643. #define PCS_MIISTAT_LS 0x00000004 /* Link Status: 1=up 0=down */
  644. #define PCS_MIISTAT_ANA 0x00000008 /* Auto-neg Ability, always 1 */
  645. #define PCS_MIISTAT_RF 0x00000010 /* Remote Fault */
  646. #define PCS_MIISTAT_ANC 0x00000020 /* Auto-neg complete */
  647. #define PCS_MIISTAT_ES 0x00000100 /* Extended Status, always 1 */
  648. /* PCS MII Advertisement Register. */
  649. #define PCS_MIIADV_FD 0x00000020 /* Advertise Full Duplex */
  650. #define PCS_MIIADV_HD 0x00000040 /* Advertise Half Duplex */
  651. #define PCS_MIIADV_SP 0x00000080 /* Advertise Symmetric Pause */
  652. #define PCS_MIIADV_AP 0x00000100 /* Advertise Asymmetric Pause */
  653. #define PCS_MIIADV_RF 0x00003000 /* Remote Fault */
  654. #define PCS_MIIADV_ACK 0x00004000 /* Read-only */
  655. #define PCS_MIIADV_NP 0x00008000 /* Next-page, forced low */
  656. /* PCS MII Link Partner Ability Register. This register is equivalent
  657. * to the Link Partnet Ability Register of the standard MII register set.
  658. * It's layout corresponds to the PCS MII Advertisement Register.
  659. */
  660. /* PCS Configuration Register. */
  661. #define PCS_CFG_ENABLE 0x00000001 /* Must be zero while changing
  662. * PCS MII advertisement reg.
  663. */
  664. #define PCS_CFG_SDO 0x00000002 /* Signal detect override */
  665. #define PCS_CFG_SDL 0x00000004 /* Signal detect active low */
  666. #define PCS_CFG_JS 0x00000018 /* Jitter-study:
  667. * 0 = normal operation
  668. * 1 = high-frequency test pattern
  669. * 2 = low-frequency test pattern
  670. * 3 = reserved
  671. */
  672. #define PCS_CFG_TO 0x00000020 /* 10ms auto-neg timer override */
  673. /* PCS Interrupt Status Register. This register is self-clearing
  674. * when read.
  675. */
  676. #define PCS_ISTAT_LSC 0x00000004 /* Link Status Change */
  677. /* Datapath Mode Register. */
  678. #define PCS_DMODE_SM 0x00000001 /* 1 = use internal Serialink */
  679. #define PCS_DMODE_ESM 0x00000002 /* External SERDES mode */
  680. #define PCS_DMODE_MGM 0x00000004 /* MII/GMII mode */
  681. #define PCS_DMODE_GMOE 0x00000008 /* GMII Output Enable */
  682. /* Serialink Control Register.
  683. *
  684. * NOTE: When in SERDES mode, the loopback bit has inverse logic.
  685. */
  686. #define PCS_SCTRL_LOOP 0x00000001 /* Loopback enable */
  687. #define PCS_SCTRL_ESCD 0x00000002 /* Enable sync char detection */
  688. #define PCS_SCTRL_LOCK 0x00000004 /* Lock to reference clock */
  689. #define PCS_SCTRL_EMP 0x00000018 /* Output driver emphasis */
  690. #define PCS_SCTRL_STEST 0x000001c0 /* Self test patterns */
  691. #define PCS_SCTRL_PDWN 0x00000200 /* Software power-down */
  692. #define PCS_SCTRL_RXZ 0x00000c00 /* PLL input to Serialink */
  693. #define PCS_SCTRL_RXP 0x00003000 /* PLL input to Serialink */
  694. #define PCS_SCTRL_TXZ 0x0000c000 /* PLL input to Serialink */
  695. #define PCS_SCTRL_TXP 0x00030000 /* PLL input to Serialink */
  696. /* Shared Output Select Register. For test and debug, allows multiplexing
  697. * test outputs into the PROM address pins. Set to zero for normal
  698. * operation.
  699. */
  700. #define PCS_SOS_PADDR 0x00000003 /* PROM Address */
  701. /* PROM Image Space */
  702. #define PROM_START 0x100000UL /* Expansion ROM run time access*/
  703. #define PROM_SIZE 0x0fffffUL /* Size of ROM */
  704. #define PROM_END 0x200000UL /* End of ROM */
  705. /* MII definitions missing from mii.h */
  706. #define BMCR_SPD2 0x0040 /* Gigabit enable? (bcm5411) */
  707. #define LPA_PAUSE 0x0400
  708. /* More PHY registers (specific to Broadcom models) */
  709. /* MII BCM5201 MULTIPHY interrupt register */
  710. #define MII_BCM5201_INTERRUPT 0x1A
  711. #define MII_BCM5201_INTERRUPT_INTENABLE 0x4000
  712. #define MII_BCM5201_AUXMODE2 0x1B
  713. #define MII_BCM5201_AUXMODE2_LOWPOWER 0x0008
  714. #define MII_BCM5201_MULTIPHY 0x1E
  715. /* MII BCM5201 MULTIPHY register bits */
  716. #define MII_BCM5201_MULTIPHY_SERIALMODE 0x0002
  717. #define MII_BCM5201_MULTIPHY_SUPERISOLATE 0x0008
  718. /* MII BCM5400 1000-BASET Control register */
  719. #define MII_BCM5400_GB_CONTROL 0x09
  720. #define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200
  721. /* MII BCM5400 AUXCONTROL register */
  722. #define MII_BCM5400_AUXCONTROL 0x18
  723. #define MII_BCM5400_AUXCONTROL_PWR10BASET 0x0004
  724. /* MII BCM5400 AUXSTATUS register */
  725. #define MII_BCM5400_AUXSTATUS 0x19
  726. #define MII_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700
  727. #define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8
  728. /* When it can, GEM internally caches 4 aligned TX descriptors
  729. * at a time, so that it can use full cacheline DMA reads.
  730. *
  731. * Note that unlike HME, there is no ownership bit in the descriptor
  732. * control word. The same functionality is obtained via the TX-Kick
  733. * and TX-Complete registers. As a result, GEM need not write back
  734. * updated values to the TX descriptor ring, it only performs reads.
  735. *
  736. * Since TX descriptors are never modified by GEM, the driver can
  737. * use the buffer DMA address as a place to keep track of allocated
  738. * DMA mappings for a transmitted packet.
  739. */
  740. struct gem_txd {
  741. __le64 control_word;
  742. __le64 buffer;
  743. };
  744. #define TXDCTRL_BUFSZ 0x0000000000007fffULL /* Buffer Size */
  745. #define TXDCTRL_CSTART 0x00000000001f8000ULL /* CSUM Start Offset */
  746. #define TXDCTRL_COFF 0x000000001fe00000ULL /* CSUM Stuff Offset */
  747. #define TXDCTRL_CENAB 0x0000000020000000ULL /* CSUM Enable */
  748. #define TXDCTRL_EOF 0x0000000040000000ULL /* End of Frame */
  749. #define TXDCTRL_SOF 0x0000000080000000ULL /* Start of Frame */
  750. #define TXDCTRL_INTME 0x0000000100000000ULL /* "Interrupt Me" */
  751. #define TXDCTRL_NOCRC 0x0000000200000000ULL /* No CRC Present */
  752. /* GEM requires that RX descriptors are provided four at a time,
  753. * aligned. Also, the RX ring may not wrap around. This means that
  754. * there will be at least 4 unused descriptor entries in the middle
  755. * of the RX ring at all times.
  756. *
  757. * Similar to HME, GEM assumes that it can write garbage bytes before
  758. * the beginning of the buffer and right after the end in order to DMA
  759. * whole cachelines.
  760. *
  761. * Unlike for TX, GEM does update the status word in the RX descriptors
  762. * when packets arrive. Therefore an ownership bit does exist in the
  763. * RX descriptors. It is advisory, GEM clears it but does not check
  764. * it in any way. So when buffers are posted to the RX ring (via the
  765. * RX Kick register) by the driver it must make sure the buffers are
  766. * truly ready and that the ownership bits are set properly.
  767. *
  768. * Even though GEM modifies the RX descriptors, it guarantees that the
  769. * buffer DMA address field will stay the same when it performs these
  770. * updates. Therefore it can be used to keep track of DMA mappings
  771. * by the host driver just as in the TX descriptor case above.
  772. */
  773. struct gem_rxd {
  774. __le64 status_word;
  775. __le64 buffer;
  776. };
  777. #define RXDCTRL_TCPCSUM 0x000000000000ffffULL /* TCP Pseudo-CSUM */
  778. #define RXDCTRL_BUFSZ 0x000000007fff0000ULL /* Buffer Size */
  779. #define RXDCTRL_OWN 0x0000000080000000ULL /* GEM owns this entry */
  780. #define RXDCTRL_HASHVAL 0x0ffff00000000000ULL /* Hash Value */
  781. #define RXDCTRL_HPASS 0x1000000000000000ULL /* Passed Hash Filter */
  782. #define RXDCTRL_ALTMAC 0x2000000000000000ULL /* Matched ALT MAC */
  783. #define RXDCTRL_BAD 0x4000000000000000ULL /* Frame has bad CRC */
  784. #define RXDCTRL_FRESH(gp) \
  785. ((((RX_BUF_ALLOC_SIZE(gp) - RX_OFFSET) << 16) & RXDCTRL_BUFSZ) | \
  786. RXDCTRL_OWN)
  787. #define TX_RING_SIZE 128
  788. #define RX_RING_SIZE 128
  789. #if TX_RING_SIZE == 32
  790. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_32
  791. #elif TX_RING_SIZE == 64
  792. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_64
  793. #elif TX_RING_SIZE == 128
  794. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_128
  795. #elif TX_RING_SIZE == 256
  796. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_256
  797. #elif TX_RING_SIZE == 512
  798. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_512
  799. #elif TX_RING_SIZE == 1024
  800. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_1K
  801. #elif TX_RING_SIZE == 2048
  802. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_2K
  803. #elif TX_RING_SIZE == 4096
  804. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_4K
  805. #elif TX_RING_SIZE == 8192
  806. #define TXDMA_CFG_BASE TXDMA_CFG_RINGSZ_8K
  807. #else
  808. #error TX_RING_SIZE value is illegal...
  809. #endif
  810. #if RX_RING_SIZE == 32
  811. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_32
  812. #elif RX_RING_SIZE == 64
  813. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_64
  814. #elif RX_RING_SIZE == 128
  815. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_128
  816. #elif RX_RING_SIZE == 256
  817. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_256
  818. #elif RX_RING_SIZE == 512
  819. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_512
  820. #elif RX_RING_SIZE == 1024
  821. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_1K
  822. #elif RX_RING_SIZE == 2048
  823. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_2K
  824. #elif RX_RING_SIZE == 4096
  825. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_4K
  826. #elif RX_RING_SIZE == 8192
  827. #define RXDMA_CFG_BASE RXDMA_CFG_RINGSZ_8K
  828. #else
  829. #error RX_RING_SIZE is illegal...
  830. #endif
  831. #define NEXT_TX(N) (((N) + 1) & (TX_RING_SIZE - 1))
  832. #define NEXT_RX(N) (((N) + 1) & (RX_RING_SIZE - 1))
  833. #define TX_BUFFS_AVAIL(GP) \
  834. (((GP)->tx_old <= (GP)->tx_new) ? \
  835. (GP)->tx_old + (TX_RING_SIZE - 1) - (GP)->tx_new : \
  836. (GP)->tx_old - (GP)->tx_new - 1)
  837. #define RX_OFFSET 2
  838. #define RX_BUF_ALLOC_SIZE(gp) ((gp)->rx_buf_sz + 28 + RX_OFFSET + 64)
  839. #define RX_COPY_THRESHOLD 256
  840. #if TX_RING_SIZE < 128
  841. #define INIT_BLOCK_TX_RING_SIZE 128
  842. #else
  843. #define INIT_BLOCK_TX_RING_SIZE TX_RING_SIZE
  844. #endif
  845. #if RX_RING_SIZE < 128
  846. #define INIT_BLOCK_RX_RING_SIZE 128
  847. #else
  848. #define INIT_BLOCK_RX_RING_SIZE RX_RING_SIZE
  849. #endif
  850. struct gem_init_block {
  851. struct gem_txd txd[INIT_BLOCK_TX_RING_SIZE];
  852. struct gem_rxd rxd[INIT_BLOCK_RX_RING_SIZE];
  853. };
  854. enum gem_phy_type {
  855. phy_mii_mdio0,
  856. phy_mii_mdio1,
  857. phy_serialink,
  858. phy_serdes,
  859. };
  860. enum link_state {
  861. link_down = 0, /* No link, will retry */
  862. link_aneg, /* Autoneg in progress */
  863. link_force_try, /* Try Forced link speed */
  864. link_force_ret, /* Forced mode worked, retrying autoneg */
  865. link_force_ok, /* Stay in forced mode */
  866. link_up /* Link is up */
  867. };
  868. struct gem {
  869. void __iomem *regs;
  870. int rx_new, rx_old;
  871. int tx_new, tx_old;
  872. unsigned int has_wol : 1; /* chip supports wake-on-lan */
  873. unsigned int asleep_wol : 1; /* was asleep with WOL enabled */
  874. int cell_enabled;
  875. u32 msg_enable;
  876. u32 status;
  877. struct napi_struct napi;
  878. int tx_fifo_sz;
  879. int rx_fifo_sz;
  880. int rx_pause_off;
  881. int rx_pause_on;
  882. int rx_buf_sz;
  883. u64 pause_entered;
  884. u16 pause_last_time_recvd;
  885. u32 mac_rx_cfg;
  886. u32 swrst_base;
  887. int want_autoneg;
  888. int last_forced_speed;
  889. enum link_state lstate;
  890. struct timer_list link_timer;
  891. int timer_ticks;
  892. int wake_on_lan;
  893. struct work_struct reset_task;
  894. volatile int reset_task_pending;
  895. enum gem_phy_type phy_type;
  896. struct mii_phy phy_mii;
  897. int mii_phy_addr;
  898. struct gem_init_block *init_block;
  899. struct sk_buff *rx_skbs[RX_RING_SIZE];
  900. struct sk_buff *tx_skbs[TX_RING_SIZE];
  901. dma_addr_t gblock_dvma;
  902. struct pci_dev *pdev;
  903. struct net_device *dev;
  904. #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_SPARC)
  905. struct device_node *of_node;
  906. #endif
  907. };
  908. #define found_mii_phy(gp) ((gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) && \
  909. gp->phy_mii.def && gp->phy_mii.def->ops)
  910. #endif /* _SUNGEM_H */