Lines Matching refs:priv

58 	(TOTAL_DESC - priv->hw_params->rx_queues * priv->hw_params->rx_bds_per_q)
60 (TOTAL_DESC - priv->hw_params->tx_queues * priv->hw_params->tx_bds_per_q)
67 #define DMA_DESC_SIZE (WORDS_PER_BD(priv) * sizeof(u32))
69 #define GENET_TDMA_REG_OFF (priv->hw_params->tdma_offset + \
72 #define GENET_RDMA_REG_OFF (priv->hw_params->rdma_offset + \
75 static inline void dmadesc_set_length_status(struct bcmgenet_priv *priv, in dmadesc_set_length_status() argument
81 static inline u32 dmadesc_get_length_status(struct bcmgenet_priv *priv, in dmadesc_get_length_status() argument
87 static inline void dmadesc_set_addr(struct bcmgenet_priv *priv, in dmadesc_set_addr() argument
98 if (priv->hw_params->flags & GENET_HAS_40BITS) in dmadesc_set_addr()
104 static inline void dmadesc_set(struct bcmgenet_priv *priv, in dmadesc_set() argument
107 dmadesc_set_length_status(priv, d, val); in dmadesc_set()
108 dmadesc_set_addr(priv, d, addr); in dmadesc_set()
111 static inline dma_addr_t dmadesc_get_addr(struct bcmgenet_priv *priv, in dmadesc_get_addr() argument
123 if (priv->hw_params->flags & GENET_HAS_40BITS) in dmadesc_get_addr()
134 static inline u32 bcmgenet_rbuf_ctrl_get(struct bcmgenet_priv *priv) in bcmgenet_rbuf_ctrl_get() argument
136 if (GENET_IS_V1(priv)) in bcmgenet_rbuf_ctrl_get()
137 return bcmgenet_rbuf_readl(priv, RBUF_FLUSH_CTRL_V1); in bcmgenet_rbuf_ctrl_get()
139 return bcmgenet_sys_readl(priv, SYS_RBUF_FLUSH_CTRL); in bcmgenet_rbuf_ctrl_get()
142 static inline void bcmgenet_rbuf_ctrl_set(struct bcmgenet_priv *priv, u32 val) in bcmgenet_rbuf_ctrl_set() argument
144 if (GENET_IS_V1(priv)) in bcmgenet_rbuf_ctrl_set()
145 bcmgenet_rbuf_writel(priv, val, RBUF_FLUSH_CTRL_V1); in bcmgenet_rbuf_ctrl_set()
147 bcmgenet_sys_writel(priv, val, SYS_RBUF_FLUSH_CTRL); in bcmgenet_rbuf_ctrl_set()
154 static inline u32 bcmgenet_tbuf_ctrl_get(struct bcmgenet_priv *priv) in bcmgenet_tbuf_ctrl_get() argument
156 if (GENET_IS_V1(priv)) in bcmgenet_tbuf_ctrl_get()
157 return bcmgenet_rbuf_readl(priv, TBUF_CTRL_V1); in bcmgenet_tbuf_ctrl_get()
159 return __raw_readl(priv->base + in bcmgenet_tbuf_ctrl_get()
160 priv->hw_params->tbuf_offset + TBUF_CTRL); in bcmgenet_tbuf_ctrl_get()
163 static inline void bcmgenet_tbuf_ctrl_set(struct bcmgenet_priv *priv, u32 val) in bcmgenet_tbuf_ctrl_set() argument
165 if (GENET_IS_V1(priv)) in bcmgenet_tbuf_ctrl_set()
166 bcmgenet_rbuf_writel(priv, val, TBUF_CTRL_V1); in bcmgenet_tbuf_ctrl_set()
168 __raw_writel(val, priv->base + in bcmgenet_tbuf_ctrl_set()
169 priv->hw_params->tbuf_offset + TBUF_CTRL); in bcmgenet_tbuf_ctrl_set()
172 static inline u32 bcmgenet_bp_mc_get(struct bcmgenet_priv *priv) in bcmgenet_bp_mc_get() argument
174 if (GENET_IS_V1(priv)) in bcmgenet_bp_mc_get()
175 return bcmgenet_rbuf_readl(priv, TBUF_BP_MC_V1); in bcmgenet_bp_mc_get()
177 return __raw_readl(priv->base + in bcmgenet_bp_mc_get()
178 priv->hw_params->tbuf_offset + TBUF_BP_MC); in bcmgenet_bp_mc_get()
181 static inline void bcmgenet_bp_mc_set(struct bcmgenet_priv *priv, u32 val) in bcmgenet_bp_mc_set() argument
183 if (GENET_IS_V1(priv)) in bcmgenet_bp_mc_set()
184 bcmgenet_rbuf_writel(priv, val, TBUF_BP_MC_V1); in bcmgenet_bp_mc_set()
186 __raw_writel(val, priv->base + in bcmgenet_bp_mc_set()
187 priv->hw_params->tbuf_offset + TBUF_BP_MC); in bcmgenet_bp_mc_set()
326 static inline u32 bcmgenet_tdma_readl(struct bcmgenet_priv *priv, in bcmgenet_tdma_readl() argument
329 return __raw_readl(priv->base + GENET_TDMA_REG_OFF + in bcmgenet_tdma_readl()
333 static inline void bcmgenet_tdma_writel(struct bcmgenet_priv *priv, in bcmgenet_tdma_writel() argument
336 __raw_writel(val, priv->base + GENET_TDMA_REG_OFF + in bcmgenet_tdma_writel()
340 static inline u32 bcmgenet_rdma_readl(struct bcmgenet_priv *priv, in bcmgenet_rdma_readl() argument
343 return __raw_readl(priv->base + GENET_RDMA_REG_OFF + in bcmgenet_rdma_readl()
347 static inline void bcmgenet_rdma_writel(struct bcmgenet_priv *priv, in bcmgenet_rdma_writel() argument
350 __raw_writel(val, priv->base + GENET_RDMA_REG_OFF + in bcmgenet_rdma_writel()
417 static inline u32 bcmgenet_tdma_ring_readl(struct bcmgenet_priv *priv, in bcmgenet_tdma_ring_readl() argument
421 return __raw_readl(priv->base + GENET_TDMA_REG_OFF + in bcmgenet_tdma_ring_readl()
426 static inline void bcmgenet_tdma_ring_writel(struct bcmgenet_priv *priv, in bcmgenet_tdma_ring_writel() argument
430 __raw_writel(val, priv->base + GENET_TDMA_REG_OFF + in bcmgenet_tdma_ring_writel()
435 static inline u32 bcmgenet_rdma_ring_readl(struct bcmgenet_priv *priv, in bcmgenet_rdma_ring_readl() argument
439 return __raw_readl(priv->base + GENET_RDMA_REG_OFF + in bcmgenet_rdma_ring_readl()
444 static inline void bcmgenet_rdma_ring_writel(struct bcmgenet_priv *priv, in bcmgenet_rdma_ring_writel() argument
448 __raw_writel(val, priv->base + GENET_RDMA_REG_OFF + in bcmgenet_rdma_ring_writel()
456 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_get_settings() local
461 if (!priv->phydev) in bcmgenet_get_settings()
464 return phy_ethtool_gset(priv->phydev, cmd); in bcmgenet_get_settings()
470 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_settings() local
475 if (!priv->phydev) in bcmgenet_set_settings()
478 return phy_ethtool_sset(priv->phydev, cmd); in bcmgenet_set_settings()
484 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_rx_csum() local
490 rbuf_chk_ctrl = bcmgenet_rbuf_readl(priv, RBUF_CHK_CTRL); in bcmgenet_set_rx_csum()
497 priv->desc_rxchk_en = rx_csum_en; in bcmgenet_set_rx_csum()
502 if (rx_csum_en && priv->crc_fwd_en) in bcmgenet_set_rx_csum()
507 bcmgenet_rbuf_writel(priv, rbuf_chk_ctrl, RBUF_CHK_CTRL); in bcmgenet_set_rx_csum()
515 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_tx_csum() local
519 tbuf_ctrl = bcmgenet_tbuf_ctrl_get(priv); in bcmgenet_set_tx_csum()
520 rbuf_ctrl = bcmgenet_rbuf_readl(priv, RBUF_CTRL); in bcmgenet_set_tx_csum()
532 priv->desc_64b_en = desc_64b_en; in bcmgenet_set_tx_csum()
534 bcmgenet_tbuf_ctrl_set(priv, tbuf_ctrl); in bcmgenet_set_tx_csum()
535 bcmgenet_rbuf_writel(priv, rbuf_ctrl, RBUF_CTRL); in bcmgenet_set_tx_csum()
557 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_get_msglevel() local
559 return priv->msg_enable; in bcmgenet_get_msglevel()
564 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_msglevel() local
566 priv->msg_enable = level; in bcmgenet_set_msglevel()
572 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_get_coalesce() local
575 bcmgenet_tdma_ring_readl(priv, DESC_INDEX, in bcmgenet_get_coalesce()
578 bcmgenet_rdma_ring_readl(priv, DESC_INDEX, in bcmgenet_get_coalesce()
581 bcmgenet_rdma_readl(priv, DMA_RING16_TIMEOUT) * 8192 / 1000; in bcmgenet_get_coalesce()
589 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_coalesce() local
617 for (i = 0; i < priv->hw_params->tx_queues; i++) in bcmgenet_set_coalesce()
618 bcmgenet_tdma_ring_writel(priv, i, in bcmgenet_set_coalesce()
621 bcmgenet_tdma_ring_writel(priv, DESC_INDEX, in bcmgenet_set_coalesce()
625 for (i = 0; i < priv->hw_params->rx_queues; i++) { in bcmgenet_set_coalesce()
626 bcmgenet_rdma_ring_writel(priv, i, in bcmgenet_set_coalesce()
630 reg = bcmgenet_rdma_readl(priv, DMA_RING0_TIMEOUT + i); in bcmgenet_set_coalesce()
633 bcmgenet_rdma_writel(priv, reg, DMA_RING0_TIMEOUT + i); in bcmgenet_set_coalesce()
636 bcmgenet_rdma_ring_writel(priv, DESC_INDEX, in bcmgenet_set_coalesce()
640 reg = bcmgenet_rdma_readl(priv, DMA_RING16_TIMEOUT); in bcmgenet_set_coalesce()
643 bcmgenet_rdma_writel(priv, reg, DMA_RING16_TIMEOUT); in bcmgenet_set_coalesce()
824 static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv) in bcmgenet_update_mib_counters() argument
844 val = bcmgenet_umac_readl(priv, in bcmgenet_update_mib_counters()
848 val = bcmgenet_umac_readl(priv, s->reg_offset); in bcmgenet_update_mib_counters()
851 bcmgenet_umac_writel(priv, 0, s->reg_offset); in bcmgenet_update_mib_counters()
856 p = (char *)priv + s->stat_offset; in bcmgenet_update_mib_counters()
865 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_get_ethtool_stats() local
869 bcmgenet_update_mib_counters(priv); in bcmgenet_get_ethtool_stats()
879 p = (char *)priv; in bcmgenet_get_ethtool_stats()
887 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_eee_enable_set() local
888 u32 off = priv->hw_params->tbuf_offset + TBUF_ENERGY_CTRL; in bcmgenet_eee_enable_set()
891 if (enable && !priv->clk_eee_enabled) { in bcmgenet_eee_enable_set()
892 clk_prepare_enable(priv->clk_eee); in bcmgenet_eee_enable_set()
893 priv->clk_eee_enabled = true; in bcmgenet_eee_enable_set()
896 reg = bcmgenet_umac_readl(priv, UMAC_EEE_CTRL); in bcmgenet_eee_enable_set()
901 bcmgenet_umac_writel(priv, reg, UMAC_EEE_CTRL); in bcmgenet_eee_enable_set()
904 reg = __raw_readl(priv->base + off); in bcmgenet_eee_enable_set()
909 __raw_writel(reg, priv->base + off); in bcmgenet_eee_enable_set()
912 reg = bcmgenet_rbuf_readl(priv, RBUF_ENERGY_CTRL); in bcmgenet_eee_enable_set()
917 bcmgenet_rbuf_writel(priv, reg, RBUF_ENERGY_CTRL); in bcmgenet_eee_enable_set()
919 if (!enable && priv->clk_eee_enabled) { in bcmgenet_eee_enable_set()
920 clk_disable_unprepare(priv->clk_eee); in bcmgenet_eee_enable_set()
921 priv->clk_eee_enabled = false; in bcmgenet_eee_enable_set()
924 priv->eee.eee_enabled = enable; in bcmgenet_eee_enable_set()
925 priv->eee.eee_active = enable; in bcmgenet_eee_enable_set()
930 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_get_eee() local
931 struct ethtool_eee *p = &priv->eee; in bcmgenet_get_eee()
933 if (GENET_IS_V1(priv)) in bcmgenet_get_eee()
938 e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER); in bcmgenet_get_eee()
940 return phy_ethtool_get_eee(priv->phydev, e); in bcmgenet_get_eee()
945 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_eee() local
946 struct ethtool_eee *p = &priv->eee; in bcmgenet_set_eee()
949 if (GENET_IS_V1(priv)) in bcmgenet_set_eee()
957 ret = phy_init_eee(priv->phydev, 0); in bcmgenet_set_eee()
959 netif_err(priv, hw, dev, "EEE initialization failed\n"); in bcmgenet_set_eee()
963 bcmgenet_umac_writel(priv, e->tx_lpi_timer, UMAC_EEE_LPI_TIMER); in bcmgenet_set_eee()
967 return phy_ethtool_set_eee(priv->phydev, e); in bcmgenet_set_eee()
972 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_nway_reset() local
974 return genphy_restart_aneg(priv->phydev); in bcmgenet_nway_reset()
998 static int bcmgenet_power_down(struct bcmgenet_priv *priv, in bcmgenet_power_down() argument
1006 phy_detach(priv->phydev); in bcmgenet_power_down()
1010 ret = bcmgenet_wol_power_down_cfg(priv, mode); in bcmgenet_power_down()
1015 if (priv->hw_params->flags & GENET_HAS_EXT) { in bcmgenet_power_down()
1016 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); in bcmgenet_power_down()
1019 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); in bcmgenet_power_down()
1021 bcmgenet_phy_power_set(priv->dev, false); in bcmgenet_power_down()
1031 static void bcmgenet_power_up(struct bcmgenet_priv *priv, in bcmgenet_power_up() argument
1036 if (!(priv->hw_params->flags & GENET_HAS_EXT)) in bcmgenet_power_up()
1039 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); in bcmgenet_power_up()
1051 bcmgenet_wol_power_up_cfg(priv, mode); in bcmgenet_power_up()
1057 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); in bcmgenet_power_up()
1059 bcmgenet_phy_power_set(priv->dev, true); in bcmgenet_power_up()
1060 bcmgenet_mii_reset(priv->dev); in bcmgenet_power_up()
1067 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_ioctl() local
1077 if (!priv->phydev) in bcmgenet_ioctl()
1080 val = phy_mii_ioctl(priv->phydev, rq, cmd); in bcmgenet_ioctl()
1091 static struct enet_cb *bcmgenet_get_txcb(struct bcmgenet_priv *priv, in bcmgenet_get_txcb() argument
1118 bcmgenet_intrl2_0_writel(ring->priv, UMAC_IRQ_RXDMA_DONE, in bcmgenet_rx_ring16_int_disable()
1124 bcmgenet_intrl2_0_writel(ring->priv, UMAC_IRQ_RXDMA_DONE, in bcmgenet_rx_ring16_int_enable()
1130 bcmgenet_intrl2_1_writel(ring->priv, in bcmgenet_rx_ring_int_disable()
1137 bcmgenet_intrl2_1_writel(ring->priv, in bcmgenet_rx_ring_int_enable()
1144 bcmgenet_intrl2_0_writel(ring->priv, UMAC_IRQ_TXDMA_DONE, in bcmgenet_tx_ring16_int_disable()
1150 bcmgenet_intrl2_0_writel(ring->priv, UMAC_IRQ_TXDMA_DONE, in bcmgenet_tx_ring16_int_enable()
1156 bcmgenet_intrl2_1_writel(ring->priv, 1 << ring->index, in bcmgenet_tx_ring_int_enable()
1162 bcmgenet_intrl2_1_writel(ring->priv, 1 << ring->index, in bcmgenet_tx_ring_int_disable()
1170 struct bcmgenet_priv *priv = netdev_priv(dev); in __bcmgenet_tx_reclaim() local
1179 c_index = bcmgenet_tdma_ring_readl(priv, ring->index, TDMA_CONS_INDEX); in __bcmgenet_tx_reclaim()
1187 netif_dbg(priv, tx_done, dev, in __bcmgenet_tx_reclaim()
1193 tx_cb_ptr = &priv->tx_cbs[ring->clean_ptr]; in __bcmgenet_tx_reclaim()
1251 work_done = bcmgenet_tx_reclaim(ring->priv->dev, ring); in bcmgenet_tx_poll()
1265 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_tx_reclaim_all() local
1269 for (i = 0; i < priv->hw_params->tx_queues; i++) in bcmgenet_tx_reclaim_all()
1270 bcmgenet_tx_reclaim(dev, &priv->tx_rings[i]); in bcmgenet_tx_reclaim_all()
1273 bcmgenet_tx_reclaim(dev, &priv->tx_rings[DESC_INDEX]); in bcmgenet_tx_reclaim_all()
1284 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_xmit_single() local
1285 struct device *kdev = &priv->pdev->dev; in bcmgenet_xmit_single()
1292 tx_cb_ptr = bcmgenet_get_txcb(priv, ring); in bcmgenet_xmit_single()
1304 priv->mib.tx_dma_failed++; in bcmgenet_xmit_single()
1305 netif_err(priv, tx_err, dev, "Tx DMA map failed\n"); in bcmgenet_xmit_single()
1313 (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT) | in bcmgenet_xmit_single()
1319 dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status); in bcmgenet_xmit_single()
1330 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_xmit_frag() local
1331 struct device *kdev = &priv->pdev->dev; in bcmgenet_xmit_frag()
1336 tx_cb_ptr = bcmgenet_get_txcb(priv, ring); in bcmgenet_xmit_frag()
1346 priv->mib.tx_dma_failed++; in bcmgenet_xmit_frag()
1347 netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n", in bcmgenet_xmit_frag()
1355 dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, in bcmgenet_xmit_frag()
1357 (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT)); in bcmgenet_xmit_frag()
1427 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_xmit() local
1450 ring = &priv->tx_rings[index]; in bcmgenet_xmit()
1468 if (priv->desc_64b_en) { in bcmgenet_xmit()
1511 bcmgenet_tdma_ring_writel(priv, ring->index, in bcmgenet_xmit()
1519 static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv, in bcmgenet_rx_refill() argument
1522 struct device *kdev = &priv->pdev->dev; in bcmgenet_rx_refill()
1528 skb = netdev_alloc_skb(priv->dev, priv->rx_buf_len + SKB_ALIGNMENT); in bcmgenet_rx_refill()
1530 priv->mib.alloc_rx_buff_failed++; in bcmgenet_rx_refill()
1531 netif_err(priv, rx_err, priv->dev, in bcmgenet_rx_refill()
1537 mapping = dma_map_single(kdev, skb->data, priv->rx_buf_len, in bcmgenet_rx_refill()
1540 priv->mib.rx_dma_failed++; in bcmgenet_rx_refill()
1542 netif_err(priv, rx_err, priv->dev, in bcmgenet_rx_refill()
1551 priv->rx_buf_len, DMA_FROM_DEVICE); in bcmgenet_rx_refill()
1556 dmadesc_set_addr(priv, cb->bd_addr, mapping); in bcmgenet_rx_refill()
1568 struct bcmgenet_priv *priv = ring->priv; in bcmgenet_desc_rx() local
1569 struct net_device *dev = priv->dev; in bcmgenet_desc_rx()
1580 p_index = bcmgenet_rdma_ring_readl(priv, ring->index, RDMA_PROD_INDEX); in bcmgenet_desc_rx()
1593 bcmgenet_rdma_ring_writel(priv, ring->index, 0, in bcmgenet_desc_rx()
1606 netif_dbg(priv, rx_status, dev, in bcmgenet_desc_rx()
1611 cb = &priv->rx_cbs[ring->read_ptr]; in bcmgenet_desc_rx()
1612 skb = bcmgenet_rx_refill(priv, cb); in bcmgenet_desc_rx()
1619 if (!priv->desc_64b_en) { in bcmgenet_desc_rx()
1621 dmadesc_get_length_status(priv, cb->bd_addr); in bcmgenet_desc_rx()
1635 netif_dbg(priv, rx_status, dev, in bcmgenet_desc_rx()
1641 netif_err(priv, rx_status, dev, in bcmgenet_desc_rx()
1654 netif_err(priv, rx_status, dev, "dma_flag=0x%x\n", in bcmgenet_desc_rx()
1669 chksum_ok = (dma_flag & priv->dma_rx_chk_bit) && in bcmgenet_desc_rx()
1670 priv->desc_rxchk_en; in bcmgenet_desc_rx()
1673 if (priv->desc_64b_en) { in bcmgenet_desc_rx()
1685 if (priv->crc_fwd_en) { in bcmgenet_desc_rx()
1691 skb->protocol = eth_type_trans(skb, priv->dev); in bcmgenet_desc_rx()
1699 netif_dbg(priv, rx_status, dev, "pushed up to kernel\n"); in bcmgenet_desc_rx()
1709 bcmgenet_rdma_ring_writel(priv, ring->index, ring->c_index, RDMA_CONS_INDEX); in bcmgenet_desc_rx()
1733 static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, in bcmgenet_alloc_rx_buffers() argument
1740 netif_dbg(priv, hw, priv->dev, "%s\n", __func__); in bcmgenet_alloc_rx_buffers()
1745 skb = bcmgenet_rx_refill(priv, cb); in bcmgenet_alloc_rx_buffers()
1755 static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) in bcmgenet_free_rx_buffers() argument
1760 for (i = 0; i < priv->num_rx_bds; i++) { in bcmgenet_free_rx_buffers()
1761 cb = &priv->rx_cbs[i]; in bcmgenet_free_rx_buffers()
1764 dma_unmap_single(&priv->dev->dev, in bcmgenet_free_rx_buffers()
1766 priv->rx_buf_len, DMA_FROM_DEVICE); in bcmgenet_free_rx_buffers()
1775 static void umac_enable_set(struct bcmgenet_priv *priv, u32 mask, bool enable) in umac_enable_set() argument
1779 reg = bcmgenet_umac_readl(priv, UMAC_CMD); in umac_enable_set()
1784 bcmgenet_umac_writel(priv, reg, UMAC_CMD); in umac_enable_set()
1793 static int reset_umac(struct bcmgenet_priv *priv) in reset_umac() argument
1795 struct device *kdev = &priv->pdev->dev; in reset_umac()
1800 bcmgenet_rbuf_ctrl_set(priv, 0); in reset_umac()
1804 bcmgenet_umac_writel(priv, 0, UMAC_CMD); in reset_umac()
1807 bcmgenet_umac_writel(priv, CMD_SW_RESET, UMAC_CMD); in reset_umac()
1809 reg = bcmgenet_umac_readl(priv, UMAC_CMD); in reset_umac()
1825 static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) in bcmgenet_intr_disable() argument
1828 bcmgenet_intrl2_0_writel(priv, 0xFFFFFFFF, INTRL2_CPU_MASK_SET); in bcmgenet_intr_disable()
1829 bcmgenet_intrl2_0_writel(priv, 0xFFFFFFFF, INTRL2_CPU_CLEAR); in bcmgenet_intr_disable()
1830 bcmgenet_intrl2_0_writel(priv, 0, INTRL2_CPU_MASK_CLEAR); in bcmgenet_intr_disable()
1831 bcmgenet_intrl2_1_writel(priv, 0xFFFFFFFF, INTRL2_CPU_MASK_SET); in bcmgenet_intr_disable()
1832 bcmgenet_intrl2_1_writel(priv, 0xFFFFFFFF, INTRL2_CPU_CLEAR); in bcmgenet_intr_disable()
1833 bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR); in bcmgenet_intr_disable()
1836 static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv) in bcmgenet_link_intr_enable() argument
1843 if (priv->internal_phy) { in bcmgenet_link_intr_enable()
1845 } else if (priv->ext_phy) { in bcmgenet_link_intr_enable()
1847 } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { in bcmgenet_link_intr_enable()
1848 if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) in bcmgenet_link_intr_enable()
1851 bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR); in bcmgenet_link_intr_enable()
1854 static int init_umac(struct bcmgenet_priv *priv) in init_umac() argument
1856 struct device *kdev = &priv->pdev->dev; in init_umac()
1863 dev_dbg(&priv->pdev->dev, "bcmgenet: init_umac\n"); in init_umac()
1865 ret = reset_umac(priv); in init_umac()
1869 bcmgenet_umac_writel(priv, 0, UMAC_CMD); in init_umac()
1871 bcmgenet_umac_writel(priv, in init_umac()
1874 bcmgenet_umac_writel(priv, 0, UMAC_MIB_CTRL); in init_umac()
1876 bcmgenet_umac_writel(priv, ENET_MAX_MTU_SIZE, UMAC_MAX_FRAME_LEN); in init_umac()
1879 reg = bcmgenet_rbuf_readl(priv, RBUF_CTRL); in init_umac()
1881 bcmgenet_rbuf_writel(priv, reg, RBUF_CTRL); in init_umac()
1883 if (!GENET_IS_V1(priv) && !GENET_IS_V2(priv)) in init_umac()
1884 bcmgenet_rbuf_writel(priv, 1, RBUF_TBUF_SIZE_CTRL); in init_umac()
1886 bcmgenet_intr_disable(priv); in init_umac()
1895 if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { in init_umac()
1896 reg = bcmgenet_bp_mc_get(priv); in init_umac()
1897 reg |= BIT(priv->hw_params->bp_in_en_shift); in init_umac()
1900 if (netif_is_multiqueue(priv->dev)) in init_umac()
1901 reg |= priv->hw_params->bp_in_mask; in init_umac()
1903 reg &= ~priv->hw_params->bp_in_mask; in init_umac()
1904 bcmgenet_bp_mc_set(priv, reg); in init_umac()
1908 if (priv->hw_params->flags & GENET_HAS_MDIO_INTR) in init_umac()
1912 for (i = 0; i < priv->hw_params->rx_queues; ++i) in init_umac()
1916 for (i = 0; i < priv->hw_params->tx_queues; ++i) in init_umac()
1919 bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR); in init_umac()
1920 bcmgenet_intrl2_1_writel(priv, int1_enable, INTRL2_CPU_MASK_CLEAR); in init_umac()
1929 static void bcmgenet_init_tx_ring(struct bcmgenet_priv *priv, in bcmgenet_init_tx_ring() argument
1933 struct bcmgenet_tx_ring *ring = &priv->tx_rings[index]; in bcmgenet_init_tx_ring()
1934 u32 words_per_bd = WORDS_PER_BD(priv); in bcmgenet_init_tx_ring()
1938 ring->priv = priv; in bcmgenet_init_tx_ring()
1949 ring->cbs = priv->tx_cbs + start_ptr; in bcmgenet_init_tx_ring()
1963 bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_PROD_INDEX); in bcmgenet_init_tx_ring()
1964 bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_CONS_INDEX); in bcmgenet_init_tx_ring()
1965 bcmgenet_tdma_ring_writel(priv, index, 1, DMA_MBUF_DONE_THRESH); in bcmgenet_init_tx_ring()
1967 bcmgenet_tdma_ring_writel(priv, index, flow_period_val, in bcmgenet_init_tx_ring()
1969 bcmgenet_tdma_ring_writel(priv, index, in bcmgenet_init_tx_ring()
1974 bcmgenet_tdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_tx_ring()
1976 bcmgenet_tdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_tx_ring()
1978 bcmgenet_tdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_tx_ring()
1980 bcmgenet_tdma_ring_writel(priv, index, end_ptr * words_per_bd - 1, in bcmgenet_init_tx_ring()
1985 static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv, in bcmgenet_init_rx_ring() argument
1989 struct bcmgenet_rx_ring *ring = &priv->rx_rings[index]; in bcmgenet_init_rx_ring()
1990 u32 words_per_bd = WORDS_PER_BD(priv); in bcmgenet_init_rx_ring()
1993 ring->priv = priv; in bcmgenet_init_rx_ring()
2002 ring->cbs = priv->rx_cbs + start_ptr; in bcmgenet_init_rx_ring()
2009 ret = bcmgenet_alloc_rx_buffers(priv, ring); in bcmgenet_init_rx_ring()
2013 bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_PROD_INDEX); in bcmgenet_init_rx_ring()
2014 bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_CONS_INDEX); in bcmgenet_init_rx_ring()
2015 bcmgenet_rdma_ring_writel(priv, index, 1, DMA_MBUF_DONE_THRESH); in bcmgenet_init_rx_ring()
2016 bcmgenet_rdma_ring_writel(priv, index, in bcmgenet_init_rx_ring()
2019 bcmgenet_rdma_ring_writel(priv, index, in bcmgenet_init_rx_ring()
2025 bcmgenet_rdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_rx_ring()
2027 bcmgenet_rdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_rx_ring()
2029 bcmgenet_rdma_ring_writel(priv, index, start_ptr * words_per_bd, in bcmgenet_init_rx_ring()
2031 bcmgenet_rdma_ring_writel(priv, index, end_ptr * words_per_bd - 1, in bcmgenet_init_rx_ring()
2037 static void bcmgenet_init_tx_napi(struct bcmgenet_priv *priv) in bcmgenet_init_tx_napi() argument
2042 for (i = 0; i < priv->hw_params->tx_queues; ++i) { in bcmgenet_init_tx_napi()
2043 ring = &priv->tx_rings[i]; in bcmgenet_init_tx_napi()
2044 netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); in bcmgenet_init_tx_napi()
2047 ring = &priv->tx_rings[DESC_INDEX]; in bcmgenet_init_tx_napi()
2048 netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); in bcmgenet_init_tx_napi()
2051 static void bcmgenet_enable_tx_napi(struct bcmgenet_priv *priv) in bcmgenet_enable_tx_napi() argument
2056 for (i = 0; i < priv->hw_params->tx_queues; ++i) { in bcmgenet_enable_tx_napi()
2057 ring = &priv->tx_rings[i]; in bcmgenet_enable_tx_napi()
2061 ring = &priv->tx_rings[DESC_INDEX]; in bcmgenet_enable_tx_napi()
2065 static void bcmgenet_disable_tx_napi(struct bcmgenet_priv *priv) in bcmgenet_disable_tx_napi() argument
2070 for (i = 0; i < priv->hw_params->tx_queues; ++i) { in bcmgenet_disable_tx_napi()
2071 ring = &priv->tx_rings[i]; in bcmgenet_disable_tx_napi()
2075 ring = &priv->tx_rings[DESC_INDEX]; in bcmgenet_disable_tx_napi()
2079 static void bcmgenet_fini_tx_napi(struct bcmgenet_priv *priv) in bcmgenet_fini_tx_napi() argument
2084 for (i = 0; i < priv->hw_params->tx_queues; ++i) { in bcmgenet_fini_tx_napi()
2085 ring = &priv->tx_rings[i]; in bcmgenet_fini_tx_napi()
2089 ring = &priv->tx_rings[DESC_INDEX]; in bcmgenet_fini_tx_napi()
2110 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_init_tx_queues() local
2115 dma_ctrl = bcmgenet_tdma_readl(priv, DMA_CTRL); in bcmgenet_init_tx_queues()
2118 bcmgenet_tdma_writel(priv, dma_ctrl, DMA_CTRL); in bcmgenet_init_tx_queues()
2124 bcmgenet_tdma_writel(priv, DMA_ARBITER_SP, DMA_ARB_CTRL); in bcmgenet_init_tx_queues()
2127 for (i = 0; i < priv->hw_params->tx_queues; i++) { in bcmgenet_init_tx_queues()
2128 bcmgenet_init_tx_ring(priv, i, priv->hw_params->tx_bds_per_q, in bcmgenet_init_tx_queues()
2129 i * priv->hw_params->tx_bds_per_q, in bcmgenet_init_tx_queues()
2130 (i + 1) * priv->hw_params->tx_bds_per_q); in bcmgenet_init_tx_queues()
2138 bcmgenet_init_tx_ring(priv, DESC_INDEX, GENET_Q16_TX_BD_CNT, in bcmgenet_init_tx_queues()
2139 priv->hw_params->tx_queues * in bcmgenet_init_tx_queues()
2140 priv->hw_params->tx_bds_per_q, in bcmgenet_init_tx_queues()
2145 ((GENET_Q0_PRIORITY + priv->hw_params->tx_queues) << in bcmgenet_init_tx_queues()
2149 bcmgenet_tdma_writel(priv, dma_priority[0], DMA_PRIORITY_0); in bcmgenet_init_tx_queues()
2150 bcmgenet_tdma_writel(priv, dma_priority[1], DMA_PRIORITY_1); in bcmgenet_init_tx_queues()
2151 bcmgenet_tdma_writel(priv, dma_priority[2], DMA_PRIORITY_2); in bcmgenet_init_tx_queues()
2154 bcmgenet_init_tx_napi(priv); in bcmgenet_init_tx_queues()
2157 bcmgenet_tdma_writel(priv, ring_cfg, DMA_RING_CFG); in bcmgenet_init_tx_queues()
2162 bcmgenet_tdma_writel(priv, dma_ctrl, DMA_CTRL); in bcmgenet_init_tx_queues()
2165 static void bcmgenet_init_rx_napi(struct bcmgenet_priv *priv) in bcmgenet_init_rx_napi() argument
2170 for (i = 0; i < priv->hw_params->rx_queues; ++i) { in bcmgenet_init_rx_napi()
2171 ring = &priv->rx_rings[i]; in bcmgenet_init_rx_napi()
2172 netif_napi_add(priv->dev, &ring->napi, bcmgenet_rx_poll, 64); in bcmgenet_init_rx_napi()
2175 ring = &priv->rx_rings[DESC_INDEX]; in bcmgenet_init_rx_napi()
2176 netif_napi_add(priv->dev, &ring->napi, bcmgenet_rx_poll, 64); in bcmgenet_init_rx_napi()
2179 static void bcmgenet_enable_rx_napi(struct bcmgenet_priv *priv) in bcmgenet_enable_rx_napi() argument
2184 for (i = 0; i < priv->hw_params->rx_queues; ++i) { in bcmgenet_enable_rx_napi()
2185 ring = &priv->rx_rings[i]; in bcmgenet_enable_rx_napi()
2189 ring = &priv->rx_rings[DESC_INDEX]; in bcmgenet_enable_rx_napi()
2193 static void bcmgenet_disable_rx_napi(struct bcmgenet_priv *priv) in bcmgenet_disable_rx_napi() argument
2198 for (i = 0; i < priv->hw_params->rx_queues; ++i) { in bcmgenet_disable_rx_napi()
2199 ring = &priv->rx_rings[i]; in bcmgenet_disable_rx_napi()
2203 ring = &priv->rx_rings[DESC_INDEX]; in bcmgenet_disable_rx_napi()
2207 static void bcmgenet_fini_rx_napi(struct bcmgenet_priv *priv) in bcmgenet_fini_rx_napi() argument
2212 for (i = 0; i < priv->hw_params->rx_queues; ++i) { in bcmgenet_fini_rx_napi()
2213 ring = &priv->rx_rings[i]; in bcmgenet_fini_rx_napi()
2217 ring = &priv->rx_rings[DESC_INDEX]; in bcmgenet_fini_rx_napi()
2230 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_init_rx_queues() local
2237 dma_ctrl = bcmgenet_rdma_readl(priv, DMA_CTRL); in bcmgenet_init_rx_queues()
2240 bcmgenet_rdma_writel(priv, dma_ctrl, DMA_CTRL); in bcmgenet_init_rx_queues()
2246 for (i = 0; i < priv->hw_params->rx_queues; i++) { in bcmgenet_init_rx_queues()
2247 ret = bcmgenet_init_rx_ring(priv, i, in bcmgenet_init_rx_queues()
2248 priv->hw_params->rx_bds_per_q, in bcmgenet_init_rx_queues()
2249 i * priv->hw_params->rx_bds_per_q, in bcmgenet_init_rx_queues()
2251 priv->hw_params->rx_bds_per_q); in bcmgenet_init_rx_queues()
2260 ret = bcmgenet_init_rx_ring(priv, DESC_INDEX, GENET_Q16_RX_BD_CNT, in bcmgenet_init_rx_queues()
2261 priv->hw_params->rx_queues * in bcmgenet_init_rx_queues()
2262 priv->hw_params->rx_bds_per_q, in bcmgenet_init_rx_queues()
2271 bcmgenet_init_rx_napi(priv); in bcmgenet_init_rx_queues()
2274 bcmgenet_rdma_writel(priv, ring_cfg, DMA_RING_CFG); in bcmgenet_init_rx_queues()
2279 bcmgenet_rdma_writel(priv, dma_ctrl, DMA_CTRL); in bcmgenet_init_rx_queues()
2284 static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) in bcmgenet_dma_teardown() argument
2293 reg = bcmgenet_tdma_readl(priv, DMA_CTRL); in bcmgenet_dma_teardown()
2295 bcmgenet_tdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_teardown()
2299 reg = bcmgenet_tdma_readl(priv, DMA_STATUS); in bcmgenet_dma_teardown()
2307 netdev_warn(priv->dev, "Timed out while disabling TX DMA\n"); in bcmgenet_dma_teardown()
2315 reg = bcmgenet_rdma_readl(priv, DMA_CTRL); in bcmgenet_dma_teardown()
2317 bcmgenet_rdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_teardown()
2322 reg = bcmgenet_rdma_readl(priv, DMA_STATUS); in bcmgenet_dma_teardown()
2330 netdev_warn(priv->dev, "Timed out while disabling RX DMA\n"); in bcmgenet_dma_teardown()
2335 for (i = 0; i < priv->hw_params->rx_queues; i++) in bcmgenet_dma_teardown()
2337 reg = bcmgenet_rdma_readl(priv, DMA_CTRL); in bcmgenet_dma_teardown()
2339 bcmgenet_rdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_teardown()
2342 for (i = 0; i < priv->hw_params->tx_queues; i++) in bcmgenet_dma_teardown()
2344 reg = bcmgenet_tdma_readl(priv, DMA_CTRL); in bcmgenet_dma_teardown()
2346 bcmgenet_tdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_teardown()
2351 static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) in bcmgenet_fini_dma() argument
2355 bcmgenet_fini_rx_napi(priv); in bcmgenet_fini_dma()
2356 bcmgenet_fini_tx_napi(priv); in bcmgenet_fini_dma()
2359 bcmgenet_dma_teardown(priv); in bcmgenet_fini_dma()
2361 for (i = 0; i < priv->num_tx_bds; i++) { in bcmgenet_fini_dma()
2362 if (priv->tx_cbs[i].skb != NULL) { in bcmgenet_fini_dma()
2363 dev_kfree_skb(priv->tx_cbs[i].skb); in bcmgenet_fini_dma()
2364 priv->tx_cbs[i].skb = NULL; in bcmgenet_fini_dma()
2368 bcmgenet_free_rx_buffers(priv); in bcmgenet_fini_dma()
2369 kfree(priv->rx_cbs); in bcmgenet_fini_dma()
2370 kfree(priv->tx_cbs); in bcmgenet_fini_dma()
2374 static int bcmgenet_init_dma(struct bcmgenet_priv *priv) in bcmgenet_init_dma() argument
2380 netif_dbg(priv, hw, priv->dev, "%s\n", __func__); in bcmgenet_init_dma()
2383 priv->rx_bds = priv->base + priv->hw_params->rdma_offset; in bcmgenet_init_dma()
2384 priv->num_rx_bds = TOTAL_DESC; in bcmgenet_init_dma()
2385 priv->rx_cbs = kcalloc(priv->num_rx_bds, sizeof(struct enet_cb), in bcmgenet_init_dma()
2387 if (!priv->rx_cbs) in bcmgenet_init_dma()
2390 for (i = 0; i < priv->num_rx_bds; i++) { in bcmgenet_init_dma()
2391 cb = priv->rx_cbs + i; in bcmgenet_init_dma()
2392 cb->bd_addr = priv->rx_bds + i * DMA_DESC_SIZE; in bcmgenet_init_dma()
2396 priv->tx_bds = priv->base + priv->hw_params->tdma_offset; in bcmgenet_init_dma()
2397 priv->num_tx_bds = TOTAL_DESC; in bcmgenet_init_dma()
2398 priv->tx_cbs = kcalloc(priv->num_tx_bds, sizeof(struct enet_cb), in bcmgenet_init_dma()
2400 if (!priv->tx_cbs) { in bcmgenet_init_dma()
2401 kfree(priv->rx_cbs); in bcmgenet_init_dma()
2405 for (i = 0; i < priv->num_tx_bds; i++) { in bcmgenet_init_dma()
2406 cb = priv->tx_cbs + i; in bcmgenet_init_dma()
2407 cb->bd_addr = priv->tx_bds + i * DMA_DESC_SIZE; in bcmgenet_init_dma()
2411 bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); in bcmgenet_init_dma()
2414 ret = bcmgenet_init_rx_queues(priv->dev); in bcmgenet_init_dma()
2416 netdev_err(priv->dev, "failed to initialize Rx queues\n"); in bcmgenet_init_dma()
2417 bcmgenet_free_rx_buffers(priv); in bcmgenet_init_dma()
2418 kfree(priv->rx_cbs); in bcmgenet_init_dma()
2419 kfree(priv->tx_cbs); in bcmgenet_init_dma()
2424 bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); in bcmgenet_init_dma()
2427 bcmgenet_init_tx_queues(priv->dev); in bcmgenet_init_dma()
2435 struct bcmgenet_priv *priv = container_of( in bcmgenet_irq_task() local
2438 netif_dbg(priv, intr, priv->dev, "%s\n", __func__); in bcmgenet_irq_task()
2440 if (priv->irq0_stat & UMAC_IRQ_MPD_R) { in bcmgenet_irq_task()
2441 priv->irq0_stat &= ~UMAC_IRQ_MPD_R; in bcmgenet_irq_task()
2442 netif_dbg(priv, wol, priv->dev, in bcmgenet_irq_task()
2444 bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC); in bcmgenet_irq_task()
2448 if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && in bcmgenet_irq_task()
2449 (priv->irq0_stat & UMAC_IRQ_LINK_EVENT)) { in bcmgenet_irq_task()
2450 phy_mac_interrupt(priv->phydev, in bcmgenet_irq_task()
2451 !!(priv->irq0_stat & UMAC_IRQ_LINK_UP)); in bcmgenet_irq_task()
2452 priv->irq0_stat &= ~UMAC_IRQ_LINK_EVENT; in bcmgenet_irq_task()
2459 struct bcmgenet_priv *priv = dev_id; in bcmgenet_isr1() local
2465 priv->irq1_stat = in bcmgenet_isr1()
2466 bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_STAT) & in bcmgenet_isr1()
2467 ~bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_MASK_STATUS); in bcmgenet_isr1()
2470 bcmgenet_intrl2_1_writel(priv, priv->irq1_stat, INTRL2_CPU_CLEAR); in bcmgenet_isr1()
2472 netif_dbg(priv, intr, priv->dev, in bcmgenet_isr1()
2473 "%s: IRQ=0x%x\n", __func__, priv->irq1_stat); in bcmgenet_isr1()
2476 for (index = 0; index < priv->hw_params->rx_queues; index++) { in bcmgenet_isr1()
2477 if (!(priv->irq1_stat & BIT(UMAC_IRQ1_RX_INTR_SHIFT + index))) in bcmgenet_isr1()
2480 rx_ring = &priv->rx_rings[index]; in bcmgenet_isr1()
2489 for (index = 0; index < priv->hw_params->tx_queues; index++) { in bcmgenet_isr1()
2490 if (!(priv->irq1_stat & BIT(index))) in bcmgenet_isr1()
2493 tx_ring = &priv->tx_rings[index]; in bcmgenet_isr1()
2507 struct bcmgenet_priv *priv = dev_id; in bcmgenet_isr0() local
2512 priv->irq0_stat = in bcmgenet_isr0()
2513 bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_STAT) & in bcmgenet_isr0()
2514 ~bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_MASK_STATUS); in bcmgenet_isr0()
2517 bcmgenet_intrl2_0_writel(priv, priv->irq0_stat, INTRL2_CPU_CLEAR); in bcmgenet_isr0()
2519 netif_dbg(priv, intr, priv->dev, in bcmgenet_isr0()
2520 "IRQ=0x%x\n", priv->irq0_stat); in bcmgenet_isr0()
2522 if (priv->irq0_stat & UMAC_IRQ_RXDMA_DONE) { in bcmgenet_isr0()
2523 rx_ring = &priv->rx_rings[DESC_INDEX]; in bcmgenet_isr0()
2531 if (priv->irq0_stat & UMAC_IRQ_TXDMA_DONE) { in bcmgenet_isr0()
2532 tx_ring = &priv->tx_rings[DESC_INDEX]; in bcmgenet_isr0()
2540 if (priv->irq0_stat & (UMAC_IRQ_PHY_DET_R | in bcmgenet_isr0()
2547 schedule_work(&priv->bcmgenet_irq_work); in bcmgenet_isr0()
2550 if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && in bcmgenet_isr0()
2551 priv->irq0_stat & (UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR)) { in bcmgenet_isr0()
2552 priv->irq0_stat &= ~(UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR); in bcmgenet_isr0()
2553 wake_up(&priv->wq); in bcmgenet_isr0()
2561 struct bcmgenet_priv *priv = dev_id; in bcmgenet_wol_isr() local
2563 pm_wakeup_event(&priv->pdev->dev, 0); in bcmgenet_wol_isr()
2571 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_poll_controller() local
2574 disable_irq(priv->irq0); in bcmgenet_poll_controller()
2575 bcmgenet_isr0(priv->irq0, priv); in bcmgenet_poll_controller()
2576 enable_irq(priv->irq0); in bcmgenet_poll_controller()
2579 disable_irq(priv->irq1); in bcmgenet_poll_controller()
2580 bcmgenet_isr1(priv->irq1, priv); in bcmgenet_poll_controller()
2581 enable_irq(priv->irq1); in bcmgenet_poll_controller()
2585 static void bcmgenet_umac_reset(struct bcmgenet_priv *priv) in bcmgenet_umac_reset() argument
2589 reg = bcmgenet_rbuf_ctrl_get(priv); in bcmgenet_umac_reset()
2591 bcmgenet_rbuf_ctrl_set(priv, reg); in bcmgenet_umac_reset()
2595 bcmgenet_rbuf_ctrl_set(priv, reg); in bcmgenet_umac_reset()
2599 static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv, in bcmgenet_set_hw_addr() argument
2602 bcmgenet_umac_writel(priv, (addr[0] << 24) | (addr[1] << 16) | in bcmgenet_set_hw_addr()
2604 bcmgenet_umac_writel(priv, (addr[4] << 8) | addr[5], UMAC_MAC1); in bcmgenet_set_hw_addr()
2608 static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv) in bcmgenet_dma_disable() argument
2615 reg = bcmgenet_tdma_readl(priv, DMA_CTRL); in bcmgenet_dma_disable()
2617 bcmgenet_tdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_disable()
2619 reg = bcmgenet_rdma_readl(priv, DMA_CTRL); in bcmgenet_dma_disable()
2621 bcmgenet_rdma_writel(priv, reg, DMA_CTRL); in bcmgenet_dma_disable()
2623 bcmgenet_umac_writel(priv, 1, UMAC_TX_FLUSH); in bcmgenet_dma_disable()
2625 bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH); in bcmgenet_dma_disable()
2630 static void bcmgenet_enable_dma(struct bcmgenet_priv *priv, u32 dma_ctrl) in bcmgenet_enable_dma() argument
2634 reg = bcmgenet_rdma_readl(priv, DMA_CTRL); in bcmgenet_enable_dma()
2636 bcmgenet_rdma_writel(priv, reg, DMA_CTRL); in bcmgenet_enable_dma()
2638 reg = bcmgenet_tdma_readl(priv, DMA_CTRL); in bcmgenet_enable_dma()
2640 bcmgenet_tdma_writel(priv, reg, DMA_CTRL); in bcmgenet_enable_dma()
2643 static bool bcmgenet_hfb_is_filter_enabled(struct bcmgenet_priv *priv, in bcmgenet_hfb_is_filter_enabled() argument
2650 reg = bcmgenet_hfb_reg_readl(priv, offset); in bcmgenet_hfb_is_filter_enabled()
2654 static void bcmgenet_hfb_enable_filter(struct bcmgenet_priv *priv, u32 f_index) in bcmgenet_hfb_enable_filter() argument
2660 reg = bcmgenet_hfb_reg_readl(priv, offset); in bcmgenet_hfb_enable_filter()
2662 bcmgenet_hfb_reg_writel(priv, reg, offset); in bcmgenet_hfb_enable_filter()
2665 static void bcmgenet_hfb_set_filter_rx_queue_mapping(struct bcmgenet_priv *priv, in bcmgenet_hfb_set_filter_rx_queue_mapping() argument
2672 reg = bcmgenet_rdma_readl(priv, DMA_INDEX2RING_0 + offset); in bcmgenet_hfb_set_filter_rx_queue_mapping()
2675 bcmgenet_rdma_writel(priv, reg, DMA_INDEX2RING_0 + offset); in bcmgenet_hfb_set_filter_rx_queue_mapping()
2678 static void bcmgenet_hfb_set_filter_length(struct bcmgenet_priv *priv, in bcmgenet_hfb_set_filter_length() argument
2685 ((priv->hw_params->hfb_filter_cnt - 1 - f_index) / 4) * in bcmgenet_hfb_set_filter_length()
2687 reg = bcmgenet_hfb_reg_readl(priv, offset); in bcmgenet_hfb_set_filter_length()
2690 bcmgenet_hfb_reg_writel(priv, reg, offset); in bcmgenet_hfb_set_filter_length()
2693 static int bcmgenet_hfb_find_unused_filter(struct bcmgenet_priv *priv) in bcmgenet_hfb_find_unused_filter() argument
2697 for (f_index = 0; f_index < priv->hw_params->hfb_filter_cnt; f_index++) in bcmgenet_hfb_find_unused_filter()
2698 if (!bcmgenet_hfb_is_filter_enabled(priv, f_index)) in bcmgenet_hfb_find_unused_filter()
2739 int bcmgenet_hfb_add_filter(struct bcmgenet_priv *priv, u32 *f_data, in bcmgenet_hfb_add_filter() argument
2745 f_index = bcmgenet_hfb_find_unused_filter(priv); in bcmgenet_hfb_add_filter()
2749 if (f_length > priv->hw_params->hfb_filter_size) in bcmgenet_hfb_add_filter()
2753 bcmgenet_hfb_writel(priv, f_data[i], in bcmgenet_hfb_add_filter()
2754 (f_index * priv->hw_params->hfb_filter_size + i) * in bcmgenet_hfb_add_filter()
2757 bcmgenet_hfb_set_filter_length(priv, f_index, 2 * f_length); in bcmgenet_hfb_add_filter()
2758 bcmgenet_hfb_set_filter_rx_queue_mapping(priv, f_index, rx_queue); in bcmgenet_hfb_add_filter()
2759 bcmgenet_hfb_enable_filter(priv, f_index); in bcmgenet_hfb_add_filter()
2760 bcmgenet_hfb_reg_writel(priv, 0x1, HFB_CTRL); in bcmgenet_hfb_add_filter()
2769 static void bcmgenet_hfb_clear(struct bcmgenet_priv *priv) in bcmgenet_hfb_clear() argument
2773 bcmgenet_hfb_reg_writel(priv, 0x0, HFB_CTRL); in bcmgenet_hfb_clear()
2774 bcmgenet_hfb_reg_writel(priv, 0x0, HFB_FLT_ENABLE_V3PLUS); in bcmgenet_hfb_clear()
2775 bcmgenet_hfb_reg_writel(priv, 0x0, HFB_FLT_ENABLE_V3PLUS + 4); in bcmgenet_hfb_clear()
2778 bcmgenet_rdma_writel(priv, 0x0, i); in bcmgenet_hfb_clear()
2780 for (i = 0; i < (priv->hw_params->hfb_filter_cnt / 4); i++) in bcmgenet_hfb_clear()
2781 bcmgenet_hfb_reg_writel(priv, 0x0, in bcmgenet_hfb_clear()
2784 for (i = 0; i < priv->hw_params->hfb_filter_cnt * in bcmgenet_hfb_clear()
2785 priv->hw_params->hfb_filter_size; i++) in bcmgenet_hfb_clear()
2786 bcmgenet_hfb_writel(priv, 0x0, i * sizeof(u32)); in bcmgenet_hfb_clear()
2789 static void bcmgenet_hfb_init(struct bcmgenet_priv *priv) in bcmgenet_hfb_init() argument
2791 if (GENET_IS_V1(priv) || GENET_IS_V2(priv)) in bcmgenet_hfb_init()
2794 bcmgenet_hfb_clear(priv); in bcmgenet_hfb_init()
2799 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_netif_start() local
2802 bcmgenet_enable_rx_napi(priv); in bcmgenet_netif_start()
2803 bcmgenet_enable_tx_napi(priv); in bcmgenet_netif_start()
2805 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true); in bcmgenet_netif_start()
2810 bcmgenet_link_intr_enable(priv); in bcmgenet_netif_start()
2812 phy_start(priv->phydev); in bcmgenet_netif_start()
2817 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_open() local
2822 netif_dbg(priv, ifup, dev, "bcmgenet_open\n"); in bcmgenet_open()
2825 clk_prepare_enable(priv->clk); in bcmgenet_open()
2830 if (priv->internal_phy) in bcmgenet_open()
2831 bcmgenet_power_up(priv, GENET_POWER_PASSIVE); in bcmgenet_open()
2834 bcmgenet_umac_reset(priv); in bcmgenet_open()
2836 ret = init_umac(priv); in bcmgenet_open()
2841 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false); in bcmgenet_open()
2844 reg = bcmgenet_umac_readl(priv, UMAC_CMD); in bcmgenet_open()
2845 priv->crc_fwd_en = !!(reg & CMD_CRC_FWD); in bcmgenet_open()
2847 bcmgenet_set_hw_addr(priv, dev->dev_addr); in bcmgenet_open()
2849 if (priv->internal_phy) { in bcmgenet_open()
2850 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); in bcmgenet_open()
2852 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); in bcmgenet_open()
2856 dma_ctrl = bcmgenet_dma_disable(priv); in bcmgenet_open()
2859 ret = bcmgenet_init_dma(priv); in bcmgenet_open()
2866 bcmgenet_enable_dma(priv, dma_ctrl); in bcmgenet_open()
2869 bcmgenet_hfb_init(priv); in bcmgenet_open()
2871 ret = request_irq(priv->irq0, bcmgenet_isr0, IRQF_SHARED, in bcmgenet_open()
2872 dev->name, priv); in bcmgenet_open()
2874 netdev_err(dev, "can't request IRQ %d\n", priv->irq0); in bcmgenet_open()
2878 ret = request_irq(priv->irq1, bcmgenet_isr1, IRQF_SHARED, in bcmgenet_open()
2879 dev->name, priv); in bcmgenet_open()
2881 netdev_err(dev, "can't request IRQ %d\n", priv->irq1); in bcmgenet_open()
2896 free_irq(priv->irq1, priv); in bcmgenet_open()
2898 free_irq(priv->irq0, priv); in bcmgenet_open()
2900 bcmgenet_fini_dma(priv); in bcmgenet_open()
2902 clk_disable_unprepare(priv->clk); in bcmgenet_open()
2908 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_netif_stop() local
2911 phy_stop(priv->phydev); in bcmgenet_netif_stop()
2912 bcmgenet_intr_disable(priv); in bcmgenet_netif_stop()
2913 bcmgenet_disable_rx_napi(priv); in bcmgenet_netif_stop()
2914 bcmgenet_disable_tx_napi(priv); in bcmgenet_netif_stop()
2919 cancel_work_sync(&priv->bcmgenet_irq_work); in bcmgenet_netif_stop()
2921 priv->old_link = -1; in bcmgenet_netif_stop()
2922 priv->old_speed = -1; in bcmgenet_netif_stop()
2923 priv->old_duplex = -1; in bcmgenet_netif_stop()
2924 priv->old_pause = -1; in bcmgenet_netif_stop()
2929 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_close() local
2932 netif_dbg(priv, ifdown, dev, "bcmgenet_close\n"); in bcmgenet_close()
2937 phy_disconnect(priv->phydev); in bcmgenet_close()
2940 umac_enable_set(priv, CMD_RX_EN, false); in bcmgenet_close()
2942 ret = bcmgenet_dma_teardown(priv); in bcmgenet_close()
2947 umac_enable_set(priv, CMD_TX_EN, false); in bcmgenet_close()
2951 bcmgenet_fini_dma(priv); in bcmgenet_close()
2953 free_irq(priv->irq0, priv); in bcmgenet_close()
2954 free_irq(priv->irq1, priv); in bcmgenet_close()
2956 if (priv->internal_phy) in bcmgenet_close()
2957 ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE); in bcmgenet_close()
2959 clk_disable_unprepare(priv->clk); in bcmgenet_close()
2966 struct bcmgenet_priv *priv = ring->priv; in bcmgenet_dump_tx_queue() local
2973 if (!netif_msg_tx_err(priv)) in bcmgenet_dump_tx_queue()
2976 txq = netdev_get_tx_queue(priv->dev, ring->queue); in bcmgenet_dump_tx_queue()
2980 intsts = ~bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_MASK_STATUS); in bcmgenet_dump_tx_queue()
2983 intsts = ~bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_MASK_STATUS); in bcmgenet_dump_tx_queue()
2986 c_index = bcmgenet_tdma_ring_readl(priv, ring->index, TDMA_CONS_INDEX); in bcmgenet_dump_tx_queue()
2987 p_index = bcmgenet_tdma_ring_readl(priv, ring->index, TDMA_PROD_INDEX); in bcmgenet_dump_tx_queue()
2992 netif_err(priv, tx_err, priv->dev, "Ring %d queue %d status summary\n" in bcmgenet_dump_tx_queue()
3011 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_timeout() local
3016 netif_dbg(priv, tx_err, dev, "bcmgenet_timeout\n"); in bcmgenet_timeout()
3018 for (q = 0; q < priv->hw_params->tx_queues; q++) in bcmgenet_timeout()
3019 bcmgenet_dump_tx_queue(&priv->tx_rings[q]); in bcmgenet_timeout()
3020 bcmgenet_dump_tx_queue(&priv->tx_rings[DESC_INDEX]); in bcmgenet_timeout()
3024 for (q = 0; q < priv->hw_params->tx_queues; q++) in bcmgenet_timeout()
3030 bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR); in bcmgenet_timeout()
3031 bcmgenet_intrl2_1_writel(priv, int1_enable, INTRL2_CPU_MASK_CLEAR); in bcmgenet_timeout()
3042 static inline void bcmgenet_set_mdf_addr(struct bcmgenet_priv *priv, in bcmgenet_set_mdf_addr() argument
3049 bcmgenet_umac_writel(priv, addr[0] << 8 | addr[1], in bcmgenet_set_mdf_addr()
3051 bcmgenet_umac_writel(priv, addr[2] << 24 | addr[3] << 16 | in bcmgenet_set_mdf_addr()
3054 reg = bcmgenet_umac_readl(priv, UMAC_MDF_CTRL); in bcmgenet_set_mdf_addr()
3056 bcmgenet_umac_writel(priv, reg, UMAC_MDF_CTRL); in bcmgenet_set_mdf_addr()
3063 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_set_rx_mode() local
3068 netif_dbg(priv, hw, dev, "%s: %08X\n", __func__, dev->flags); in bcmgenet_set_rx_mode()
3071 reg = bcmgenet_umac_readl(priv, UMAC_CMD); in bcmgenet_set_rx_mode()
3074 bcmgenet_umac_writel(priv, reg, UMAC_CMD); in bcmgenet_set_rx_mode()
3075 bcmgenet_umac_writel(priv, 0, UMAC_MDF_CTRL); in bcmgenet_set_rx_mode()
3079 bcmgenet_umac_writel(priv, reg, UMAC_CMD); in bcmgenet_set_rx_mode()
3092 bcmgenet_set_mdf_addr(priv, dev->broadcast, &i, &mc); in bcmgenet_set_rx_mode()
3094 bcmgenet_set_mdf_addr(priv, dev->dev_addr, &i, &mc); in bcmgenet_set_rx_mode()
3101 bcmgenet_set_mdf_addr(priv, ha->addr, &i, &mc); in bcmgenet_set_rx_mode()
3107 bcmgenet_set_mdf_addr(priv, ha->addr, &i, &mc); in bcmgenet_set_rx_mode()
3214 static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv) in bcmgenet_set_hw_params() argument
3221 if (GENET_IS_V4(priv)) { in bcmgenet_set_hw_params()
3224 priv->dma_rx_chk_bit = DMA_RX_CHK_V3PLUS; in bcmgenet_set_hw_params()
3225 priv->version = GENET_V4; in bcmgenet_set_hw_params()
3226 } else if (GENET_IS_V3(priv)) { in bcmgenet_set_hw_params()
3229 priv->dma_rx_chk_bit = DMA_RX_CHK_V3PLUS; in bcmgenet_set_hw_params()
3230 priv->version = GENET_V3; in bcmgenet_set_hw_params()
3231 } else if (GENET_IS_V2(priv)) { in bcmgenet_set_hw_params()
3234 priv->dma_rx_chk_bit = DMA_RX_CHK_V12; in bcmgenet_set_hw_params()
3235 priv->version = GENET_V2; in bcmgenet_set_hw_params()
3236 } else if (GENET_IS_V1(priv)) { in bcmgenet_set_hw_params()
3239 priv->dma_rx_chk_bit = DMA_RX_CHK_V12; in bcmgenet_set_hw_params()
3240 priv->version = GENET_V1; in bcmgenet_set_hw_params()
3244 priv->hw_params = &bcmgenet_hw_params[priv->version]; in bcmgenet_set_hw_params()
3245 params = priv->hw_params; in bcmgenet_set_hw_params()
3248 reg = bcmgenet_sys_readl(priv, SYS_REV_CTRL); in bcmgenet_set_hw_params()
3254 if (major != priv->version) { in bcmgenet_set_hw_params()
3255 dev_err(&priv->pdev->dev, in bcmgenet_set_hw_params()
3257 major, priv->version); in bcmgenet_set_hw_params()
3261 dev_info(&priv->pdev->dev, "GENET " GENET_VER_FMT, in bcmgenet_set_hw_params()
3280 priv->gphy_rev = gphy_rev << 8; in bcmgenet_set_hw_params()
3284 priv->gphy_rev = gphy_rev; in bcmgenet_set_hw_params()
3304 priv->version, in bcmgenet_set_hw_params()
3329 struct bcmgenet_priv *priv; in bcmgenet_probe() local
3336 dev = alloc_etherdev_mqs(sizeof(*priv), GENET_MAX_MQ_CNT + 1, in bcmgenet_probe()
3349 priv = netdev_priv(dev); in bcmgenet_probe()
3350 priv->irq0 = platform_get_irq(pdev, 0); in bcmgenet_probe()
3351 priv->irq1 = platform_get_irq(pdev, 1); in bcmgenet_probe()
3352 priv->wol_irq = platform_get_irq(pdev, 2); in bcmgenet_probe()
3353 if (!priv->irq0 || !priv->irq1) { in bcmgenet_probe()
3371 priv->base = devm_ioremap_resource(&pdev->dev, r); in bcmgenet_probe()
3372 if (IS_ERR(priv->base)) { in bcmgenet_probe()
3373 err = PTR_ERR(priv->base); in bcmgenet_probe()
3384 priv->msg_enable = netif_msg_init(-1, GENET_MSG_DEFAULT); in bcmgenet_probe()
3391 priv->wol_irq_disabled = true; in bcmgenet_probe()
3392 err = devm_request_irq(&pdev->dev, priv->wol_irq, bcmgenet_wol_isr, 0, in bcmgenet_probe()
3393 dev->name, priv); in bcmgenet_probe()
3404 priv->dev = dev; in bcmgenet_probe()
3405 priv->pdev = pdev; in bcmgenet_probe()
3407 priv->version = (enum bcmgenet_version)of_id->data; in bcmgenet_probe()
3409 priv->version = pd->genet_version; in bcmgenet_probe()
3411 priv->clk = devm_clk_get(&priv->pdev->dev, "enet"); in bcmgenet_probe()
3412 if (IS_ERR(priv->clk)) { in bcmgenet_probe()
3413 dev_warn(&priv->pdev->dev, "failed to get enet clock\n"); in bcmgenet_probe()
3414 priv->clk = NULL; in bcmgenet_probe()
3417 clk_prepare_enable(priv->clk); in bcmgenet_probe()
3419 bcmgenet_set_hw_params(priv); in bcmgenet_probe()
3422 init_waitqueue_head(&priv->wq); in bcmgenet_probe()
3424 priv->rx_buf_len = RX_BUF_LENGTH; in bcmgenet_probe()
3425 INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); in bcmgenet_probe()
3427 priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol"); in bcmgenet_probe()
3428 if (IS_ERR(priv->clk_wol)) { in bcmgenet_probe()
3429 dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n"); in bcmgenet_probe()
3430 priv->clk_wol = NULL; in bcmgenet_probe()
3433 priv->clk_eee = devm_clk_get(&priv->pdev->dev, "enet-eee"); in bcmgenet_probe()
3434 if (IS_ERR(priv->clk_eee)) { in bcmgenet_probe()
3435 dev_warn(&priv->pdev->dev, "failed to get enet-eee clock\n"); in bcmgenet_probe()
3436 priv->clk_eee = NULL; in bcmgenet_probe()
3439 err = reset_umac(priv); in bcmgenet_probe()
3450 netif_set_real_num_tx_queues(priv->dev, priv->hw_params->tx_queues + 1); in bcmgenet_probe()
3451 netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); in bcmgenet_probe()
3457 clk_disable_unprepare(priv->clk); in bcmgenet_probe()
3466 clk_disable_unprepare(priv->clk); in bcmgenet_probe()
3474 struct bcmgenet_priv *priv = dev_to_priv(&pdev->dev); in bcmgenet_remove() local
3477 unregister_netdev(priv->dev); in bcmgenet_remove()
3478 bcmgenet_mii_exit(priv->dev); in bcmgenet_remove()
3479 free_netdev(priv->dev); in bcmgenet_remove()
3488 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_suspend() local
3496 phy_suspend(priv->phydev); in bcmgenet_suspend()
3501 umac_enable_set(priv, CMD_RX_EN, false); in bcmgenet_suspend()
3503 ret = bcmgenet_dma_teardown(priv); in bcmgenet_suspend()
3508 umac_enable_set(priv, CMD_TX_EN, false); in bcmgenet_suspend()
3512 bcmgenet_fini_dma(priv); in bcmgenet_suspend()
3515 if (device_may_wakeup(d) && priv->wolopts) { in bcmgenet_suspend()
3516 ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC); in bcmgenet_suspend()
3517 clk_prepare_enable(priv->clk_wol); in bcmgenet_suspend()
3518 } else if (priv->internal_phy) { in bcmgenet_suspend()
3519 ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE); in bcmgenet_suspend()
3523 clk_disable_unprepare(priv->clk); in bcmgenet_suspend()
3531 struct bcmgenet_priv *priv = netdev_priv(dev); in bcmgenet_resume() local
3540 ret = clk_prepare_enable(priv->clk); in bcmgenet_resume()
3547 if (priv->internal_phy) in bcmgenet_resume()
3548 bcmgenet_power_up(priv, GENET_POWER_PASSIVE); in bcmgenet_resume()
3550 bcmgenet_umac_reset(priv); in bcmgenet_resume()
3552 ret = init_umac(priv); in bcmgenet_resume()
3557 if (priv->wolopts) in bcmgenet_resume()
3558 clk_disable_unprepare(priv->clk_wol); in bcmgenet_resume()
3560 phy_init_hw(priv->phydev); in bcmgenet_resume()
3562 bcmgenet_mii_config(priv->dev); in bcmgenet_resume()
3565 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false); in bcmgenet_resume()
3567 bcmgenet_set_hw_addr(priv, dev->dev_addr); in bcmgenet_resume()
3569 if (priv->internal_phy) { in bcmgenet_resume()
3570 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); in bcmgenet_resume()
3572 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); in bcmgenet_resume()
3575 if (priv->wolopts) in bcmgenet_resume()
3576 bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC); in bcmgenet_resume()
3579 dma_ctrl = bcmgenet_dma_disable(priv); in bcmgenet_resume()
3582 ret = bcmgenet_init_dma(priv); in bcmgenet_resume()
3589 bcmgenet_enable_dma(priv, dma_ctrl); in bcmgenet_resume()
3593 phy_resume(priv->phydev); in bcmgenet_resume()
3595 if (priv->eee.eee_enabled) in bcmgenet_resume()
3603 clk_disable_unprepare(priv->clk); in bcmgenet_resume()