miiphy.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*----------------------------------------------------------------------------+
  2. |
  3. | This source code has been made available to you by IBM on an AS-IS
  4. | basis. Anyone receiving this source is licensed under IBM
  5. | copyrights to use it in any way he or she deems fit, including
  6. | copying it, modifying it, compiling it, and redistributing it either
  7. | with or without modifications. No license under IBM patents or
  8. | patent applications is to be implied by the copyright license.
  9. |
  10. | Any user of this software should understand that IBM cannot provide
  11. | technical support for this software and will not be responsible for
  12. | any consequences resulting from the use of this software.
  13. |
  14. | Any person who transfers this source code or any derivative work
  15. | must include the IBM copyright notice, this paragraph, and the
  16. | preceding two paragraphs in the transferred software.
  17. |
  18. | COPYRIGHT I B M CORPORATION 1999
  19. | LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  20. +----------------------------------------------------------------------------*/
  21. /*----------------------------------------------------------------------------+
  22. |
  23. | File Name: miiphy.h
  24. |
  25. | Function: Include file defining PHY registers.
  26. |
  27. | Author: Mark Wisner
  28. |
  29. +----------------------------------------------------------------------------*/
  30. #ifndef _miiphy_h_
  31. #define _miiphy_h_
  32. #include <net.h>
  33. int miiphy_read (char *devname, unsigned char addr, unsigned char reg,
  34. unsigned short *value);
  35. int miiphy_write (char *devname, unsigned char addr, unsigned char reg,
  36. unsigned short value);
  37. int miiphy_info (char *devname, unsigned char addr, unsigned int *oui,
  38. unsigned char *model, unsigned char *rev);
  39. int miiphy_reset (char *devname, unsigned char addr);
  40. int miiphy_speed (char *devname, unsigned char addr);
  41. int miiphy_duplex (char *devname, unsigned char addr);
  42. int miiphy_is_1000base_x (char *devname, unsigned char addr);
  43. #ifdef CONFIG_SYS_FAULT_ECHO_LINK_DOWN
  44. int miiphy_link (char *devname, unsigned char addr);
  45. #endif
  46. void miiphy_init (void);
  47. void miiphy_register (char *devname,
  48. int (*read) (char *devname, unsigned char addr,
  49. unsigned char reg, unsigned short *value),
  50. int (*write) (char *devname, unsigned char addr,
  51. unsigned char reg, unsigned short value));
  52. int miiphy_set_current_dev (char *devname);
  53. char *miiphy_get_current_dev (void);
  54. void miiphy_listdev (void);
  55. #define BB_MII_DEVNAME "bbmii"
  56. int bb_miiphy_read (char *devname, unsigned char addr,
  57. unsigned char reg, unsigned short *value);
  58. int bb_miiphy_write (char *devname, unsigned char addr,
  59. unsigned char reg, unsigned short value);
  60. /* phy seed setup */
  61. #define AUTO 99
  62. #define _1000BASET 1000
  63. #define _100BASET 100
  64. #define _10BASET 10
  65. #define HALF 22
  66. #define FULL 44
  67. /* phy register offsets */
  68. #define PHY_BMCR 0x00
  69. #define PHY_BMSR 0x01
  70. #define PHY_PHYIDR1 0x02
  71. #define PHY_PHYIDR2 0x03
  72. #define PHY_ANAR 0x04
  73. #define PHY_ANLPAR 0x05
  74. #define PHY_ANER 0x06
  75. #define PHY_ANNPTR 0x07
  76. #define PHY_ANLPNP 0x08
  77. #define PHY_1000BTCR 0x09
  78. #define PHY_1000BTSR 0x0A
  79. #define PHY_EXSR 0x0F
  80. #define PHY_PHYSTS 0x10
  81. #define PHY_MIPSCR 0x11
  82. #define PHY_MIPGSR 0x12
  83. #define PHY_DCR 0x13
  84. #define PHY_FCSCR 0x14
  85. #define PHY_RECR 0x15
  86. #define PHY_PCSR 0x16
  87. #define PHY_LBR 0x17
  88. #define PHY_10BTSCR 0x18
  89. #define PHY_PHYCTRL 0x19
  90. /* PHY BMCR */
  91. #define PHY_BMCR_RESET 0x8000
  92. #define PHY_BMCR_LOOP 0x4000
  93. #define PHY_BMCR_100MB 0x2000
  94. #define PHY_BMCR_AUTON 0x1000
  95. #define PHY_BMCR_POWD 0x0800
  96. #define PHY_BMCR_ISO 0x0400
  97. #define PHY_BMCR_RST_NEG 0x0200
  98. #define PHY_BMCR_DPLX 0x0100
  99. #define PHY_BMCR_COL_TST 0x0080
  100. #define PHY_BMCR_SPEED_MASK 0x2040
  101. #define PHY_BMCR_1000_MBPS 0x0040
  102. #define PHY_BMCR_100_MBPS 0x2000
  103. #define PHY_BMCR_10_MBPS 0x0000
  104. /* phy BMSR */
  105. #define PHY_BMSR_100T4 0x8000
  106. #define PHY_BMSR_100TXF 0x4000
  107. #define PHY_BMSR_100TXH 0x2000
  108. #define PHY_BMSR_10TF 0x1000
  109. #define PHY_BMSR_10TH 0x0800
  110. #define PHY_BMSR_EXT_STAT 0x0100
  111. #define PHY_BMSR_PRE_SUP 0x0040
  112. #define PHY_BMSR_AUTN_COMP 0x0020
  113. #define PHY_BMSR_RF 0x0010
  114. #define PHY_BMSR_AUTN_ABLE 0x0008
  115. #define PHY_BMSR_LS 0x0004
  116. #define PHY_BMSR_JD 0x0002
  117. #define PHY_BMSR_EXT 0x0001
  118. /*phy ANLPAR */
  119. #define PHY_ANLPAR_NP 0x8000
  120. #define PHY_ANLPAR_ACK 0x4000
  121. #define PHY_ANLPAR_RF 0x2000
  122. #define PHY_ANLPAR_ASYMP 0x0800
  123. #define PHY_ANLPAR_PAUSE 0x0400
  124. #define PHY_ANLPAR_T4 0x0200
  125. #define PHY_ANLPAR_TXFD 0x0100
  126. #define PHY_ANLPAR_TX 0x0080
  127. #define PHY_ANLPAR_10FD 0x0040
  128. #define PHY_ANLPAR_10 0x0020
  129. #define PHY_ANLPAR_100 0x0380 /* we can run at 100 */
  130. /* phy ANLPAR 1000BASE-X */
  131. #define PHY_X_ANLPAR_NP 0x8000
  132. #define PHY_X_ANLPAR_ACK 0x4000
  133. #define PHY_X_ANLPAR_RF_MASK 0x3000
  134. #define PHY_X_ANLPAR_PAUSE_MASK 0x0180
  135. #define PHY_X_ANLPAR_HD 0x0040
  136. #define PHY_X_ANLPAR_FD 0x0020
  137. #define PHY_ANLPAR_PSB_MASK 0x001f
  138. #define PHY_ANLPAR_PSB_802_3 0x0001
  139. #define PHY_ANLPAR_PSB_802_9 0x0002
  140. /* phy 1000BTCR */
  141. #define PHY_1000BTCR_1000FD 0x0200
  142. #define PHY_1000BTCR_1000HD 0x0100
  143. /* phy 1000BTSR */
  144. #define PHY_1000BTSR_MSCF 0x8000
  145. #define PHY_1000BTSR_MSCR 0x4000
  146. #define PHY_1000BTSR_LRS 0x2000
  147. #define PHY_1000BTSR_RRS 0x1000
  148. #define PHY_1000BTSR_1000FD 0x0800
  149. #define PHY_1000BTSR_1000HD 0x0400
  150. /* phy EXSR */
  151. #define PHY_EXSR_1000XF 0x8000
  152. #define PHY_EXSR_1000XH 0x4000
  153. #define PHY_EXSR_1000TF 0x2000
  154. #define PHY_EXSR_1000TH 0x1000
  155. #endif