pasemi_mac.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 2006 PA Semi, Inc
  3. *
  4. * Driver for the PA6T-1682M onchip 1G/10G Ethernet MACs, soft state and
  5. * hardware register layouts.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef PASEMI_MAC_H
  21. #define PASEMI_MAC_H
  22. #include <linux/ethtool.h>
  23. #include <linux/netdevice.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/phy.h>
  26. struct pasemi_mac_txring {
  27. struct pasemi_dmachan chan; /* Must be first */
  28. spinlock_t lock;
  29. unsigned int size;
  30. unsigned int next_to_fill;
  31. unsigned int next_to_clean;
  32. struct pasemi_mac_buffer *ring_info;
  33. struct pasemi_mac *mac; /* Needed in intr handler */
  34. };
  35. struct pasemi_mac_rxring {
  36. struct pasemi_dmachan chan; /* Must be first */
  37. spinlock_t lock;
  38. u64 *buffers; /* RX interface buffer ring */
  39. dma_addr_t buf_dma;
  40. unsigned int size;
  41. unsigned int next_to_fill;
  42. unsigned int next_to_clean;
  43. struct pasemi_mac_buffer *ring_info;
  44. struct pasemi_mac *mac; /* Needed in intr handler */
  45. };
  46. struct pasemi_mac {
  47. struct net_device *netdev;
  48. struct pci_dev *pdev;
  49. struct pci_dev *dma_pdev;
  50. struct pci_dev *iob_pdev;
  51. struct phy_device *phydev;
  52. struct napi_struct napi;
  53. u8 type;
  54. #define MAC_TYPE_GMAC 1
  55. #define MAC_TYPE_XAUI 2
  56. u32 dma_if;
  57. u8 mac_addr[6];
  58. struct timer_list rxtimer;
  59. struct pasemi_mac_txring *tx;
  60. struct pasemi_mac_rxring *rx;
  61. char tx_irq_name[10]; /* "eth%d tx" */
  62. char rx_irq_name[10]; /* "eth%d rx" */
  63. int link;
  64. int speed;
  65. int duplex;
  66. unsigned int msg_enable;
  67. char phy_id[BUS_ID_SIZE];
  68. };
  69. /* Software status descriptor (ring_info) */
  70. struct pasemi_mac_buffer {
  71. struct sk_buff *skb;
  72. dma_addr_t dma;
  73. };
  74. /* PCI register offsets and formats */
  75. /* MAC CFG register offsets */
  76. enum {
  77. PAS_MAC_CFG_PCFG = 0x80,
  78. PAS_MAC_CFG_TXP = 0x98,
  79. PAS_MAC_IPC_CHNL = 0x208,
  80. };
  81. /* MAC CFG register fields */
  82. #define PAS_MAC_CFG_PCFG_PE 0x80000000
  83. #define PAS_MAC_CFG_PCFG_CE 0x40000000
  84. #define PAS_MAC_CFG_PCFG_BU 0x20000000
  85. #define PAS_MAC_CFG_PCFG_TT 0x10000000
  86. #define PAS_MAC_CFG_PCFG_TSR_M 0x0c000000
  87. #define PAS_MAC_CFG_PCFG_TSR_10M 0x00000000
  88. #define PAS_MAC_CFG_PCFG_TSR_100M 0x04000000
  89. #define PAS_MAC_CFG_PCFG_TSR_1G 0x08000000
  90. #define PAS_MAC_CFG_PCFG_TSR_10G 0x0c000000
  91. #define PAS_MAC_CFG_PCFG_T24 0x02000000
  92. #define PAS_MAC_CFG_PCFG_PR 0x01000000
  93. #define PAS_MAC_CFG_PCFG_CRO_M 0x00ff0000
  94. #define PAS_MAC_CFG_PCFG_CRO_S 16
  95. #define PAS_MAC_CFG_PCFG_IPO_M 0x0000ff00
  96. #define PAS_MAC_CFG_PCFG_IPO_S 8
  97. #define PAS_MAC_CFG_PCFG_S1 0x00000080
  98. #define PAS_MAC_CFG_PCFG_IO_M 0x00000060
  99. #define PAS_MAC_CFG_PCFG_IO_MAC 0x00000000
  100. #define PAS_MAC_CFG_PCFG_IO_OFF 0x00000020
  101. #define PAS_MAC_CFG_PCFG_IO_IND_ETH 0x00000040
  102. #define PAS_MAC_CFG_PCFG_IO_IND_IP 0x00000060
  103. #define PAS_MAC_CFG_PCFG_LP 0x00000010
  104. #define PAS_MAC_CFG_PCFG_TS 0x00000008
  105. #define PAS_MAC_CFG_PCFG_HD 0x00000004
  106. #define PAS_MAC_CFG_PCFG_SPD_M 0x00000003
  107. #define PAS_MAC_CFG_PCFG_SPD_10M 0x00000000
  108. #define PAS_MAC_CFG_PCFG_SPD_100M 0x00000001
  109. #define PAS_MAC_CFG_PCFG_SPD_1G 0x00000002
  110. #define PAS_MAC_CFG_PCFG_SPD_10G 0x00000003
  111. #define PAS_MAC_CFG_TXP_FCF 0x01000000
  112. #define PAS_MAC_CFG_TXP_FCE 0x00800000
  113. #define PAS_MAC_CFG_TXP_FC 0x00400000
  114. #define PAS_MAC_CFG_TXP_FPC_M 0x00300000
  115. #define PAS_MAC_CFG_TXP_FPC_S 20
  116. #define PAS_MAC_CFG_TXP_FPC(x) (((x) << PAS_MAC_CFG_TXP_FPC_S) & \
  117. PAS_MAC_CFG_TXP_FPC_M)
  118. #define PAS_MAC_CFG_TXP_RT 0x00080000
  119. #define PAS_MAC_CFG_TXP_BL 0x00040000
  120. #define PAS_MAC_CFG_TXP_SL_M 0x00030000
  121. #define PAS_MAC_CFG_TXP_SL_S 16
  122. #define PAS_MAC_CFG_TXP_SL(x) (((x) << PAS_MAC_CFG_TXP_SL_S) & \
  123. PAS_MAC_CFG_TXP_SL_M)
  124. #define PAS_MAC_CFG_TXP_COB_M 0x0000f000
  125. #define PAS_MAC_CFG_TXP_COB_S 12
  126. #define PAS_MAC_CFG_TXP_COB(x) (((x) << PAS_MAC_CFG_TXP_COB_S) & \
  127. PAS_MAC_CFG_TXP_COB_M)
  128. #define PAS_MAC_CFG_TXP_TIFT_M 0x00000f00
  129. #define PAS_MAC_CFG_TXP_TIFT_S 8
  130. #define PAS_MAC_CFG_TXP_TIFT(x) (((x) << PAS_MAC_CFG_TXP_TIFT_S) & \
  131. PAS_MAC_CFG_TXP_TIFT_M)
  132. #define PAS_MAC_CFG_TXP_TIFG_M 0x000000ff
  133. #define PAS_MAC_CFG_TXP_TIFG_S 0
  134. #define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \
  135. PAS_MAC_CFG_TXP_TIFG_M)
  136. #define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000
  137. #define PAS_MAC_IPC_CHNL_DCHNO_S 16
  138. #define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \
  139. PAS_MAC_IPC_CHNL_DCHNO_M)
  140. #define PAS_MAC_IPC_CHNL_BCH_M 0x0000003f
  141. #define PAS_MAC_IPC_CHNL_BCH_S 0
  142. #define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \
  143. PAS_MAC_IPC_CHNL_BCH_M)
  144. #endif /* PASEMI_MAC_H */