16 #include <linux/module.h>
18 #include <linux/kernel.h>
24 #include <linux/ethtool.h>
28 #include <linux/slab.h>
31 #define XGMAC_CONTROL 0x00000000
32 #define XGMAC_FRAME_FILTER 0x00000004
33 #define XGMAC_FLOW_CTRL 0x00000018
34 #define XGMAC_VLAN_TAG 0x0000001C
35 #define XGMAC_VERSION 0x00000020
36 #define XGMAC_VLAN_INCL 0x00000024
37 #define XGMAC_LPI_CTRL 0x00000028
38 #define XGMAC_LPI_TIMER 0x0000002C
39 #define XGMAC_TX_PACE 0x00000030
40 #define XGMAC_VLAN_HASH 0x00000034
41 #define XGMAC_DEBUG 0x00000038
42 #define XGMAC_INT_STAT 0x0000003C
43 #define XGMAC_ADDR_HIGH(reg) (0x00000040 + ((reg) * 8))
44 #define XGMAC_ADDR_LOW(reg) (0x00000044 + ((reg) * 8))
45 #define XGMAC_HASH(n) (0x00000300 + (n) * 4)
46 #define XGMAC_NUM_HASH 16
47 #define XGMAC_OMR 0x00000400
48 #define XGMAC_REMOTE_WAKE 0x00000700
49 #define XGMAC_PMT 0x00000704
50 #define XGMAC_MMC_CTRL 0x00000800
51 #define XGMAC_MMC_INTR_RX 0x00000804
52 #define XGMAC_MMC_INTR_TX 0x00000808
53 #define XGMAC_MMC_INTR_MASK_RX 0x0000080c
54 #define XGMAC_MMC_INTR_MASK_TX 0x00000810
57 #define XGMAC_MMC_TXOCTET_GB_LO 0x00000814
58 #define XGMAC_MMC_TXOCTET_GB_HI 0x00000818
59 #define XGMAC_MMC_TXFRAME_GB_LO 0x0000081C
60 #define XGMAC_MMC_TXFRAME_GB_HI 0x00000820
61 #define XGMAC_MMC_TXBCFRAME_G 0x00000824
62 #define XGMAC_MMC_TXMCFRAME_G 0x0000082C
63 #define XGMAC_MMC_TXUCFRAME_GB 0x00000864
64 #define XGMAC_MMC_TXMCFRAME_GB 0x0000086C
65 #define XGMAC_MMC_TXBCFRAME_GB 0x00000874
66 #define XGMAC_MMC_TXUNDERFLOW 0x0000087C
67 #define XGMAC_MMC_TXOCTET_G_LO 0x00000884
68 #define XGMAC_MMC_TXOCTET_G_HI 0x00000888
69 #define XGMAC_MMC_TXFRAME_G_LO 0x0000088C
70 #define XGMAC_MMC_TXFRAME_G_HI 0x00000890
71 #define XGMAC_MMC_TXPAUSEFRAME 0x00000894
72 #define XGMAC_MMC_TXVLANFRAME 0x0000089C
75 #define XGMAC_MMC_RXFRAME_GB_LO 0x00000900
76 #define XGMAC_MMC_RXFRAME_GB_HI 0x00000904
77 #define XGMAC_MMC_RXOCTET_GB_LO 0x00000908
78 #define XGMAC_MMC_RXOCTET_GB_HI 0x0000090C
79 #define XGMAC_MMC_RXOCTET_G_LO 0x00000910
80 #define XGMAC_MMC_RXOCTET_G_HI 0x00000914
81 #define XGMAC_MMC_RXBCFRAME_G 0x00000918
82 #define XGMAC_MMC_RXMCFRAME_G 0x00000920
83 #define XGMAC_MMC_RXCRCERR 0x00000928
84 #define XGMAC_MMC_RXRUNT 0x00000930
85 #define XGMAC_MMC_RXJABBER 0x00000934
86 #define XGMAC_MMC_RXUCFRAME_G 0x00000970
87 #define XGMAC_MMC_RXLENGTHERR 0x00000978
88 #define XGMAC_MMC_RXPAUSEFRAME 0x00000988
89 #define XGMAC_MMC_RXOVERFLOW 0x00000990
90 #define XGMAC_MMC_RXVLANFRAME 0x00000998
91 #define XGMAC_MMC_RXWATCHDOG 0x000009a0
94 #define XGMAC_DMA_BUS_MODE 0x00000f00
95 #define XGMAC_DMA_TX_POLL 0x00000f04
96 #define XGMAC_DMA_RX_POLL 0x00000f08
97 #define XGMAC_DMA_RX_BASE_ADDR 0x00000f0c
98 #define XGMAC_DMA_TX_BASE_ADDR 0x00000f10
99 #define XGMAC_DMA_STATUS 0x00000f14
100 #define XGMAC_DMA_CONTROL 0x00000f18
101 #define XGMAC_DMA_INTR_ENA 0x00000f1c
102 #define XGMAC_DMA_MISS_FRAME_CTR 0x00000f20
103 #define XGMAC_DMA_RI_WDOG_TIMER 0x00000f24
104 #define XGMAC_DMA_AXI_BUS 0x00000f28
105 #define XGMAC_DMA_AXI_STATUS 0x00000f2C
106 #define XGMAC_DMA_HW_FEATURE 0x00000f58
108 #define XGMAC_ADDR_AE 0x80000000
109 #define XGMAC_MAX_FILTER_ADDR 31
112 #define XGMAC_PMT_POINTER_RESET 0x80000000
113 #define XGMAC_PMT_GLBL_UNICAST 0x00000200
114 #define XGMAC_PMT_WAKEUP_RX_FRM 0x00000040
115 #define XGMAC_PMT_MAGIC_PKT 0x00000020
116 #define XGMAC_PMT_WAKEUP_FRM_EN 0x00000004
117 #define XGMAC_PMT_MAGIC_PKT_EN 0x00000002
118 #define XGMAC_PMT_POWERDOWN 0x00000001
120 #define XGMAC_CONTROL_SPD 0x40000000
121 #define XGMAC_CONTROL_SPD_MASK 0x60000000
122 #define XGMAC_CONTROL_SPD_1G 0x60000000
123 #define XGMAC_CONTROL_SPD_2_5G 0x40000000
124 #define XGMAC_CONTROL_SPD_10G 0x00000000
125 #define XGMAC_CONTROL_SARC 0x10000000
126 #define XGMAC_CONTROL_SARK_MASK 0x18000000
127 #define XGMAC_CONTROL_CAR 0x04000000
128 #define XGMAC_CONTROL_CAR_MASK 0x06000000
129 #define XGMAC_CONTROL_DP 0x01000000
130 #define XGMAC_CONTROL_WD 0x00800000
131 #define XGMAC_CONTROL_JD 0x00400000
132 #define XGMAC_CONTROL_JE 0x00100000
133 #define XGMAC_CONTROL_LM 0x00001000
134 #define XGMAC_CONTROL_IPC 0x00000400
135 #define XGMAC_CONTROL_ACS 0x00000080
136 #define XGMAC_CONTROL_DDIC 0x00000010
137 #define XGMAC_CONTROL_TE 0x00000008
138 #define XGMAC_CONTROL_RE 0x00000004
141 #define XGMAC_FRAME_FILTER_PR 0x00000001
142 #define XGMAC_FRAME_FILTER_HUC 0x00000002
143 #define XGMAC_FRAME_FILTER_HMC 0x00000004
144 #define XGMAC_FRAME_FILTER_DAIF 0x00000008
145 #define XGMAC_FRAME_FILTER_PM 0x00000010
146 #define XGMAC_FRAME_FILTER_DBF 0x00000020
147 #define XGMAC_FRAME_FILTER_SAIF 0x00000100
148 #define XGMAC_FRAME_FILTER_SAF 0x00000200
149 #define XGMAC_FRAME_FILTER_HPF 0x00000400
150 #define XGMAC_FRAME_FILTER_VHF 0x00000800
151 #define XGMAC_FRAME_FILTER_VPF 0x00001000
152 #define XGMAC_FRAME_FILTER_RA 0x80000000
155 #define XGMAC_FLOW_CTRL_PT_MASK 0xffff0000
156 #define XGMAC_FLOW_CTRL_PT_SHIFT 16
157 #define XGMAC_FLOW_CTRL_DZQP 0x00000080
158 #define XGMAC_FLOW_CTRL_PLT 0x00000020
159 #define XGMAC_FLOW_CTRL_PLT_MASK 0x00000030
160 #define XGMAC_FLOW_CTRL_UP 0x00000008
161 #define XGMAC_FLOW_CTRL_RFE 0x00000004
162 #define XGMAC_FLOW_CTRL_TFE 0x00000002
163 #define XGMAC_FLOW_CTRL_FCB_BPA 0x00000001
166 #define XGMAC_INT_STAT_PMT 0x0080
167 #define XGMAC_INT_STAT_LPI 0x0040
170 #define DMA_BUS_MODE_SFT_RESET 0x00000001
171 #define DMA_BUS_MODE_DSL_MASK 0x0000007c
172 #define DMA_BUS_MODE_DSL_SHIFT 2
173 #define DMA_BUS_MODE_ATDS 0x00000080
176 #define DMA_BUS_MODE_PBL_MASK 0x00003f00
177 #define DMA_BUS_MODE_PBL_SHIFT 8
178 #define DMA_BUS_MODE_FB 0x00010000
179 #define DMA_BUS_MODE_RPBL_MASK 0x003e0000
180 #define DMA_BUS_MODE_RPBL_SHIFT 17
181 #define DMA_BUS_MODE_USP 0x00800000
182 #define DMA_BUS_MODE_8PBL 0x01000000
183 #define DMA_BUS_MODE_AAL 0x02000000
186 #define DMA_BUS_PR_RATIO_MASK 0x0000c000
187 #define DMA_BUS_PR_RATIO_SHIFT 14
188 #define DMA_BUS_FB 0x00010000
191 #define DMA_CONTROL_ST 0x00002000
192 #define DMA_CONTROL_SR 0x00000002
193 #define DMA_CONTROL_DFF 0x01000000
196 #define DMA_INTR_ENA_NIE 0x00010000
197 #define DMA_INTR_ENA_AIE 0x00008000
198 #define DMA_INTR_ENA_ERE 0x00004000
199 #define DMA_INTR_ENA_FBE 0x00002000
200 #define DMA_INTR_ENA_ETE 0x00000400
201 #define DMA_INTR_ENA_RWE 0x00000200
202 #define DMA_INTR_ENA_RSE 0x00000100
203 #define DMA_INTR_ENA_RUE 0x00000080
204 #define DMA_INTR_ENA_RIE 0x00000040
205 #define DMA_INTR_ENA_UNE 0x00000020
206 #define DMA_INTR_ENA_OVE 0x00000010
207 #define DMA_INTR_ENA_TJE 0x00000008
208 #define DMA_INTR_ENA_TUE 0x00000004
209 #define DMA_INTR_ENA_TSE 0x00000002
210 #define DMA_INTR_ENA_TIE 0x00000001
212 #define DMA_INTR_NORMAL (DMA_INTR_ENA_NIE | DMA_INTR_ENA_RIE | \
215 #define DMA_INTR_ABNORMAL (DMA_INTR_ENA_AIE | DMA_INTR_ENA_FBE | \
216 DMA_INTR_ENA_RWE | DMA_INTR_ENA_RSE | \
217 DMA_INTR_ENA_RUE | DMA_INTR_ENA_UNE | \
218 DMA_INTR_ENA_OVE | DMA_INTR_ENA_TJE | \
222 #define DMA_INTR_DEFAULT_MASK (DMA_INTR_NORMAL | DMA_INTR_ABNORMAL)
225 #define DMA_STATUS_GMI 0x08000000
226 #define DMA_STATUS_GLI 0x04000000
227 #define DMA_STATUS_EB_MASK 0x00380000
228 #define DMA_STATUS_EB_TX_ABORT 0x00080000
229 #define DMA_STATUS_EB_RX_ABORT 0x00100000
230 #define DMA_STATUS_TS_MASK 0x00700000
231 #define DMA_STATUS_TS_SHIFT 20
232 #define DMA_STATUS_RS_MASK 0x000e0000
233 #define DMA_STATUS_RS_SHIFT 17
234 #define DMA_STATUS_NIS 0x00010000
235 #define DMA_STATUS_AIS 0x00008000
236 #define DMA_STATUS_ERI 0x00004000
237 #define DMA_STATUS_FBI 0x00002000
238 #define DMA_STATUS_ETI 0x00000400
239 #define DMA_STATUS_RWT 0x00000200
240 #define DMA_STATUS_RPS 0x00000100
241 #define DMA_STATUS_RU 0x00000080
242 #define DMA_STATUS_RI 0x00000040
243 #define DMA_STATUS_UNF 0x00000020
244 #define DMA_STATUS_OVF 0x00000010
245 #define DMA_STATUS_TJT 0x00000008
246 #define DMA_STATUS_TU 0x00000004
247 #define DMA_STATUS_TPS 0x00000002
248 #define DMA_STATUS_TI 0x00000001
251 #define MAC_ENABLE_TX 0x00000008
252 #define MAC_ENABLE_RX 0x00000004
255 #define XGMAC_OMR_TSF 0x00200000
256 #define XGMAC_OMR_FTF 0x00100000
257 #define XGMAC_OMR_TTC 0x00020000
258 #define XGMAC_OMR_TTC_MASK 0x00030000
259 #define XGMAC_OMR_RFD 0x00006000
260 #define XGMAC_OMR_RFD_MASK 0x00007000
261 #define XGMAC_OMR_RFA 0x00000600
262 #define XGMAC_OMR_RFA_MASK 0x00000E00
263 #define XGMAC_OMR_EFC 0x00000100
264 #define XGMAC_OMR_FEF 0x00000080
265 #define XGMAC_OMR_DT 0x00000040
266 #define XGMAC_OMR_RSF 0x00000020
267 #define XGMAC_OMR_RTC_256 0x00000018
268 #define XGMAC_OMR_RTC_MASK 0x00000018
271 #define DMA_HW_FEAT_TXCOESEL 0x00010000
273 #define XGMAC_MMC_CTRL_CNT_FRZ 0x00000008
276 #define MAX_DESC_BUF_SZ (0x2000 - 8)
278 #define RXDESC_EXT_STATUS 0x00000001
279 #define RXDESC_CRC_ERR 0x00000002
280 #define RXDESC_RX_ERR 0x00000008
281 #define RXDESC_RX_WDOG 0x00000010
282 #define RXDESC_FRAME_TYPE 0x00000020
283 #define RXDESC_GIANT_FRAME 0x00000080
284 #define RXDESC_LAST_SEG 0x00000100
285 #define RXDESC_FIRST_SEG 0x00000200
286 #define RXDESC_VLAN_FRAME 0x00000400
287 #define RXDESC_OVERFLOW_ERR 0x00000800
288 #define RXDESC_LENGTH_ERR 0x00001000
289 #define RXDESC_SA_FILTER_FAIL 0x00002000
290 #define RXDESC_DESCRIPTOR_ERR 0x00004000
291 #define RXDESC_ERROR_SUMMARY 0x00008000
292 #define RXDESC_FRAME_LEN_OFFSET 16
293 #define RXDESC_FRAME_LEN_MASK 0x3fff0000
294 #define RXDESC_DA_FILTER_FAIL 0x40000000
296 #define RXDESC1_END_RING 0x00008000
298 #define RXDESC_IP_PAYLOAD_MASK 0x00000003
299 #define RXDESC_IP_PAYLOAD_UDP 0x00000001
300 #define RXDESC_IP_PAYLOAD_TCP 0x00000002
301 #define RXDESC_IP_PAYLOAD_ICMP 0x00000003
302 #define RXDESC_IP_HEADER_ERR 0x00000008
303 #define RXDESC_IP_PAYLOAD_ERR 0x00000010
304 #define RXDESC_IPV4_PACKET 0x00000040
305 #define RXDESC_IPV6_PACKET 0x00000080
306 #define TXDESC_UNDERFLOW_ERR 0x00000001
307 #define TXDESC_JABBER_TIMEOUT 0x00000002
308 #define TXDESC_LOCAL_FAULT 0x00000004
309 #define TXDESC_REMOTE_FAULT 0x00000008
310 #define TXDESC_VLAN_FRAME 0x00000010
311 #define TXDESC_FRAME_FLUSHED 0x00000020
312 #define TXDESC_IP_HEADER_ERR 0x00000040
313 #define TXDESC_PAYLOAD_CSUM_ERR 0x00000080
314 #define TXDESC_ERROR_SUMMARY 0x00008000
315 #define TXDESC_SA_CTRL_INSERT 0x00040000
316 #define TXDESC_SA_CTRL_REPLACE 0x00080000
317 #define TXDESC_2ND_ADDR_CHAINED 0x00100000
318 #define TXDESC_END_RING 0x00200000
319 #define TXDESC_CSUM_IP 0x00400000
320 #define TXDESC_CSUM_IP_PAYLD 0x00800000
321 #define TXDESC_CSUM_ALL 0x00C00000
322 #define TXDESC_CRC_EN_REPLACE 0x01000000
323 #define TXDESC_CRC_EN_APPEND 0x02000000
324 #define TXDESC_DISABLE_PAD 0x04000000
325 #define TXDESC_FIRST_SEG 0x10000000
326 #define TXDESC_LAST_SEG 0x20000000
327 #define TXDESC_INTERRUPT 0x40000000
329 #define DESC_OWN 0x80000000
330 #define DESC_BUFFER1_SZ_MASK 0x00001fff
331 #define DESC_BUFFER2_SZ_MASK 0x1fff0000
332 #define DESC_BUFFER2_SZ_OFFSET 16
397 #define PAUSE_TIME 0x400
399 #define DMA_RX_RING_SZ 256
400 #define DMA_TX_RING_SZ 128
402 #define TX_THRESH (DMA_TX_RING_SZ/4)
405 #define dma_ring_incr(n, s) (((n) + 1) & ((s) - 1))
406 #define dma_ring_space(h, t, s) CIRC_SPACE(h, t, s)
407 #define dma_ring_cnt(h, t, s) CIRC_CNT(h, t, s)
431 memset(p, 0,
sizeof(*p) * ring_size);
433 for (; p <=
end; p++)
434 desc_set_buf_len(p, buf_sz);
441 memset(p, 0,
sizeof(*p) * ring_size);
482 static inline void desc_set_buf_addr_and_size(
struct xgmac_dma_desc *p,
485 desc_set_buf_len(p, len);
486 desc_set_buf_addr(p, paddr, len);
499 static void xgmac_dma_flush_tx_fifo(
void __iomem *ioaddr)
523 xgmac_dma_flush_tx_fifo(priv->
base);
544 netdev_dbg(priv->
dev,
"XGMAC RX : Dest Address filter fail\n");
554 netdev_dbg(priv->
dev,
"rx status - frame type=%d, csum = %d, ext stat %08x\n",
555 (status & RXDESC_FRAME_TYPE) ? 1 : 0, ret, ext_status);
565 if (status & RXDESC_EXT_STATUS) {
578 static inline void xgmac_mac_enable(
void __iomem *ioaddr)
589 static inline void xgmac_mac_disable(
void __iomem *ioaddr)
600 static void xgmac_set_mac_addr(
void __iomem *ioaddr,
unsigned char *
addr,
607 data = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0];
611 static void xgmac_get_mac_addr(
void __iomem *ioaddr,
unsigned char *addr,
614 u32 hi_addr, lo_addr;
621 addr[0] = lo_addr & 0xff;
622 addr[1] = (lo_addr >> 8) & 0xff;
623 addr[2] = (lo_addr >> 16) & 0xff;
624 addr[3] = (lo_addr >> 24) & 0xff;
625 addr[4] = hi_addr & 0xff;
626 addr[5] = (hi_addr >> 8) & 0xff;
629 static int xgmac_set_flow_ctrl(
struct xgmac_priv *priv,
int rx,
int tx)
632 unsigned int flow = 0;
662 static void xgmac_rx_refill(
struct xgmac_priv *priv)
681 desc_set_buf_addr(p, paddr, priv->
dma_buf_sz);
688 desc_set_rx_owner(p);
738 "Tx %p)\n\tDMA phy addr (Rx 0x%08x, Tx 0x%08x)\n",
746 xgmac_rx_refill(priv);
768 static void xgmac_free_rx_skbufs(
struct xgmac_priv *priv)
788 static void xgmac_free_tx_skbufs(
struct xgmac_priv *priv)
804 for (f = 0; f < skb_shinfo(priv->
tx_skbuff[i])->nr_frags; f++) {
815 static void xgmac_free_dma_desc_rings(
struct xgmac_priv *priv)
818 xgmac_free_rx_skbufs(priv);
819 xgmac_free_tx_skbufs(priv);
845 static void xgmac_tx_complete(
struct xgmac_priv *priv)
853 unsigned int entry = priv->
tx_tail;
858 if (desc_get_owner(p))
862 if (desc_get_tx_ls(p))
863 desc_get_tx_status(priv, p);
878 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
892 netif_wake_queue(priv->
dev);
901 static void xgmac_tx_err(
struct xgmac_priv *priv)
905 netif_stop_queue(priv->
dev);
914 }
while (value && (value != 0x600000));
916 xgmac_free_tx_skbufs(priv);
917 desc_init_tx_desc(priv->
dma_tx, DMA_TX_RING_SZ);
927 netif_wake_queue(priv->
dev);
930 static int xgmac_hw_init(
struct net_device *dev)
1000 if (!is_valid_ether_addr(dev->
dev_addr)) {
1001 eth_hw_addr_random(dev);
1010 xgmac_set_mac_addr(ioaddr, dev->
dev_addr, 0);
1013 ret = xgmac_dma_desc_rings_init(dev);
1018 xgmac_mac_enable(ioaddr);
1020 napi_enable(&priv->
napi);
1021 netif_start_queue(dev);
1032 static int xgmac_stop(
struct net_device *dev)
1036 netif_stop_queue(dev);
1039 napi_disable(&priv->
napi);
1044 xgmac_mac_disable(priv->
base);
1047 xgmac_free_dma_desc_rings(priv);
1063 int nfrags = skb_shinfo(skb)->nr_frags;
1065 unsigned int desc_flags;
1073 netif_stop_queue(dev);
1083 len = skb_headlen(skb);
1090 desc_set_buf_addr_and_size(desc, paddr, len);
1092 for (i = 0; i < nfrags; i++) {
1097 paddr = skb_frag_dma_map(priv->
device, frag, 0, len,
1108 desc_set_buf_addr_and_size(desc, paddr, len);
1109 if (i < (nfrags - 1))
1110 desc_set_tx_owner(desc, desc_flags);
1115 desc_set_tx_owner(desc, desc_flags |
1131 static int xgmac_rx(
struct xgmac_priv *priv,
int limit)
1134 unsigned int count = 0;
1137 while (count < limit) {
1147 if (desc_get_owner(p))
1154 ip_checksum = desc_get_rx_status(priv, p);
1155 if (ip_checksum < 0)
1160 netdev_err(priv->
dev,
"Inconsistent Rx descriptor chain\n");
1165 frame_len = desc_get_rx_frame_len(p);
1167 frame_len, ip_checksum);
1181 xgmac_rx_refill(priv);
1203 xgmac_tx_complete(priv);
1204 work_done = xgmac_rx(priv, budget);
1206 if (work_done < budget) {
1221 static void xgmac_tx_timeout(
struct net_device *dev)
1238 static void xgmac_set_rx_mode(
struct net_device *dev)
1243 unsigned int value = 0;
1247 bool use_hash =
false;
1257 memset(hash_filter, 0,
sizeof(hash_filter));
1270 hash_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
1272 xgmac_set_mac_addr(ioaddr, ha->
addr, reg);
1293 hash_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
1295 xgmac_set_mac_addr(ioaddr, ha->
addr, reg);
1318 static int xgmac_change_mtu(
struct net_device *dev,
int new_mtu)
1323 if ((new_mtu < 46) || (new_mtu >
MAX_MTU)) {
1324 netdev_err(priv->
dev,
"invalid MTU, max MTU is: %d\n",
MAX_MTU);
1334 if (old_mtu == new_mtu)
1338 if (!netif_running(dev))
1343 return xgmac_open(dev);
1362 static irqreturn_t xgmac_interrupt(
int irq,
void *dev_id)
1365 bool tx_err =
false;
1379 netdev_err(priv->
dev,
"transmit jabber\n");
1385 netdev_err(priv->
dev,
"receive process stopped\n");
1389 netdev_err(priv->
dev,
"transmit early interrupt\n");
1393 netdev_err(priv->
dev,
"transmit process stopped\n");
1398 netdev_err(priv->
dev,
"fatal bus error\n");
1410 napi_schedule(&priv->
napi);
1416 #ifdef CONFIG_NET_POLL_CONTROLLER
1419 static void xgmac_poll_controller(
struct net_device *dev)
1422 xgmac_interrupt(dev->
irq, dev);
1460 static int xgmac_set_mac_address(
struct net_device *dev,
void *p)
1466 if (!is_valid_ether_addr(addr->
sa_data))
1472 xgmac_set_mac_addr(ioaddr, dev->
dev_addr, 0);
1488 if (features & NETIF_F_RXCSUM)
1498 .ndo_open = xgmac_open,
1499 .ndo_start_xmit = xgmac_xmit,
1500 .ndo_stop = xgmac_stop,
1501 .ndo_change_mtu = xgmac_change_mtu,
1502 .ndo_set_rx_mode = xgmac_set_rx_mode,
1503 .ndo_tx_timeout = xgmac_tx_timeout,
1504 .ndo_get_stats64 = xgmac_get_stats64,
1505 #ifdef CONFIG_NET_POLL_CONTROLLER
1506 .ndo_poll_controller = xgmac_poll_controller,
1508 .ndo_set_mac_address = xgmac_set_mac_address,
1509 .ndo_set_features = xgmac_set_features,
1512 static int xgmac_ethtool_getsettings(
struct net_device *dev,
1517 ethtool_cmd_speed_set(cmd, 10000);
1524 static void xgmac_get_pauseparam(
struct net_device *netdev,
1527 struct xgmac_priv *priv = netdev_priv(netdev);
1533 static int xgmac_set_pauseparam(
struct net_device *netdev,
1536 struct xgmac_priv *priv = netdev_priv(netdev);
1550 #define XGMAC_STAT(m) \
1551 { #m, offsetof(struct xgmac_priv, xstats.m), false }
1552 #define XGMAC_HW_STAT(m, reg_offset) \
1553 { #m, reg_offset, true }
1555 static const struct xgmac_stats xgmac_gstrings_stats[] = {
1577 #define XGMAC_STATS_LEN ARRAY_SIZE(xgmac_gstrings_stats)
1579 static void xgmac_get_ethtool_stats(
struct net_device *dev,
1588 if (xgmac_gstrings_stats[i].is_reg)
1592 *data++ = *(
u32 *)(p +
1593 xgmac_gstrings_stats[i].stat_offset);
1597 static int xgmac_get_sset_count(
struct net_device *netdev,
int sset)
1607 static void xgmac_get_strings(
struct net_device *dev,
u32 stringset,
1613 switch (stringset) {
1616 memcpy(p, xgmac_gstrings_stats[i].stat_string,
1627 static void xgmac_get_wol(
struct net_device *dev,
1632 if (device_can_wakeup(priv->
device)) {
1638 static int xgmac_set_wol(
struct net_device *dev,
1644 if (!device_can_wakeup(priv->
device))
1654 enable_irq_wake(dev->
irq);
1657 disable_irq_wake(dev->
irq);
1663 static const struct ethtool_ops xgmac_ethtool_ops = {
1664 .get_settings = xgmac_ethtool_getsettings,
1666 .get_pauseparam = xgmac_get_pauseparam,
1667 .set_pauseparam = xgmac_set_pauseparam,
1668 .get_ethtool_stats = xgmac_get_ethtool_stats,
1669 .get_strings = xgmac_get_strings,
1670 .get_wol = xgmac_get_wol,
1671 .set_wol = xgmac_set_wol,
1672 .get_sset_count = xgmac_get_sset_count,
1695 ndev = alloc_etherdev(
sizeof(
struct xgmac_priv));
1702 priv = netdev_priv(ndev);
1703 platform_set_drvdata(pdev, ndev);
1716 netdev_err(ndev,
"ioremap failed\n");
1722 netdev_info(ndev,
"h/w version is 0x%x\n", uid);
1727 netdev_err(ndev,
"No irq resource\n");
1733 dev_name(&pdev->
dev), ndev);
1735 netdev_err(ndev,
"Could not request irq %d - ret %d)\n",
1742 netdev_err(ndev,
"No pmt irq resource\n");
1748 dev_name(&pdev->
dev), ndev);
1750 netdev_err(ndev,
"Could not request irq %d - ret %d)\n",
1756 if (device_can_wakeup(priv->
device))
1768 if (!is_valid_ether_addr(ndev->
dev_addr))
1769 netdev_warn(ndev,
"MAC address %pM not valid",
1790 platform_set_drvdata(pdev,
NULL);
1803 struct net_device *ndev = platform_get_drvdata(pdev);
1807 xgmac_mac_disable(priv->
base);
1813 platform_set_drvdata(pdev,
NULL);
1826 #ifdef CONFIG_PM_SLEEP
1827 static void xgmac_pmt(
void __iomem *ioaddr,
unsigned long mode)
1829 unsigned int pmt = 0;
1839 static int xgmac_suspend(
struct device *dev)
1845 if (!ndev || !netif_running(ndev))
1849 napi_disable(&priv->
napi);
1852 if (device_may_wakeup(priv->
device)) {
1860 xgmac_mac_disable(priv->
base);
1865 static int xgmac_resume(
struct device *dev)
1871 if (!netif_running(ndev))
1874 xgmac_pmt(ioaddr, 0);
1877 xgmac_mac_enable(ioaddr);
1882 napi_enable(&priv->
napi);
1888 #define XGMAC_PM_OPS (&xgmac_pm_ops)
1890 #define XGMAC_PM_OPS NULL
1894 { .compatible =
"calxeda,hb-xgmac", },
1901 .name =
"calxedaxgmac",
1902 .of_match_table = xgmac_of_match,
1904 .probe = xgmac_probe,
1905 .remove = xgmac_remove,