Lines Matching refs:priv

164 static void stmmac_clk_csr_set(struct stmmac_priv *priv)  in stmmac_clk_csr_set()  argument
168 clk_rate = clk_get_rate(priv->stmmac_clk); in stmmac_clk_csr_set()
177 if (!(priv->clk_csr & MAC_CSR_H_FRQ_MASK)) { in stmmac_clk_csr_set()
179 priv->clk_csr = STMMAC_CSR_20_35M; in stmmac_clk_csr_set()
181 priv->clk_csr = STMMAC_CSR_35_60M; in stmmac_clk_csr_set()
183 priv->clk_csr = STMMAC_CSR_60_100M; in stmmac_clk_csr_set()
185 priv->clk_csr = STMMAC_CSR_100_150M; in stmmac_clk_csr_set()
187 priv->clk_csr = STMMAC_CSR_150_250M; in stmmac_clk_csr_set()
189 priv->clk_csr = STMMAC_CSR_250_300M; in stmmac_clk_csr_set()
202 static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) in stmmac_tx_avail() argument
204 return priv->dirty_tx + priv->dma_tx_size - priv->cur_tx - 1; in stmmac_tx_avail()
213 static inline void stmmac_hw_fix_mac_speed(struct stmmac_priv *priv) in stmmac_hw_fix_mac_speed() argument
215 struct phy_device *phydev = priv->phydev; in stmmac_hw_fix_mac_speed()
217 if (likely(priv->plat->fix_mac_speed)) in stmmac_hw_fix_mac_speed()
218 priv->plat->fix_mac_speed(priv->plat->bsp_priv, phydev->speed); in stmmac_hw_fix_mac_speed()
227 static void stmmac_enable_eee_mode(struct stmmac_priv *priv) in stmmac_enable_eee_mode() argument
230 if ((priv->dirty_tx == priv->cur_tx) && in stmmac_enable_eee_mode()
231 (priv->tx_path_in_lpi_mode == false)) in stmmac_enable_eee_mode()
232 priv->hw->mac->set_eee_mode(priv->hw); in stmmac_enable_eee_mode()
241 void stmmac_disable_eee_mode(struct stmmac_priv *priv) in stmmac_disable_eee_mode() argument
243 priv->hw->mac->reset_eee_mode(priv->hw); in stmmac_disable_eee_mode()
244 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_disable_eee_mode()
245 priv->tx_path_in_lpi_mode = false; in stmmac_disable_eee_mode()
257 struct stmmac_priv *priv = (struct stmmac_priv *)arg; in stmmac_eee_ctrl_timer() local
259 stmmac_enable_eee_mode(priv); in stmmac_eee_ctrl_timer()
260 mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(eee_timer)); in stmmac_eee_ctrl_timer()
271 bool stmmac_eee_init(struct stmmac_priv *priv) in stmmac_eee_init() argument
273 char *phy_bus_name = priv->plat->phy_bus_name; in stmmac_eee_init()
280 if ((priv->pcs == STMMAC_PCS_RGMII) || (priv->pcs == STMMAC_PCS_TBI) || in stmmac_eee_init()
281 (priv->pcs == STMMAC_PCS_RTBI)) in stmmac_eee_init()
289 if (priv->dma_cap.eee) { in stmmac_eee_init()
290 int tx_lpi_timer = priv->tx_lpi_timer; in stmmac_eee_init()
293 if (phy_init_eee(priv->phydev, 1)) { in stmmac_eee_init()
299 spin_lock_irqsave(&priv->lock, flags); in stmmac_eee_init()
300 if (priv->eee_active) { in stmmac_eee_init()
302 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_eee_init()
303 priv->hw->mac->set_eee_timer(priv->hw, 0, in stmmac_eee_init()
306 priv->eee_active = 0; in stmmac_eee_init()
307 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_eee_init()
311 spin_lock_irqsave(&priv->lock, flags); in stmmac_eee_init()
312 if (!priv->eee_active) { in stmmac_eee_init()
313 priv->eee_active = 1; in stmmac_eee_init()
314 setup_timer(&priv->eee_ctrl_timer, in stmmac_eee_init()
316 (unsigned long)priv); in stmmac_eee_init()
317 mod_timer(&priv->eee_ctrl_timer, in stmmac_eee_init()
320 priv->hw->mac->set_eee_timer(priv->hw, in stmmac_eee_init()
325 priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); in stmmac_eee_init()
328 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_eee_init()
344 static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, in stmmac_get_tx_hwtstamp() argument
351 if (!priv->hwts_tx_en) in stmmac_get_tx_hwtstamp()
358 if (priv->adv_ts) in stmmac_get_tx_hwtstamp()
359 desc = (priv->dma_etx + entry); in stmmac_get_tx_hwtstamp()
361 desc = (priv->dma_tx + entry); in stmmac_get_tx_hwtstamp()
364 if (!priv->hw->desc->get_tx_timestamp_status((struct dma_desc *)desc)) in stmmac_get_tx_hwtstamp()
368 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); in stmmac_get_tx_hwtstamp()
386 static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, in stmmac_get_rx_hwtstamp() argument
393 if (!priv->hwts_rx_en) in stmmac_get_rx_hwtstamp()
396 if (priv->adv_ts) in stmmac_get_rx_hwtstamp()
397 desc = (priv->dma_erx + entry); in stmmac_get_rx_hwtstamp()
399 desc = (priv->dma_rx + entry); in stmmac_get_rx_hwtstamp()
402 if (!priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) in stmmac_get_rx_hwtstamp()
406 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); in stmmac_get_rx_hwtstamp()
425 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_hwtstamp_ioctl() local
439 if (!(priv->dma_cap.time_stamp || priv->adv_ts)) { in stmmac_hwtstamp_ioctl()
440 netdev_alert(priv->dev, "No support for HW time stamping\n"); in stmmac_hwtstamp_ioctl()
441 priv->hwts_tx_en = 0; in stmmac_hwtstamp_ioctl()
442 priv->hwts_rx_en = 0; in stmmac_hwtstamp_ioctl()
462 if (priv->adv_ts) { in stmmac_hwtstamp_ioctl()
591 priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); in stmmac_hwtstamp_ioctl()
592 priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; in stmmac_hwtstamp_ioctl()
594 if (!priv->hwts_tx_en && !priv->hwts_rx_en) in stmmac_hwtstamp_ioctl()
595 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0); in stmmac_hwtstamp_ioctl()
602 priv->hw->ptp->config_hw_tstamping(priv->ioaddr, value); in stmmac_hwtstamp_ioctl()
605 priv->hw->ptp->config_sub_second_increment(priv->ioaddr); in stmmac_hwtstamp_ioctl()
619 priv->default_addend = div_u64(temp, priv->clk_ptp_rate); in stmmac_hwtstamp_ioctl()
620 priv->hw->ptp->config_addend(priv->ioaddr, in stmmac_hwtstamp_ioctl()
621 priv->default_addend); in stmmac_hwtstamp_ioctl()
627 priv->hw->ptp->init_systime(priv->ioaddr, (u32)now.tv_sec, in stmmac_hwtstamp_ioctl()
642 static int stmmac_init_ptp(struct stmmac_priv *priv) in stmmac_init_ptp() argument
644 if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) in stmmac_init_ptp()
648 priv->clk_ptp_ref = devm_clk_get(priv->device, "clk_ptp_ref"); in stmmac_init_ptp()
649 if (IS_ERR(priv->clk_ptp_ref)) { in stmmac_init_ptp()
650 priv->clk_ptp_rate = clk_get_rate(priv->stmmac_clk); in stmmac_init_ptp()
651 priv->clk_ptp_ref = NULL; in stmmac_init_ptp()
653 clk_prepare_enable(priv->clk_ptp_ref); in stmmac_init_ptp()
654 priv->clk_ptp_rate = clk_get_rate(priv->clk_ptp_ref); in stmmac_init_ptp()
657 priv->adv_ts = 0; in stmmac_init_ptp()
658 if (priv->dma_cap.atime_stamp && priv->extend_desc) in stmmac_init_ptp()
659 priv->adv_ts = 1; in stmmac_init_ptp()
661 if (netif_msg_hw(priv) && priv->dma_cap.time_stamp) in stmmac_init_ptp()
664 if (netif_msg_hw(priv) && priv->adv_ts) in stmmac_init_ptp()
667 priv->hw->ptp = &stmmac_ptp; in stmmac_init_ptp()
668 priv->hwts_tx_en = 0; in stmmac_init_ptp()
669 priv->hwts_rx_en = 0; in stmmac_init_ptp()
671 return stmmac_ptp_register(priv); in stmmac_init_ptp()
674 static void stmmac_release_ptp(struct stmmac_priv *priv) in stmmac_release_ptp() argument
676 if (priv->clk_ptp_ref) in stmmac_release_ptp()
677 clk_disable_unprepare(priv->clk_ptp_ref); in stmmac_release_ptp()
678 stmmac_ptp_unregister(priv); in stmmac_release_ptp()
692 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_adjust_link() local
693 struct phy_device *phydev = priv->phydev; in stmmac_adjust_link()
696 unsigned int fc = priv->flow_ctrl, pause_time = priv->pause; in stmmac_adjust_link()
701 spin_lock_irqsave(&priv->lock, flags); in stmmac_adjust_link()
704 u32 ctrl = readl(priv->ioaddr + MAC_CTRL_REG); in stmmac_adjust_link()
708 if (phydev->duplex != priv->oldduplex) { in stmmac_adjust_link()
711 ctrl &= ~priv->hw->link.duplex; in stmmac_adjust_link()
713 ctrl |= priv->hw->link.duplex; in stmmac_adjust_link()
714 priv->oldduplex = phydev->duplex; in stmmac_adjust_link()
718 priv->hw->mac->flow_ctrl(priv->hw, phydev->duplex, in stmmac_adjust_link()
721 if (phydev->speed != priv->speed) { in stmmac_adjust_link()
725 if (likely(priv->plat->has_gmac)) in stmmac_adjust_link()
726 ctrl &= ~priv->hw->link.port; in stmmac_adjust_link()
727 stmmac_hw_fix_mac_speed(priv); in stmmac_adjust_link()
731 if (priv->plat->has_gmac) { in stmmac_adjust_link()
732 ctrl |= priv->hw->link.port; in stmmac_adjust_link()
734 ctrl |= priv->hw->link.speed; in stmmac_adjust_link()
736 ctrl &= ~(priv->hw->link.speed); in stmmac_adjust_link()
739 ctrl &= ~priv->hw->link.port; in stmmac_adjust_link()
741 stmmac_hw_fix_mac_speed(priv); in stmmac_adjust_link()
744 if (netif_msg_link(priv)) in stmmac_adjust_link()
750 priv->speed = phydev->speed; in stmmac_adjust_link()
753 writel(ctrl, priv->ioaddr + MAC_CTRL_REG); in stmmac_adjust_link()
755 if (!priv->oldlink) { in stmmac_adjust_link()
757 priv->oldlink = 1; in stmmac_adjust_link()
759 } else if (priv->oldlink) { in stmmac_adjust_link()
761 priv->oldlink = 0; in stmmac_adjust_link()
762 priv->speed = 0; in stmmac_adjust_link()
763 priv->oldduplex = -1; in stmmac_adjust_link()
766 if (new_state && netif_msg_link(priv)) in stmmac_adjust_link()
769 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_adjust_link()
774 priv->eee_enabled = stmmac_eee_init(priv); in stmmac_adjust_link()
784 static void stmmac_check_pcs_mode(struct stmmac_priv *priv) in stmmac_check_pcs_mode() argument
786 int interface = priv->plat->interface; in stmmac_check_pcs_mode()
788 if (priv->dma_cap.pcs) { in stmmac_check_pcs_mode()
794 priv->pcs = STMMAC_PCS_RGMII; in stmmac_check_pcs_mode()
797 priv->pcs = STMMAC_PCS_SGMII; in stmmac_check_pcs_mode()
812 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_init_phy() local
816 int interface = priv->plat->interface; in stmmac_init_phy()
817 int max_speed = priv->plat->max_speed; in stmmac_init_phy()
818 priv->oldlink = 0; in stmmac_init_phy()
819 priv->speed = 0; in stmmac_init_phy()
820 priv->oldduplex = -1; in stmmac_init_phy()
822 if (priv->plat->phy_node) { in stmmac_init_phy()
823 phydev = of_phy_connect(dev, priv->plat->phy_node, in stmmac_init_phy()
826 if (priv->plat->phy_bus_name) in stmmac_init_phy()
828 priv->plat->phy_bus_name, priv->plat->bus_id); in stmmac_init_phy()
831 priv->plat->bus_id); in stmmac_init_phy()
834 priv->plat->phy_addr); in stmmac_init_phy()
864 if (!priv->plat->phy_node && phydev->phy_id == 0) { in stmmac_init_phy()
871 priv->phydev = phydev; in stmmac_init_phy()
910 static void stmmac_display_rings(struct stmmac_priv *priv) in stmmac_display_rings() argument
912 unsigned int txsize = priv->dma_tx_size; in stmmac_display_rings()
913 unsigned int rxsize = priv->dma_rx_size; in stmmac_display_rings()
915 if (priv->extend_desc) { in stmmac_display_rings()
917 stmmac_display_ring((void *)priv->dma_erx, rxsize, 1); in stmmac_display_rings()
919 stmmac_display_ring((void *)priv->dma_etx, txsize, 1); in stmmac_display_rings()
922 stmmac_display_ring((void *)priv->dma_rx, rxsize, 0); in stmmac_display_rings()
924 stmmac_display_ring((void *)priv->dma_tx, txsize, 0); in stmmac_display_rings()
950 static void stmmac_clear_descriptors(struct stmmac_priv *priv) in stmmac_clear_descriptors() argument
953 unsigned int txsize = priv->dma_tx_size; in stmmac_clear_descriptors()
954 unsigned int rxsize = priv->dma_rx_size; in stmmac_clear_descriptors()
958 if (priv->extend_desc) in stmmac_clear_descriptors()
959 priv->hw->desc->init_rx_desc(&priv->dma_erx[i].basic, in stmmac_clear_descriptors()
960 priv->use_riwt, priv->mode, in stmmac_clear_descriptors()
963 priv->hw->desc->init_rx_desc(&priv->dma_rx[i], in stmmac_clear_descriptors()
964 priv->use_riwt, priv->mode, in stmmac_clear_descriptors()
967 if (priv->extend_desc) in stmmac_clear_descriptors()
968 priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, in stmmac_clear_descriptors()
969 priv->mode, in stmmac_clear_descriptors()
972 priv->hw->desc->init_tx_desc(&priv->dma_tx[i], in stmmac_clear_descriptors()
973 priv->mode, in stmmac_clear_descriptors()
986 static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, in stmmac_init_rx_buffers() argument
991 skb = __netdev_alloc_skb_ip_align(priv->dev, priv->dma_buf_sz, flags); in stmmac_init_rx_buffers()
996 priv->rx_skbuff[i] = skb; in stmmac_init_rx_buffers()
997 priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data, in stmmac_init_rx_buffers()
998 priv->dma_buf_sz, in stmmac_init_rx_buffers()
1000 if (dma_mapping_error(priv->device, priv->rx_skbuff_dma[i])) { in stmmac_init_rx_buffers()
1006 p->des2 = priv->rx_skbuff_dma[i]; in stmmac_init_rx_buffers()
1008 if ((priv->hw->mode->init_desc3) && in stmmac_init_rx_buffers()
1009 (priv->dma_buf_sz == BUF_SIZE_16KiB)) in stmmac_init_rx_buffers()
1010 priv->hw->mode->init_desc3(p); in stmmac_init_rx_buffers()
1015 static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i) in stmmac_free_rx_buffers() argument
1017 if (priv->rx_skbuff[i]) { in stmmac_free_rx_buffers()
1018 dma_unmap_single(priv->device, priv->rx_skbuff_dma[i], in stmmac_free_rx_buffers()
1019 priv->dma_buf_sz, DMA_FROM_DEVICE); in stmmac_free_rx_buffers()
1020 dev_kfree_skb_any(priv->rx_skbuff[i]); in stmmac_free_rx_buffers()
1022 priv->rx_skbuff[i] = NULL; in stmmac_free_rx_buffers()
1036 struct stmmac_priv *priv = netdev_priv(dev); in init_dma_desc_rings() local
1037 unsigned int txsize = priv->dma_tx_size; in init_dma_desc_rings()
1038 unsigned int rxsize = priv->dma_rx_size; in init_dma_desc_rings()
1042 if (priv->hw->mode->set_16kib_bfsize) in init_dma_desc_rings()
1043 bfsize = priv->hw->mode->set_16kib_bfsize(dev->mtu); in init_dma_desc_rings()
1046 bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz); in init_dma_desc_rings()
1048 priv->dma_buf_sz = bfsize; in init_dma_desc_rings()
1050 if (netif_msg_probe(priv)) in init_dma_desc_rings()
1054 if (netif_msg_probe(priv)) { in init_dma_desc_rings()
1056 (u32) priv->dma_rx_phy, (u32) priv->dma_tx_phy); in init_dma_desc_rings()
1063 if (priv->extend_desc) in init_dma_desc_rings()
1064 p = &((priv->dma_erx + i)->basic); in init_dma_desc_rings()
1066 p = priv->dma_rx + i; in init_dma_desc_rings()
1068 ret = stmmac_init_rx_buffers(priv, p, i, flags); in init_dma_desc_rings()
1072 if (netif_msg_probe(priv)) in init_dma_desc_rings()
1073 pr_debug("[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i], in init_dma_desc_rings()
1074 priv->rx_skbuff[i]->data, in init_dma_desc_rings()
1075 (unsigned int)priv->rx_skbuff_dma[i]); in init_dma_desc_rings()
1077 priv->cur_rx = 0; in init_dma_desc_rings()
1078 priv->dirty_rx = (unsigned int)(i - rxsize); in init_dma_desc_rings()
1082 if (priv->mode == STMMAC_CHAIN_MODE) { in init_dma_desc_rings()
1083 if (priv->extend_desc) { in init_dma_desc_rings()
1084 priv->hw->mode->init(priv->dma_erx, priv->dma_rx_phy, in init_dma_desc_rings()
1086 priv->hw->mode->init(priv->dma_etx, priv->dma_tx_phy, in init_dma_desc_rings()
1089 priv->hw->mode->init(priv->dma_rx, priv->dma_rx_phy, in init_dma_desc_rings()
1091 priv->hw->mode->init(priv->dma_tx, priv->dma_tx_phy, in init_dma_desc_rings()
1099 if (priv->extend_desc) in init_dma_desc_rings()
1100 p = &((priv->dma_etx + i)->basic); in init_dma_desc_rings()
1102 p = priv->dma_tx + i; in init_dma_desc_rings()
1104 priv->tx_skbuff_dma[i].buf = 0; in init_dma_desc_rings()
1105 priv->tx_skbuff_dma[i].map_as_page = false; in init_dma_desc_rings()
1106 priv->tx_skbuff[i] = NULL; in init_dma_desc_rings()
1109 priv->dirty_tx = 0; in init_dma_desc_rings()
1110 priv->cur_tx = 0; in init_dma_desc_rings()
1111 netdev_reset_queue(priv->dev); in init_dma_desc_rings()
1113 stmmac_clear_descriptors(priv); in init_dma_desc_rings()
1115 if (netif_msg_hw(priv)) in init_dma_desc_rings()
1116 stmmac_display_rings(priv); in init_dma_desc_rings()
1121 stmmac_free_rx_buffers(priv, i); in init_dma_desc_rings()
1125 static void dma_free_rx_skbufs(struct stmmac_priv *priv) in dma_free_rx_skbufs() argument
1129 for (i = 0; i < priv->dma_rx_size; i++) in dma_free_rx_skbufs()
1130 stmmac_free_rx_buffers(priv, i); in dma_free_rx_skbufs()
1133 static void dma_free_tx_skbufs(struct stmmac_priv *priv) in dma_free_tx_skbufs() argument
1137 for (i = 0; i < priv->dma_tx_size; i++) { in dma_free_tx_skbufs()
1140 if (priv->extend_desc) in dma_free_tx_skbufs()
1141 p = &((priv->dma_etx + i)->basic); in dma_free_tx_skbufs()
1143 p = priv->dma_tx + i; in dma_free_tx_skbufs()
1145 if (priv->tx_skbuff_dma[i].buf) { in dma_free_tx_skbufs()
1146 if (priv->tx_skbuff_dma[i].map_as_page) in dma_free_tx_skbufs()
1147 dma_unmap_page(priv->device, in dma_free_tx_skbufs()
1148 priv->tx_skbuff_dma[i].buf, in dma_free_tx_skbufs()
1149 priv->hw->desc->get_tx_len(p), in dma_free_tx_skbufs()
1152 dma_unmap_single(priv->device, in dma_free_tx_skbufs()
1153 priv->tx_skbuff_dma[i].buf, in dma_free_tx_skbufs()
1154 priv->hw->desc->get_tx_len(p), in dma_free_tx_skbufs()
1158 if (priv->tx_skbuff[i] != NULL) { in dma_free_tx_skbufs()
1159 dev_kfree_skb_any(priv->tx_skbuff[i]); in dma_free_tx_skbufs()
1160 priv->tx_skbuff[i] = NULL; in dma_free_tx_skbufs()
1161 priv->tx_skbuff_dma[i].buf = 0; in dma_free_tx_skbufs()
1162 priv->tx_skbuff_dma[i].map_as_page = false; in dma_free_tx_skbufs()
1175 static int alloc_dma_desc_resources(struct stmmac_priv *priv) in alloc_dma_desc_resources() argument
1177 unsigned int txsize = priv->dma_tx_size; in alloc_dma_desc_resources()
1178 unsigned int rxsize = priv->dma_rx_size; in alloc_dma_desc_resources()
1181 priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t), in alloc_dma_desc_resources()
1183 if (!priv->rx_skbuff_dma) in alloc_dma_desc_resources()
1186 priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *), in alloc_dma_desc_resources()
1188 if (!priv->rx_skbuff) in alloc_dma_desc_resources()
1191 priv->tx_skbuff_dma = kmalloc_array(txsize, in alloc_dma_desc_resources()
1192 sizeof(*priv->tx_skbuff_dma), in alloc_dma_desc_resources()
1194 if (!priv->tx_skbuff_dma) in alloc_dma_desc_resources()
1197 priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *), in alloc_dma_desc_resources()
1199 if (!priv->tx_skbuff) in alloc_dma_desc_resources()
1202 if (priv->extend_desc) { in alloc_dma_desc_resources()
1203 priv->dma_erx = dma_zalloc_coherent(priv->device, rxsize * in alloc_dma_desc_resources()
1206 &priv->dma_rx_phy, in alloc_dma_desc_resources()
1208 if (!priv->dma_erx) in alloc_dma_desc_resources()
1211 priv->dma_etx = dma_zalloc_coherent(priv->device, txsize * in alloc_dma_desc_resources()
1214 &priv->dma_tx_phy, in alloc_dma_desc_resources()
1216 if (!priv->dma_etx) { in alloc_dma_desc_resources()
1217 dma_free_coherent(priv->device, priv->dma_rx_size * in alloc_dma_desc_resources()
1219 priv->dma_erx, priv->dma_rx_phy); in alloc_dma_desc_resources()
1223 priv->dma_rx = dma_zalloc_coherent(priv->device, rxsize * in alloc_dma_desc_resources()
1225 &priv->dma_rx_phy, in alloc_dma_desc_resources()
1227 if (!priv->dma_rx) in alloc_dma_desc_resources()
1230 priv->dma_tx = dma_zalloc_coherent(priv->device, txsize * in alloc_dma_desc_resources()
1232 &priv->dma_tx_phy, in alloc_dma_desc_resources()
1234 if (!priv->dma_tx) { in alloc_dma_desc_resources()
1235 dma_free_coherent(priv->device, priv->dma_rx_size * in alloc_dma_desc_resources()
1237 priv->dma_rx, priv->dma_rx_phy); in alloc_dma_desc_resources()
1245 kfree(priv->tx_skbuff); in alloc_dma_desc_resources()
1247 kfree(priv->tx_skbuff_dma); in alloc_dma_desc_resources()
1249 kfree(priv->rx_skbuff); in alloc_dma_desc_resources()
1251 kfree(priv->rx_skbuff_dma); in alloc_dma_desc_resources()
1255 static void free_dma_desc_resources(struct stmmac_priv *priv) in free_dma_desc_resources() argument
1258 dma_free_rx_skbufs(priv); in free_dma_desc_resources()
1259 dma_free_tx_skbufs(priv); in free_dma_desc_resources()
1262 if (!priv->extend_desc) { in free_dma_desc_resources()
1263 dma_free_coherent(priv->device, in free_dma_desc_resources()
1264 priv->dma_tx_size * sizeof(struct dma_desc), in free_dma_desc_resources()
1265 priv->dma_tx, priv->dma_tx_phy); in free_dma_desc_resources()
1266 dma_free_coherent(priv->device, in free_dma_desc_resources()
1267 priv->dma_rx_size * sizeof(struct dma_desc), in free_dma_desc_resources()
1268 priv->dma_rx, priv->dma_rx_phy); in free_dma_desc_resources()
1270 dma_free_coherent(priv->device, priv->dma_tx_size * in free_dma_desc_resources()
1272 priv->dma_etx, priv->dma_tx_phy); in free_dma_desc_resources()
1273 dma_free_coherent(priv->device, priv->dma_rx_size * in free_dma_desc_resources()
1275 priv->dma_erx, priv->dma_rx_phy); in free_dma_desc_resources()
1277 kfree(priv->rx_skbuff_dma); in free_dma_desc_resources()
1278 kfree(priv->rx_skbuff); in free_dma_desc_resources()
1279 kfree(priv->tx_skbuff_dma); in free_dma_desc_resources()
1280 kfree(priv->tx_skbuff); in free_dma_desc_resources()
1289 static void stmmac_dma_operation_mode(struct stmmac_priv *priv) in stmmac_dma_operation_mode() argument
1291 int rxfifosz = priv->plat->rx_fifo_size; in stmmac_dma_operation_mode()
1293 if (priv->plat->force_thresh_dma_mode) in stmmac_dma_operation_mode()
1294 priv->hw->dma->dma_mode(priv->ioaddr, tc, tc, rxfifosz); in stmmac_dma_operation_mode()
1295 else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) { in stmmac_dma_operation_mode()
1303 priv->hw->dma->dma_mode(priv->ioaddr, SF_DMA_MODE, SF_DMA_MODE, in stmmac_dma_operation_mode()
1305 priv->xstats.threshold = SF_DMA_MODE; in stmmac_dma_operation_mode()
1307 priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE, in stmmac_dma_operation_mode()
1316 static void stmmac_tx_clean(struct stmmac_priv *priv) in stmmac_tx_clean() argument
1318 unsigned int txsize = priv->dma_tx_size; in stmmac_tx_clean()
1321 spin_lock(&priv->tx_lock); in stmmac_tx_clean()
1323 priv->xstats.tx_clean++; in stmmac_tx_clean()
1325 while (priv->dirty_tx != priv->cur_tx) { in stmmac_tx_clean()
1327 unsigned int entry = priv->dirty_tx % txsize; in stmmac_tx_clean()
1328 struct sk_buff *skb = priv->tx_skbuff[entry]; in stmmac_tx_clean()
1331 if (priv->extend_desc) in stmmac_tx_clean()
1332 p = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_tx_clean()
1334 p = priv->dma_tx + entry; in stmmac_tx_clean()
1337 if (priv->hw->desc->get_tx_owner(p)) in stmmac_tx_clean()
1341 last = priv->hw->desc->get_tx_ls(p); in stmmac_tx_clean()
1344 priv->hw->desc->tx_status(&priv->dev->stats, in stmmac_tx_clean()
1345 &priv->xstats, p, in stmmac_tx_clean()
1346 priv->ioaddr); in stmmac_tx_clean()
1348 priv->dev->stats.tx_packets++; in stmmac_tx_clean()
1349 priv->xstats.tx_pkt_n++; in stmmac_tx_clean()
1351 priv->dev->stats.tx_errors++; in stmmac_tx_clean()
1353 stmmac_get_tx_hwtstamp(priv, entry, skb); in stmmac_tx_clean()
1355 if (netif_msg_tx_done(priv)) in stmmac_tx_clean()
1357 priv->cur_tx, priv->dirty_tx); in stmmac_tx_clean()
1359 if (likely(priv->tx_skbuff_dma[entry].buf)) { in stmmac_tx_clean()
1360 if (priv->tx_skbuff_dma[entry].map_as_page) in stmmac_tx_clean()
1361 dma_unmap_page(priv->device, in stmmac_tx_clean()
1362 priv->tx_skbuff_dma[entry].buf, in stmmac_tx_clean()
1363 priv->hw->desc->get_tx_len(p), in stmmac_tx_clean()
1366 dma_unmap_single(priv->device, in stmmac_tx_clean()
1367 priv->tx_skbuff_dma[entry].buf, in stmmac_tx_clean()
1368 priv->hw->desc->get_tx_len(p), in stmmac_tx_clean()
1370 priv->tx_skbuff_dma[entry].buf = 0; in stmmac_tx_clean()
1371 priv->tx_skbuff_dma[entry].map_as_page = false; in stmmac_tx_clean()
1373 priv->hw->mode->clean_desc3(priv, p); in stmmac_tx_clean()
1379 priv->tx_skbuff[entry] = NULL; in stmmac_tx_clean()
1382 priv->hw->desc->release_tx_desc(p, priv->mode); in stmmac_tx_clean()
1384 priv->dirty_tx++; in stmmac_tx_clean()
1387 netdev_completed_queue(priv->dev, pkts_compl, bytes_compl); in stmmac_tx_clean()
1389 if (unlikely(netif_queue_stopped(priv->dev) && in stmmac_tx_clean()
1390 stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) { in stmmac_tx_clean()
1391 netif_tx_lock(priv->dev); in stmmac_tx_clean()
1392 if (netif_queue_stopped(priv->dev) && in stmmac_tx_clean()
1393 stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv)) { in stmmac_tx_clean()
1394 if (netif_msg_tx_done(priv)) in stmmac_tx_clean()
1396 netif_wake_queue(priv->dev); in stmmac_tx_clean()
1398 netif_tx_unlock(priv->dev); in stmmac_tx_clean()
1401 if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) { in stmmac_tx_clean()
1402 stmmac_enable_eee_mode(priv); in stmmac_tx_clean()
1403 mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(eee_timer)); in stmmac_tx_clean()
1405 spin_unlock(&priv->tx_lock); in stmmac_tx_clean()
1408 static inline void stmmac_enable_dma_irq(struct stmmac_priv *priv) in stmmac_enable_dma_irq() argument
1410 priv->hw->dma->enable_dma_irq(priv->ioaddr); in stmmac_enable_dma_irq()
1413 static inline void stmmac_disable_dma_irq(struct stmmac_priv *priv) in stmmac_disable_dma_irq() argument
1415 priv->hw->dma->disable_dma_irq(priv->ioaddr); in stmmac_disable_dma_irq()
1424 static void stmmac_tx_err(struct stmmac_priv *priv) in stmmac_tx_err() argument
1427 int txsize = priv->dma_tx_size; in stmmac_tx_err()
1428 netif_stop_queue(priv->dev); in stmmac_tx_err()
1430 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_tx_err()
1431 dma_free_tx_skbufs(priv); in stmmac_tx_err()
1433 if (priv->extend_desc) in stmmac_tx_err()
1434 priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, in stmmac_tx_err()
1435 priv->mode, in stmmac_tx_err()
1438 priv->hw->desc->init_tx_desc(&priv->dma_tx[i], in stmmac_tx_err()
1439 priv->mode, in stmmac_tx_err()
1441 priv->dirty_tx = 0; in stmmac_tx_err()
1442 priv->cur_tx = 0; in stmmac_tx_err()
1443 netdev_reset_queue(priv->dev); in stmmac_tx_err()
1444 priv->hw->dma->start_tx(priv->ioaddr); in stmmac_tx_err()
1446 priv->dev->stats.tx_errors++; in stmmac_tx_err()
1447 netif_wake_queue(priv->dev); in stmmac_tx_err()
1457 static void stmmac_dma_interrupt(struct stmmac_priv *priv) in stmmac_dma_interrupt() argument
1460 int rxfifosz = priv->plat->rx_fifo_size; in stmmac_dma_interrupt()
1462 status = priv->hw->dma->dma_interrupt(priv->ioaddr, &priv->xstats); in stmmac_dma_interrupt()
1464 if (likely(napi_schedule_prep(&priv->napi))) { in stmmac_dma_interrupt()
1465 stmmac_disable_dma_irq(priv); in stmmac_dma_interrupt()
1466 __napi_schedule(&priv->napi); in stmmac_dma_interrupt()
1471 if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && in stmmac_dma_interrupt()
1474 if (priv->plat->force_thresh_dma_mode) in stmmac_dma_interrupt()
1475 priv->hw->dma->dma_mode(priv->ioaddr, tc, tc, in stmmac_dma_interrupt()
1478 priv->hw->dma->dma_mode(priv->ioaddr, tc, in stmmac_dma_interrupt()
1480 priv->xstats.threshold = tc; in stmmac_dma_interrupt()
1483 stmmac_tx_err(priv); in stmmac_dma_interrupt()
1491 static void stmmac_mmc_setup(struct stmmac_priv *priv) in stmmac_mmc_setup() argument
1496 dwmac_mmc_intr_all_mask(priv->ioaddr); in stmmac_mmc_setup()
1498 if (priv->dma_cap.rmon) { in stmmac_mmc_setup()
1499 dwmac_mmc_ctrl(priv->ioaddr, mode); in stmmac_mmc_setup()
1500 memset(&priv->mmc, 0, sizeof(struct stmmac_counters)); in stmmac_mmc_setup()
1511 static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv) in stmmac_get_synopsys_id() argument
1513 u32 hwid = priv->hw->synopsys_uid; in stmmac_get_synopsys_id()
1535 static void stmmac_selec_desc_mode(struct stmmac_priv *priv) in stmmac_selec_desc_mode() argument
1537 if (priv->plat->enh_desc) { in stmmac_selec_desc_mode()
1541 if (priv->synopsys_id >= DWMAC_CORE_3_50) { in stmmac_selec_desc_mode()
1543 priv->extend_desc = 1; in stmmac_selec_desc_mode()
1547 priv->hw->desc = &enh_desc_ops; in stmmac_selec_desc_mode()
1550 priv->hw->desc = &ndesc_ops; in stmmac_selec_desc_mode()
1563 static int stmmac_get_hw_features(struct stmmac_priv *priv) in stmmac_get_hw_features() argument
1567 if (priv->hw->dma->get_hw_feature) { in stmmac_get_hw_features()
1568 hw_cap = priv->hw->dma->get_hw_feature(priv->ioaddr); in stmmac_get_hw_features()
1570 priv->dma_cap.mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL); in stmmac_get_hw_features()
1571 priv->dma_cap.mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1; in stmmac_get_hw_features()
1572 priv->dma_cap.half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2; in stmmac_get_hw_features()
1573 priv->dma_cap.hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4; in stmmac_get_hw_features()
1574 priv->dma_cap.multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5; in stmmac_get_hw_features()
1575 priv->dma_cap.pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6; in stmmac_get_hw_features()
1576 priv->dma_cap.sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8; in stmmac_get_hw_features()
1577 priv->dma_cap.pmt_remote_wake_up = in stmmac_get_hw_features()
1579 priv->dma_cap.pmt_magic_frame = in stmmac_get_hw_features()
1582 priv->dma_cap.rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11; in stmmac_get_hw_features()
1584 priv->dma_cap.time_stamp = in stmmac_get_hw_features()
1587 priv->dma_cap.atime_stamp = in stmmac_get_hw_features()
1590 priv->dma_cap.eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14; in stmmac_get_hw_features()
1591 priv->dma_cap.av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15; in stmmac_get_hw_features()
1593 priv->dma_cap.tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16; in stmmac_get_hw_features()
1594 priv->dma_cap.rx_coe_type1 = in stmmac_get_hw_features()
1596 priv->dma_cap.rx_coe_type2 = in stmmac_get_hw_features()
1598 priv->dma_cap.rxfifo_over_2048 = in stmmac_get_hw_features()
1601 priv->dma_cap.number_rx_channel = in stmmac_get_hw_features()
1603 priv->dma_cap.number_tx_channel = in stmmac_get_hw_features()
1606 priv->dma_cap.enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24; in stmmac_get_hw_features()
1619 static void stmmac_check_ether_addr(struct stmmac_priv *priv) in stmmac_check_ether_addr() argument
1621 if (!is_valid_ether_addr(priv->dev->dev_addr)) { in stmmac_check_ether_addr()
1622 priv->hw->mac->get_umac_addr(priv->hw, in stmmac_check_ether_addr()
1623 priv->dev->dev_addr, 0); in stmmac_check_ether_addr()
1624 if (!is_valid_ether_addr(priv->dev->dev_addr)) in stmmac_check_ether_addr()
1625 eth_hw_addr_random(priv->dev); in stmmac_check_ether_addr()
1626 pr_info("%s: device MAC address %pM\n", priv->dev->name, in stmmac_check_ether_addr()
1627 priv->dev->dev_addr); in stmmac_check_ether_addr()
1639 static int stmmac_init_dma_engine(struct stmmac_priv *priv) in stmmac_init_dma_engine() argument
1645 if (priv->plat->dma_cfg) { in stmmac_init_dma_engine()
1646 pbl = priv->plat->dma_cfg->pbl; in stmmac_init_dma_engine()
1647 fixed_burst = priv->plat->dma_cfg->fixed_burst; in stmmac_init_dma_engine()
1648 mixed_burst = priv->plat->dma_cfg->mixed_burst; in stmmac_init_dma_engine()
1649 burst_len = priv->plat->dma_cfg->burst_len; in stmmac_init_dma_engine()
1652 if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE)) in stmmac_init_dma_engine()
1655 return priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst, mixed_burst, in stmmac_init_dma_engine()
1656 burst_len, priv->dma_tx_phy, in stmmac_init_dma_engine()
1657 priv->dma_rx_phy, atds); in stmmac_init_dma_engine()
1668 struct stmmac_priv *priv = (struct stmmac_priv *)data; in stmmac_tx_timer() local
1670 stmmac_tx_clean(priv); in stmmac_tx_timer()
1681 static void stmmac_init_tx_coalesce(struct stmmac_priv *priv) in stmmac_init_tx_coalesce() argument
1683 priv->tx_coal_frames = STMMAC_TX_FRAMES; in stmmac_init_tx_coalesce()
1684 priv->tx_coal_timer = STMMAC_COAL_TX_TIMER; in stmmac_init_tx_coalesce()
1685 init_timer(&priv->txtimer); in stmmac_init_tx_coalesce()
1686 priv->txtimer.expires = STMMAC_COAL_TIMER(priv->tx_coal_timer); in stmmac_init_tx_coalesce()
1687 priv->txtimer.data = (unsigned long)priv; in stmmac_init_tx_coalesce()
1688 priv->txtimer.function = stmmac_tx_timer; in stmmac_init_tx_coalesce()
1689 add_timer(&priv->txtimer); in stmmac_init_tx_coalesce()
1706 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_hw_setup() local
1710 ret = stmmac_init_dma_engine(priv); in stmmac_hw_setup()
1717 priv->hw->mac->set_umac_addr(priv->hw, dev->dev_addr, 0); in stmmac_hw_setup()
1720 if (priv->plat->bus_setup) in stmmac_hw_setup()
1721 priv->plat->bus_setup(priv->ioaddr); in stmmac_hw_setup()
1724 priv->hw->mac->core_init(priv->hw, dev->mtu); in stmmac_hw_setup()
1726 ret = priv->hw->mac->rx_ipc(priv->hw); in stmmac_hw_setup()
1729 priv->plat->rx_coe = STMMAC_RX_COE_NONE; in stmmac_hw_setup()
1730 priv->hw->rx_csum = 0; in stmmac_hw_setup()
1734 stmmac_set_mac(priv->ioaddr, true); in stmmac_hw_setup()
1737 stmmac_dma_operation_mode(priv); in stmmac_hw_setup()
1739 stmmac_mmc_setup(priv); in stmmac_hw_setup()
1742 ret = stmmac_init_ptp(priv); in stmmac_hw_setup()
1754 priv->hw->dma->start_tx(priv->ioaddr); in stmmac_hw_setup()
1755 priv->hw->dma->start_rx(priv->ioaddr); in stmmac_hw_setup()
1758 if (netif_msg_hw(priv)) { in stmmac_hw_setup()
1759 priv->hw->mac->dump_regs(priv->hw); in stmmac_hw_setup()
1760 priv->hw->dma->dump_regs(priv->ioaddr); in stmmac_hw_setup()
1762 priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; in stmmac_hw_setup()
1764 if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { in stmmac_hw_setup()
1765 priv->rx_riwt = MAX_DMA_RIWT; in stmmac_hw_setup()
1766 priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); in stmmac_hw_setup()
1769 if (priv->pcs && priv->hw->mac->ctrl_ane) in stmmac_hw_setup()
1770 priv->hw->mac->ctrl_ane(priv->hw, 0); in stmmac_hw_setup()
1786 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_open() local
1789 stmmac_check_ether_addr(priv); in stmmac_open()
1791 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_open()
1792 priv->pcs != STMMAC_PCS_RTBI) { in stmmac_open()
1802 memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); in stmmac_open()
1803 priv->xstats.threshold = tc; in stmmac_open()
1806 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); in stmmac_open()
1807 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); in stmmac_open()
1808 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); in stmmac_open()
1810 ret = alloc_dma_desc_resources(priv); in stmmac_open()
1828 stmmac_init_tx_coalesce(priv); in stmmac_open()
1830 if (priv->phydev) in stmmac_open()
1831 phy_start(priv->phydev); in stmmac_open()
1843 if (priv->wol_irq != dev->irq) { in stmmac_open()
1844 ret = request_irq(priv->wol_irq, stmmac_interrupt, in stmmac_open()
1848 __func__, priv->wol_irq, ret); in stmmac_open()
1854 if (priv->lpi_irq > 0) { in stmmac_open()
1855 ret = request_irq(priv->lpi_irq, stmmac_interrupt, IRQF_SHARED, in stmmac_open()
1859 __func__, priv->lpi_irq, ret); in stmmac_open()
1864 napi_enable(&priv->napi); in stmmac_open()
1870 if (priv->wol_irq != dev->irq) in stmmac_open()
1871 free_irq(priv->wol_irq, dev); in stmmac_open()
1876 free_dma_desc_resources(priv); in stmmac_open()
1878 if (priv->phydev) in stmmac_open()
1879 phy_disconnect(priv->phydev); in stmmac_open()
1892 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_release() local
1894 if (priv->eee_enabled) in stmmac_release()
1895 del_timer_sync(&priv->eee_ctrl_timer); in stmmac_release()
1898 if (priv->phydev) { in stmmac_release()
1899 phy_stop(priv->phydev); in stmmac_release()
1900 phy_disconnect(priv->phydev); in stmmac_release()
1901 priv->phydev = NULL; in stmmac_release()
1906 napi_disable(&priv->napi); in stmmac_release()
1908 del_timer_sync(&priv->txtimer); in stmmac_release()
1912 if (priv->wol_irq != dev->irq) in stmmac_release()
1913 free_irq(priv->wol_irq, dev); in stmmac_release()
1914 if (priv->lpi_irq > 0) in stmmac_release()
1915 free_irq(priv->lpi_irq, dev); in stmmac_release()
1918 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_release()
1919 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_release()
1922 free_dma_desc_resources(priv); in stmmac_release()
1925 stmmac_set_mac(priv->ioaddr, false); in stmmac_release()
1933 stmmac_release_ptp(priv); in stmmac_release()
1948 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_xmit() local
1949 unsigned int txsize = priv->dma_tx_size; in stmmac_xmit()
1955 unsigned int enh_desc = priv->plat->enh_desc; in stmmac_xmit()
1957 spin_lock(&priv->tx_lock); in stmmac_xmit()
1959 if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { in stmmac_xmit()
1960 spin_unlock(&priv->tx_lock); in stmmac_xmit()
1969 if (priv->tx_path_in_lpi_mode) in stmmac_xmit()
1970 stmmac_disable_eee_mode(priv); in stmmac_xmit()
1972 entry = priv->cur_tx % txsize; in stmmac_xmit()
1976 if (priv->extend_desc) in stmmac_xmit()
1977 desc = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_xmit()
1979 desc = priv->dma_tx + entry; in stmmac_xmit()
1985 is_jumbo = priv->hw->mode->is_jumbo_frm(skb->len, enh_desc); in stmmac_xmit()
1988 desc->des2 = dma_map_single(priv->device, skb->data, in stmmac_xmit()
1990 if (dma_mapping_error(priv->device, desc->des2)) in stmmac_xmit()
1992 priv->tx_skbuff_dma[entry].buf = desc->des2; in stmmac_xmit()
1993 priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, in stmmac_xmit()
1994 csum_insertion, priv->mode); in stmmac_xmit()
1997 entry = priv->hw->mode->jumbo_frm(priv, skb, csum_insertion); in stmmac_xmit()
2006 priv->tx_skbuff[entry] = NULL; in stmmac_xmit()
2007 entry = (++priv->cur_tx) % txsize; in stmmac_xmit()
2008 if (priv->extend_desc) in stmmac_xmit()
2009 desc = (struct dma_desc *)(priv->dma_etx + entry); in stmmac_xmit()
2011 desc = priv->dma_tx + entry; in stmmac_xmit()
2013 desc->des2 = skb_frag_dma_map(priv->device, frag, 0, len, in stmmac_xmit()
2015 if (dma_mapping_error(priv->device, desc->des2)) in stmmac_xmit()
2018 priv->tx_skbuff_dma[entry].buf = desc->des2; in stmmac_xmit()
2019 priv->tx_skbuff_dma[entry].map_as_page = true; in stmmac_xmit()
2020 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion, in stmmac_xmit()
2021 priv->mode); in stmmac_xmit()
2023 priv->hw->desc->set_tx_owner(desc); in stmmac_xmit()
2027 priv->tx_skbuff[entry] = skb; in stmmac_xmit()
2030 priv->hw->desc->close_tx_desc(desc); in stmmac_xmit()
2037 priv->tx_count_frames += nfrags + 1; in stmmac_xmit()
2038 if (priv->tx_coal_frames > priv->tx_count_frames) { in stmmac_xmit()
2039 priv->hw->desc->clear_tx_ic(desc); in stmmac_xmit()
2040 priv->xstats.tx_reset_ic_bit++; in stmmac_xmit()
2041 mod_timer(&priv->txtimer, in stmmac_xmit()
2042 STMMAC_COAL_TIMER(priv->tx_coal_timer)); in stmmac_xmit()
2044 priv->tx_count_frames = 0; in stmmac_xmit()
2047 priv->hw->desc->set_tx_owner(first); in stmmac_xmit()
2050 priv->cur_tx++; in stmmac_xmit()
2052 if (netif_msg_pktdata(priv)) { in stmmac_xmit()
2054 __func__, (priv->cur_tx % txsize), in stmmac_xmit()
2055 (priv->dirty_tx % txsize), entry, first, nfrags); in stmmac_xmit()
2057 if (priv->extend_desc) in stmmac_xmit()
2058 stmmac_display_ring((void *)priv->dma_etx, txsize, 1); in stmmac_xmit()
2060 stmmac_display_ring((void *)priv->dma_tx, txsize, 0); in stmmac_xmit()
2065 if (unlikely(stmmac_tx_avail(priv) <= (MAX_SKB_FRAGS + 1))) { in stmmac_xmit()
2066 if (netif_msg_hw(priv)) in stmmac_xmit()
2074 priv->hwts_tx_en)) { in stmmac_xmit()
2077 priv->hw->desc->enable_tx_timestamp(first); in stmmac_xmit()
2080 if (!priv->hwts_tx_en) in stmmac_xmit()
2084 priv->hw->dma->enable_dma_transmission(priv->ioaddr); in stmmac_xmit()
2086 spin_unlock(&priv->tx_lock); in stmmac_xmit()
2090 spin_unlock(&priv->tx_lock); in stmmac_xmit()
2091 dev_err(priv->device, "Tx dma map failed\n"); in stmmac_xmit()
2093 priv->dev->stats.tx_dropped++; in stmmac_xmit()
2120 static inline void stmmac_rx_refill(struct stmmac_priv *priv) in stmmac_rx_refill() argument
2122 unsigned int rxsize = priv->dma_rx_size; in stmmac_rx_refill()
2123 int bfsize = priv->dma_buf_sz; in stmmac_rx_refill()
2125 for (; priv->cur_rx - priv->dirty_rx > 0; priv->dirty_rx++) { in stmmac_rx_refill()
2126 unsigned int entry = priv->dirty_rx % rxsize; in stmmac_rx_refill()
2129 if (priv->extend_desc) in stmmac_rx_refill()
2130 p = (struct dma_desc *)(priv->dma_erx + entry); in stmmac_rx_refill()
2132 p = priv->dma_rx + entry; in stmmac_rx_refill()
2134 if (likely(priv->rx_skbuff[entry] == NULL)) { in stmmac_rx_refill()
2137 skb = netdev_alloc_skb_ip_align(priv->dev, bfsize); in stmmac_rx_refill()
2142 priv->rx_skbuff[entry] = skb; in stmmac_rx_refill()
2143 priv->rx_skbuff_dma[entry] = in stmmac_rx_refill()
2144 dma_map_single(priv->device, skb->data, bfsize, in stmmac_rx_refill()
2146 if (dma_mapping_error(priv->device, in stmmac_rx_refill()
2147 priv->rx_skbuff_dma[entry])) { in stmmac_rx_refill()
2148 dev_err(priv->device, "Rx dma map failed\n"); in stmmac_rx_refill()
2152 p->des2 = priv->rx_skbuff_dma[entry]; in stmmac_rx_refill()
2154 priv->hw->mode->refill_desc3(priv, p); in stmmac_rx_refill()
2156 if (netif_msg_rx_status(priv)) in stmmac_rx_refill()
2160 priv->hw->desc->set_rx_owner(p); in stmmac_rx_refill()
2172 static int stmmac_rx(struct stmmac_priv *priv, int limit) in stmmac_rx() argument
2174 unsigned int rxsize = priv->dma_rx_size; in stmmac_rx()
2175 unsigned int entry = priv->cur_rx % rxsize; in stmmac_rx()
2178 int coe = priv->hw->rx_csum; in stmmac_rx()
2180 if (netif_msg_rx_status(priv)) { in stmmac_rx()
2182 if (priv->extend_desc) in stmmac_rx()
2183 stmmac_display_ring((void *)priv->dma_erx, rxsize, 1); in stmmac_rx()
2185 stmmac_display_ring((void *)priv->dma_rx, rxsize, 0); in stmmac_rx()
2191 if (priv->extend_desc) in stmmac_rx()
2192 p = (struct dma_desc *)(priv->dma_erx + entry); in stmmac_rx()
2194 p = priv->dma_rx + entry; in stmmac_rx()
2196 if (priv->hw->desc->get_rx_owner(p)) in stmmac_rx()
2201 next_entry = (++priv->cur_rx) % rxsize; in stmmac_rx()
2202 if (priv->extend_desc) in stmmac_rx()
2203 prefetch(priv->dma_erx + next_entry); in stmmac_rx()
2205 prefetch(priv->dma_rx + next_entry); in stmmac_rx()
2208 status = priv->hw->desc->rx_status(&priv->dev->stats, in stmmac_rx()
2209 &priv->xstats, p); in stmmac_rx()
2210 if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status)) in stmmac_rx()
2211 priv->hw->desc->rx_extended_status(&priv->dev->stats, in stmmac_rx()
2212 &priv->xstats, in stmmac_rx()
2213 priv->dma_erx + in stmmac_rx()
2216 priv->dev->stats.rx_errors++; in stmmac_rx()
2217 if (priv->hwts_rx_en && !priv->extend_desc) { in stmmac_rx()
2223 priv->rx_skbuff[entry] = NULL; in stmmac_rx()
2224 dma_unmap_single(priv->device, in stmmac_rx()
2225 priv->rx_skbuff_dma[entry], in stmmac_rx()
2226 priv->dma_buf_sz, in stmmac_rx()
2233 frame_len = priv->hw->desc->get_rx_frame_len(p, coe); in stmmac_rx()
2236 if (frame_len > priv->dma_buf_sz) { in stmmac_rx()
2237 priv->dev->stats.rx_length_errors++; in stmmac_rx()
2247 if (netif_msg_rx_status(priv)) { in stmmac_rx()
2254 skb = priv->rx_skbuff[entry]; in stmmac_rx()
2257 priv->dev->name); in stmmac_rx()
2258 priv->dev->stats.rx_dropped++; in stmmac_rx()
2262 priv->rx_skbuff[entry] = NULL; in stmmac_rx()
2264 stmmac_get_rx_hwtstamp(priv, entry, skb); in stmmac_rx()
2267 dma_unmap_single(priv->device, in stmmac_rx()
2268 priv->rx_skbuff_dma[entry], in stmmac_rx()
2269 priv->dma_buf_sz, DMA_FROM_DEVICE); in stmmac_rx()
2271 if (netif_msg_pktdata(priv)) { in stmmac_rx()
2276 stmmac_rx_vlan(priv->dev, skb); in stmmac_rx()
2278 skb->protocol = eth_type_trans(skb, priv->dev); in stmmac_rx()
2285 napi_gro_receive(&priv->napi, skb); in stmmac_rx()
2287 priv->dev->stats.rx_packets++; in stmmac_rx()
2288 priv->dev->stats.rx_bytes += frame_len; in stmmac_rx()
2293 stmmac_rx_refill(priv); in stmmac_rx()
2295 priv->xstats.rx_pkt_n += count; in stmmac_rx()
2310 struct stmmac_priv *priv = container_of(napi, struct stmmac_priv, napi); in stmmac_poll() local
2313 priv->xstats.napi_poll++; in stmmac_poll()
2314 stmmac_tx_clean(priv); in stmmac_poll()
2316 work_done = stmmac_rx(priv, budget); in stmmac_poll()
2319 stmmac_enable_dma_irq(priv); in stmmac_poll()
2334 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_tx_timeout() local
2337 stmmac_tx_err(priv); in stmmac_tx_timeout()
2351 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_set_rx_mode() local
2353 priv->hw->mac->set_filter(priv->hw, dev); in stmmac_set_rx_mode()
2369 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_change_mtu() local
2377 if (priv->plat->enh_desc) in stmmac_change_mtu()
2382 if (priv->plat->maxmtu < max_mtu) in stmmac_change_mtu()
2383 max_mtu = priv->plat->maxmtu; in stmmac_change_mtu()
2399 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_fix_features() local
2401 if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) in stmmac_fix_features()
2404 if (!priv->plat->tx_coe) in stmmac_fix_features()
2412 if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) in stmmac_fix_features()
2421 struct stmmac_priv *priv = netdev_priv(netdev); in stmmac_set_features() local
2425 priv->hw->rx_csum = priv->plat->rx_coe; in stmmac_set_features()
2427 priv->hw->rx_csum = 0; in stmmac_set_features()
2431 priv->hw->mac->rx_ipc(priv->hw); in stmmac_set_features()
2450 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_interrupt() local
2452 if (priv->irq_wake) in stmmac_interrupt()
2453 pm_wakeup_event(priv->device, 0); in stmmac_interrupt()
2461 if (priv->plat->has_gmac) { in stmmac_interrupt()
2462 int status = priv->hw->mac->host_irq_status(priv->hw, in stmmac_interrupt()
2463 &priv->xstats); in stmmac_interrupt()
2467 priv->tx_path_in_lpi_mode = true; in stmmac_interrupt()
2469 priv->tx_path_in_lpi_mode = false; in stmmac_interrupt()
2474 stmmac_dma_interrupt(priv); in stmmac_interrupt()
2502 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_ioctl() local
2512 if (!priv->phydev) in stmmac_ioctl()
2514 ret = phy_mii_ioctl(priv->phydev, rq, cmd); in stmmac_ioctl()
2560 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_sysfs_ring_read() local
2561 unsigned int txsize = priv->dma_tx_size; in stmmac_sysfs_ring_read()
2562 unsigned int rxsize = priv->dma_rx_size; in stmmac_sysfs_ring_read()
2564 if (priv->extend_desc) { in stmmac_sysfs_ring_read()
2566 sysfs_display_ring((void *)priv->dma_erx, rxsize, 1, seq); in stmmac_sysfs_ring_read()
2568 sysfs_display_ring((void *)priv->dma_etx, txsize, 1, seq); in stmmac_sysfs_ring_read()
2571 sysfs_display_ring((void *)priv->dma_rx, rxsize, 0, seq); in stmmac_sysfs_ring_read()
2573 sysfs_display_ring((void *)priv->dma_tx, txsize, 0, seq); in stmmac_sysfs_ring_read()
2595 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_sysfs_dma_cap_read() local
2597 if (!priv->hw_cap_support) { in stmmac_sysfs_dma_cap_read()
2607 (priv->dma_cap.mbps_10_100) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2609 (priv->dma_cap.mbps_1000) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2611 (priv->dma_cap.half_duplex) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2613 (priv->dma_cap.hash_filter) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2615 (priv->dma_cap.multi_addr) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2617 (priv->dma_cap.pcs) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2619 (priv->dma_cap.sma_mdio) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2621 (priv->dma_cap.pmt_remote_wake_up) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2623 (priv->dma_cap.pmt_magic_frame) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2625 (priv->dma_cap.rmon) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2627 (priv->dma_cap.time_stamp) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2629 (priv->dma_cap.atime_stamp) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2631 (priv->dma_cap.eee) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2632 seq_printf(seq, "\tAV features: %s\n", (priv->dma_cap.av) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2634 (priv->dma_cap.tx_coe) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2636 (priv->dma_cap.rx_coe_type1) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2638 (priv->dma_cap.rx_coe_type2) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2640 (priv->dma_cap.rxfifo_over_2048) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2642 priv->dma_cap.number_rx_channel); in stmmac_sysfs_dma_cap_read()
2644 priv->dma_cap.number_tx_channel); in stmmac_sysfs_dma_cap_read()
2646 (priv->dma_cap.enh_desc) ? "Y" : "N"); in stmmac_sysfs_dma_cap_read()
2666 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_init_fs() local
2669 priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir); in stmmac_init_fs()
2671 if (!priv->dbgfs_dir || IS_ERR(priv->dbgfs_dir)) { in stmmac_init_fs()
2679 priv->dbgfs_rings_status = in stmmac_init_fs()
2681 priv->dbgfs_dir, dev, in stmmac_init_fs()
2684 if (!priv->dbgfs_rings_status || IS_ERR(priv->dbgfs_rings_status)) { in stmmac_init_fs()
2686 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_init_fs()
2692 priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", S_IRUGO, in stmmac_init_fs()
2693 priv->dbgfs_dir, in stmmac_init_fs()
2696 if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) { in stmmac_init_fs()
2698 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_init_fs()
2708 struct stmmac_priv *priv = netdev_priv(dev); in stmmac_exit_fs() local
2710 debugfs_remove_recursive(priv->dbgfs_dir); in stmmac_exit_fs()
2738 static int stmmac_hw_init(struct stmmac_priv *priv) in stmmac_hw_init() argument
2743 if (priv->plat->has_gmac) { in stmmac_hw_init()
2744 priv->dev->priv_flags |= IFF_UNICAST_FLT; in stmmac_hw_init()
2745 mac = dwmac1000_setup(priv->ioaddr, in stmmac_hw_init()
2746 priv->plat->multicast_filter_bins, in stmmac_hw_init()
2747 priv->plat->unicast_filter_entries); in stmmac_hw_init()
2749 mac = dwmac100_setup(priv->ioaddr); in stmmac_hw_init()
2754 priv->hw = mac; in stmmac_hw_init()
2757 priv->synopsys_id = stmmac_get_synopsys_id(priv); in stmmac_hw_init()
2761 priv->hw->mode = &chain_mode_ops; in stmmac_hw_init()
2763 priv->mode = STMMAC_CHAIN_MODE; in stmmac_hw_init()
2765 priv->hw->mode = &ring_mode_ops; in stmmac_hw_init()
2767 priv->mode = STMMAC_RING_MODE; in stmmac_hw_init()
2771 priv->hw_cap_support = stmmac_get_hw_features(priv); in stmmac_hw_init()
2772 if (priv->hw_cap_support) { in stmmac_hw_init()
2780 priv->plat->enh_desc = priv->dma_cap.enh_desc; in stmmac_hw_init()
2781 priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up; in stmmac_hw_init()
2784 if (priv->plat->force_thresh_dma_mode) in stmmac_hw_init()
2785 priv->plat->tx_coe = 0; in stmmac_hw_init()
2787 priv->plat->tx_coe = priv->dma_cap.tx_coe; in stmmac_hw_init()
2789 if (priv->dma_cap.rx_coe_type2) in stmmac_hw_init()
2790 priv->plat->rx_coe = STMMAC_RX_COE_TYPE2; in stmmac_hw_init()
2791 else if (priv->dma_cap.rx_coe_type1) in stmmac_hw_init()
2792 priv->plat->rx_coe = STMMAC_RX_COE_TYPE1; in stmmac_hw_init()
2798 stmmac_selec_desc_mode(priv); in stmmac_hw_init()
2800 if (priv->plat->rx_coe) { in stmmac_hw_init()
2801 priv->hw->rx_csum = priv->plat->rx_coe; in stmmac_hw_init()
2803 priv->plat->rx_coe); in stmmac_hw_init()
2805 if (priv->plat->tx_coe) in stmmac_hw_init()
2808 if (priv->plat->pmt) { in stmmac_hw_init()
2810 device_set_wakeup_capable(priv->device, 1); in stmmac_hw_init()
2832 struct stmmac_priv *priv; in stmmac_dvr_probe() local
2840 priv = netdev_priv(ndev); in stmmac_dvr_probe()
2841 priv->device = device; in stmmac_dvr_probe()
2842 priv->dev = ndev; in stmmac_dvr_probe()
2845 priv->pause = pause; in stmmac_dvr_probe()
2846 priv->plat = plat_dat; in stmmac_dvr_probe()
2847 priv->ioaddr = res->addr; in stmmac_dvr_probe()
2848 priv->dev->base_addr = (unsigned long)res->addr; in stmmac_dvr_probe()
2850 priv->dev->irq = res->irq; in stmmac_dvr_probe()
2851 priv->wol_irq = res->wol_irq; in stmmac_dvr_probe()
2852 priv->lpi_irq = res->lpi_irq; in stmmac_dvr_probe()
2855 memcpy(priv->dev->dev_addr, res->mac, ETH_ALEN); in stmmac_dvr_probe()
2857 dev_set_drvdata(device, priv->dev); in stmmac_dvr_probe()
2866 priv->plat->phy_addr = phyaddr; in stmmac_dvr_probe()
2868 priv->stmmac_clk = devm_clk_get(priv->device, STMMAC_RESOURCE_NAME); in stmmac_dvr_probe()
2869 if (IS_ERR(priv->stmmac_clk)) { in stmmac_dvr_probe()
2870 dev_warn(priv->device, "%s: warning: cannot get CSR clock\n", in stmmac_dvr_probe()
2875 if (!priv->plat->clk_csr) { in stmmac_dvr_probe()
2876 ret = PTR_ERR(priv->stmmac_clk); in stmmac_dvr_probe()
2879 priv->stmmac_clk = NULL; in stmmac_dvr_probe()
2882 clk_prepare_enable(priv->stmmac_clk); in stmmac_dvr_probe()
2884 priv->pclk = devm_clk_get(priv->device, "pclk"); in stmmac_dvr_probe()
2885 if (IS_ERR(priv->pclk)) { in stmmac_dvr_probe()
2886 if (PTR_ERR(priv->pclk) == -EPROBE_DEFER) { in stmmac_dvr_probe()
2890 priv->pclk = NULL; in stmmac_dvr_probe()
2892 clk_prepare_enable(priv->pclk); in stmmac_dvr_probe()
2894 priv->stmmac_rst = devm_reset_control_get(priv->device, in stmmac_dvr_probe()
2896 if (IS_ERR(priv->stmmac_rst)) { in stmmac_dvr_probe()
2897 if (PTR_ERR(priv->stmmac_rst) == -EPROBE_DEFER) { in stmmac_dvr_probe()
2901 dev_info(priv->device, "no reset control found\n"); in stmmac_dvr_probe()
2902 priv->stmmac_rst = NULL; in stmmac_dvr_probe()
2904 if (priv->stmmac_rst) in stmmac_dvr_probe()
2905 reset_control_deassert(priv->stmmac_rst); in stmmac_dvr_probe()
2908 ret = stmmac_hw_init(priv); in stmmac_dvr_probe()
2922 priv->msg_enable = netif_msg_init(debug, default_msg_level); in stmmac_dvr_probe()
2925 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ in stmmac_dvr_probe()
2932 if ((priv->synopsys_id >= DWMAC_CORE_3_50) && (!priv->plat->riwt_off)) { in stmmac_dvr_probe()
2933 priv->use_riwt = 1; in stmmac_dvr_probe()
2937 netif_napi_add(ndev, &priv->napi, stmmac_poll, 64); in stmmac_dvr_probe()
2939 spin_lock_init(&priv->lock); in stmmac_dvr_probe()
2940 spin_lock_init(&priv->tx_lock); in stmmac_dvr_probe()
2954 if (!priv->plat->clk_csr) in stmmac_dvr_probe()
2955 stmmac_clk_csr_set(priv); in stmmac_dvr_probe()
2957 priv->clk_csr = priv->plat->clk_csr; in stmmac_dvr_probe()
2959 stmmac_check_pcs_mode(priv); in stmmac_dvr_probe()
2961 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_dvr_probe()
2962 priv->pcs != STMMAC_PCS_RTBI) { in stmmac_dvr_probe()
2967 __func__, priv->plat->bus_id); in stmmac_dvr_probe()
2977 netif_napi_del(&priv->napi); in stmmac_dvr_probe()
2979 clk_disable_unprepare(priv->pclk); in stmmac_dvr_probe()
2981 clk_disable_unprepare(priv->stmmac_clk); in stmmac_dvr_probe()
2997 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_dvr_remove() local
3001 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_dvr_remove()
3002 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_dvr_remove()
3004 stmmac_set_mac(priv->ioaddr, false); in stmmac_dvr_remove()
3007 if (priv->stmmac_rst) in stmmac_dvr_remove()
3008 reset_control_assert(priv->stmmac_rst); in stmmac_dvr_remove()
3009 clk_disable_unprepare(priv->pclk); in stmmac_dvr_remove()
3010 clk_disable_unprepare(priv->stmmac_clk); in stmmac_dvr_remove()
3011 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI && in stmmac_dvr_remove()
3012 priv->pcs != STMMAC_PCS_RTBI) in stmmac_dvr_remove()
3029 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_suspend() local
3035 if (priv->phydev) in stmmac_suspend()
3036 phy_stop(priv->phydev); in stmmac_suspend()
3038 spin_lock_irqsave(&priv->lock, flags); in stmmac_suspend()
3043 napi_disable(&priv->napi); in stmmac_suspend()
3046 priv->hw->dma->stop_tx(priv->ioaddr); in stmmac_suspend()
3047 priv->hw->dma->stop_rx(priv->ioaddr); in stmmac_suspend()
3050 if (device_may_wakeup(priv->device)) { in stmmac_suspend()
3051 priv->hw->mac->pmt(priv->hw, priv->wolopts); in stmmac_suspend()
3052 priv->irq_wake = 1; in stmmac_suspend()
3054 stmmac_set_mac(priv->ioaddr, false); in stmmac_suspend()
3055 pinctrl_pm_select_sleep_state(priv->device); in stmmac_suspend()
3057 clk_disable(priv->pclk); in stmmac_suspend()
3058 clk_disable(priv->stmmac_clk); in stmmac_suspend()
3060 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_suspend()
3062 priv->oldlink = 0; in stmmac_suspend()
3063 priv->speed = 0; in stmmac_suspend()
3064 priv->oldduplex = -1; in stmmac_suspend()
3077 struct stmmac_priv *priv = netdev_priv(ndev); in stmmac_resume() local
3083 spin_lock_irqsave(&priv->lock, flags); in stmmac_resume()
3091 if (device_may_wakeup(priv->device)) { in stmmac_resume()
3092 priv->hw->mac->pmt(priv->hw, 0); in stmmac_resume()
3093 priv->irq_wake = 0; in stmmac_resume()
3095 pinctrl_pm_select_default_state(priv->device); in stmmac_resume()
3097 clk_enable(priv->stmmac_clk); in stmmac_resume()
3098 clk_enable(priv->pclk); in stmmac_resume()
3100 if (priv->mii) in stmmac_resume()
3101 stmmac_mdio_reset(priv->mii); in stmmac_resume()
3106 priv->cur_rx = 0; in stmmac_resume()
3107 priv->dirty_rx = 0; in stmmac_resume()
3108 priv->dirty_tx = 0; in stmmac_resume()
3109 priv->cur_tx = 0; in stmmac_resume()
3110 stmmac_clear_descriptors(priv); in stmmac_resume()
3113 stmmac_init_tx_coalesce(priv); in stmmac_resume()
3116 napi_enable(&priv->napi); in stmmac_resume()
3120 spin_unlock_irqrestore(&priv->lock, flags); in stmmac_resume()
3122 if (priv->phydev) in stmmac_resume()
3123 phy_start(priv->phydev); in stmmac_resume()