rtl8366.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * (C) Copyright 2010
  3. * Michael Kurz <michi.kurz@googlemail.com>.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef RTL8366_MII_H
  24. #define RTL8366_MII_H
  25. #define MII_CONTROL_REG 0
  26. #define MII_STATUS_REG 1
  27. #define MII_PHY_ID0 2
  28. #define MII_PHY_ID1 3
  29. #define MII_LOCAL_CAP 4
  30. #define MII_REMOTE_CAP 5
  31. #define MII_EXT_AUTONEG 6
  32. #define MII_LOCAL_NEXT_PAGE 7
  33. #define MII_REMOTE_NEXT_PAGE 8
  34. #define MII_GIGA_CONTROL 9
  35. #define MII_GIGA_STATUS 10
  36. #define MII_EXT_STATUS_REG 15
  37. /* Control register */
  38. #define MII_CONTROL_1000MBPS 6
  39. #define MII_CONTROL_COLL_TEST 7
  40. #define MII_CONTROL_FULLDUPLEX 8
  41. #define MII_CONTROL_RENEG 9
  42. #define MII_CONTROL_ISOLATE 10
  43. #define MII_CONTROL_POWERDOWN 11
  44. #define MII_CONTROL_AUTONEG 12
  45. #define MII_CONTROL_100MBPS 13
  46. #define MII_CONTROL_LOOPBACK 14
  47. #define MII_CONTROL_RESET 15
  48. /* Status/Extended status register */
  49. /* Basic status */
  50. #define MII_STATUS_CAPABILITY 0
  51. #define MII_STATUS_JABBER 1
  52. #define MII_STATUS_LINK_UP 2
  53. #define MII_STATUS_AUTONEG_ABLE 3
  54. #define MII_STATUS_REMOTE_FAULT 4
  55. #define MII_STATUS_AUTONEG_DONE 5
  56. #define MII_STATUS_NO_PREAMBLE 6
  57. #define MII_STATUS_RESERVED 7
  58. #define MII_STATUS_EXTENDED 8
  59. #define MII_STATUS_100_T2_HALF 9
  60. #define MII_STATUS_100_T2_FULL 10
  61. #define MII_STATUS_10_TX_HALF 11
  62. #define MII_STATUS_10_TX_FULL 12
  63. #define MII_STATUS_100_TX_HALF 13
  64. #define MII_STATUS_100_TX_FULL 14
  65. #define MII_STATUS_100_T4 15
  66. #define MII_GIGA_CONTROL_HALF 8
  67. #define MII_GIGA_CONTROL_FULL 9
  68. #define MII_GIGA_STATUS_HALF 10
  69. #define MII_GIGA_STATUS_FULL 11
  70. /* Extended status */
  71. #define MII_STATUS_1000_T_HALF 12
  72. #define MII_STATUS_1000_T_FULL 13
  73. #define MII_STATUS_1000_X_HALF 14
  74. #define MII_STATUS_1000_X_FULL 15
  75. /* Local/Remmote capability register */
  76. #define MII_CAP_10BASE_TX 5
  77. #define MII_CAP_10BASE_TX_FULL 6
  78. #define MII_CAP_100BASE_TX 7
  79. #define MII_CAP_100BASE_TX_FULL 8
  80. #define MII_CAP_100BASE_T4 9
  81. #define MII_CAP_SYMM_PAUSE 10
  82. #define MII_CAP_ASYMM_PAUSE 11
  83. #define MII_CAP_RESERVED 12
  84. #define MII_CAP_REMOTE_FAULT 13
  85. #define MII_CAP_ACKNOWLEDGE 14
  86. #define MII_CAP_NEXT_PAGE 15
  87. #define MII_CAP_IEEE_802_3 0x0001
  88. #define MII_LINK_MODE_MASK 0x1f
  89. #define REALTEK_RTL8366_CHIP_ID0 0x001C
  90. #define REALTEK_RTL8366_CHIP_ID1 0xC940
  91. #define REALTEK_RTL8366_CHIP_ID1_MP 0xC960
  92. #define REALTEK_MIN_PORT_ID 0
  93. #define REALTEK_MAX_PORT_ID 5
  94. #define REALTEK_MIN_PHY_ID REALTEK_MIN_PORT_ID
  95. #define REALTEK_MAX_PHY_ID 4
  96. #define REALTEK_CPU_PORT_ID REALTEK_MAX_PORT_ID
  97. #define REALTEK_PHY_PORT_MASK ((1<<(REALTEK_MAX_PHY_ID+1)) - (1<<REALTEK_MIN_PHY_ID))
  98. #define REALTEK_CPU_PORT_MASK (1<<REALTEK_CPU_PORT_ID)
  99. #define REALTEK_ALL_PORT_MASK (REALTEK_PHY_PORT_MASK | REALTEK_CPU_PORT_MASK)
  100. /* port ability */
  101. #define RTL8366S_PORT_ABILITY_BASE 0x0011
  102. /* port vlan control register */
  103. #define RTL8366S_PORT_VLAN_CTRL_BASE 0x0058
  104. /* port linking status */
  105. #define RTL8366S_PORT_LINK_STATUS_BASE 0x0060
  106. #define RTL8366S_PORT_STATUS_SPEED_BIT 0
  107. #define RTL8366S_PORT_STATUS_SPEED_MSK 0x0003
  108. #define RTL8366S_PORT_STATUS_DUPLEX_BIT 2
  109. #define RTL8366S_PORT_STATUS_DUPLEX_MSK 0x0004
  110. #define RTL8366S_PORT_STATUS_LINK_BIT 4
  111. #define RTL8366S_PORT_STATUS_LINK_MSK 0x0010
  112. #define RTL8366S_PORT_STATUS_TXPAUSE_BIT 5
  113. #define RTL8366S_PORT_STATUS_TXPAUSE_MSK 0x0020
  114. #define RTL8366S_PORT_STATUS_RXPAUSE_BIT 6
  115. #define RTL8366S_PORT_STATUS_RXPAUSE_MSK 0x0040
  116. #define RTL8366S_PORT_STATUS_AN_BIT 7
  117. #define RTL8366S_PORT_STATUS_AN_MSK 0x0080
  118. /* internal control */
  119. #define RTL8366S_RESET_CONTROL_REG 0x0100
  120. #define RTL8366S_RESET_QUEUE_BIT 2
  121. #define RTL8366S_CHIP_ID_REG 0x0105
  122. /* MAC control */
  123. #define RTL8366S_MAC_FORCE_CTRL0_REG 0x0F04
  124. #define RTL8366S_MAC_FORCE_CTRL1_REG 0x0F05
  125. /* PHY registers control */
  126. #define RTL8366S_PHY_ACCESS_CTRL_REG 0x8028
  127. #define RTL8366S_PHY_ACCESS_DATA_REG 0x8029
  128. #define RTL8366S_PHY_CTRL_READ 1
  129. #define RTL8366S_PHY_CTRL_WRITE 0
  130. #define RTL8366S_PHY_REG_MASK 0x1F
  131. #define RTL8366S_PHY_PAGE_OFFSET 5
  132. #define RTL8366S_PHY_PAGE_MASK (0x7<<5)
  133. #define RTL8366S_PHY_NO_OFFSET 9
  134. #define RTL8366S_PHY_NO_MASK (0x1F<<9)
  135. #define RTL8366S_PHY_NO_MAX 4
  136. #define RTL8366S_PHY_PAGE_MAX 7
  137. #define RTL8366S_PHY_ADDR_MAX 31
  138. /* cpu port control reg */
  139. #define RTL8366S_CPU_CTRL_REG 0x004F
  140. #define RTL8366S_CPU_DRP_BIT 14
  141. #define RTL8366S_CPU_DRP_MSK 0x4000
  142. #define RTL8366S_CPU_INSTAG_BIT 15
  143. #define RTL8366S_CPU_INSTAG_MSK 0x8000
  144. /* LED registers*/
  145. #define RTL8366S_LED_BLINK_REG 0x420
  146. #define RTL8366S_LED_BLINKRATE_BIT 0
  147. #define RTL8366S_LED_BLINKRATE_MSK 0x0007
  148. #define RTL8366S_LED_INDICATED_CONF_REG 0x421
  149. #define RTL8366S_LED_0_1_FORCE_REG 0x422
  150. #define RTL8366S_LED_2_3_FORCE_REG 0x423
  151. #define RTL8366S_LEDCONF_LEDFORCE 0x1F
  152. #define RTL8366S_LED_GROUP_MAX 4
  153. #define RTL8366S_GREEN_FEATURE_REG 0x000A
  154. #define RTL8366S_GREEN_FEATURE_TX_BIT 3
  155. #define RTL8366S_GREEN_FEATURE_TX_MSK 0x0008
  156. #define RTL8366S_GREEN_FEATURE_RX_BIT 4
  157. #define RTL8366S_GREEN_FEATURE_RX_MSK 0x0010
  158. #define RTL8366S_MODEL_ID_REG 0x5C
  159. #define RTL8366S_REV_ID_REG 0x5D
  160. #define RTL8366S_MODEL_8366SR 0x6027
  161. #define RTL8366S_MODEL_8366RB 0x5937
  162. #endif