eth_phy_regs_struct.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Copyright 2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdint.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /******************Basic PHY Registers*******************/
  20. /**
  21. * @brief BMCR(Basic Mode Control Register)
  22. *
  23. */
  24. typedef union {
  25. struct {
  26. uint32_t reserved : 7; /*!< Reserved */
  27. uint32_t collision_test : 1; /*!< Collision test */
  28. uint32_t duplex_mode : 1; /*!< Duplex mode:Full Duplex(1) and Half Duplex(0) */
  29. uint32_t restart_auto_nego : 1; /*!< Restart auto-negotiation */
  30. uint32_t isolate : 1; /*!< Isolate the PHY from MII except the SMI interface */
  31. uint32_t power_down : 1; /*!< Power off PHY except SMI interface */
  32. uint32_t en_auto_nego : 1; /*!< Enable auto negotiation */
  33. uint32_t speed_select : 1; /*!< Select speed: 100Mbps(1) and 10Mbps(0) */
  34. uint32_t en_loopback : 1; /*!< Enables transmit data to be routed to the receive path */
  35. uint32_t reset : 1; /*!< Reset PHY registers. This bit is self-clearing. */
  36. };
  37. uint32_t val;
  38. } bmcr_reg_t;
  39. #define ETH_PHY_BMCR_REG_ADDR (0x00)
  40. /**
  41. * @brief BMSR(Basic Mode Status Register)
  42. *
  43. */
  44. typedef union {
  45. struct {
  46. uint32_t ext_capability : 1; /*!< Extended register capability */
  47. uint32_t jabber_detect : 1; /*!< Jabber condition detected */
  48. uint32_t link_status : 1; /*!< Link status */
  49. uint32_t auto_nego_ability : 1; /*!< Auto negotiation ability */
  50. uint32_t remote_fault : 1; /*!< Remote fault detected */
  51. uint32_t auto_nego_complete : 1; /*!< Auto negotiation completed */
  52. uint32_t mf_preamble_suppress : 1; /*!< Preamble suppression capability for management frame */
  53. uint32_t reserved : 1; /*!< Reserved */
  54. uint32_t ext_status : 1; /*!< Extended Status */
  55. uint32_t base100_t2_hdx : 1; /*!< 100Base-T2 Half Duplex capability */
  56. uint32_t base100_t2_fdx : 1; /*!< 100Base-T2 Full Duplex capability */
  57. uint32_t base10_t_hdx : 1; /*!< 10Base-T Half Duplex capability */
  58. uint32_t base10_t_fdx : 1; /*!< 10Base-T Full Duplex capability */
  59. uint32_t base100_tx_hdx : 1; /*!< 100Base-Tx Half Duplex capability */
  60. uint32_t base100_tx_fdx : 1; /*!< 100Base-Tx Full Duplex capability */
  61. uint32_t based100_t4 : 1; /*!< 100Base-T4 capability */
  62. };
  63. uint32_t val;
  64. } bmsr_reg_t;
  65. #define ETH_PHY_BMSR_REG_ADDR (0x01)
  66. /**
  67. * @brief PHYIDR1(PHY Identifier Register 1)
  68. *
  69. */
  70. typedef union {
  71. struct {
  72. uint32_t oui_msb : 16; /*!< Organizationally Unique Identifier(OUI) most significant bits */
  73. };
  74. uint32_t val;
  75. } phyidr1_reg_t;
  76. #define ETH_PHY_IDR1_REG_ADDR (0x02)
  77. /**
  78. * @brief PHYIDR2(PHY Identifier Register 2)
  79. *
  80. */
  81. typedef union {
  82. struct {
  83. uint32_t model_revision : 4; /*!< Model revision number */
  84. uint32_t vendor_model : 6; /*!< Vendor model number */
  85. uint32_t oui_lsb : 6; /*!< Organizationally Unique Identifier(OUI) least significant bits */
  86. };
  87. uint32_t val;
  88. } phyidr2_reg_t;
  89. #define ETH_PHY_IDR2_REG_ADDR (0x03)
  90. /**
  91. * @brief ANAR(Auto-Negotiation Advertisement Register)
  92. *
  93. */
  94. typedef union {
  95. struct {
  96. uint32_t protocol_select : 5; /*!< Binary encoded selector supported by this PHY */
  97. uint32_t base10_t : 1; /*!< 10Base-T support */
  98. uint32_t base10_t_fd : 1; /*!< 10Base-T full duplex support */
  99. uint32_t base100_tx : 1; /*!< 100Base-TX support */
  100. uint32_t base100_tx_fd : 1; /*!< 100Base-TX full duplex support */
  101. uint32_t base100_t4 : 1; /*!< 100Base-T4 support */
  102. uint32_t symmetric_pause : 1; /*!< Symmetric pause support for full duplex links */
  103. uint32_t asymmetric_pause : 1; /*!< Asymmetric pause support for full duplex links */
  104. uint32_t reserved1 : 1; /*!< Reserved */
  105. uint32_t remote_fault : 1; /*!< Advertise remote fault detection capability */
  106. uint32_t acknowledge : 1; /*!< Link partner ability data reception acknowledged */
  107. uint32_t next_page : 1; /*!< Next page indication, if set, next page transfer is desired */
  108. };
  109. uint32_t val;
  110. } anar_reg_t;
  111. #define ETH_PHY_ANAR_REG_ADDR (0x04)
  112. /**
  113. * @brief ANLPAR(Auto-Negotiation Link Partner Ability Register)
  114. *
  115. */
  116. typedef union {
  117. struct {
  118. uint32_t protocol_select : 5; /*!< Link Partner’s binary encoded node selector */
  119. uint32_t base10_t : 1; /*!< 10Base-T support */
  120. uint32_t base10_t_fd : 1; /*!< 10Base-T full duplex support */
  121. uint32_t base100_tx : 1; /*!< 100Base-TX support */
  122. uint32_t base100_tx_fd : 1; /*!< 100Base-TX full duplex support */
  123. uint32_t base100_t4 : 1; /*!< 100Base-T4 support */
  124. uint32_t symmetric_pause : 1; /*!< Symmetric pause supported by Link Partner */
  125. uint32_t asymmetric_pause : 1; /*!< Asymmetric pause supported by Link Partner */
  126. uint32_t reserved : 1; /*!< Reserved */
  127. uint32_t remote_fault : 1; /*!< Link partner is indicating a remote fault */
  128. uint32_t acknowledge : 1; /*!< Acknowledges from link partner */
  129. uint32_t next_page : 1; /*!< Next page indication */
  130. };
  131. uint32_t val;
  132. } anlpar_reg_t;
  133. #define ETH_PHY_ANLPAR_REG_ADDR (0x05)
  134. /**
  135. * @brief ANER(Auto-Negotiate Expansion Register)
  136. *
  137. */
  138. typedef union {
  139. struct {
  140. uint32_t link_partner_auto_nego_able : 1; /*!< Link partner auto-negotiation ability */
  141. uint32_t link_page_received : 1; /*!< Link code word page has received */
  142. uint32_t next_page_able : 1; /*!< Next page ablility */
  143. uint32_t link_partner_next_page_able : 1; /*!< Link partner next page ability */
  144. uint32_t parallel_detection_fault : 1; /*!< Parallel detection fault */
  145. uint32_t reserved : 11; /*!< Reserved */
  146. };
  147. uint32_t val;
  148. } aner_reg_t;
  149. #define ETH_PHY_ANER_REG_ADDR (0x06)
  150. #ifdef __cplusplus
  151. }
  152. #endif