au1000_eth.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. *
  3. * Alchemy Au1x00 ethernet driver include file
  4. *
  5. * Author: Pete Popov <ppopov@mvista.com>
  6. *
  7. * Copyright 2001 MontaVista Software Inc.
  8. *
  9. * ########################################################################
  10. *
  11. * This program is free software; you can distribute it and/or modify it
  12. * under the terms of the GNU General Public License (Version 2) as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18. * for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  23. *
  24. * ########################################################################
  25. *
  26. *
  27. */
  28. #define MAC_IOSIZE 0x10000
  29. #define NUM_RX_DMA 4 /* Au1x00 has 4 rx hardware descriptors */
  30. #define NUM_TX_DMA 4 /* Au1x00 has 4 tx hardware descriptors */
  31. #define NUM_RX_BUFFS 4
  32. #define NUM_TX_BUFFS 4
  33. #define MAX_BUF_SIZE 2048
  34. #define ETH_TX_TIMEOUT HZ/4
  35. #define MAC_MIN_PKT_SIZE 64
  36. #define MULTICAST_FILTER_LIMIT 64
  37. /* FIXME
  38. * The PHY defines should be in a separate file.
  39. */
  40. /* MII register offsets */
  41. #define MII_CONTROL 0x0000
  42. #define MII_STATUS 0x0001
  43. #define MII_PHY_ID0 0x0002
  44. #define MII_PHY_ID1 0x0003
  45. #define MII_ANADV 0x0004
  46. #define MII_ANLPAR 0x0005
  47. #define MII_AEXP 0x0006
  48. #define MII_ANEXT 0x0007
  49. #define MII_LSI_PHY_CONFIG 0x0011
  50. /* Status register */
  51. #define MII_LSI_PHY_STAT 0x0012
  52. #define MII_AMD_PHY_STAT MII_LSI_PHY_STAT
  53. #define MII_INTEL_PHY_STAT 0x0011
  54. #define MII_AUX_CNTRL 0x0018
  55. /* mii registers specific to AMD 79C901 */
  56. #define MII_STATUS_SUMMARY = 0x0018
  57. /* MII Control register bit definitions. */
  58. #define MII_CNTL_FDX 0x0100
  59. #define MII_CNTL_RST_AUTO 0x0200
  60. #define MII_CNTL_ISOLATE 0x0400
  61. #define MII_CNTL_PWRDWN 0x0800
  62. #define MII_CNTL_AUTO 0x1000
  63. #define MII_CNTL_F100 0x2000
  64. #define MII_CNTL_LPBK 0x4000
  65. #define MII_CNTL_RESET 0x8000
  66. /* MII Status register bit */
  67. #define MII_STAT_EXT 0x0001
  68. #define MII_STAT_JAB 0x0002
  69. #define MII_STAT_LINK 0x0004
  70. #define MII_STAT_CAN_AUTO 0x0008
  71. #define MII_STAT_FAULT 0x0010
  72. #define MII_STAT_AUTO_DONE 0x0020
  73. #define MII_STAT_CAN_T 0x0800
  74. #define MII_STAT_CAN_T_FDX 0x1000
  75. #define MII_STAT_CAN_TX 0x2000
  76. #define MII_STAT_CAN_TX_FDX 0x4000
  77. #define MII_STAT_CAN_T4 0x8000
  78. #define MII_ID1_OUI_LO 0xFC00 /* low bits of OUI mask */
  79. #define MII_ID1_MODEL 0x03F0 /* model number */
  80. #define MII_ID1_REV 0x000F /* model number */
  81. /* MII NWAY Register Bits ...
  82. valid for the ANAR (Auto-Negotiation Advertisement) and
  83. ANLPAR (Auto-Negotiation Link Partner) registers */
  84. #define MII_NWAY_NODE_SEL 0x001f
  85. #define MII_NWAY_CSMA_CD 0x0001
  86. #define MII_NWAY_T 0x0020
  87. #define MII_NWAY_T_FDX 0x0040
  88. #define MII_NWAY_TX 0x0080
  89. #define MII_NWAY_TX_FDX 0x0100
  90. #define MII_NWAY_T4 0x0200
  91. #define MII_NWAY_PAUSE 0x0400
  92. #define MII_NWAY_RF 0x2000 /* Remote Fault */
  93. #define MII_NWAY_ACK 0x4000 /* Remote Acknowledge */
  94. #define MII_NWAY_NP 0x8000 /* Next Page (Enable) */
  95. /* mii stsout register bits */
  96. #define MII_STSOUT_LINK_FAIL 0x4000
  97. #define MII_STSOUT_SPD 0x0080
  98. #define MII_STSOUT_DPLX 0x0040
  99. /* mii stsics register bits */
  100. #define MII_STSICS_SPD 0x8000
  101. #define MII_STSICS_DPLX 0x4000
  102. #define MII_STSICS_LINKSTS 0x0001
  103. /* mii stssum register bits */
  104. #define MII_STSSUM_LINK 0x0008
  105. #define MII_STSSUM_DPLX 0x0004
  106. #define MII_STSSUM_AUTO 0x0002
  107. #define MII_STSSUM_SPD 0x0001
  108. /* lsi phy status register */
  109. #define MII_LSI_PHY_STAT_FDX 0x0040
  110. #define MII_LSI_PHY_STAT_SPD 0x0080
  111. /* amd phy status register */
  112. #define MII_AMD_PHY_STAT_FDX 0x0800
  113. #define MII_AMD_PHY_STAT_SPD 0x0400
  114. /* intel phy status register */
  115. #define MII_INTEL_PHY_STAT_FDX 0x0200
  116. #define MII_INTEL_PHY_STAT_SPD 0x4000
  117. /* Auxilliary Control/Status Register */
  118. #define MII_AUX_FDX 0x0001
  119. #define MII_AUX_100 0x0002
  120. #define MII_AUX_F100 0x0004
  121. #define MII_AUX_ANEG 0x0008
  122. typedef struct mii_phy {
  123. struct mii_phy * next;
  124. struct mii_chip_info * chip_info;
  125. u16 status;
  126. u32 *mii_control_reg;
  127. u32 *mii_data_reg;
  128. } mii_phy_t;
  129. struct phy_ops {
  130. int (*phy_init) (struct net_device *, int);
  131. int (*phy_reset) (struct net_device *, int);
  132. int (*phy_status) (struct net_device *, int, u16 *, u16 *);
  133. };
  134. /*
  135. * Data Buffer Descriptor. Data buffers must be aligned on 32 byte
  136. * boundary for both, receive and transmit.
  137. */
  138. typedef struct db_dest {
  139. struct db_dest *pnext;
  140. volatile u32 *vaddr;
  141. dma_addr_t dma_addr;
  142. } db_dest_t;
  143. /*
  144. * The transmit and receive descriptors are memory
  145. * mapped registers.
  146. */
  147. typedef struct tx_dma {
  148. u32 status;
  149. u32 buff_stat;
  150. u32 len;
  151. u32 pad;
  152. } tx_dma_t;
  153. typedef struct rx_dma {
  154. u32 status;
  155. u32 buff_stat;
  156. u32 pad[2];
  157. } rx_dma_t;
  158. /*
  159. * MAC control registers, memory mapped.
  160. */
  161. typedef struct mac_reg {
  162. u32 control;
  163. u32 mac_addr_high;
  164. u32 mac_addr_low;
  165. u32 multi_hash_high;
  166. u32 multi_hash_low;
  167. u32 mii_control;
  168. u32 mii_data;
  169. u32 flow_control;
  170. u32 vlan1_tag;
  171. u32 vlan2_tag;
  172. } mac_reg_t;
  173. struct au1000_private {
  174. db_dest_t *pDBfree;
  175. db_dest_t db[NUM_RX_BUFFS+NUM_TX_BUFFS];
  176. volatile rx_dma_t *rx_dma_ring[NUM_RX_DMA];
  177. volatile tx_dma_t *tx_dma_ring[NUM_TX_DMA];
  178. db_dest_t *rx_db_inuse[NUM_RX_DMA];
  179. db_dest_t *tx_db_inuse[NUM_TX_DMA];
  180. u32 rx_head;
  181. u32 tx_head;
  182. u32 tx_tail;
  183. u32 tx_full;
  184. int mac_id;
  185. mii_phy_t *mii;
  186. struct phy_ops *phy_ops;
  187. /* These variables are just for quick access to certain regs addresses. */
  188. volatile mac_reg_t *mac; /* mac registers */
  189. volatile u32 *enable; /* address of MAC Enable Register */
  190. u32 vaddr; /* virtual address of rx/tx buffers */
  191. dma_addr_t dma_addr; /* dma address of rx/tx buffers */
  192. u8 *hash_table;
  193. u32 hash_mode;
  194. u32 intr_work_done; /* number of Rx and Tx pkts processed in the isr */
  195. int phy_addr; /* phy address */
  196. u32 options; /* User-settable misc. driver options. */
  197. u32 drv_flags;
  198. int want_autoneg;
  199. struct net_device_stats stats;
  200. struct timer_list timer;
  201. spinlock_t lock; /* Serialise access to device */
  202. };