sam7x_emac.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __SAM7X_EMAC_H__
  2. #define __SAM7X_EMAC_H__
  3. //#define DM9161
  4. #define RTL8201
  5. #ifdef DM9161
  6. #define AT91C_PHY_ADDR 31
  7. #else
  8. #define AT91C_PHY_ADDR 0x01
  9. #endif
  10. #define MII_DM9161_ID 0x0181b8a0
  11. #define MII_RTL8201_ID 0x82010000
  12. /* RTL8201 PHY registers. */
  13. #define PHY_REG_BMCR 0x00 /* Basic mode control register */
  14. #define PHY_REG_BMSR 0x01 /* Basic mode status register */
  15. #define PHY_REG_PHYID1 0x02 /* PHY ID identifier #1 */
  16. #define PHY_REG_PHYID2 0x03 /* PHY ID identifier #2 */
  17. #define PHY_REG_ANAR 0x04 /* AutoNegotiation Advertisement reg.*/
  18. #define PHY_REG_ANLPAR 0x05 /* AutoNeg.Link partner ability reg */
  19. #define PHY_REG_ANER 0x06 /* AutoNeg. Expansion register */
  20. #define PHY_REG_DSCR 0x10 /* DAVICOM Specified Config. reg */
  21. #define PHY_REG_DSCSR 0x11 /* DAVICOM Spec. Config/Status reg */
  22. #define PHY_REG_10BTCSR 0x12 /* 10BASET Configuration/Status reg */
  23. #define PHY_REG_PWDOR 0x13 /* Power Down Control Register */
  24. #define PHY_REG_SCR 0x14 /* Specified Config register */
  25. #define PHY_REG_INTR 0x15 /* Interrupt register */
  26. #define PHY_REG_RECR 0x16 /* Receive Error Counter register */
  27. #define PHY_REG_DISCR 0x17 /* Disconnect Counter register */
  28. #define PHY_REG_RLSR 0x18 /* Hardware Reset Latch State reg. */
  29. /* Basic mode control register. */
  30. #define BMCR_RESV 0x007f /* Unused... */
  31. #define BMCR_CTST 0x0080 /* Collision test */
  32. #define BMCR_FULLDPLX 0x0100 /* Full duplex */
  33. #define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
  34. #define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
  35. #define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
  36. #define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
  37. #define BMCR_SPEED100 0x2000 /* Select 100Mbps */
  38. #define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
  39. #define BMCR_RESET 0x8000 /* Reset the DP83840 */
  40. #define PHY_FULLD_100M 0x2100 /* Full Duplex 100Mbit */
  41. #define PHY_HALFD_100M 0x2000 /* Half Duplex 100Mbit */
  42. #define PHY_FULLD_10M 0x0100 /* Full Duplex 10Mbit */
  43. #define PHY_HALFD_10M 0x0000 /* Half Duplex 10MBit */
  44. #define PHY_AUTO_NEG 0x3000 /* Select Auto Negotiation */
  45. /* Basic mode status register. */
  46. #define BMSR_ERCAP 0x0001 /* Ext-reg capability */
  47. #define BMSR_JCD 0x0002 /* Jabber detected */
  48. #define BMSR_LINKST 0x0004 /* Link status */
  49. #define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
  50. #define BMSR_RFAULT 0x0010 /* Remote fault detected */
  51. #define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  52. #define BMSR_MIIPRESUP 0x0040 /* MII Frame Preamble Suppression */
  53. #define BMSR_RESV 0x0780 /* Unused... */
  54. #define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
  55. #define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
  56. #define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
  57. #define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
  58. #define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
  59. #define RxDESC_FLAG_ADDR_MASK 0xfffffffc
  60. #define RxDESC_FLAG_WARP 0x00000002
  61. #define RxDESC_FLAG_OWNSHIP 0x00000001
  62. #define RxDESC_STATUS_BUF_SIZE (0x00000FFF)
  63. #define RxDESC_STATUS_FRAME_START (1U << 14)
  64. #define RxDESC_STATUS_FRAME_END (1U << 15)
  65. #define TxDESC_STATUS_BUF_SIZE (0x000007FF)
  66. #define TxDESC_STATUS_LAST_BUF (1U << 15)
  67. #define TxDESC_STATUS_NO_CRC (1U << 16)
  68. #define TxDESC_STATUS_BUF_EXHAUSTED (1U << 27)
  69. #define TxDESC_STATUS_Tx_UNDERRUN (1U << 28)
  70. #define TxDESC_STATUS_Tx_ERROR (1U << 29)
  71. #define TxDESC_STATUS_WRAP (1U << 30)
  72. #define TxDESC_STATUS_USED (1U << 31)
  73. //----dm9161 define----
  74. #define DM9161_RESET (1 << 15) // 1= Software Reset; 0=Normal Operation
  75. #define DM9161_LOOPBACK (1 << 14) // 1=loopback Enabled; 0=Normal Operation
  76. #define DM9161_SPEED_SELECT (1 << 13) // 1=100Mbps; 0=10Mbps
  77. #define DM9161_AUTONEG (1 << 12) // Auto-negotiation Enable
  78. #define DM9161_POWER_DOWN (1 << 11) // 1=Power down 0=Normal operation
  79. #define DM9161_ISOLATE (1 << 10) // 1 = Isolates 0 = Normal operation
  80. #define DM9161_RESTART_AUTONEG (1 << 9) // 1 = Restart auto-negotiation 0 = Normal operation
  81. #define DM9161_DUPLEX_MODE (1 << 8) // 1 = Full duplex operation 0 = Normal operation
  82. #define DM9161_COLLISION_TEST (1 << 7) // 1 = Collision test enabled 0 = Normal operation
  83. #define DM9161_NP (1 << 15) // Next page Indication
  84. #define DM9161_ACK (1 << 14) // Acknowledge
  85. #define DM9161_RF (1 << 13) // Remote Fault
  86. // Reserved 12 to 11 // Write as 0, ignore on read
  87. #define DM9161_FCS (1 << 10) // Flow Control Support
  88. #define DM9161_T4 (1 << 9) // 100BASE-T4 Support
  89. #define DM9161_TX_FDX (1 << 8) // 100BASE-TX Full Duplex Support
  90. #define DM9161_TX_HDX (1 << 7) // 100BASE-TX Support
  91. #define DM9161_10_FDX (1 << 6) // 10BASE-T Full Duplex Support
  92. #define DM9161_10_HDX (1 << 5) // 10BASE-T Support
  93. // Selector 4 to 0 // Protocol Selection Bits
  94. #define DM9161_AN_IEEE_802_3 0x0001
  95. int sam7xether_register(char *name);
  96. #endif