au1000_eth.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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