ether_bf537.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #define PHYADDR 0x01
  2. #define NO_PHY_REGS 0x20
  3. #define DEFAULT_PHY_PHYID1 0x0007
  4. #define DEFAULT_PHY_PHYID2 0xC0A3
  5. #define PHY_MODECTL 0x00
  6. #define PHY_MODESTAT 0x01
  7. #define PHY_PHYID1 0x02
  8. #define PHY_PHYID2 0x03
  9. #define PHY_ANAR 0x04
  10. #define PHY_ANLPAR 0x05
  11. #define PHY_ANER 0x06
  12. #define PHY_RESET 0x8000
  13. #define PHY_ANEG_EN 0x1000
  14. #define PHY_DUPLEX 0x0100
  15. #define PHY_SPD_SET 0x2000
  16. #define RECV_BUFSIZE (0x614)
  17. typedef volatile u32 reg32;
  18. typedef volatile u16 reg16;
  19. typedef struct ADI_DMA_CONFIG_REG {
  20. u16 b_DMA_EN:1; /* 0 Enabled */
  21. u16 b_WNR:1; /* 1 Direction */
  22. u16 b_WDSIZE:2; /* 2:3 Transfer word size */
  23. u16 b_DMA2D:1; /* 4 DMA mode */
  24. u16 b_RESTART:1; /* 5 Retain FIFO */
  25. u16 b_DI_SEL:1; /* 6 Data interrupt timing select */
  26. u16 b_DI_EN:1; /* 7 Data interrupt enabled */
  27. u16 b_NDSIZE:4; /* 8:11 Flex descriptor size */
  28. u16 b_FLOW:3; /* 12:14Flow */
  29. } ADI_DMA_CONFIG_REG;
  30. typedef struct adi_ether_frame_buffer {
  31. u16 NoBytes; /* the no. of following bytes */
  32. u8 Dest[6]; /* destination MAC address */
  33. u8 Srce[6]; /* source MAC address */
  34. u16 LTfield; /* length/type field */
  35. u8 Data[0]; /* payload bytes */
  36. } ADI_ETHER_FRAME_BUFFER;
  37. /* 16 bytes/struct */
  38. typedef struct dma_descriptor {
  39. struct dma_descriptor *NEXT_DESC_PTR;
  40. u32 START_ADDR;
  41. ADI_DMA_CONFIG_REG CONFIG;
  42. } DMA_DESCRIPTOR;
  43. /* 10 bytes/struct in 12 bytes */
  44. typedef struct adi_ether_buffer {
  45. DMA_DESCRIPTOR Dma[2]; /* first for the frame, second for the status */
  46. ADI_ETHER_FRAME_BUFFER *FrmData;/* pointer to data */
  47. struct adi_ether_buffer *pNext; /* next buffer */
  48. struct adi_ether_buffer *pPrev; /* prev buffer */
  49. u16 IPHdrChksum; /* the IP header checksum */
  50. u16 IPPayloadChksum; /* the IP header and payload checksum */
  51. volatile u32 StatusWord; /* the frame status word */
  52. } ADI_ETHER_BUFFER;
  53. /* 40 bytes/struct in 44 bytes */
  54. void SetupMacAddr(u8 * MACaddr);
  55. void PollMdcDone(void);
  56. void WrPHYReg(u16 PHYAddr, u16 RegAddr, u16 Data);
  57. u16 RdPHYReg(u16 PHYAddr, u16 RegAddr);
  58. void SoftResetPHY(void);
  59. void DumpPHYRegs(void);
  60. int SetupSystemRegs(int *opmode);
  61. /**
  62. * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
  63. * @addr: Pointer to a six-byte array containing the Ethernet address
  64. *
  65. * Return true if the address is all zeroes.
  66. */
  67. static inline int is_zero_ether_addr(const u8 * addr)
  68. {
  69. return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
  70. }
  71. /**
  72. * is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
  73. * @addr: Pointer to a six-byte array containing the Ethernet address
  74. *
  75. * Return true if the address is a multicast address.
  76. * By definition the broadcast address is also a multicast address.
  77. */
  78. static inline int is_multicast_ether_addr(const u8 * addr)
  79. {
  80. return (0x01 & addr[0]);
  81. }
  82. /**
  83. * is_valid_ether_addr - Determine if the given Ethernet address is valid
  84. * @addr: Pointer to a six-byte array containing the Ethernet address
  85. *
  86. * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
  87. * a multicast address, and is not FF:FF:FF:FF:FF:FF.
  88. *
  89. * Return true if the address is valid.
  90. */
  91. static inline int is_valid_ether_addr(const u8 * addr)
  92. {
  93. /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
  94. * explicitly check for it here. */
  95. return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
  96. }