Lines Matching refs:intf
57 static void bcmasp_enable_tx(struct bcmasp_intf *intf, int en) in bcmasp_enable_tx() argument
60 tx_spb_ctrl_wl(intf, TX_SPB_CTRL_ENABLE_EN, TX_SPB_CTRL_ENABLE); in bcmasp_enable_tx()
61 tx_epkt_core_wl(intf, (TX_EPKT_C_CFG_MISC_EN | in bcmasp_enable_tx()
63 (intf->port << TX_EPKT_C_CFG_MISC_PS_SHIFT)), in bcmasp_enable_tx()
66 tx_spb_ctrl_wl(intf, 0x0, TX_SPB_CTRL_ENABLE); in bcmasp_enable_tx()
67 tx_epkt_core_wl(intf, 0x0, TX_EPKT_C_CFG_MISC); in bcmasp_enable_tx()
71 static void bcmasp_enable_rx(struct bcmasp_intf *intf, int en) in bcmasp_enable_rx() argument
74 rx_edpkt_cfg_wl(intf, RX_EDPKT_CFG_ENABLE_EN, in bcmasp_enable_rx()
77 rx_edpkt_cfg_wl(intf, 0x0, RX_EDPKT_CFG_ENABLE); in bcmasp_enable_rx()
83 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_set_rx_mode() local
87 spin_lock_bh(&intf->parent->mda_lock); in bcmasp_set_rx_mode()
89 bcmasp_disable_all_filters(intf); in bcmasp_set_rx_mode()
94 bcmasp_set_promisc(intf, 0); in bcmasp_set_rx_mode()
96 bcmasp_set_broad(intf, 1); in bcmasp_set_rx_mode()
98 bcmasp_set_oaddr(intf, dev->dev_addr, 1); in bcmasp_set_rx_mode()
101 bcmasp_set_allmulti(intf, 1); in bcmasp_set_rx_mode()
103 bcmasp_set_allmulti(intf, 0); in bcmasp_set_rx_mode()
106 ret = bcmasp_set_en_mda_filter(intf, ha->addr, mask); in bcmasp_set_rx_mode()
108 intf->mib.mc_filters_full_cnt++; in bcmasp_set_rx_mode()
115 ret = bcmasp_set_en_mda_filter(intf, ha->addr, mask); in bcmasp_set_rx_mode()
117 intf->mib.uc_filters_full_cnt++; in bcmasp_set_rx_mode()
122 spin_unlock_bh(&intf->parent->mda_lock); in bcmasp_set_rx_mode()
126 bcmasp_set_promisc(intf, 1); in bcmasp_set_rx_mode()
127 intf->mib.promisc_filters_cnt++; in bcmasp_set_rx_mode()
130 bcmasp_disable_all_filters(intf); in bcmasp_set_rx_mode()
132 spin_unlock_bh(&intf->parent->mda_lock); in bcmasp_set_rx_mode()
135 static void bcmasp_clean_txcb(struct bcmasp_intf *intf, int index) in bcmasp_clean_txcb() argument
137 struct bcmasp_tx_cb *txcb = &intf->tx_cbs[index]; in bcmasp_clean_txcb()
145 static int tx_spb_ring_full(struct bcmasp_intf *intf, int cnt) in tx_spb_ring_full() argument
151 next_index = incr_ring(intf->tx_spb_index, DESC_RING_COUNT); in tx_spb_ring_full()
152 if (next_index == intf->tx_spb_clean_index) in tx_spb_ring_full()
163 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_csum_offload() local
175 intf->mib.tx_realloc_offload_failed++; in bcmasp_csum_offload()
234 static unsigned long bcmasp_rx_edpkt_dma_rq(struct bcmasp_intf *intf) in bcmasp_rx_edpkt_dma_rq() argument
236 return rx_edpkt_dma_rq(intf, RX_EDPKT_DMA_VALID); in bcmasp_rx_edpkt_dma_rq()
239 static void bcmasp_rx_edpkt_cfg_wq(struct bcmasp_intf *intf, dma_addr_t addr) in bcmasp_rx_edpkt_cfg_wq() argument
241 rx_edpkt_cfg_wq(intf, addr, RX_EDPKT_RING_BUFFER_READ); in bcmasp_rx_edpkt_cfg_wq()
244 static void bcmasp_rx_edpkt_dma_wq(struct bcmasp_intf *intf, dma_addr_t addr) in bcmasp_rx_edpkt_dma_wq() argument
246 rx_edpkt_dma_wq(intf, addr, RX_EDPKT_DMA_READ); in bcmasp_rx_edpkt_dma_wq()
249 static unsigned long bcmasp_tx_spb_dma_rq(struct bcmasp_intf *intf) in bcmasp_tx_spb_dma_rq() argument
251 return tx_spb_dma_rq(intf, TX_SPB_DMA_READ); in bcmasp_tx_spb_dma_rq()
254 static void bcmasp_tx_spb_dma_wq(struct bcmasp_intf *intf, dma_addr_t addr) in bcmasp_tx_spb_dma_wq() argument
256 tx_spb_dma_wq(intf, addr, TX_SPB_DMA_VALID); in bcmasp_tx_spb_dma_wq()
269 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_xmit() local
279 kdev = &intf->parent->pdev->dev; in bcmasp_xmit()
283 if (tx_spb_ring_full(intf, nr_frags + 1)) { in bcmasp_xmit()
296 spb_index = intf->tx_spb_index; in bcmasp_xmit()
297 valid = intf->tx_spb_dma_valid; in bcmasp_xmit()
316 intf->mib.tx_dma_failed++; in bcmasp_xmit()
317 spb_index = intf->tx_spb_index; in bcmasp_xmit()
319 bcmasp_clean_txcb(intf, spb_index); in bcmasp_xmit()
324 spb_index = intf->tx_spb_index; in bcmasp_xmit()
328 txcb = &intf->tx_cbs[spb_index]; in bcmasp_xmit()
329 desc = &intf->tx_spb_cpu[spb_index]; in bcmasp_xmit()
350 netif_dbg(intf, tx_queued, dev, in bcmasp_xmit()
356 valid = incr_last_byte(valid, intf->tx_spb_dma_addr, in bcmasp_xmit()
365 intf->tx_spb_index = spb_index; in bcmasp_xmit()
366 intf->tx_spb_dma_valid = valid; in bcmasp_xmit()
367 bcmasp_intf_tx_write(intf, intf->tx_spb_dma_valid); in bcmasp_xmit()
369 if (tx_spb_ring_full(intf, MAX_SKB_FRAGS + 1)) in bcmasp_xmit()
377 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_netif_start() local
380 napi_enable(&intf->tx_napi); in bcmasp_netif_start()
381 napi_enable(&intf->rx_napi); in bcmasp_netif_start()
383 bcmasp_enable_rx_irq(intf, 1); in bcmasp_netif_start()
384 bcmasp_enable_tx_irq(intf, 1); in bcmasp_netif_start()
389 static void umac_reset(struct bcmasp_intf *intf) in umac_reset() argument
391 umac_wl(intf, 0x0, UMC_CMD); in umac_reset()
392 umac_wl(intf, UMC_CMD_SW_RESET, UMC_CMD); in umac_reset()
394 umac_wl(intf, 0x0, UMC_CMD); in umac_reset()
397 static void umac_set_hw_addr(struct bcmasp_intf *intf, in umac_set_hw_addr() argument
404 umac_wl(intf, mac0, UMC_MAC0); in umac_set_hw_addr()
405 umac_wl(intf, mac1, UMC_MAC1); in umac_set_hw_addr()
408 static void umac_enable_set(struct bcmasp_intf *intf, u32 mask, in umac_enable_set() argument
413 reg = umac_rl(intf, UMC_CMD); in umac_enable_set()
418 umac_wl(intf, reg, UMC_CMD); in umac_enable_set()
427 static void umac_init(struct bcmasp_intf *intf) in umac_init() argument
429 umac_wl(intf, 0x800, UMC_FRM_LEN); in umac_init()
430 umac_wl(intf, 0xffff, UMC_PAUSE_CNTRL); in umac_init()
431 umac_wl(intf, 0x800, UMC_RX_MAX_PKT_SZ); in umac_init()
432 umac_enable_set(intf, UMC_CMD_PROMISC, 1); in umac_init()
437 struct bcmasp_intf *intf = in bcmasp_tx_poll() local
439 struct bcmasp_intf_stats64 *stats = &intf->stats64; in bcmasp_tx_poll()
440 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_tx_poll()
446 read = bcmasp_intf_tx_read(intf); in bcmasp_tx_poll()
447 while (intf->tx_spb_dma_read != read) { in bcmasp_tx_poll()
448 txcb = &intf->tx_cbs[intf->tx_spb_clean_index]; in bcmasp_tx_poll()
464 desc = &intf->tx_spb_cpu[intf->tx_spb_clean_index]; in bcmasp_tx_poll()
466 netif_dbg(intf, tx_done, intf->ndev, in bcmasp_tx_poll()
469 intf->tx_spb_clean_index); in bcmasp_tx_poll()
471 bcmasp_clean_txcb(intf, intf->tx_spb_clean_index); in bcmasp_tx_poll()
474 intf->tx_spb_clean_index = incr_ring(intf->tx_spb_clean_index, in bcmasp_tx_poll()
476 intf->tx_spb_dma_read = incr_first_byte(intf->tx_spb_dma_read, in bcmasp_tx_poll()
477 intf->tx_spb_dma_addr, in bcmasp_tx_poll()
486 napi_complete(&intf->tx_napi); in bcmasp_tx_poll()
488 bcmasp_enable_tx_irq(intf, 1); in bcmasp_tx_poll()
491 netif_wake_queue(intf->ndev); in bcmasp_tx_poll()
498 struct bcmasp_intf *intf = in bcmasp_rx_poll() local
500 struct bcmasp_intf_stats64 *stats = &intf->stats64; in bcmasp_rx_poll()
501 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_rx_poll()
510 valid = bcmasp_intf_rx_desc_read(intf) + 1; in bcmasp_rx_poll()
511 if (valid == intf->rx_edpkt_dma_addr + DESC_RING_SIZE) in bcmasp_rx_poll()
512 valid = intf->rx_edpkt_dma_addr; in bcmasp_rx_poll()
514 while ((processed < budget) && (valid != intf->rx_edpkt_dma_read)) { in bcmasp_rx_poll()
515 desc = &intf->rx_edpkt_cpu[intf->rx_edpkt_index]; in bcmasp_rx_poll()
523 data = intf->rx_ring_cpu + in bcmasp_rx_poll()
524 (DESC_ADDR(desc->buf) - intf->rx_ring_dma); in bcmasp_rx_poll()
529 netif_err(intf, rx_status, intf->ndev, in bcmasp_rx_poll()
553 intf->mib.alloc_rx_skb_failed++; in bcmasp_rx_poll()
563 if (likely(intf->crc_fwd)) { in bcmasp_rx_poll()
568 if ((intf->ndev->features & NETIF_F_RXCSUM) && in bcmasp_rx_poll()
572 skb->protocol = eth_type_trans(skb, intf->ndev); in bcmasp_rx_poll()
582 bcmasp_intf_rx_buffer_write(intf, (DESC_ADDR(desc->buf) + in bcmasp_rx_poll()
586 intf->rx_edpkt_dma_read = in bcmasp_rx_poll()
587 incr_first_byte(intf->rx_edpkt_dma_read, in bcmasp_rx_poll()
588 intf->rx_edpkt_dma_addr, in bcmasp_rx_poll()
590 intf->rx_edpkt_index = incr_ring(intf->rx_edpkt_index, in bcmasp_rx_poll()
594 bcmasp_intf_rx_desc_write(intf, intf->rx_edpkt_dma_read); in bcmasp_rx_poll()
597 napi_complete_done(&intf->rx_napi, processed); in bcmasp_rx_poll()
598 bcmasp_enable_rx_irq(intf, 1); in bcmasp_rx_poll()
606 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_adj_link() local
611 if (intf->old_link != phydev->link) { in bcmasp_adj_link()
613 intf->old_link = phydev->link; in bcmasp_adj_link()
616 if (intf->old_duplex != phydev->duplex) { in bcmasp_adj_link()
618 intf->old_duplex = phydev->duplex; in bcmasp_adj_link()
642 if (intf->old_pause != phydev->pause) { in bcmasp_adj_link()
644 intf->old_pause = phydev->pause; in bcmasp_adj_link()
654 reg = umac_rl(intf, UMC_CMD); in bcmasp_adj_link()
659 umac_wl(intf, reg, UMC_CMD); in bcmasp_adj_link()
661 intf->eee.eee_active = phy_init_eee(phydev, 0) >= 0; in bcmasp_adj_link()
662 bcmasp_eee_enable_set(intf, intf->eee.eee_active); in bcmasp_adj_link()
665 reg = rgmii_rl(intf, RGMII_OOB_CNTRL); in bcmasp_adj_link()
670 rgmii_wl(intf, reg, RGMII_OOB_CNTRL); in bcmasp_adj_link()
676 static int bcmasp_init_rx(struct bcmasp_intf *intf) in bcmasp_init_rx() argument
678 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_init_rx()
685 intf->rx_buf_order = get_order(RING_BUFFER_SIZE); in bcmasp_init_rx()
686 buffer_pg = alloc_pages(GFP_KERNEL, intf->rx_buf_order); in bcmasp_init_rx()
691 __free_pages(buffer_pg, intf->rx_buf_order); in bcmasp_init_rx()
694 intf->rx_ring_cpu = page_to_virt(buffer_pg); in bcmasp_init_rx()
695 intf->rx_ring_dma = dma; in bcmasp_init_rx()
696 intf->rx_ring_dma_valid = intf->rx_ring_dma + RING_BUFFER_SIZE - 1; in bcmasp_init_rx()
698 p = dma_alloc_coherent(kdev, DESC_RING_SIZE, &intf->rx_edpkt_dma_addr, in bcmasp_init_rx()
704 intf->rx_edpkt_cpu = p; in bcmasp_init_rx()
706 netif_napi_add(intf->ndev, &intf->rx_napi, bcmasp_rx_poll); in bcmasp_init_rx()
708 intf->rx_edpkt_dma_read = intf->rx_edpkt_dma_addr; in bcmasp_init_rx()
709 intf->rx_edpkt_index = 0; in bcmasp_init_rx()
712 rx_edpkt_cfg_wl(intf, 0x0, RX_EDPKT_CFG_ENABLE); in bcmasp_init_rx()
715 rx_edpkt_cfg_wq(intf, intf->rx_ring_dma, RX_EDPKT_RING_BUFFER_READ); in bcmasp_init_rx()
716 rx_edpkt_cfg_wq(intf, intf->rx_ring_dma, RX_EDPKT_RING_BUFFER_WRITE); in bcmasp_init_rx()
717 rx_edpkt_cfg_wq(intf, intf->rx_ring_dma, RX_EDPKT_RING_BUFFER_BASE); in bcmasp_init_rx()
718 rx_edpkt_cfg_wq(intf, intf->rx_ring_dma_valid, in bcmasp_init_rx()
720 rx_edpkt_cfg_wq(intf, intf->rx_ring_dma_valid, in bcmasp_init_rx()
724 rx_edpkt_cfg_wl(intf, (RX_EDPKT_CFG_CFG0_RBUF_4K << in bcmasp_init_rx()
730 rx_edpkt_dma_wq(intf, intf->rx_edpkt_dma_addr, RX_EDPKT_DMA_WRITE); in bcmasp_init_rx()
731 rx_edpkt_dma_wq(intf, intf->rx_edpkt_dma_addr, RX_EDPKT_DMA_READ); in bcmasp_init_rx()
732 rx_edpkt_dma_wq(intf, intf->rx_edpkt_dma_addr, RX_EDPKT_DMA_BASE); in bcmasp_init_rx()
733 rx_edpkt_dma_wq(intf, intf->rx_edpkt_dma_addr + (DESC_RING_SIZE - 1), in bcmasp_init_rx()
735 rx_edpkt_dma_wq(intf, intf->rx_edpkt_dma_addr + (DESC_RING_SIZE - 1), in bcmasp_init_rx()
739 ((intf->channel + 11) << UMAC2FB_CFG_CHID_SHIFT); in bcmasp_init_rx()
741 umac2fb_wl(intf, reg, UMAC2FB_CFG); in bcmasp_init_rx()
746 dma_unmap_page(kdev, intf->rx_ring_dma, RING_BUFFER_SIZE, in bcmasp_init_rx()
748 __free_pages(virt_to_page(intf->rx_ring_cpu), intf->rx_buf_order); in bcmasp_init_rx()
753 static void bcmasp_reclaim_free_all_rx(struct bcmasp_intf *intf) in bcmasp_reclaim_free_all_rx() argument
755 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_reclaim_free_all_rx()
757 dma_free_coherent(kdev, DESC_RING_SIZE, intf->rx_edpkt_cpu, in bcmasp_reclaim_free_all_rx()
758 intf->rx_edpkt_dma_addr); in bcmasp_reclaim_free_all_rx()
759 dma_unmap_page(kdev, intf->rx_ring_dma, RING_BUFFER_SIZE, in bcmasp_reclaim_free_all_rx()
761 __free_pages(virt_to_page(intf->rx_ring_cpu), intf->rx_buf_order); in bcmasp_reclaim_free_all_rx()
764 static int bcmasp_init_tx(struct bcmasp_intf *intf) in bcmasp_init_tx() argument
766 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_init_tx()
770 p = dma_alloc_coherent(kdev, DESC_RING_SIZE, &intf->tx_spb_dma_addr, in bcmasp_init_tx()
775 intf->tx_spb_cpu = p; in bcmasp_init_tx()
776 intf->tx_spb_dma_valid = intf->tx_spb_dma_addr + DESC_RING_SIZE - 1; in bcmasp_init_tx()
777 intf->tx_spb_dma_read = intf->tx_spb_dma_addr; in bcmasp_init_tx()
779 intf->tx_cbs = kcalloc(DESC_RING_COUNT, sizeof(struct bcmasp_tx_cb), in bcmasp_init_tx()
781 if (!intf->tx_cbs) { in bcmasp_init_tx()
786 intf->tx_spb_index = 0; in bcmasp_init_tx()
787 intf->tx_spb_clean_index = 0; in bcmasp_init_tx()
789 netif_napi_add_tx(intf->ndev, &intf->tx_napi, bcmasp_tx_poll); in bcmasp_init_tx()
792 tx_spb_ctrl_wl(intf, 0x0, TX_SPB_CTRL_ENABLE); in bcmasp_init_tx()
793 tx_epkt_core_wl(intf, 0x0, TX_EPKT_C_CFG_MISC); in bcmasp_init_tx()
796 tx_spb_ctrl_wl(intf, ((intf->channel + 8) << TX_SPB_CTRL_XF_BID_SHIFT), in bcmasp_init_tx()
798 tx_pause_ctrl_wl(intf, (1 << (intf->channel + 8)), TX_PAUSE_MAP_VECTOR); in bcmasp_init_tx()
799 tx_spb_top_wl(intf, 0x1e, TX_SPB_TOP_BLKOUT); in bcmasp_init_tx()
800 tx_spb_top_wl(intf, 0x0, TX_SPB_TOP_SPRE_BW_CTRL); in bcmasp_init_tx()
802 tx_spb_dma_wq(intf, intf->tx_spb_dma_addr, TX_SPB_DMA_READ); in bcmasp_init_tx()
803 tx_spb_dma_wq(intf, intf->tx_spb_dma_addr, TX_SPB_DMA_BASE); in bcmasp_init_tx()
804 tx_spb_dma_wq(intf, intf->tx_spb_dma_valid, TX_SPB_DMA_END); in bcmasp_init_tx()
805 tx_spb_dma_wq(intf, intf->tx_spb_dma_valid, TX_SPB_DMA_VALID); in bcmasp_init_tx()
810 dma_free_coherent(kdev, DESC_RING_SIZE, intf->tx_spb_cpu, in bcmasp_init_tx()
811 intf->tx_spb_dma_addr); in bcmasp_init_tx()
816 static void bcmasp_reclaim_free_all_tx(struct bcmasp_intf *intf) in bcmasp_reclaim_free_all_tx() argument
818 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_reclaim_free_all_tx()
821 dma_free_coherent(kdev, DESC_RING_SIZE, intf->tx_spb_cpu, in bcmasp_reclaim_free_all_tx()
822 intf->tx_spb_dma_addr); in bcmasp_reclaim_free_all_tx()
825 kfree(intf->tx_cbs); in bcmasp_reclaim_free_all_tx()
828 static void bcmasp_ephy_enable_set(struct bcmasp_intf *intf, bool enable) in bcmasp_ephy_enable_set() argument
834 reg = rgmii_rl(intf, RGMII_EPHY_CNTRL); in bcmasp_ephy_enable_set()
837 rgmii_wl(intf, reg, RGMII_EPHY_CNTRL); in bcmasp_ephy_enable_set()
842 rgmii_wl(intf, reg, RGMII_EPHY_CNTRL); in bcmasp_ephy_enable_set()
848 rgmii_wl(intf, reg, RGMII_EPHY_CNTRL); in bcmasp_ephy_enable_set()
852 rgmii_wl(intf, reg, RGMII_EPHY_CNTRL); in bcmasp_ephy_enable_set()
858 reg = rgmii_rl(intf, RGMII_SYS_LED_CNTRL); in bcmasp_ephy_enable_set()
863 rgmii_wl(intf, reg, RGMII_SYS_LED_CNTRL); in bcmasp_ephy_enable_set()
866 static void bcmasp_rgmii_mode_en_set(struct bcmasp_intf *intf, bool enable) in bcmasp_rgmii_mode_en_set() argument
870 reg = rgmii_rl(intf, RGMII_OOB_CNTRL); in bcmasp_rgmii_mode_en_set()
876 rgmii_wl(intf, reg, RGMII_OOB_CNTRL); in bcmasp_rgmii_mode_en_set()
881 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_netif_deinit() local
884 napi_disable(&intf->tx_napi); in bcmasp_netif_deinit()
886 bcmasp_enable_tx(intf, 0); in bcmasp_netif_deinit()
889 tx_spb_dma_wl(intf, TX_SPB_DMA_FIFO_FLUSH, TX_SPB_DMA_FIFO_CTRL); in bcmasp_netif_deinit()
891 reg = tx_spb_dma_rl(intf, TX_SPB_DMA_FIFO_STATUS); in bcmasp_netif_deinit()
896 tx_spb_dma_wl(intf, 0x0, TX_SPB_DMA_FIFO_CTRL); in bcmasp_netif_deinit()
898 umac_enable_set(intf, UMC_CMD_TX_EN, 0); in bcmasp_netif_deinit()
902 umac_enable_set(intf, UMC_CMD_RX_EN, 0); in bcmasp_netif_deinit()
904 bcmasp_flush_rx_port(intf); in bcmasp_netif_deinit()
906 bcmasp_enable_rx(intf, 0); in bcmasp_netif_deinit()
908 napi_disable(&intf->rx_napi); in bcmasp_netif_deinit()
911 bcmasp_enable_tx_irq(intf, 0); in bcmasp_netif_deinit()
912 bcmasp_enable_rx_irq(intf, 0); in bcmasp_netif_deinit()
914 netif_napi_del(&intf->tx_napi); in bcmasp_netif_deinit()
915 bcmasp_reclaim_free_all_tx(intf); in bcmasp_netif_deinit()
917 netif_napi_del(&intf->rx_napi); in bcmasp_netif_deinit()
918 bcmasp_reclaim_free_all_rx(intf); in bcmasp_netif_deinit()
923 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_stop() local
925 netif_dbg(intf, ifdown, dev, "bcmasp stop\n"); in bcmasp_stop()
935 if (intf->internal_phy) in bcmasp_stop()
936 bcmasp_ephy_enable_set(intf, false); in bcmasp_stop()
938 bcmasp_rgmii_mode_en_set(intf, false); in bcmasp_stop()
941 bcmasp_core_clock_set_intf(intf, false); in bcmasp_stop()
943 clk_disable_unprepare(intf->parent->clk); in bcmasp_stop()
948 static void bcmasp_configure_port(struct bcmasp_intf *intf) in bcmasp_configure_port() argument
952 reg = rgmii_rl(intf, RGMII_PORT_CNTRL); in bcmasp_configure_port()
955 switch (intf->phy_interface) { in bcmasp_configure_port()
975 if (intf->internal_phy) in bcmasp_configure_port()
978 rgmii_wl(intf, reg, RGMII_PORT_CNTRL); in bcmasp_configure_port()
980 reg = rgmii_rl(intf, RGMII_OOB_CNTRL); in bcmasp_configure_port()
983 rgmii_wl(intf, reg, RGMII_OOB_CNTRL); in bcmasp_configure_port()
988 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_netif_init() local
989 phy_interface_t phy_iface = intf->phy_interface; in bcmasp_netif_init()
997 bcmasp_core_clock_set_intf(intf, true); in bcmasp_netif_init()
1000 if (intf->internal_phy) in bcmasp_netif_init()
1001 bcmasp_ephy_enable_set(intf, true); in bcmasp_netif_init()
1003 bcmasp_rgmii_mode_en_set(intf, true); in bcmasp_netif_init()
1004 bcmasp_configure_port(intf); in bcmasp_netif_init()
1043 phydev = of_phy_connect(dev, intf->phy_dn, in bcmasp_netif_init()
1054 } else if (!intf->wolopts) { in bcmasp_netif_init()
1060 umac_reset(intf); in bcmasp_netif_init()
1062 umac_init(intf); in bcmasp_netif_init()
1065 umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 0); in bcmasp_netif_init()
1067 umac_set_hw_addr(intf, dev->dev_addr); in bcmasp_netif_init()
1069 intf->old_duplex = -1; in bcmasp_netif_init()
1070 intf->old_link = -1; in bcmasp_netif_init()
1071 intf->old_pause = -1; in bcmasp_netif_init()
1073 ret = bcmasp_init_tx(intf); in bcmasp_netif_init()
1078 bcmasp_enable_tx(intf, 1); in bcmasp_netif_init()
1080 ret = bcmasp_init_rx(intf); in bcmasp_netif_init()
1084 bcmasp_enable_rx(intf, 1); in bcmasp_netif_init()
1087 umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 1); in bcmasp_netif_init()
1089 intf->crc_fwd = !!(umac_rl(intf, UMC_CMD) & UMC_CMD_CRC_FWD); in bcmasp_netif_init()
1098 bcmasp_reclaim_free_all_tx(intf); in bcmasp_netif_init()
1103 if (intf->internal_phy) in bcmasp_netif_init()
1104 bcmasp_ephy_enable_set(intf, false); in bcmasp_netif_init()
1106 bcmasp_rgmii_mode_en_set(intf, false); in bcmasp_netif_init()
1112 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_open() local
1115 netif_dbg(intf, ifup, dev, "bcmasp open\n"); in bcmasp_open()
1117 ret = clk_prepare_enable(intf->parent->clk); in bcmasp_open()
1123 clk_disable_unprepare(intf->parent->clk); in bcmasp_open()
1130 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_tx_timeout() local
1132 netif_dbg(intf, tx_err, dev, "transmit timeout!\n"); in bcmasp_tx_timeout()
1133 intf->mib.tx_timeout_cnt++; in bcmasp_tx_timeout()
1139 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_get_phys_port_name() local
1141 if (snprintf(name, len, "p%d", intf->port) >= len) in bcmasp_get_phys_port_name()
1150 struct bcmasp_intf *intf = netdev_priv(dev); in bcmasp_get_stats64() local
1154 lstats = &intf->stats64; in bcmasp_get_stats64()
1182 static void bcmasp_map_res(struct bcmasp_priv *priv, struct bcmasp_intf *intf) in bcmasp_map_res() argument
1185 intf->res.umac = priv->base + UMC_OFFSET(intf); in bcmasp_map_res()
1186 intf->res.umac2fb = priv->base + (priv->hw_info->umac2fb + in bcmasp_map_res()
1187 (intf->port * 0x4)); in bcmasp_map_res()
1188 intf->res.rgmii = priv->base + RGMII_OFFSET(intf); in bcmasp_map_res()
1191 intf->tx_spb_dma = priv->base + TX_SPB_DMA_OFFSET(intf); in bcmasp_map_res()
1192 intf->res.tx_spb_ctrl = priv->base + TX_SPB_CTRL_OFFSET(intf); in bcmasp_map_res()
1193 intf->res.tx_spb_top = priv->base + TX_SPB_TOP_OFFSET(intf); in bcmasp_map_res()
1194 intf->res.tx_epkt_core = priv->base + TX_EPKT_C_OFFSET(intf); in bcmasp_map_res()
1195 intf->res.tx_pause_ctrl = priv->base + TX_PAUSE_CTRL_OFFSET(intf); in bcmasp_map_res()
1197 intf->rx_edpkt_dma = priv->base + RX_EDPKT_DMA_OFFSET(intf); in bcmasp_map_res()
1198 intf->rx_edpkt_cfg = priv->base + RX_EDPKT_CFG_OFFSET(intf); in bcmasp_map_res()
1206 struct bcmasp_intf *intf; in bcmasp_interface_create() local
1225 intf = netdev_priv(ndev); in bcmasp_interface_create()
1227 intf->parent = priv; in bcmasp_interface_create()
1228 intf->ndev = ndev; in bcmasp_interface_create()
1229 intf->channel = ch; in bcmasp_interface_create()
1230 intf->port = port; in bcmasp_interface_create()
1231 intf->ndev_dn = ndev_dn; in bcmasp_interface_create()
1232 intf->index = i; in bcmasp_interface_create()
1234 ret = of_get_phy_mode(ndev_dn, &intf->phy_interface); in bcmasp_interface_create()
1240 if (intf->phy_interface == PHY_INTERFACE_MODE_INTERNAL) in bcmasp_interface_create()
1241 intf->internal_phy = true; in bcmasp_interface_create()
1243 intf->phy_dn = of_parse_phandle(ndev_dn, "phy-handle", 0); in bcmasp_interface_create()
1244 if (!intf->phy_dn && of_phy_is_fixed_link(ndev_dn)) { in bcmasp_interface_create()
1251 intf->phy_dn = ndev_dn; in bcmasp_interface_create()
1255 bcmasp_map_res(priv, intf); in bcmasp_interface_create()
1257 if ((!phy_interface_mode_is_rgmii(intf->phy_interface) && in bcmasp_interface_create()
1258 intf->phy_interface != PHY_INTERFACE_MODE_MII && in bcmasp_interface_create()
1259 intf->phy_interface != PHY_INTERFACE_MODE_INTERNAL) || in bcmasp_interface_create()
1260 (intf->port != 1 && intf->internal_phy)) { in bcmasp_interface_create()
1261 netdev_err(intf->ndev, "invalid PHY mode: %s for port %d\n", in bcmasp_interface_create()
1262 phy_modes(intf->phy_interface), intf->port); in bcmasp_interface_create()
1274 intf->ops = &bcmasp_intf_ops; in bcmasp_interface_create()
1277 intf->msg_enable = netif_msg_init(-1, NETIF_MSG_DRV | in bcmasp_interface_create()
1285 return intf; in bcmasp_interface_create()
1293 void bcmasp_interface_destroy(struct bcmasp_intf *intf) in bcmasp_interface_destroy() argument
1295 if (intf->ndev->reg_state == NETREG_REGISTERED) in bcmasp_interface_destroy()
1296 unregister_netdev(intf->ndev); in bcmasp_interface_destroy()
1297 if (of_phy_is_fixed_link(intf->ndev_dn)) in bcmasp_interface_destroy()
1298 of_phy_deregister_fixed_link(intf->ndev_dn); in bcmasp_interface_destroy()
1299 free_netdev(intf->ndev); in bcmasp_interface_destroy()
1302 static void bcmasp_suspend_to_wol(struct bcmasp_intf *intf) in bcmasp_suspend_to_wol() argument
1304 struct net_device *ndev = intf->ndev; in bcmasp_suspend_to_wol()
1307 reg = umac_rl(intf, UMC_MPD_CTRL); in bcmasp_suspend_to_wol()
1308 if (intf->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE)) in bcmasp_suspend_to_wol()
1311 if (intf->wolopts & WAKE_MAGICSECURE) { in bcmasp_suspend_to_wol()
1313 umac_wl(intf, get_unaligned_be16(&intf->sopass[0]), in bcmasp_suspend_to_wol()
1315 umac_wl(intf, get_unaligned_be32(&intf->sopass[2]), in bcmasp_suspend_to_wol()
1319 umac_wl(intf, reg, UMC_MPD_CTRL); in bcmasp_suspend_to_wol()
1321 if (intf->wolopts & WAKE_FILTER) in bcmasp_suspend_to_wol()
1322 bcmasp_netfilt_suspend(intf); in bcmasp_suspend_to_wol()
1325 umac_enable_set(intf, UMC_CMD_RX_EN, 1); in bcmasp_suspend_to_wol()
1327 if (intf->parent->wol_irq > 0) { in bcmasp_suspend_to_wol()
1328 wakeup_intr2_core_wl(intf->parent, 0xffffffff, in bcmasp_suspend_to_wol()
1332 netif_dbg(intf, wol, ndev, "entered WOL mode\n"); in bcmasp_suspend_to_wol()
1335 int bcmasp_interface_suspend(struct bcmasp_intf *intf) in bcmasp_interface_suspend() argument
1337 struct device *kdev = &intf->parent->pdev->dev; in bcmasp_interface_suspend()
1338 struct net_device *dev = intf->ndev; in bcmasp_interface_suspend()
1348 if (!intf->wolopts) { in bcmasp_interface_suspend()
1353 if (intf->internal_phy) in bcmasp_interface_suspend()
1354 bcmasp_ephy_enable_set(intf, false); in bcmasp_interface_suspend()
1356 bcmasp_rgmii_mode_en_set(intf, false); in bcmasp_interface_suspend()
1361 bcmasp_core_clock_set_intf(intf, false); in bcmasp_interface_suspend()
1364 if (device_may_wakeup(kdev) && intf->wolopts) in bcmasp_interface_suspend()
1365 bcmasp_suspend_to_wol(intf); in bcmasp_interface_suspend()
1367 clk_disable_unprepare(intf->parent->clk); in bcmasp_interface_suspend()
1376 static void bcmasp_resume_from_wol(struct bcmasp_intf *intf) in bcmasp_resume_from_wol() argument
1380 reg = umac_rl(intf, UMC_MPD_CTRL); in bcmasp_resume_from_wol()
1382 umac_wl(intf, reg, UMC_MPD_CTRL); in bcmasp_resume_from_wol()
1384 if (intf->parent->wol_irq > 0) { in bcmasp_resume_from_wol()
1385 wakeup_intr2_core_wl(intf->parent, 0xffffffff, in bcmasp_resume_from_wol()
1390 int bcmasp_interface_resume(struct bcmasp_intf *intf) in bcmasp_interface_resume() argument
1392 struct net_device *dev = intf->ndev; in bcmasp_interface_resume()
1398 ret = clk_prepare_enable(intf->parent->clk); in bcmasp_interface_resume()
1406 bcmasp_resume_from_wol(intf); in bcmasp_interface_resume()
1408 if (intf->eee.eee_enabled) in bcmasp_interface_resume()
1409 bcmasp_eee_enable_set(intf, true); in bcmasp_interface_resume()
1416 clk_disable_unprepare(intf->parent->clk); in bcmasp_interface_resume()