2 * This is the driver for the GMAC on-chip Ethernet controller for ST SoCs.
3 * DWC Ether MAC version 4.00 has been used for developing this code.
5 * This only implements the mac core functions for this chip.
7 * Copyright (C) 2015 STMicroelectronics Ltd
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
13 * Author: Alexandre Torgue <alexandre.torgue@st.com>
16 #include <linux/crc32.h>
17 #include <linux/slab.h>
18 #include <linux/ethtool.h>
20 #include "stmmac_pcs.h"
23 static void dwmac4_core_init(struct mac_device_info *hw, int mtu)
25 void __iomem *ioaddr = hw->pcsr;
26 u32 value = readl(ioaddr + GMAC_CONFIG);
28 value |= GMAC_CORE_INIT;
31 value |= GMAC_CONFIG_2K;
33 value |= GMAC_CONFIG_JE;
36 value |= GMAC_CONFIG_TE;
38 if (hw->ps == SPEED_1000) {
39 value &= ~GMAC_CONFIG_PS;
41 value |= GMAC_CONFIG_PS;
43 if (hw->ps == SPEED_10)
44 value &= ~GMAC_CONFIG_FES;
46 value |= GMAC_CONFIG_FES;
50 writel(value, ioaddr + GMAC_CONFIG);
52 /* Mask GMAC interrupts */
53 value = GMAC_INT_DEFAULT_MASK;
55 value |= GMAC_INT_PMT_EN;
57 value |= GMAC_PCS_IRQ_DEFAULT;
59 writel(value, ioaddr + GMAC_INT_EN);
62 static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
65 void __iomem *ioaddr = hw->pcsr;
66 u32 value = readl(ioaddr + GMAC_RXQ_CTRL0);
68 value &= GMAC_RX_QUEUE_CLEAR(queue);
69 if (mode == MTL_QUEUE_AVB)
70 value |= GMAC_RX_AV_QUEUE_ENABLE(queue);
71 else if (mode == MTL_QUEUE_DCB)
72 value |= GMAC_RX_DCB_QUEUE_ENABLE(queue);
74 writel(value, ioaddr + GMAC_RXQ_CTRL0);
77 static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
80 void __iomem *ioaddr = hw->pcsr;
81 u32 value = readl(ioaddr + MTL_OPERATION_MODE);
83 value &= ~MTL_OPERATION_RAA;
85 case MTL_RX_ALGORITHM_SP:
86 value |= MTL_OPERATION_RAA_SP;
88 case MTL_RX_ALGORITHM_WSP:
89 value |= MTL_OPERATION_RAA_WSP;
95 writel(value, ioaddr + MTL_OPERATION_MODE);
98 static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
101 void __iomem *ioaddr = hw->pcsr;
102 u32 value = readl(ioaddr + MTL_OPERATION_MODE);
104 value &= ~MTL_OPERATION_SCHALG_MASK;
106 case MTL_TX_ALGORITHM_WRR:
107 value |= MTL_OPERATION_SCHALG_WRR;
109 case MTL_TX_ALGORITHM_WFQ:
110 value |= MTL_OPERATION_SCHALG_WFQ;
112 case MTL_TX_ALGORITHM_DWRR:
113 value |= MTL_OPERATION_SCHALG_DWRR;
115 case MTL_TX_ALGORITHM_SP:
116 value |= MTL_OPERATION_SCHALG_SP;
123 static void dwmac4_set_mtl_tx_queue_weight(struct mac_device_info *hw,
124 u32 weight, u32 queue)
126 void __iomem *ioaddr = hw->pcsr;
127 u32 value = readl(ioaddr + MTL_TXQX_WEIGHT_BASE_ADDR(queue));
129 value &= ~MTL_TXQ_WEIGHT_ISCQW_MASK;
130 value |= weight & MTL_TXQ_WEIGHT_ISCQW_MASK;
131 writel(value, ioaddr + MTL_TXQX_WEIGHT_BASE_ADDR(queue));
134 static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan)
136 void __iomem *ioaddr = hw->pcsr;
140 value = readl(ioaddr + MTL_RXQ_DMA_MAP0);
142 value = readl(ioaddr + MTL_RXQ_DMA_MAP1);
144 if (queue == 0 || queue == 4) {
145 value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK;
146 value |= MTL_RXQ_DMA_Q04MDMACH(chan);
148 value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue);
149 value |= MTL_RXQ_DMA_QXMDMACH(chan, queue);
153 writel(value, ioaddr + MTL_RXQ_DMA_MAP0);
155 writel(value, ioaddr + MTL_RXQ_DMA_MAP1);
158 static void dwmac4_config_cbs(struct mac_device_info *hw,
159 u32 send_slope, u32 idle_slope,
160 u32 high_credit, u32 low_credit, u32 queue)
162 void __iomem *ioaddr = hw->pcsr;
165 pr_debug("Queue %d configured as AVB. Parameters:\n", queue);
166 pr_debug("\tsend_slope: 0x%08x\n", send_slope);
167 pr_debug("\tidle_slope: 0x%08x\n", idle_slope);
168 pr_debug("\thigh_credit: 0x%08x\n", high_credit);
169 pr_debug("\tlow_credit: 0x%08x\n", low_credit);
171 /* enable AV algorithm */
172 value = readl(ioaddr + MTL_ETSX_CTRL_BASE_ADDR(queue));
173 value |= MTL_ETS_CTRL_AVALG;
174 value |= MTL_ETS_CTRL_CC;
175 writel(value, ioaddr + MTL_ETSX_CTRL_BASE_ADDR(queue));
177 /* configure send slope */
178 value = readl(ioaddr + MTL_SEND_SLP_CREDX_BASE_ADDR(queue));
179 value &= ~MTL_SEND_SLP_CRED_SSC_MASK;
180 value |= send_slope & MTL_SEND_SLP_CRED_SSC_MASK;
181 writel(value, ioaddr + MTL_SEND_SLP_CREDX_BASE_ADDR(queue));
183 /* configure idle slope (same register as tx weight) */
184 dwmac4_set_mtl_tx_queue_weight(hw, idle_slope, queue);
186 /* configure high credit */
187 value = readl(ioaddr + MTL_HIGH_CREDX_BASE_ADDR(queue));
188 value &= ~MTL_HIGH_CRED_HC_MASK;
189 value |= high_credit & MTL_HIGH_CRED_HC_MASK;
190 writel(value, ioaddr + MTL_HIGH_CREDX_BASE_ADDR(queue));
192 /* configure high credit */
193 value = readl(ioaddr + MTL_LOW_CREDX_BASE_ADDR(queue));
194 value &= ~MTL_HIGH_CRED_LC_MASK;
195 value |= low_credit & MTL_HIGH_CRED_LC_MASK;
196 writel(value, ioaddr + MTL_LOW_CREDX_BASE_ADDR(queue));
199 static void dwmac4_dump_regs(struct mac_device_info *hw, u32 *reg_space)
201 void __iomem *ioaddr = hw->pcsr;
204 for (i = 0; i < GMAC_REG_NUM; i++)
205 reg_space[i] = readl(ioaddr + i * 4);
208 static int dwmac4_rx_ipc_enable(struct mac_device_info *hw)
210 void __iomem *ioaddr = hw->pcsr;
211 u32 value = readl(ioaddr + GMAC_CONFIG);
214 value |= GMAC_CONFIG_IPC;
216 value &= ~GMAC_CONFIG_IPC;
218 writel(value, ioaddr + GMAC_CONFIG);
220 value = readl(ioaddr + GMAC_CONFIG);
222 return !!(value & GMAC_CONFIG_IPC);
225 static void dwmac4_pmt(struct mac_device_info *hw, unsigned long mode)
227 void __iomem *ioaddr = hw->pcsr;
228 unsigned int pmt = 0;
230 if (mode & WAKE_MAGIC) {
231 pr_debug("GMAC: WOL Magic frame\n");
232 pmt |= power_down | magic_pkt_en;
234 if (mode & WAKE_UCAST) {
235 pr_debug("GMAC: WOL on global unicast\n");
236 pmt |= power_down | global_unicast | wake_up_frame_en;
239 writel(pmt, ioaddr + GMAC_PMT);
242 static void dwmac4_set_umac_addr(struct mac_device_info *hw,
243 unsigned char *addr, unsigned int reg_n)
245 void __iomem *ioaddr = hw->pcsr;
247 stmmac_dwmac4_set_mac_addr(ioaddr, addr, GMAC_ADDR_HIGH(reg_n),
248 GMAC_ADDR_LOW(reg_n));
251 static void dwmac4_get_umac_addr(struct mac_device_info *hw,
252 unsigned char *addr, unsigned int reg_n)
254 void __iomem *ioaddr = hw->pcsr;
256 stmmac_dwmac4_get_mac_addr(ioaddr, addr, GMAC_ADDR_HIGH(reg_n),
257 GMAC_ADDR_LOW(reg_n));
260 static void dwmac4_set_eee_mode(struct mac_device_info *hw,
261 bool en_tx_lpi_clockgating)
263 void __iomem *ioaddr = hw->pcsr;
266 /* Enable the link status receive on RGMII, SGMII ore SMII
267 * receive path and instruct the transmit to enter in LPI
270 value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
271 value |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA;
273 if (en_tx_lpi_clockgating)
274 value |= GMAC4_LPI_CTRL_STATUS_LPITCSE;
276 writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
279 static void dwmac4_reset_eee_mode(struct mac_device_info *hw)
281 void __iomem *ioaddr = hw->pcsr;
284 value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
285 value &= ~(GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA);
286 writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
289 static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link)
291 void __iomem *ioaddr = hw->pcsr;
294 value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
297 value |= GMAC4_LPI_CTRL_STATUS_PLS;
299 value &= ~GMAC4_LPI_CTRL_STATUS_PLS;
301 writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
304 static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw)
306 void __iomem *ioaddr = hw->pcsr;
307 int value = ((tw & 0xffff)) | ((ls & 0x3ff) << 16);
309 /* Program the timers in the LPI timer control register:
310 * LS: minimum time (ms) for which the link
311 * status from PHY should be ok before transmitting
313 * TW: minimum time (us) for which the core waits
314 * after it has stopped transmitting the LPI pattern.
316 writel(value, ioaddr + GMAC4_LPI_TIMER_CTRL);
319 static void dwmac4_set_filter(struct mac_device_info *hw,
320 struct net_device *dev)
322 void __iomem *ioaddr = (void __iomem *)dev->base_addr;
323 unsigned int value = 0;
325 if (dev->flags & IFF_PROMISC) {
326 value = GMAC_PACKET_FILTER_PR;
327 } else if ((dev->flags & IFF_ALLMULTI) ||
328 (netdev_mc_count(dev) > HASH_TABLE_SIZE)) {
330 value = GMAC_PACKET_FILTER_PM;
331 /* Set the 64 bits of the HASH tab. To be updated if taller
334 writel(0xffffffff, ioaddr + GMAC_HASH_TAB_0_31);
335 writel(0xffffffff, ioaddr + GMAC_HASH_TAB_32_63);
336 } else if (!netdev_mc_empty(dev)) {
338 struct netdev_hw_addr *ha;
340 /* Hash filter for multicast */
341 value = GMAC_PACKET_FILTER_HMC;
343 memset(mc_filter, 0, sizeof(mc_filter));
344 netdev_for_each_mc_addr(ha, dev) {
345 /* The upper 6 bits of the calculated CRC are used to
346 * index the content of the Hash Table Reg 0 and 1.
349 (bitrev32(~crc32_le(~0, ha->addr, 6)) >> 26);
350 /* The most significant bit determines the register
351 * to use while the other 5 bits determines the bit
352 * within the selected register
354 mc_filter[bit_nr >> 5] |= (1 << (bit_nr & 0x1F));
356 writel(mc_filter[0], ioaddr + GMAC_HASH_TAB_0_31);
357 writel(mc_filter[1], ioaddr + GMAC_HASH_TAB_32_63);
360 /* Handle multiple unicast addresses */
361 if (netdev_uc_count(dev) > GMAC_MAX_PERFECT_ADDRESSES) {
362 /* Switch to promiscuous mode if more than 128 addrs
365 value |= GMAC_PACKET_FILTER_PR;
366 } else if (!netdev_uc_empty(dev)) {
368 struct netdev_hw_addr *ha;
370 netdev_for_each_uc_addr(ha, dev) {
371 dwmac4_set_umac_addr(hw, ha->addr, reg);
376 writel(value, ioaddr + GMAC_PACKET_FILTER);
379 static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
380 unsigned int fc, unsigned int pause_time,
383 void __iomem *ioaddr = hw->pcsr;
384 unsigned int flow = 0;
387 pr_debug("GMAC Flow-Control:\n");
389 pr_debug("\tReceive Flow-Control ON\n");
390 flow |= GMAC_RX_FLOW_CTRL_RFE;
391 writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
394 pr_debug("\tTransmit Flow-Control ON\n");
397 pr_debug("\tduplex mode: PAUSE %d\n", pause_time);
399 for (queue = 0; queue < tx_cnt; queue++) {
400 flow |= GMAC_TX_FLOW_CTRL_TFE;
404 (pause_time << GMAC_TX_FLOW_CTRL_PT_SHIFT);
406 writel(flow, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue));
411 static void dwmac4_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral,
414 dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback);
417 static void dwmac4_rane(void __iomem *ioaddr, bool restart)
419 dwmac_rane(ioaddr, GMAC_PCS_BASE, restart);
422 static void dwmac4_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv)
424 dwmac_get_adv_lp(ioaddr, GMAC_PCS_BASE, adv);
427 /* RGMII or SMII interface */
428 static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
432 status = readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS);
435 /* Check the link status */
436 if (status & GMAC_PHYIF_CTRLSTATUS_LNKSTS) {
441 speed_value = ((status & GMAC_PHYIF_CTRLSTATUS_SPEED) >>
442 GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT);
443 if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_125)
444 x->pcs_speed = SPEED_1000;
445 else if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_25)
446 x->pcs_speed = SPEED_100;
448 x->pcs_speed = SPEED_10;
450 x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK);
452 pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed,
453 x->pcs_duplex ? "Full" : "Half");
456 pr_info("Link is Down\n");
460 static int dwmac4_irq_mtl_status(struct mac_device_info *hw, u32 chan)
462 void __iomem *ioaddr = hw->pcsr;
463 u32 mtl_int_qx_status;
466 mtl_int_qx_status = readl(ioaddr + MTL_INT_STATUS);
468 /* Check MTL Interrupt */
469 if (mtl_int_qx_status & MTL_INT_QX(chan)) {
470 /* read Queue x Interrupt status */
471 u32 status = readl(ioaddr + MTL_CHAN_INT_CTRL(chan));
473 if (status & MTL_RX_OVERFLOW_INT) {
474 /* clear Interrupt */
475 writel(status | MTL_RX_OVERFLOW_INT,
476 ioaddr + MTL_CHAN_INT_CTRL(chan));
477 ret = CORE_IRQ_MTL_RX_OVERFLOW;
484 static int dwmac4_irq_status(struct mac_device_info *hw,
485 struct stmmac_extra_stats *x)
487 void __iomem *ioaddr = hw->pcsr;
491 intr_status = readl(ioaddr + GMAC_INT_STATUS);
493 /* Not used events (e.g. MMC interrupts) are not handled. */
494 if ((intr_status & mmc_tx_irq))
496 if (unlikely(intr_status & mmc_rx_irq))
498 if (unlikely(intr_status & mmc_rx_csum_offload_irq))
499 x->mmc_rx_csum_offload_irq_n++;
500 /* Clear the PMT bits 5 and 6 by reading the PMT status reg */
501 if (unlikely(intr_status & pmt_irq)) {
502 readl(ioaddr + GMAC_PMT);
503 x->irq_receive_pmt_irq_n++;
506 dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x);
507 if (intr_status & PCS_RGSMIIIS_IRQ)
508 dwmac4_phystatus(ioaddr, x);
513 static void dwmac4_debug(void __iomem *ioaddr, struct stmmac_extra_stats *x,
514 u32 rx_queues, u32 tx_queues)
519 for (queue = 0; queue < tx_queues; queue++) {
520 value = readl(ioaddr + MTL_CHAN_TX_DEBUG(queue));
522 if (value & MTL_DEBUG_TXSTSFSTS)
523 x->mtl_tx_status_fifo_full++;
524 if (value & MTL_DEBUG_TXFSTS)
525 x->mtl_tx_fifo_not_empty++;
526 if (value & MTL_DEBUG_TWCSTS)
528 if (value & MTL_DEBUG_TRCSTS_MASK) {
529 u32 trcsts = (value & MTL_DEBUG_TRCSTS_MASK)
530 >> MTL_DEBUG_TRCSTS_SHIFT;
531 if (trcsts == MTL_DEBUG_TRCSTS_WRITE)
532 x->mtl_tx_fifo_read_ctrl_write++;
533 else if (trcsts == MTL_DEBUG_TRCSTS_TXW)
534 x->mtl_tx_fifo_read_ctrl_wait++;
535 else if (trcsts == MTL_DEBUG_TRCSTS_READ)
536 x->mtl_tx_fifo_read_ctrl_read++;
538 x->mtl_tx_fifo_read_ctrl_idle++;
540 if (value & MTL_DEBUG_TXPAUSED)
541 x->mac_tx_in_pause++;
544 for (queue = 0; queue < rx_queues; queue++) {
545 value = readl(ioaddr + MTL_CHAN_RX_DEBUG(queue));
547 if (value & MTL_DEBUG_RXFSTS_MASK) {
548 u32 rxfsts = (value & MTL_DEBUG_RXFSTS_MASK)
549 >> MTL_DEBUG_RRCSTS_SHIFT;
551 if (rxfsts == MTL_DEBUG_RXFSTS_FULL)
552 x->mtl_rx_fifo_fill_level_full++;
553 else if (rxfsts == MTL_DEBUG_RXFSTS_AT)
554 x->mtl_rx_fifo_fill_above_thresh++;
555 else if (rxfsts == MTL_DEBUG_RXFSTS_BT)
556 x->mtl_rx_fifo_fill_below_thresh++;
558 x->mtl_rx_fifo_fill_level_empty++;
560 if (value & MTL_DEBUG_RRCSTS_MASK) {
561 u32 rrcsts = (value & MTL_DEBUG_RRCSTS_MASK) >>
562 MTL_DEBUG_RRCSTS_SHIFT;
564 if (rrcsts == MTL_DEBUG_RRCSTS_FLUSH)
565 x->mtl_rx_fifo_read_ctrl_flush++;
566 else if (rrcsts == MTL_DEBUG_RRCSTS_RSTAT)
567 x->mtl_rx_fifo_read_ctrl_read_data++;
568 else if (rrcsts == MTL_DEBUG_RRCSTS_RDATA)
569 x->mtl_rx_fifo_read_ctrl_status++;
571 x->mtl_rx_fifo_read_ctrl_idle++;
573 if (value & MTL_DEBUG_RWCSTS)
574 x->mtl_rx_fifo_ctrl_active++;
578 value = readl(ioaddr + GMAC_DEBUG);
580 if (value & GMAC_DEBUG_TFCSTS_MASK) {
581 u32 tfcsts = (value & GMAC_DEBUG_TFCSTS_MASK)
582 >> GMAC_DEBUG_TFCSTS_SHIFT;
584 if (tfcsts == GMAC_DEBUG_TFCSTS_XFER)
585 x->mac_tx_frame_ctrl_xfer++;
586 else if (tfcsts == GMAC_DEBUG_TFCSTS_GEN_PAUSE)
587 x->mac_tx_frame_ctrl_pause++;
588 else if (tfcsts == GMAC_DEBUG_TFCSTS_WAIT)
589 x->mac_tx_frame_ctrl_wait++;
591 x->mac_tx_frame_ctrl_idle++;
593 if (value & GMAC_DEBUG_TPESTS)
594 x->mac_gmii_tx_proto_engine++;
595 if (value & GMAC_DEBUG_RFCFCSTS_MASK)
596 x->mac_rx_frame_ctrl_fifo = (value & GMAC_DEBUG_RFCFCSTS_MASK)
597 >> GMAC_DEBUG_RFCFCSTS_SHIFT;
598 if (value & GMAC_DEBUG_RPESTS)
599 x->mac_gmii_rx_proto_engine++;
602 static const struct stmmac_ops dwmac4_ops = {
603 .core_init = dwmac4_core_init,
604 .rx_ipc = dwmac4_rx_ipc_enable,
605 .rx_queue_enable = dwmac4_rx_queue_enable,
606 .prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
607 .prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
608 .set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
609 .map_mtl_to_dma = dwmac4_map_mtl_dma,
610 .config_cbs = dwmac4_config_cbs,
611 .dump_regs = dwmac4_dump_regs,
612 .host_irq_status = dwmac4_irq_status,
613 .host_mtl_irq_status = dwmac4_irq_mtl_status,
614 .flow_ctrl = dwmac4_flow_ctrl,
616 .set_umac_addr = dwmac4_set_umac_addr,
617 .get_umac_addr = dwmac4_get_umac_addr,
618 .set_eee_mode = dwmac4_set_eee_mode,
619 .reset_eee_mode = dwmac4_reset_eee_mode,
620 .set_eee_timer = dwmac4_set_eee_timer,
621 .set_eee_pls = dwmac4_set_eee_pls,
622 .pcs_ctrl_ane = dwmac4_ctrl_ane,
623 .pcs_rane = dwmac4_rane,
624 .pcs_get_adv_lp = dwmac4_get_adv_lp,
625 .debug = dwmac4_debug,
626 .set_filter = dwmac4_set_filter,
629 struct mac_device_info *dwmac4_setup(void __iomem *ioaddr, int mcbins,
630 int perfect_uc_entries, int *synopsys_id)
632 struct mac_device_info *mac;
633 u32 hwid = readl(ioaddr + GMAC_VERSION);
635 mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
640 mac->multicast_filter_bins = mcbins;
641 mac->unicast_filter_entries = perfect_uc_entries;
642 mac->mcast_bits_log2 = 0;
644 if (mac->multicast_filter_bins)
645 mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
647 mac->mac = &dwmac4_ops;
649 mac->link.port = GMAC_CONFIG_PS;
650 mac->link.duplex = GMAC_CONFIG_DM;
651 mac->link.speed = GMAC_CONFIG_FES;
652 mac->mii.addr = GMAC_MDIO_ADDR;
653 mac->mii.data = GMAC_MDIO_DATA;
654 mac->mii.addr_shift = 21;
655 mac->mii.addr_mask = GENMASK(25, 21);
656 mac->mii.reg_shift = 16;
657 mac->mii.reg_mask = GENMASK(20, 16);
658 mac->mii.clk_csr_shift = 8;
659 mac->mii.clk_csr_mask = GENMASK(11, 8);
661 /* Get and dump the chip ID */
662 *synopsys_id = stmmac_get_synopsys_id(hwid);
664 if (*synopsys_id > DWMAC_CORE_4_00)
665 mac->dma = &dwmac410_dma_ops;
667 mac->dma = &dwmac4_dma_ops;