0001
0002
0003
0004
0005
0006
0007 #ifndef _DNET_H
0008 #define _DNET_H
0009
0010 #define DRV_NAME "dnet"
0011 #define PFX DRV_NAME ": "
0012
0013
0014 #define dnet_writel(port, value, reg) \
0015 writel((value), (port)->regs + DNET_##reg)
0016 #define dnet_readl(port, reg) readl((port)->regs + DNET_##reg)
0017
0018
0019 #define DNET_RX_LEN_FIFO 0x000
0020 #define DNET_RX_DATA_FIFO 0x004
0021 #define DNET_TX_LEN_FIFO 0x008
0022 #define DNET_TX_DATA_FIFO 0x00C
0023
0024
0025 #define DNET_VERCAPS 0x100
0026 #define DNET_INTR_SRC 0x104
0027 #define DNET_INTR_ENB 0x108
0028 #define DNET_RX_STATUS 0x10C
0029 #define DNET_TX_STATUS 0x110
0030 #define DNET_RX_FRAMES_CNT 0x114
0031 #define DNET_TX_FRAMES_CNT 0x118
0032 #define DNET_RX_FIFO_TH 0x11C
0033 #define DNET_TX_FIFO_TH 0x120
0034 #define DNET_SYS_CTL 0x124
0035 #define DNET_PAUSE_TMR 0x128
0036 #define DNET_RX_FIFO_WCNT 0x12C
0037 #define DNET_TX_FIFO_WCNT 0x130
0038
0039
0040 #define DNET_MACREG_DATA 0x200
0041 #define DNET_MACREG_ADDR 0x204
0042
0043
0044 #define DNET_RX_PKT_IGNR_CNT 0x300
0045 #define DNET_RX_LEN_CHK_ERR_CNT 0x304
0046 #define DNET_RX_LNG_FRM_CNT 0x308
0047 #define DNET_RX_SHRT_FRM_CNT 0x30C
0048 #define DNET_RX_IPG_VIOL_CNT 0x310
0049 #define DNET_RX_CRC_ERR_CNT 0x314
0050 #define DNET_RX_OK_PKT_CNT 0x318
0051 #define DNET_RX_CTL_FRM_CNT 0x31C
0052 #define DNET_RX_PAUSE_FRM_CNT 0x320
0053 #define DNET_RX_MULTICAST_CNT 0x324
0054 #define DNET_RX_BROADCAST_CNT 0x328
0055 #define DNET_RX_VLAN_TAG_CNT 0x32C
0056 #define DNET_RX_PRE_SHRINK_CNT 0x330
0057 #define DNET_RX_DRIB_NIB_CNT 0x334
0058 #define DNET_RX_UNSUP_OPCD_CNT 0x338
0059 #define DNET_RX_BYTE_CNT 0x33C
0060
0061
0062 #define DNET_TX_UNICAST_CNT 0x400
0063 #define DNET_TX_PAUSE_FRM_CNT 0x404
0064 #define DNET_TX_MULTICAST_CNT 0x408
0065 #define DNET_TX_BRDCAST_CNT 0x40C
0066 #define DNET_TX_VLAN_TAG_CNT 0x410
0067 #define DNET_TX_BAD_FCS_CNT 0x414
0068 #define DNET_TX_JUMBO_CNT 0x418
0069 #define DNET_TX_BYTE_CNT 0x41C
0070
0071
0072 #define DNET_INTERNAL_MODE_REG 0x0
0073 #define DNET_INTERNAL_RXTX_CONTROL_REG 0x2
0074 #define DNET_INTERNAL_MAX_PKT_SIZE_REG 0x4
0075 #define DNET_INTERNAL_IGP_REG 0x8
0076 #define DNET_INTERNAL_MAC_ADDR_0_REG 0xa
0077 #define DNET_INTERNAL_MAC_ADDR_1_REG 0xc
0078 #define DNET_INTERNAL_MAC_ADDR_2_REG 0xe
0079 #define DNET_INTERNAL_TX_RX_STS_REG 0x12
0080 #define DNET_INTERNAL_GMII_MNG_CTL_REG 0x14
0081 #define DNET_INTERNAL_GMII_MNG_DAT_REG 0x16
0082
0083 #define DNET_INTERNAL_GMII_MNG_CMD_FIN (1 << 14)
0084
0085 #define DNET_INTERNAL_WRITE (1 << 31)
0086
0087
0088
0089
0090 #define DNET_INTERNAL_MODE_GBITEN (1 << 0)
0091 #define DNET_INTERNAL_MODE_FCEN (1 << 1)
0092 #define DNET_INTERNAL_MODE_RXEN (1 << 2)
0093 #define DNET_INTERNAL_MODE_TXEN (1 << 3)
0094
0095
0096 #define DNET_INTERNAL_RXTX_CONTROL_RXSHORTFRAME (1 << 8)
0097 #define DNET_INTERNAL_RXTX_CONTROL_RXBROADCAST (1 << 7)
0098 #define DNET_INTERNAL_RXTX_CONTROL_RXMULTICAST (1 << 4)
0099 #define DNET_INTERNAL_RXTX_CONTROL_RXPAUSE (1 << 3)
0100 #define DNET_INTERNAL_RXTX_CONTROL_DISTXFCS (1 << 2)
0101 #define DNET_INTERNAL_RXTX_CONTROL_DISCFXFCS (1 << 1)
0102 #define DNET_INTERNAL_RXTX_CONTROL_ENPROMISC (1 << 0)
0103 #define DNET_INTERNAL_RXTX_CONTROL_DROPCONTROL (1 << 6)
0104 #define DNET_INTERNAL_RXTX_CONTROL_ENABLEHALFDUP (1 << 5)
0105
0106
0107 #define DNET_SYS_CTL_IGNORENEXTPKT (1 << 0)
0108 #define DNET_SYS_CTL_SENDPAUSE (1 << 2)
0109 #define DNET_SYS_CTL_RXFIFOFLUSH (1 << 3)
0110 #define DNET_SYS_CTL_TXFIFOFLUSH (1 << 4)
0111
0112
0113 #define DNET_TX_STATUS_FIFO_ALMOST_EMPTY (1 << 2)
0114 #define DNET_TX_STATUS_FIFO_ALMOST_FULL (1 << 1)
0115
0116
0117 #define DNET_INTR_SRC_TX_PKTSENT (1 << 0)
0118 #define DNET_INTR_SRC_TX_FIFOAF (1 << 1)
0119 #define DNET_INTR_SRC_TX_FIFOAE (1 << 2)
0120 #define DNET_INTR_SRC_TX_DISCFRM (1 << 3)
0121 #define DNET_INTR_SRC_TX_FIFOFULL (1 << 4)
0122 #define DNET_INTR_SRC_RX_CMDFIFOAF (1 << 8)
0123 #define DNET_INTR_SRC_RX_CMDFIFOFF (1 << 9)
0124 #define DNET_INTR_SRC_RX_DATAFIFOFF (1 << 10)
0125 #define DNET_INTR_SRC_TX_SUMMARY (1 << 16)
0126 #define DNET_INTR_SRC_RX_SUMMARY (1 << 17)
0127 #define DNET_INTR_SRC_PHY (1 << 19)
0128
0129
0130 #define DNET_INTR_ENB_TX_PKTSENT (1 << 0)
0131 #define DNET_INTR_ENB_TX_FIFOAF (1 << 1)
0132 #define DNET_INTR_ENB_TX_FIFOAE (1 << 2)
0133 #define DNET_INTR_ENB_TX_DISCFRM (1 << 3)
0134 #define DNET_INTR_ENB_TX_FIFOFULL (1 << 4)
0135 #define DNET_INTR_ENB_RX_PKTRDY (1 << 8)
0136 #define DNET_INTR_ENB_RX_FIFOAF (1 << 9)
0137 #define DNET_INTR_ENB_RX_FIFOERR (1 << 10)
0138 #define DNET_INTR_ENB_RX_ERROR (1 << 11)
0139 #define DNET_INTR_ENB_RX_FIFOFULL (1 << 12)
0140 #define DNET_INTR_ENB_RX_FIFOAE (1 << 13)
0141 #define DNET_INTR_ENB_TX_SUMMARY (1 << 16)
0142 #define DNET_INTR_ENB_RX_SUMMARY (1 << 17)
0143 #define DNET_INTR_ENB_GLOBAL_ENABLE (1 << 18)
0144
0145
0146
0147
0148
0149
0150 #define DNET_CFG_TX_FIFO_FULL_THRES 25
0151 #define DNET_CFG_RX_FIFO_FULL_THRES 20
0152
0153
0154
0155
0156
0157
0158 #define DNET_HAS_MDIO (1 << 0)
0159 #define DNET_HAS_IRQ (1 << 1)
0160 #define DNET_HAS_GIGABIT (1 << 2)
0161 #define DNET_HAS_DMA (1 << 3)
0162
0163 #define DNET_HAS_MII (1 << 4)
0164 #define DNET_HAS_RMII (1 << 5)
0165
0166 #define DNET_CAPS_MASK 0xFFFF
0167
0168 #define DNET_FIFO_SIZE 1024
0169 #define DNET_FIFO_TX_DATA_AF_TH (DNET_FIFO_SIZE - 384)
0170 #define DNET_FIFO_TX_DATA_AE_TH 384
0171
0172 #define DNET_FIFO_RX_CMD_AF_TH (1 << 16)
0173
0174
0175
0176
0177 struct dnet_stats {
0178 u32 rx_pkt_ignr;
0179 u32 rx_len_chk_err;
0180 u32 rx_lng_frm;
0181 u32 rx_shrt_frm;
0182 u32 rx_ipg_viol;
0183 u32 rx_crc_err;
0184 u32 rx_ok_pkt;
0185 u32 rx_ctl_frm;
0186 u32 rx_pause_frm;
0187 u32 rx_multicast;
0188 u32 rx_broadcast;
0189 u32 rx_vlan_tag;
0190 u32 rx_pre_shrink;
0191 u32 rx_drib_nib;
0192 u32 rx_unsup_opcd;
0193 u32 rx_byte;
0194 u32 tx_unicast;
0195 u32 tx_pause_frm;
0196 u32 tx_multicast;
0197 u32 tx_brdcast;
0198 u32 tx_vlan_tag;
0199 u32 tx_bad_fcs;
0200 u32 tx_jumbo;
0201 u32 tx_byte;
0202 };
0203
0204 struct dnet {
0205 void __iomem *regs;
0206 spinlock_t lock;
0207 struct platform_device *pdev;
0208 struct net_device *dev;
0209 struct dnet_stats hw_stats;
0210 unsigned int capabilities;
0211 struct napi_struct napi;
0212
0213
0214 struct mii_bus *mii_bus;
0215 unsigned int link;
0216 unsigned int speed;
0217 unsigned int duplex;
0218 };
0219
0220 #endif