chry_mii.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef CHRY_MII_H
  7. #define CHRY_MII_H
  8. /* Generic MII registers. */
  9. #define MII_BMCR 0x00 /* Basic Mode Control Register */
  10. #define MII_BMSR 0x01 /* Basic Mode Status Register */
  11. #define MII_PHYSID1 0x02 /* PHY Identifier Register #1 */
  12. #define MII_PHYSID2 0x03 /* PHY Identifier Register #2 */
  13. #define MII_ANAR 0x04 /* Auto-Negotiation Advertisement Register */
  14. #define MII_ANLPAR 0x05 /* Auto-Negotiation Link Partner Ability Register */
  15. #define MII_ANER 0x06 /* Auto-Negotiate Expansion Register */
  16. #define MII_ANNPTR 0x07 /* Auto-Negotiation Next Page Transmit Register */
  17. #define MII_ANNPRR 0x08 /* Auto-Negotiation Next Page Receive Register */
  18. #define MII_GBCR 0x09 /* 1000Base-T Control Register */
  19. #define MII_GBSR 0x0a /* 1000Base-T Status Register */
  20. #define MII_GBESR 0x0f /* 1000Base-T Extended Status Register */
  21. /* Basic Mode Control Register. */
  22. #define BMCR_RESET (1 << 15) /* Reset to default state */
  23. #define BMCR_LOOPBACK (1 << 14) /* TXD loopback bits */
  24. #define BMCR_SPEED100 (1 << 13) /* Select 100Mbps or 10Mbps */
  25. #define BMCR_ANENABLE (1 << 12) /* Enable auto negotiation */
  26. #define BMCR_POWERDOWN (1 << 11) /* Enable low power state */
  27. #define BMCR_ISOLATE (1 << 10) /* Isolate data paths from MII */
  28. #define BMCR_ANRESTART (1 << 9) /* Auto negotiation restart */
  29. #define BMCR_FULLDPLX (1 << 8) /* Full duplex */
  30. #define BMCR_CTST (1 << 7) /* Collision test */
  31. #define BMCR_SPEED1000 (1 << 6) /* MSB of Speed (1000) */
  32. #define BMCR_RESV 0x003f /* Unused... */
  33. /* Basic Mode Status Register. */
  34. #define BMSR_100T4 (1 << 15) /* Enable 100Base-T4 support */
  35. #define BMSR_100FULL (1 << 14) /* Enable 100Base-TX full duplex support */
  36. #define BMSR_100HALF (1 << 13) /* Enable 100Base-TX half duplex support */
  37. #define BMSR_10FULL (1 << 12) /* Enable 10Base-TX full duplex support */
  38. #define BMSR_10HALF (1 << 11) /* Enable 10Base-TX half duplex support */
  39. #define BMSR_100HALF2 (1 << 10) /* Can do 100BASE-T2 HDX */
  40. #define BMSR_100FULL2 (1 << 9) /* Can do 100BASE-T2 FDX */
  41. #define BMSR_ESTATEN (1 << 8) /* Extended Status in R15 */
  42. #define BMSR_ANEGCOMPLETE (1 << 5) /* Auto-negotiation complete */
  43. #define BMSR_REMOTEFAULT (1 << 4) /* Remote fault detected */
  44. #define BMSR_ANEGCAPABLE (1 << 3) /* Able to do auto-negotiation */
  45. #define BMSR_LINKSTATUS (1 << 2) /* Link status */
  46. #define BMSR_JCD (1 << 1) /* Jabber detected */
  47. #define BMSR_ERCAP (1 << 0) /* Ext-reg capability */
  48. /* Auto-Negotiation Advertisement Register. */
  49. #define ANAR_NPAGE (1 << 15) /* Next page bit */
  50. #define ANAR_ACK (1 << 14) /* Link partner acknowledges reception of local node’s capability data word */
  51. #define ANAR_REMOTEFAULT (1 << 13) /* Link partner is indicating a remote fault */
  52. #define ANAR_ASYM_PAUSE (1 << 11) /* Try for asymetric pause */
  53. #define ANAR_PAUSE (1 << 10) /* Try for pause */
  54. #define ANAR_100T4 (1 << 9) /* 100Base-T4 is supported by local mode */
  55. #define ANAR_100FULL (1 << 8) /* 100Base-TX full duplex is supported by local mode */
  56. #define ANAR_100HALF (1 << 7) /* 100Base-TX half duplex is supported by local mode */
  57. #define ANAR_10FULL (1 << 6) /* 10Base-TX full duplex is supported by local mode */
  58. #define ANAR_10HALF (1 << 5) /* 10Base-TX half duplex is supported by local mode */
  59. #define ANAR_SLCT 0x001f /* Selector bits */
  60. #define ANAR_CSMA 0x0001 /* Only selector supported */
  61. #define ANAR_SPEED_ALL (ANAR_10HALF | ANAR_10FULL | \
  62. ANAR_100HALF | ANAR_100FULL)
  63. /* Auto-Negotiation Link Partner Ability Register. */
  64. #define ANLPAR_NPAGE (1 << 15) /* Next page bit */
  65. #define ANLPAR_ACK (1 << 14) /* Link partner acknowledges reception of local node’s capability data word */
  66. #define ANLPAR_REMOTEFAULT (1 << 13) /* Link partner is indicating a remote fault */
  67. #define ANLPAR_ASYM_PAUSE (1 << 11) /* Try for asymetric pause */
  68. #define ANLPAR_PAUSE (1 << 10) /* Try for pause */
  69. #define ANLPAR_100T4 (1 << 9) /* 100Base-T4 is supported by local mode */
  70. #define ANLPAR_100FULL (1 << 8) /* 100Base-TX full duplex is supported by local mode */
  71. #define ANLPAR_100HALF (1 << 7) /* 100Base-TX half duplex is supported by local mode */
  72. #define ANLPAR_10FULL (1 << 6) /* 10Base-TX full duplex is supported by local mode */
  73. #define ANLPAR_10HALF (1 << 5) /* 10Base-TX half duplex is supported by local mode */
  74. #define ANLPAR_SLCT 0x001f /* Selector bits */
  75. #define ANLPAR_CSMA 0x0001 /* Only selector supported */
  76. /* 1000Base-T Control Register */
  77. #define GBCR_1000FULL 0x0200 /* Advertise 1000BASE-T full duplex */
  78. #define GBCR_1000HALF 0x0100 /* Advertise 1000BASE-T half duplex */
  79. #define GBCR_PREFER_MASTER 0x0400 /* prefer to operate as master */
  80. #define GBCR_AS_MASTER 0x0800
  81. #define GBCR_ENABLE_MASTER 0x1000
  82. /* 1000Base-T Status Register */
  83. #define GBSR_1000MSFAIL 0x8000 /* Master/Slave resolution failure */
  84. #define GBSR_1000MSRES 0x4000 /* Master/Slave resolution status */
  85. #define GBSR_1000LOCALRXOK 0x2000 /* Link partner local receiver status */
  86. #define GBSR_1000REMRXOK 0x1000 /* Link partner remote receiver status */
  87. #define GBSR_1000FULL 0x0800 /* Link partner 1000BASE-T full duplex */
  88. #define GBSR_1000HALF 0x0400 /* Link partner 1000BASE-T half duplex */
  89. /* 1000Base-T Extended Status Register */
  90. #define GBESR_1000_XFULL 0x8000 /* Can do 1000BaseX Full */
  91. #define GBESR_1000_XHALF 0x4000 /* Can do 1000BaseX Half */
  92. #define GBESR_1000_TFULL 0x2000 /* Can do 1000BT Full */
  93. #define GBESR_1000_THALF 0x1000 /* Can do 1000BT Half */
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif