mii.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. mii.h
  5. Abstract:
  6. This header contains definitions for the Media Independent Interface, a
  7. register set commonly used on networking PHYs.
  8. Author:
  9. Evan Green 8-Dec-2014
  10. --*/
  11. //
  12. // ------------------------------------------------------------------- Includes
  13. //
  14. //
  15. // ---------------------------------------------------------------- Definitions
  16. //
  17. #define MII_PHY_COUNT 32
  18. //
  19. // Define MII Basic Control register bits.
  20. //
  21. #define MII_BASIC_CONTROL_SPEED_1000 0x0040
  22. #define MII_BASIC_CONTROL_COLLISION_TEST 0x0080
  23. #define MII_BASIC_CONTROL_FULL_DUPLEX 0x0100
  24. #define MII_BASIC_CONTROL_RESTART_AUTONEGOTIATION 0x0200
  25. #define MII_BASIC_CONTROL_ISOLATE 0x0400
  26. #define MII_BASIC_CONTROL_POWER_DOWN 0x0800
  27. #define MII_BASIC_CONTROL_ENABLE_AUTONEGOTIATION 0x1000
  28. #define MII_BASIC_CONTROL_SPEED_100 0x2000
  29. #define MII_BASIC_CONTROL_LOOPBACK 0x4000
  30. #define MII_BASIC_CONTROL_RESET 0x8000
  31. //
  32. // Define MII Basic Status register bits.
  33. //
  34. #define MII_BASIC_STATUS_EXTENDED_CAPABILITY 0x0001
  35. #define MII_BASIC_STATUS_JABBER_DETECTED 0x0002
  36. #define MII_BASIC_STATUS_LINK_STATUS 0x0004
  37. #define MII_BASIC_STATUS_AUTONEGOTIATE_CAPABLE 0x0008
  38. #define MII_BASIC_STATUS_REMOTE_FAULT 0x0010
  39. #define MII_BASIC_STATUS_AUTONEGOTIATE_COMPLETE 0x0020
  40. #define MII_BASIC_STATUS_PREAMBLE_SUPPRESSION 0x0040
  41. //
  42. // This bit is set if there is extended status in register 0x0F.
  43. //
  44. #define MII_BASIC_STATUS_EXTENDED_STATUS 0x0100
  45. //
  46. // This bit is set if the PHY can do 100BASE-T2 half-duplex.
  47. //
  48. #define MII_BASIC_STATUS_100_HALF2 0x0200
  49. //
  50. // This bit is set if the PHY can do 100BASE-T2 full-duplex.
  51. //
  52. #define MII_BASIC_STATUS_100_FULL2 0x0400
  53. //
  54. // This bit is set if the PHY can do 10 Mbps half-duplex.
  55. //
  56. #define MII_BASIC_STATUS_10_HALF 0x0800
  57. //
  58. // This bit is set if the PHY can do 10 Mbps full-duplex.
  59. //
  60. #define MII_BASIC_STATUS_10_FULL 0x1000
  61. //
  62. // This bit is set if the PHY can do 100 Mbps, half-duplex.
  63. //
  64. #define MII_BASIC_STATUS_100_HALF 0x2000
  65. //
  66. // This bit is set if the PHY can do 100 Mbps, full-duplex.
  67. //
  68. #define MII_BASIC_STATUS_100_FULL 0x4000
  69. //
  70. // This bit is set if the PHY can do 100 Mbps with 4k packets.
  71. //
  72. #define MII_BASIC_STATUS_100_BASE4 0x8000
  73. #define MII_BASIC_STATUS_MEDIA_MASK \
  74. (MII_BASIC_STATUS_100_HALF2 | \
  75. MII_BASIC_STATUS_100_FULL2 | \
  76. MII_BASIC_STATUS_10_HALF | \
  77. MII_BASIC_STATUS_10_FULL | \
  78. MII_BASIC_STATUS_100_HALF | \
  79. MII_BASIC_STATUS_100_FULL | \
  80. MII_BASIC_STATUS_100_BASE4)
  81. //
  82. // Define MII Advertise register bits.
  83. //
  84. #define MII_ADVERTISE_SELECT_MASK 0x001F
  85. #define MII_ADVERTISE_CSMA 0x0001
  86. #define MII_ADVERTISE_10_HALF 0x0020
  87. #define MII_ADVERTISE_1000X_FULL 0x0020
  88. #define MII_ADVERTISE_10_FULL 0x0040
  89. #define MII_ADVERTISE_1000X_HALF 0x0040
  90. #define MII_ADVERTISE_100_HALF 0x0080
  91. #define MII_ADVERTISE_1000X_PAUSE 0x0080
  92. #define MII_ADVERTISE_100_FULL 0x0100
  93. #define MII_ADVERTISE_1000X_PAUSE_ASYMMETRIC 0x0100
  94. #define MII_ADVERTISE_100_BASE4 0x0200
  95. #define MII_ADVERTISE_PAUSE 0x0400
  96. #define MII_ADVERTISE_PAUSE_ASYMMETRIC 0x0800
  97. #define MII_ADVERTISE_REMOTE_FAULT 0x2000
  98. #define MII_ADVERTISE_LINK_PARTNER 0x4000
  99. #define MII_ADVERTISE_NEXT_PAGE 0x8000
  100. #define MII_ADVERTISE_FULL \
  101. (MII_ADVERTISE_100_FULL | MII_ADVERTISE_10_FULL | MII_ADVERTISE_CSMA)
  102. #define MII_ADVERTISE_ALL \
  103. (MII_ADVERTISE_10_HALF | MII_ADVERTISE_10_FULL | \
  104. MII_ADVERTISE_100_HALF | MII_ADVERTISE_100_FULL)
  105. //
  106. // Define MII Gigabit control register bits.
  107. //
  108. #define MII_GIGABIT_CONTROL_MANUAL_MASTER 0x1000
  109. #define MII_GIGABIT_CONTROL_ADVANCED_MASTER 0x0800
  110. #define MII_GIGABIT_CONTROL_ADVERTISE_1000_FULL 0x0200
  111. #define MII_GIGABIT_CONTROL_ADVERTISE_1000_HALF 0x0100
  112. //
  113. // Define MII Gigabit status register bits.
  114. //
  115. #define MII_GIGABIT_STATUS_ASYMMETRIC_PAUSE_CAPABLE 0x0200
  116. #define MII_GIGABIT_STATUS_PARTNER_1000_HALF 0x0400
  117. #define MII_GIGABIT_STATUS_PARTNER_1000_FULL 0x0800
  118. #define MII_GIGABIT_STATUS_REMOTE_RX_STATUS 0x1000
  119. #define MII_GIGABIT_STATUS_LOCAL_RX_STATUS 0x2000
  120. #define MII_GIGABIT_STATUS_MASTER 0x4000
  121. #define MII_GIGABIT_STATUS_MASTER_SLAVE_FAULT 0x8000
  122. //
  123. // ------------------------------------------------------ Data Type Definitions
  124. //
  125. typedef enum _MII_REGISTER {
  126. MiiRegisterBasicControl = 0x00, // BMCR
  127. MiiRegisterBasicStatus = 0x01, // BMSR
  128. MiiRegisterPhysicalId1 = 0x02, // PHYSID1
  129. MiiRegisterPhysicalId2 = 0x03, // PHYSID2
  130. MiiRegisterAdvertise = 0x04, // ADVERTISE
  131. MiiRegisterLinkPartnerAbility = 0x05, // LPA
  132. MiiRegisterExpansion = 0x06, // EXPANSION
  133. MiiRegisterGigabitControl = 0x09, // CTRL1000
  134. MiiRegisterGigabitStatus = 0x0A, // STAT1000
  135. MiiRegisterExtendedStatus = 0x0F, // ESTATUS
  136. MiiRegisterDisconnectCounter = 0x12, // DCOUNTER
  137. MiiRegisterFalseCarrierCounter = 0x13, // FCSCOUNTER
  138. MiiRegisterNWayTest = 0x14, // NWAYTEST
  139. MiiRegisterReceiveErrorCounter = 0x15, // RERRCOUNTER
  140. MiiRegisterSiliconRevision = 0x16, // SREVISION
  141. MiiRegisterLoopbackReceiveBypassError = 0x18, // LBRERROR
  142. MiiRegisterPhyAddress = 0x19, // PHYADDR
  143. MiiRegisterTpiStatus = 0x1B, // TPISTATUS
  144. MiiRegisterNetworkConfiguration = 0x1C, // NCONFIG
  145. } MII_REGISTER, *PMII_REGISTER;
  146. //
  147. // -------------------------------------------------------------------- Globals
  148. //
  149. //
  150. // -------------------------------------------------------- Function Prototypes
  151. //