greth.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef GRETH_H
  2. #define GRETH_H
  3. #include <linux/phy.h>
  4. /* Register bits and masks */
  5. #define GRETH_RESET 0x40
  6. #define GRETH_MII_BUSY 0x8
  7. #define GRETH_MII_NVALID 0x10
  8. #define GRETH_CTRL_FD 0x10
  9. #define GRETH_CTRL_PR 0x20
  10. #define GRETH_CTRL_SP 0x80
  11. #define GRETH_CTRL_GB 0x100
  12. #define GRETH_CTRL_PSTATIEN 0x400
  13. #define GRETH_CTRL_MCEN 0x800
  14. #define GRETH_CTRL_DISDUPLEX 0x1000
  15. #define GRETH_STATUS_PHYSTAT 0x100
  16. #define GRETH_BD_EN 0x800
  17. #define GRETH_BD_WR 0x1000
  18. #define GRETH_BD_IE 0x2000
  19. #define GRETH_BD_LEN 0x7FF
  20. #define GRETH_TXEN 0x1
  21. #define GRETH_INT_TE 0x2
  22. #define GRETH_INT_TX 0x8
  23. #define GRETH_TXI 0x4
  24. #define GRETH_TXBD_STATUS 0x0001C000
  25. #define GRETH_TXBD_MORE 0x20000
  26. #define GRETH_TXBD_IPCS 0x40000
  27. #define GRETH_TXBD_TCPCS 0x80000
  28. #define GRETH_TXBD_UDPCS 0x100000
  29. #define GRETH_TXBD_CSALL (GRETH_TXBD_IPCS | GRETH_TXBD_TCPCS | GRETH_TXBD_UDPCS)
  30. #define GRETH_TXBD_ERR_LC 0x10000
  31. #define GRETH_TXBD_ERR_UE 0x4000
  32. #define GRETH_TXBD_ERR_AL 0x8000
  33. #define GRETH_INT_RE 0x1
  34. #define GRETH_INT_RX 0x4
  35. #define GRETH_RXEN 0x2
  36. #define GRETH_RXI 0x8
  37. #define GRETH_RXBD_STATUS 0xFFFFC000
  38. #define GRETH_RXBD_ERR_AE 0x4000
  39. #define GRETH_RXBD_ERR_FT 0x8000
  40. #define GRETH_RXBD_ERR_CRC 0x10000
  41. #define GRETH_RXBD_ERR_OE 0x20000
  42. #define GRETH_RXBD_ERR_LE 0x40000
  43. #define GRETH_RXBD_IP 0x80000
  44. #define GRETH_RXBD_IP_CSERR 0x100000
  45. #define GRETH_RXBD_UDP 0x200000
  46. #define GRETH_RXBD_UDP_CSERR 0x400000
  47. #define GRETH_RXBD_TCP 0x800000
  48. #define GRETH_RXBD_TCP_CSERR 0x1000000
  49. #define GRETH_RXBD_IP_FRAG 0x2000000
  50. #define GRETH_RXBD_MCAST 0x4000000
  51. /* Descriptor parameters */
  52. #define GRETH_TXBD_NUM 128
  53. #define GRETH_TXBD_NUM_MASK (GRETH_TXBD_NUM-1)
  54. #define GRETH_TX_BUF_SIZE 2048
  55. #define GRETH_RXBD_NUM 128
  56. #define GRETH_RXBD_NUM_MASK (GRETH_RXBD_NUM-1)
  57. #define GRETH_RX_BUF_SIZE 2048
  58. /* Buffers per page */
  59. #define GRETH_RX_BUF_PPGAE (PAGE_SIZE/GRETH_RX_BUF_SIZE)
  60. #define GRETH_TX_BUF_PPGAE (PAGE_SIZE/GRETH_TX_BUF_SIZE)
  61. /* How many pages are needed for buffers */
  62. #define GRETH_RX_BUF_PAGE_NUM (GRETH_RXBD_NUM/GRETH_RX_BUF_PPGAE)
  63. #define GRETH_TX_BUF_PAGE_NUM (GRETH_TXBD_NUM/GRETH_TX_BUF_PPGAE)
  64. /* Buffer size.
  65. * Gbit MAC uses tagged maximum frame size which is 1518 excluding CRC.
  66. * Set to 1520 to make all buffers word aligned for non-gbit MAC.
  67. */
  68. #define MAX_FRAME_SIZE 1520
  69. /* GRETH APB registers */
  70. struct greth_regs {
  71. u32 control;
  72. u32 status;
  73. u32 esa_msb;
  74. u32 esa_lsb;
  75. u32 mdio;
  76. u32 tx_desc_p;
  77. u32 rx_desc_p;
  78. u32 edclip;
  79. u32 hash_msb;
  80. u32 hash_lsb;
  81. };
  82. /* GRETH buffer descriptor */
  83. struct greth_bd {
  84. u32 stat;
  85. u32 addr;
  86. };
  87. struct greth_private {
  88. struct sk_buff *rx_skbuff[GRETH_RXBD_NUM];
  89. struct sk_buff *tx_skbuff[GRETH_TXBD_NUM];
  90. unsigned char *tx_bufs[GRETH_TXBD_NUM];
  91. unsigned char *rx_bufs[GRETH_RXBD_NUM];
  92. u16 tx_bufs_length[GRETH_TXBD_NUM];
  93. u16 tx_next;
  94. u16 tx_last;
  95. u16 tx_free; /* only used on 10/100Mbit */
  96. u16 rx_cur;
  97. struct greth_regs *regs; /* Address of controller registers. */
  98. struct greth_bd *rx_bd_base; /* Address of Rx BDs. */
  99. struct greth_bd *tx_bd_base; /* Address of Tx BDs. */
  100. dma_addr_t rx_bd_base_phys;
  101. dma_addr_t tx_bd_base_phys;
  102. int irq;
  103. struct device *dev; /* Pointer to platform_device->dev */
  104. struct net_device *netdev;
  105. struct napi_struct napi;
  106. spinlock_t devlock;
  107. struct phy_device *phy;
  108. struct mii_bus *mdio;
  109. int mdio_irqs[PHY_MAX_ADDR];
  110. unsigned int link;
  111. unsigned int speed;
  112. unsigned int duplex;
  113. u32 msg_enable;
  114. u8 phyaddr;
  115. u8 multicast;
  116. u8 gbit_mac;
  117. u8 mdio_int_en;
  118. u8 edcl;
  119. };
  120. #endif