Lines Matching refs:lp

655 static void dwceqos_read_mmc_counters(struct net_local *lp, u32 rx_mask,
658 static void dwceqos_set_umac_addr(struct net_local *lp, unsigned char *addr,
662 static void dwceqos_tx_poll_demand(struct net_local *lp);
664 static void dwceqos_set_rx_flowcontrol(struct net_local *lp, bool enable);
665 static void dwceqos_set_tx_flowcontrol(struct net_local *lp, bool enable);
667 static void dwceqos_reset_state(struct net_local *lp);
669 #define dwceqos_read(lp, reg) \ argument
670 readl_relaxed(((void __iomem *)((lp)->baseaddr)) + (reg))
671 #define dwceqos_write(lp, reg, val) \ argument
672 writel_relaxed((val), ((void __iomem *)((lp)->baseaddr)) + (reg))
674 static void dwceqos_reset_state(struct net_local *lp) in dwceqos_reset_state() argument
676 lp->link = 0; in dwceqos_reset_state()
677 lp->speed = 0; in dwceqos_reset_state()
678 lp->duplex = DUPLEX_UNKNOWN; in dwceqos_reset_state()
679 lp->flowcontrol.rx_current = 0; in dwceqos_reset_state()
680 lp->flowcontrol.tx_current = 0; in dwceqos_reset_state()
681 lp->eee_active = 0; in dwceqos_reset_state()
682 lp->eee_enabled = 0; in dwceqos_reset_state()
685 static void print_descriptor(struct net_local *lp, int index, int tx) in print_descriptor() argument
690 dd = (struct dwceqos_dma_desc *)&lp->tx_descs[index]; in print_descriptor()
692 dd = (struct dwceqos_dma_desc *)&lp->rx_descs[index]; in print_descriptor()
700 static void print_status(struct net_local *lp) in print_status() argument
704 pr_info("tx_free %zu, tx_cur %zu, tx_next %zu\n", lp->tx_free, in print_status()
705 lp->tx_cur, lp->tx_next); in print_status()
707 print_descriptor(lp, lp->rx_cur, 0); in print_status()
709 for (desci = (lp->tx_cur - 10) % DWCEQOS_TX_DCNT, i = 0; in print_status()
712 print_descriptor(lp, desci, 1); in print_status()
717 dwceqos_read(lp, REG_DWCEQOS_DMA_DEBUG_ST0)); in print_status()
719 dwceqos_read(lp, REG_DWCEQOS_DMA_IS)); in print_status()
721 dwceqos_read(lp, 0x1144)); in print_status()
723 dwceqos_read(lp, 0x1154)); in print_status()
725 dwceqos_read(lp, REG_DWCEQOS_MTL_DEBUG_ST)); in print_status()
727 dwceqos_read(lp, REG_DWCEQOS_MTL_TXQ0_DEBUG_ST)); in print_status()
729 dwceqos_read(lp, REG_DWCEQOS_MTL_RXQ0_DEBUG_ST)); in print_status()
731 dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_CUR_TXDESC), in print_status()
732 dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_CUR_RXDESC)); in print_status()
735 static void dwceqos_mdio_set_csr(struct net_local *lp) in dwceqos_mdio_set_csr() argument
737 int rate = clk_get_rate(lp->apb_pclk); in dwceqos_mdio_set_csr()
740 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_20; in dwceqos_mdio_set_csr()
742 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_35; in dwceqos_mdio_set_csr()
744 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_60; in dwceqos_mdio_set_csr()
746 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_100; in dwceqos_mdio_set_csr()
748 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_150; in dwceqos_mdio_set_csr()
750 lp->csr_val = DWCEQOS_MAC_MDIO_ADDR_CR_250; in dwceqos_mdio_set_csr()
756 struct net_local *lp = bus->priv; in dwceqos_mdio_read() local
763 DWCEQOS_MAC_MDIO_ADDR_CR(lp->csr_val) | in dwceqos_mdio_read()
766 dwceqos_write(lp, REG_DWCEQOS_MAC_MDIO_ADDR, regval); in dwceqos_mdio_read()
770 if (!(dwceqos_read(lp, REG_DWCEQOS_MAC_MDIO_ADDR) & in dwceqos_mdio_read()
775 data = dwceqos_read(lp, REG_DWCEQOS_MAC_MDIO_DATA); in dwceqos_mdio_read()
777 netdev_warn(lp->ndev, "MDIO read timed out\n"); in dwceqos_mdio_read()
787 struct net_local *lp = bus->priv; in dwceqos_mdio_write() local
791 dwceqos_write(lp, REG_DWCEQOS_MAC_MDIO_DATA, value); in dwceqos_mdio_write()
795 DWCEQOS_MAC_MDIO_ADDR_CR(lp->csr_val) | in dwceqos_mdio_write()
798 dwceqos_write(lp, REG_DWCEQOS_MAC_MDIO_ADDR, regval); in dwceqos_mdio_write()
802 if (!(dwceqos_read(lp, REG_DWCEQOS_MAC_MDIO_ADDR) & in dwceqos_mdio_write()
807 netdev_warn(lp->ndev, "MDIO write timed out\n"); in dwceqos_mdio_write()
813 struct net_local *lp = netdev_priv(ndev); in dwceqos_ioctl() local
814 struct phy_device *phydev = lp->phy_dev; in dwceqos_ioctl()
828 dev_info(&lp->pdev->dev, "ioctl %X not implemented.\n", cmd); in dwceqos_ioctl()
833 static void dwceqos_link_down(struct net_local *lp) in dwceqos_link_down() argument
839 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_link_down()
840 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_link_down()
842 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS, regval); in dwceqos_link_down()
843 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_link_down()
846 static void dwceqos_link_up(struct net_local *lp) in dwceqos_link_up() argument
852 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_link_up()
853 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_link_up()
855 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS, regval); in dwceqos_link_up()
856 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_link_up()
858 lp->eee_active = !phy_init_eee(lp->phy_dev, 0); in dwceqos_link_up()
861 if (!lp->eee_active && lp->eee_enabled) { in dwceqos_link_up()
862 lp->eee_enabled = 0; in dwceqos_link_up()
864 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_link_up()
865 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_link_up()
867 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS, regval); in dwceqos_link_up()
868 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_link_up()
872 static void dwceqos_set_speed(struct net_local *lp) in dwceqos_set_speed() argument
874 struct phy_device *phydev = lp->phy_dev; in dwceqos_set_speed()
877 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_CFG); in dwceqos_set_speed()
889 netdev_err(lp->ndev, in dwceqos_set_speed()
895 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, regval); in dwceqos_set_speed()
900 struct net_local *lp = netdev_priv(ndev); in dwceqos_adjust_link() local
901 struct phy_device *phydev = lp->phy_dev; in dwceqos_adjust_link()
905 if ((lp->speed != phydev->speed) || in dwceqos_adjust_link()
906 (lp->duplex != phydev->duplex)) { in dwceqos_adjust_link()
907 dwceqos_set_speed(lp); in dwceqos_adjust_link()
909 lp->speed = phydev->speed; in dwceqos_adjust_link()
910 lp->duplex = phydev->duplex; in dwceqos_adjust_link()
914 if (lp->flowcontrol.autoneg) { in dwceqos_adjust_link()
915 lp->flowcontrol.rx = phydev->pause || in dwceqos_adjust_link()
917 lp->flowcontrol.tx = phydev->pause || in dwceqos_adjust_link()
921 if (lp->flowcontrol.rx != lp->flowcontrol.rx_current) { in dwceqos_adjust_link()
922 if (netif_msg_link(lp)) in dwceqos_adjust_link()
924 lp->flowcontrol.rx); in dwceqos_adjust_link()
925 dwceqos_set_rx_flowcontrol(lp, lp->flowcontrol.rx); in dwceqos_adjust_link()
926 lp->flowcontrol.rx_current = lp->flowcontrol.rx; in dwceqos_adjust_link()
928 if (lp->flowcontrol.tx != lp->flowcontrol.tx_current) { in dwceqos_adjust_link()
929 if (netif_msg_link(lp)) in dwceqos_adjust_link()
931 lp->flowcontrol.tx); in dwceqos_adjust_link()
932 dwceqos_set_tx_flowcontrol(lp, lp->flowcontrol.tx); in dwceqos_adjust_link()
933 lp->flowcontrol.tx_current = lp->flowcontrol.tx; in dwceqos_adjust_link()
937 if (phydev->link != lp->link) { in dwceqos_adjust_link()
938 lp->link = phydev->link; in dwceqos_adjust_link()
944 lp->ndev->trans_start = jiffies; in dwceqos_adjust_link()
945 dwceqos_link_up(lp); in dwceqos_adjust_link()
947 dwceqos_link_down(lp); in dwceqos_adjust_link()
955 struct net_local *lp = netdev_priv(ndev); in dwceqos_mii_probe() local
958 if (lp->phy_node) { in dwceqos_mii_probe()
959 phydev = of_phy_connect(lp->ndev, in dwceqos_mii_probe()
960 lp->phy_node, in dwceqos_mii_probe()
963 lp->phy_interface); in dwceqos_mii_probe()
974 if (netif_msg_probe(lp)) in dwceqos_mii_probe()
975 netdev_dbg(lp->ndev, in dwceqos_mii_probe()
981 lp->link = 0; in dwceqos_mii_probe()
982 lp->speed = 0; in dwceqos_mii_probe()
983 lp->duplex = DUPLEX_UNKNOWN; in dwceqos_mii_probe()
984 lp->phy_dev = phydev; in dwceqos_mii_probe()
986 if (netif_msg_probe(lp)) { in dwceqos_mii_probe()
987 netdev_dbg(lp->ndev, "phy_addr 0x%x, phy_id 0x%08x\n", in dwceqos_mii_probe()
988 lp->phy_dev->addr, lp->phy_dev->phy_id); in dwceqos_mii_probe()
990 netdev_dbg(lp->ndev, "attach [%s] phy driver\n", in dwceqos_mii_probe()
991 lp->phy_dev->drv->name); in dwceqos_mii_probe()
997 static void dwceqos_alloc_rxring_desc(struct net_local *lp, int index) in dwceqos_alloc_rxring_desc() argument
1002 new_skb = netdev_alloc_skb(lp->ndev, DWCEQOS_RX_BUF_SIZE); in dwceqos_alloc_rxring_desc()
1004 netdev_err(lp->ndev, "alloc_skb error for desc %d\n", index); in dwceqos_alloc_rxring_desc()
1008 new_skb_baddr = dma_map_single(lp->ndev->dev.parent, in dwceqos_alloc_rxring_desc()
1011 if (dma_mapping_error(lp->ndev->dev.parent, new_skb_baddr)) { in dwceqos_alloc_rxring_desc()
1012 netdev_err(lp->ndev, "DMA map error\n"); in dwceqos_alloc_rxring_desc()
1018 lp->rx_descs[index].des0 = new_skb_baddr; in dwceqos_alloc_rxring_desc()
1019 lp->rx_descs[index].des1 = 0; in dwceqos_alloc_rxring_desc()
1020 lp->rx_descs[index].des2 = 0; in dwceqos_alloc_rxring_desc()
1021 lp->rx_descs[index].des3 = DWCEQOS_DMA_RDES3_INTE | in dwceqos_alloc_rxring_desc()
1025 lp->rx_skb[index].mapping = new_skb_baddr; in dwceqos_alloc_rxring_desc()
1026 lp->rx_skb[index].len = DWCEQOS_RX_BUF_SIZE; in dwceqos_alloc_rxring_desc()
1029 lp->rx_skb[index].skb = new_skb; in dwceqos_alloc_rxring_desc()
1032 static void dwceqos_clean_rings(struct net_local *lp) in dwceqos_clean_rings() argument
1036 if (lp->rx_skb) { in dwceqos_clean_rings()
1038 if (lp->rx_skb[i].skb) { in dwceqos_clean_rings()
1039 dma_unmap_single(lp->ndev->dev.parent, in dwceqos_clean_rings()
1040 lp->rx_skb[i].mapping, in dwceqos_clean_rings()
1041 lp->rx_skb[i].len, in dwceqos_clean_rings()
1044 dev_kfree_skb(lp->rx_skb[i].skb); in dwceqos_clean_rings()
1045 lp->rx_skb[i].skb = NULL; in dwceqos_clean_rings()
1046 lp->rx_skb[i].mapping = 0; in dwceqos_clean_rings()
1051 if (lp->tx_skb) { in dwceqos_clean_rings()
1053 if (lp->tx_skb[i].skb) { in dwceqos_clean_rings()
1054 dev_kfree_skb(lp->tx_skb[i].skb); in dwceqos_clean_rings()
1055 lp->tx_skb[i].skb = NULL; in dwceqos_clean_rings()
1057 if (lp->tx_skb[i].mapping) { in dwceqos_clean_rings()
1058 dma_unmap_single(lp->ndev->dev.parent, in dwceqos_clean_rings()
1059 lp->tx_skb[i].mapping, in dwceqos_clean_rings()
1060 lp->tx_skb[i].len, in dwceqos_clean_rings()
1062 lp->tx_skb[i].mapping = 0; in dwceqos_clean_rings()
1068 static void dwceqos_descriptor_free(struct net_local *lp) in dwceqos_descriptor_free() argument
1072 dwceqos_clean_rings(lp); in dwceqos_descriptor_free()
1074 kfree(lp->tx_skb); in dwceqos_descriptor_free()
1075 lp->tx_skb = NULL; in dwceqos_descriptor_free()
1076 kfree(lp->rx_skb); in dwceqos_descriptor_free()
1077 lp->rx_skb = NULL; in dwceqos_descriptor_free()
1080 if (lp->rx_descs) { in dwceqos_descriptor_free()
1081 dma_free_coherent(lp->ndev->dev.parent, size, in dwceqos_descriptor_free()
1082 (void *)(lp->rx_descs), lp->rx_descs_addr); in dwceqos_descriptor_free()
1083 lp->rx_descs = NULL; in dwceqos_descriptor_free()
1087 if (lp->tx_descs) { in dwceqos_descriptor_free()
1088 dma_free_coherent(lp->ndev->dev.parent, size, in dwceqos_descriptor_free()
1089 (void *)(lp->tx_descs), lp->tx_descs_addr); in dwceqos_descriptor_free()
1090 lp->tx_descs = NULL; in dwceqos_descriptor_free()
1094 static int dwceqos_descriptor_init(struct net_local *lp) in dwceqos_descriptor_init() argument
1099 lp->gso_size = 0; in dwceqos_descriptor_init()
1101 lp->tx_skb = NULL; in dwceqos_descriptor_init()
1102 lp->rx_skb = NULL; in dwceqos_descriptor_init()
1103 lp->rx_descs = NULL; in dwceqos_descriptor_init()
1104 lp->tx_descs = NULL; in dwceqos_descriptor_init()
1107 lp->rx_cur = 0; in dwceqos_descriptor_init()
1108 lp->tx_cur = 0; in dwceqos_descriptor_init()
1109 lp->tx_next = 0; in dwceqos_descriptor_init()
1110 lp->tx_free = DWCEQOS_TX_DCNT; in dwceqos_descriptor_init()
1114 lp->rx_skb = kzalloc(size, GFP_KERNEL); in dwceqos_descriptor_init()
1115 if (!lp->rx_skb) in dwceqos_descriptor_init()
1119 lp->tx_skb = kzalloc(size, GFP_KERNEL); in dwceqos_descriptor_init()
1120 if (!lp->tx_skb) in dwceqos_descriptor_init()
1125 lp->rx_descs = dma_alloc_coherent(lp->ndev->dev.parent, size, in dwceqos_descriptor_init()
1126 &lp->rx_descs_addr, 0); in dwceqos_descriptor_init()
1127 if (!lp->rx_descs) in dwceqos_descriptor_init()
1129 lp->rx_descs_tail_addr = lp->rx_descs_addr + in dwceqos_descriptor_init()
1133 lp->tx_descs = dma_alloc_coherent(lp->ndev->dev.parent, size, in dwceqos_descriptor_init()
1134 &lp->tx_descs_addr, 0); in dwceqos_descriptor_init()
1135 if (!lp->tx_descs) in dwceqos_descriptor_init()
1137 lp->tx_descs_tail_addr = lp->tx_descs_addr + in dwceqos_descriptor_init()
1142 dwceqos_alloc_rxring_desc(lp, i); in dwceqos_descriptor_init()
1143 if (!(lp->rx_skb[lp->rx_cur].skb)) in dwceqos_descriptor_init()
1149 lp->tx_descs[i].des0 = 0; in dwceqos_descriptor_init()
1150 lp->tx_descs[i].des1 = 0; in dwceqos_descriptor_init()
1151 lp->tx_descs[i].des2 = 0; in dwceqos_descriptor_init()
1152 lp->tx_descs[i].des3 = 0; in dwceqos_descriptor_init()
1161 dwceqos_descriptor_free(lp); in dwceqos_descriptor_init()
1165 static int dwceqos_packet_avail(struct net_local *lp) in dwceqos_packet_avail() argument
1167 return !(lp->rx_descs[lp->rx_cur].des3 & DWCEQOS_DMA_RDES3_OWN); in dwceqos_packet_avail()
1170 static void dwceqos_get_hwfeatures(struct net_local *lp) in dwceqos_get_hwfeatures() argument
1172 lp->feature0 = dwceqos_read(lp, REG_DWCEQOS_MAC_HW_FEATURE0); in dwceqos_get_hwfeatures()
1173 lp->feature1 = dwceqos_read(lp, REG_DWCEQOS_MAC_HW_FEATURE1); in dwceqos_get_hwfeatures()
1174 lp->feature2 = dwceqos_read(lp, REG_DWCEQOS_MAC_HW_FEATURE2); in dwceqos_get_hwfeatures()
1177 static void dwceqos_dma_enable_txirq(struct net_local *lp) in dwceqos_dma_enable_txirq() argument
1182 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_dma_enable_txirq()
1183 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_IE); in dwceqos_dma_enable_txirq()
1185 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, regval); in dwceqos_dma_enable_txirq()
1186 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_dma_enable_txirq()
1189 static void dwceqos_dma_disable_txirq(struct net_local *lp) in dwceqos_dma_disable_txirq() argument
1194 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_dma_disable_txirq()
1195 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_IE); in dwceqos_dma_disable_txirq()
1197 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, regval); in dwceqos_dma_disable_txirq()
1198 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_dma_disable_txirq()
1201 static void dwceqos_dma_enable_rxirq(struct net_local *lp) in dwceqos_dma_enable_rxirq() argument
1206 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_dma_enable_rxirq()
1207 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_IE); in dwceqos_dma_enable_rxirq()
1209 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, regval); in dwceqos_dma_enable_rxirq()
1210 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_dma_enable_rxirq()
1213 static void dwceqos_dma_disable_rxirq(struct net_local *lp) in dwceqos_dma_disable_rxirq() argument
1218 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_dma_disable_rxirq()
1219 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_IE); in dwceqos_dma_disable_rxirq()
1221 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, regval); in dwceqos_dma_disable_rxirq()
1222 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_dma_disable_rxirq()
1225 static void dwceqos_enable_mmc_interrupt(struct net_local *lp) in dwceqos_enable_mmc_interrupt() argument
1227 dwceqos_write(lp, REG_DWCEQOS_MMC_RXIRQMASK, 0); in dwceqos_enable_mmc_interrupt()
1228 dwceqos_write(lp, REG_DWCEQOS_MMC_TXIRQMASK, 0); in dwceqos_enable_mmc_interrupt()
1231 static int dwceqos_mii_init(struct net_local *lp) in dwceqos_mii_init() argument
1237 mdionode = of_get_child_by_name(lp->pdev->dev.of_node, "mdio"); in dwceqos_mii_init()
1242 lp->mii_bus = mdiobus_alloc(); in dwceqos_mii_init()
1243 if (!lp->mii_bus) { in dwceqos_mii_init()
1248 lp->mii_bus->name = "DWCEQOS MII bus"; in dwceqos_mii_init()
1249 lp->mii_bus->read = &dwceqos_mdio_read; in dwceqos_mii_init()
1250 lp->mii_bus->write = &dwceqos_mdio_write; in dwceqos_mii_init()
1251 lp->mii_bus->priv = lp; in dwceqos_mii_init()
1252 lp->mii_bus->parent = &lp->ndev->dev; in dwceqos_mii_init()
1254 lp->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); in dwceqos_mii_init()
1255 if (!lp->mii_bus->irq) { in dwceqos_mii_init()
1261 lp->mii_bus->irq[i] = PHY_POLL; in dwceqos_mii_init()
1262 of_address_to_resource(lp->pdev->dev.of_node, 0, &res); in dwceqos_mii_init()
1263 snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%.8llx", in dwceqos_mii_init()
1265 if (of_mdiobus_register(lp->mii_bus, mdionode)) in dwceqos_mii_init()
1271 kfree(lp->mii_bus->irq); in dwceqos_mii_init()
1273 mdiobus_free(lp->mii_bus); in dwceqos_mii_init()
1280 static void dwceqos_reset_hw(struct net_local *lp) in dwceqos_reset_hw() argument
1287 reg = dwceqos_read(lp, REG_DWCEQOS_MAC_CFG); in dwceqos_reset_hw()
1290 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, reg); in dwceqos_reset_hw()
1292 dwceqos_write(lp, REG_DWCEQOS_DMA_MODE, DWCEQOS_DMA_MODE_SWR); in dwceqos_reset_hw()
1297 reg = dwceqos_read(lp, REG_DWCEQOS_DMA_MODE); in dwceqos_reset_hw()
1301 netdev_err(lp->ndev, "DMA reset timed out!\n"); in dwceqos_reset_hw()
1304 static void dwceqos_fatal_bus_error(struct net_local *lp, u32 dma_status) in dwceqos_fatal_bus_error() argument
1307 netdev_err(lp->ndev, "txdma bus error %s %s (status=%08x)\n", in dwceqos_fatal_bus_error()
1314 print_status(lp); in dwceqos_fatal_bus_error()
1317 netdev_err(lp->ndev, "rxdma bus error %s %s (status=%08x)\n", in dwceqos_fatal_bus_error()
1324 print_status(lp); in dwceqos_fatal_bus_error()
1328 static void dwceqos_mmc_interrupt(struct net_local *lp) in dwceqos_mmc_interrupt() argument
1332 spin_lock_irqsave(&lp->stats_lock, flags); in dwceqos_mmc_interrupt()
1337 dwceqos_read_mmc_counters(lp, in dwceqos_mmc_interrupt()
1338 dwceqos_read(lp, REG_DWCEQOS_MMC_RXIRQ), in dwceqos_mmc_interrupt()
1339 dwceqos_read(lp, REG_DWCEQOS_MMC_TXIRQ)); in dwceqos_mmc_interrupt()
1341 spin_unlock_irqrestore(&lp->stats_lock, flags); in dwceqos_mmc_interrupt()
1344 static void dwceqos_mac_interrupt(struct net_local *lp) in dwceqos_mac_interrupt() argument
1348 cause = dwceqos_read(lp, REG_DWCEQOS_MAC_IS); in dwceqos_mac_interrupt()
1351 dwceqos_mmc_interrupt(lp); in dwceqos_mac_interrupt()
1357 struct net_local *lp = netdev_priv(ndev); in dwceqos_interrupt() local
1363 cause = dwceqos_read(lp, REG_DWCEQOS_DMA_IS); in dwceqos_interrupt()
1366 dma_status = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_STA); in dwceqos_interrupt()
1370 tasklet_schedule(&lp->tx_bdreclaim_tasklet); in dwceqos_interrupt()
1371 dwceqos_dma_disable_txirq(lp); in dwceqos_interrupt()
1377 dwceqos_dma_disable_rxirq(lp); in dwceqos_interrupt()
1378 napi_schedule(&lp->napi); in dwceqos_interrupt()
1383 dwceqos_fatal_bus_error(lp, dma_status); in dwceqos_interrupt()
1391 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_STA, dma_status); in dwceqos_interrupt()
1396 u32 val = dwceqos_read(lp, REG_DWCEQOS_MTL_Q0_ISCTRL); in dwceqos_interrupt()
1398 dwceqos_write(lp, REG_DWCEQOS_MTL_Q0_ISCTRL, val); in dwceqos_interrupt()
1403 dwceqos_mac_interrupt(lp); in dwceqos_interrupt()
1409 static void dwceqos_set_rx_flowcontrol(struct net_local *lp, bool enable) in dwceqos_set_rx_flowcontrol() argument
1414 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_set_rx_flowcontrol()
1416 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_RX_FLOW_CTRL); in dwceqos_set_rx_flowcontrol()
1421 dwceqos_write(lp, REG_DWCEQOS_MAC_RX_FLOW_CTRL, regval); in dwceqos_set_rx_flowcontrol()
1423 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_set_rx_flowcontrol()
1426 static void dwceqos_set_tx_flowcontrol(struct net_local *lp, bool enable) in dwceqos_set_tx_flowcontrol() argument
1431 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_set_tx_flowcontrol()
1434 regval = dwceqos_read(lp, REG_DWCEQOS_MTL_RXQ0_OPER); in dwceqos_set_tx_flowcontrol()
1440 dwceqos_write(lp, REG_DWCEQOS_MTL_RXQ0_OPER, regval); in dwceqos_set_tx_flowcontrol()
1443 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_Q0_TX_FLOW); in dwceqos_set_tx_flowcontrol()
1448 dwceqos_write(lp, REG_DWCEQOS_MAC_Q0_TX_FLOW, regval); in dwceqos_set_tx_flowcontrol()
1450 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_set_tx_flowcontrol()
1453 static void dwceqos_configure_flow_control(struct net_local *lp) in dwceqos_configure_flow_control() argument
1459 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_configure_flow_control()
1461 regval = dwceqos_read(lp, REG_DWCEQOS_MTL_RXQ0_OPER); in dwceqos_configure_flow_control()
1478 dwceqos_write(lp, REG_DWCEQOS_MTL_RXQ0_OPER, regval); in dwceqos_configure_flow_control()
1480 netdev_warn(lp->ndev, in dwceqos_configure_flow_control()
1487 dwceqos_write(lp, REG_DWCEQOS_MAC_Q0_TX_FLOW, regval); in dwceqos_configure_flow_control()
1489 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_configure_flow_control()
1492 static void dwceqos_configure_clock(struct net_local *lp) in dwceqos_configure_clock() argument
1494 unsigned long rate_mhz = clk_get_rate(lp->apb_pclk) / 1000000; in dwceqos_configure_clock()
1498 dwceqos_write(lp, in dwceqos_configure_clock()
1503 static void dwceqos_configure_bus(struct net_local *lp) in dwceqos_configure_bus() argument
1514 if (lp->bus_cfg.en_lpi) in dwceqos_configure_bus()
1517 if (lp->bus_cfg.burst_map) in dwceqos_configure_bus()
1519 lp->bus_cfg.burst_map); in dwceqos_configure_bus()
1524 if (lp->bus_cfg.read_requests) in dwceqos_configure_bus()
1526 lp->bus_cfg.read_requests - 1); in dwceqos_configure_bus()
1531 if (lp->bus_cfg.write_requests) in dwceqos_configure_bus()
1533 lp->bus_cfg.write_requests - 1); in dwceqos_configure_bus()
1538 if (netif_msg_hw(lp)) in dwceqos_configure_bus()
1539 netdev_dbg(lp->ndev, "SysbusMode %#X\n", sysbus_reg); in dwceqos_configure_bus()
1541 dwceqos_write(lp, REG_DWCEQOS_DMA_SYSBUS_MODE, sysbus_reg); in dwceqos_configure_bus()
1544 static void dwceqos_init_hw(struct net_local *lp) in dwceqos_init_hw() argument
1551 dwceqos_reset_hw(lp); in dwceqos_init_hw()
1553 dwceqos_configure_bus(lp); in dwceqos_init_hw()
1556 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TXDESC_TAIL, 0xF); in dwceqos_init_hw()
1557 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_TXDESC_TAIL); in dwceqos_init_hw()
1562 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_CTRL, in dwceqos_init_hw()
1567 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TXDESC_LEN, DWCEQOS_TX_DCNT - 1); in dwceqos_init_hw()
1568 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RXDESC_LEN, DWCEQOS_RX_DCNT - 1); in dwceqos_init_hw()
1569 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TXDESC_LIST, in dwceqos_init_hw()
1570 (u32)lp->tx_descs_addr); in dwceqos_init_hw()
1571 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RXDESC_LIST, in dwceqos_init_hw()
1572 (u32)lp->rx_descs_addr); in dwceqos_init_hw()
1574 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TXDESC_TAIL, in dwceqos_init_hw()
1575 lp->tx_descs_tail_addr); in dwceqos_init_hw()
1576 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RXDESC_TAIL, in dwceqos_init_hw()
1577 lp->rx_descs_tail_addr); in dwceqos_init_hw()
1579 if (lp->bus_cfg.tx_pbl) in dwceqos_init_hw()
1580 regval = DWCEQOS_DMA_CH_CTRL_PBL(lp->bus_cfg.tx_pbl); in dwceqos_init_hw()
1585 if (lp->feature1 & DWCEQOS_MAC_HW_FEATURE1_TSOEN) in dwceqos_init_hw()
1588 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TX_CTRL, regval); in dwceqos_init_hw()
1590 if (lp->bus_cfg.rx_pbl) in dwceqos_init_hw()
1591 regval = DWCEQOS_DMA_CH_CTRL_PBL(lp->bus_cfg.rx_pbl); in dwceqos_init_hw()
1596 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RX_CTRL, regval); in dwceqos_init_hw()
1599 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RX_CTRL, regval); in dwceqos_init_hw()
1603 dwceqos_write(lp, REG_DWCEQOS_MTL_OPER, regval); in dwceqos_init_hw()
1606 DWCEQOS_MAC_HW_FEATURE1_TXFIFOSIZE(lp->feature1)) | in dwceqos_init_hw()
1609 dwceqos_write(lp, REG_DWCEQOS_MTL_TXQ0_OPER, regval); in dwceqos_init_hw()
1612 DWCEQOS_MAC_HW_FEATURE1_RXFIFOSIZE(lp->feature1)) | in dwceqos_init_hw()
1614 dwceqos_write(lp, REG_DWCEQOS_MTL_RXQ0_OPER, regval); in dwceqos_init_hw()
1616 dwceqos_configure_flow_control(lp); in dwceqos_init_hw()
1619 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); in dwceqos_init_hw()
1621 lp->eee_enabled = 0; in dwceqos_init_hw()
1623 dwceqos_configure_clock(lp); in dwceqos_init_hw()
1628 dwceqos_write(lp, REG_DWCEQOS_MMC_RXIRQMASK, ~0u); in dwceqos_init_hw()
1629 dwceqos_write(lp, REG_DWCEQOS_MMC_TXIRQMASK, ~0u); in dwceqos_init_hw()
1630 lp->mmc_rx_counters_mask = dwceqos_read(lp, REG_DWCEQOS_MMC_RXIRQMASK); in dwceqos_init_hw()
1631 lp->mmc_tx_counters_mask = dwceqos_read(lp, REG_DWCEQOS_MMC_TXIRQMASK); in dwceqos_init_hw()
1633 dwceqos_write(lp, REG_DWCEQOS_MMC_CTRL, DWCEQOS_MMC_CTRL_CNTRST | in dwceqos_init_hw()
1635 dwceqos_enable_mmc_interrupt(lp); in dwceqos_init_hw()
1638 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, in dwceqos_init_hw()
1644 dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0); in dwceqos_init_hw()
1646 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC | in dwceqos_init_hw()
1650 regval = dwceqos_read(lp, REG_DWCEQOS_DMA_CH0_TX_CTRL); in dwceqos_init_hw()
1651 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TX_CTRL, in dwceqos_init_hw()
1655 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_CFG); in dwceqos_init_hw()
1656 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, in dwceqos_init_hw()
1663 struct net_local *lp = netdev_priv(ndev); in dwceqos_tx_reclaim() local
1667 spin_lock(&lp->tx_lock); in dwceqos_tx_reclaim()
1669 while (lp->tx_free < DWCEQOS_TX_DCNT) { in dwceqos_tx_reclaim()
1670 struct dwceqos_dma_desc *dd = &lp->tx_descs[lp->tx_cur]; in dwceqos_tx_reclaim()
1671 struct ring_desc *rd = &lp->tx_skb[lp->tx_cur]; in dwceqos_tx_reclaim()
1689 lp->tx_free++; in dwceqos_tx_reclaim()
1690 lp->tx_cur = (lp->tx_cur + 1) % DWCEQOS_TX_DCNT; in dwceqos_tx_reclaim()
1694 if (netif_msg_tx_err(lp)) in dwceqos_tx_reclaim()
1697 if (netif_msg_hw(lp)) in dwceqos_tx_reclaim()
1698 print_status(lp); in dwceqos_tx_reclaim()
1701 spin_unlock(&lp->tx_lock); in dwceqos_tx_reclaim()
1705 dwceqos_dma_enable_txirq(lp); in dwceqos_tx_reclaim()
1709 static int dwceqos_rx(struct net_local *lp, int budget) in dwceqos_rx() argument
1722 if (!dwceqos_packet_avail(lp)) in dwceqos_rx()
1725 new_skb = netdev_alloc_skb(lp->ndev, DWCEQOS_RX_BUF_SIZE); in dwceqos_rx()
1727 netdev_err(lp->ndev, "no memory for new sk_buff\n"); in dwceqos_rx()
1732 new_skb_baddr = (u32)dma_map_single(lp->ndev->dev.parent, in dwceqos_rx()
1736 if (dma_mapping_error(lp->ndev->dev.parent, new_skb_baddr)) { in dwceqos_rx()
1737 netdev_err(lp->ndev, "DMA map error\n"); in dwceqos_rx()
1745 dd = &lp->rx_descs[lp->rx_cur]; in dwceqos_rx()
1747 skb = lp->rx_skb[lp->rx_cur].skb; in dwceqos_rx()
1750 dma_unmap_single(lp->ndev->dev.parent, in dwceqos_rx()
1751 lp->rx_skb[lp->rx_cur].mapping, in dwceqos_rx()
1752 lp->rx_skb[lp->rx_cur].len, DMA_FROM_DEVICE); in dwceqos_rx()
1761 skb->protocol = eth_type_trans(skb, lp->ndev); in dwceqos_rx()
1775 if (netif_msg_rx_err(lp)) in dwceqos_rx()
1776 netdev_dbg(lp->ndev, "rx error: des3=%X\n", in dwceqos_rx()
1777 lp->rx_descs[lp->rx_cur].des3); in dwceqos_rx()
1785 lp->rx_descs[lp->rx_cur].des0 = new_skb_baddr; in dwceqos_rx()
1786 lp->rx_descs[lp->rx_cur].des1 = 0; in dwceqos_rx()
1787 lp->rx_descs[lp->rx_cur].des2 = 0; in dwceqos_rx()
1790 lp->rx_descs[lp->rx_cur].des3 = DWCEQOS_DMA_RDES3_INTE | in dwceqos_rx()
1794 lp->rx_skb[lp->rx_cur].mapping = new_skb_baddr; in dwceqos_rx()
1795 lp->rx_skb[lp->rx_cur].len = DWCEQOS_RX_BUF_SIZE; in dwceqos_rx()
1796 lp->rx_skb[lp->rx_cur].skb = new_skb; in dwceqos_rx()
1799 lp->rx_cur = (lp->rx_cur + 1) % DWCEQOS_RX_DCNT; in dwceqos_rx()
1807 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_STA, DWCEQOS_DMA_CH0_IS_RI); in dwceqos_rx()
1809 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_RXDESC_TAIL, in dwceqos_rx()
1810 lp->rx_descs_tail_addr); in dwceqos_rx()
1817 struct net_local *lp = container_of(napi, struct net_local, napi); in dwceqos_rx_poll() local
1820 work_done = dwceqos_rx(lp, budget - work_done); in dwceqos_rx_poll()
1822 if (!dwceqos_packet_avail(lp) && work_done < budget) { in dwceqos_rx_poll()
1824 dwceqos_dma_enable_rxirq(lp); in dwceqos_rx_poll()
1835 struct net_local *lp = container_of(data, struct net_local, in dwceqos_reinit_for_txtimeout() local
1838 netdev_err(lp->ndev, "transmit timeout %d s, resetting...\n", in dwceqos_reinit_for_txtimeout()
1841 if (netif_msg_hw(lp)) in dwceqos_reinit_for_txtimeout()
1842 print_status(lp); in dwceqos_reinit_for_txtimeout()
1845 dwceqos_stop(lp->ndev); in dwceqos_reinit_for_txtimeout()
1846 dwceqos_open(lp->ndev); in dwceqos_reinit_for_txtimeout()
1854 struct net_local *lp; in dwceqos_probe_config_dt() local
1860 lp = netdev_priv(ndev); in dwceqos_probe_config_dt()
1861 bus_cfg = &lp->bus_cfg; in dwceqos_probe_config_dt()
1869 lp->en_tx_lpi_clockgating = of_property_read_bool(np, in dwceqos_probe_config_dt()
1892 struct net_local *lp = netdev_priv(ndev); in dwceqos_open() local
1895 dwceqos_reset_state(lp); in dwceqos_open()
1896 res = dwceqos_descriptor_init(lp); in dwceqos_open()
1903 napi_enable(&lp->napi); in dwceqos_open()
1904 phy_start(lp->phy_dev); in dwceqos_open()
1905 dwceqos_init_hw(lp); in dwceqos_open()
1908 tasklet_enable(&lp->tx_bdreclaim_tasklet); in dwceqos_open()
1913 static bool dweqos_is_tx_dma_suspended(struct net_local *lp) in dweqos_is_tx_dma_suspended() argument
1917 reg = dwceqos_read(lp, REG_DWCEQOS_DMA_DEBUG_ST0); in dweqos_is_tx_dma_suspended()
1923 static void dwceqos_drain_dma(struct net_local *lp) in dwceqos_drain_dma() argument
1930 while (!dweqos_is_tx_dma_suspended(lp) && limit--) in dwceqos_drain_dma()
1936 struct net_local *lp = netdev_priv(ndev); in dwceqos_stop() local
1938 phy_stop(lp->phy_dev); in dwceqos_stop()
1940 tasklet_disable(&lp->tx_bdreclaim_tasklet); in dwceqos_stop()
1942 napi_disable(&lp->napi); in dwceqos_stop()
1944 dwceqos_drain_dma(lp); in dwceqos_stop()
1946 netif_tx_lock(lp->ndev); in dwceqos_stop()
1947 dwceqos_reset_hw(lp); in dwceqos_stop()
1948 dwceqos_descriptor_free(lp); in dwceqos_stop()
1949 netif_tx_unlock(lp->ndev); in dwceqos_stop()
1954 static void dwceqos_dmadesc_set_ctx(struct net_local *lp, in dwceqos_dmadesc_set_ctx() argument
1957 struct dwceqos_dma_desc *dd = &lp->tx_descs[lp->tx_next]; in dwceqos_dmadesc_set_ctx()
1964 lp->tx_next = (lp->tx_next + 1) % DWCEQOS_TX_DCNT; in dwceqos_dmadesc_set_ctx()
1967 static void dwceqos_tx_poll_demand(struct net_local *lp) in dwceqos_tx_poll_demand() argument
1969 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_TXDESC_TAIL, in dwceqos_tx_poll_demand()
1970 lp->tx_descs_tail_addr); in dwceqos_tx_poll_demand()
1981 static void dwceqos_tx_prepare(struct sk_buff *skb, struct net_local *lp, in dwceqos_tx_prepare() argument
1987 if (skb_is_gso(skb) && skb_shinfo(skb)->gso_size != lp->gso_size) in dwceqos_tx_prepare()
1998 tx->initial_descriptor = lp->tx_next; in dwceqos_tx_prepare()
1999 tx->last_descriptor = lp->tx_next; in dwceqos_tx_prepare()
2000 tx->prev_gso_size = lp->gso_size; in dwceqos_tx_prepare()
2007 static int dwceqos_tx_linear(struct sk_buff *skb, struct net_local *lp, in dwceqos_tx_linear() argument
2015 if (skb_is_gso(skb) && skb_shinfo(skb)->gso_size != lp->gso_size) { in dwceqos_tx_linear()
2016 dwceqos_dmadesc_set_ctx(lp, skb_shinfo(skb)->gso_size); in dwceqos_tx_linear()
2017 lp->gso_size = skb_shinfo(skb)->gso_size; in dwceqos_tx_linear()
2020 dma_handle = dma_map_single(lp->ndev->dev.parent, skb->data, in dwceqos_tx_linear()
2023 if (dma_mapping_error(lp->ndev->dev.parent, dma_handle)) { in dwceqos_tx_linear()
2024 netdev_err(lp->ndev, "TX DMA Mapping error\n"); in dwceqos_tx_linear()
2028 rd = &lp->tx_skb[lp->tx_next]; in dwceqos_tx_linear()
2029 dd = &lp->tx_descs[lp->tx_next]; in dwceqos_tx_linear()
2065 if (lp->tx_next != tx->initial_descriptor) in dwceqos_tx_linear()
2068 tx->last_descriptor = lp->tx_next; in dwceqos_tx_linear()
2069 lp->tx_next = (lp->tx_next + 1) % DWCEQOS_TX_DCNT; in dwceqos_tx_linear()
2074 static int dwceqos_tx_frags(struct sk_buff *skb, struct net_local *lp, in dwceqos_tx_frags() argument
2089 dma_handle = skb_frag_dma_map(lp->ndev->dev.parent, frag, 0, in dwceqos_tx_frags()
2092 if (dma_mapping_error(lp->ndev->dev.parent, dma_handle)) { in dwceqos_tx_frags()
2093 netdev_err(lp->ndev, "DMA Mapping error\n"); in dwceqos_tx_frags()
2104 rd = &lp->tx_skb[lp->tx_next]; in dwceqos_tx_frags()
2107 dd = &lp->tx_descs[lp->tx_next]; in dwceqos_tx_frags()
2121 tx->last_descriptor = lp->tx_next; in dwceqos_tx_frags()
2122 lp->tx_next = (lp->tx_next + 1) % DWCEQOS_TX_DCNT; in dwceqos_tx_frags()
2133 static void dwceqos_tx_finalize(struct sk_buff *skb, struct net_local *lp, in dwceqos_tx_finalize() argument
2136 lp->tx_descs[tx->last_descriptor].des3 |= DWCEQOS_DMA_TDES3_LD; in dwceqos_tx_finalize()
2137 lp->tx_descs[tx->last_descriptor].des2 |= DWCEQOS_DMA_TDES2_IOC; in dwceqos_tx_finalize()
2139 lp->tx_skb[tx->last_descriptor].skb = skb; in dwceqos_tx_finalize()
2146 lp->tx_descs[tx->initial_descriptor].des3 |= DWCEQOS_DMA_TDES3_OWN; in dwceqos_tx_finalize()
2151 dwceqos_tx_poll_demand(lp); in dwceqos_tx_finalize()
2154 static void dwceqos_tx_rollback(struct net_local *lp, struct dwceqos_tx *tx) in dwceqos_tx_rollback() argument
2158 while (i != lp->tx_next) { in dwceqos_tx_rollback()
2159 if (lp->tx_skb[i].mapping) in dwceqos_tx_rollback()
2160 dma_unmap_single(lp->ndev->dev.parent, in dwceqos_tx_rollback()
2161 lp->tx_skb[i].mapping, in dwceqos_tx_rollback()
2162 lp->tx_skb[i].len, in dwceqos_tx_rollback()
2165 lp->tx_skb[i].mapping = 0; in dwceqos_tx_rollback()
2166 lp->tx_skb[i].skb = NULL; in dwceqos_tx_rollback()
2168 memset(&lp->tx_descs[i], 0, sizeof(lp->tx_descs[i])); in dwceqos_tx_rollback()
2173 lp->tx_next = tx->initial_descriptor; in dwceqos_tx_rollback()
2174 lp->gso_size = tx->prev_gso_size; in dwceqos_tx_rollback()
2179 struct net_local *lp = netdev_priv(ndev); in dwceqos_start_xmit() local
2183 dwceqos_tx_prepare(skb, lp, &trans); in dwceqos_start_xmit()
2184 if (lp->tx_free < trans.nr_descriptors) { in dwceqos_start_xmit()
2189 err = dwceqos_tx_linear(skb, lp, &trans); in dwceqos_start_xmit()
2193 err = dwceqos_tx_frags(skb, lp, &trans); in dwceqos_start_xmit()
2197 WARN_ON(lp->tx_next != in dwceqos_start_xmit()
2201 dwceqos_tx_finalize(skb, lp, &trans); in dwceqos_start_xmit()
2205 spin_lock_bh(&lp->tx_lock); in dwceqos_start_xmit()
2206 lp->tx_free -= trans.nr_descriptors; in dwceqos_start_xmit()
2207 spin_unlock_bh(&lp->tx_lock); in dwceqos_start_xmit()
2213 dwceqos_tx_rollback(lp, &trans); in dwceqos_start_xmit()
2221 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_mac_address() local
2232 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); in dwceqos_set_mac_address()
2238 struct net_local *lp = netdev_priv(ndev); in dwceqos_tx_timeout() local
2240 queue_work(lp->txtimeout_handler_wq, &lp->txtimeout_reinit); in dwceqos_tx_timeout()
2243 static void dwceqos_set_umac_addr(struct net_local *lp, unsigned char *addr, in dwceqos_set_umac_addr() argument
2249 dwceqos_write(lp, DWCEQOS_ADDR_HIGH(reg_n), in dwceqos_set_umac_addr()
2252 dwceqos_write(lp, DWCEQOS_ADDR_LOW(reg_n), data); in dwceqos_set_umac_addr()
2255 static void dwceqos_disable_umac_addr(struct net_local *lp, unsigned int reg_n) in dwceqos_disable_umac_addr() argument
2259 dwceqos_write(lp, DWCEQOS_ADDR_HIGH(reg_n), 0); in dwceqos_disable_umac_addr()
2264 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_rx_mode() local
2271 max_mac_addr = DWCEQOS_MAX_PERFECT_ADDRESSES(lp->feature1); in dwceqos_set_rx_mode()
2278 dwceqos_write(lp, REG_DWCEQOS_HASTABLE_LO, 0xffffffff); in dwceqos_set_rx_mode()
2279 dwceqos_write(lp, REG_DWCEQOS_HASTABLE_HI, 0xffffffff); in dwceqos_set_rx_mode()
2294 dwceqos_write(lp, REG_DWCEQOS_HASTABLE_LO, mc_filter[0]); in dwceqos_set_rx_mode()
2295 dwceqos_write(lp, REG_DWCEQOS_HASTABLE_HI, mc_filter[1]); in dwceqos_set_rx_mode()
2301 dwceqos_set_umac_addr(lp, ha->addr, reg); in dwceqos_set_rx_mode()
2304 for (; reg < DWCEQOS_MAX_PERFECT_ADDRESSES(lp->feature1); reg++) in dwceqos_set_rx_mode()
2305 dwceqos_disable_umac_addr(lp, reg); in dwceqos_set_rx_mode()
2307 dwceqos_write(lp, REG_DWCEQOS_MAC_PKT_FILT, regval); in dwceqos_set_rx_mode()
2319 static void dwceqos_read_mmc_counters(struct net_local *lp, u32 rx_mask, in dwceqos_read_mmc_counters() argument
2323 lp->mmc_counters.txlpitranscntr += in dwceqos_read_mmc_counters()
2324 dwceqos_read(lp, DWC_MMC_TXLPITRANSCNTR); in dwceqos_read_mmc_counters()
2326 lp->mmc_counters.txpiuscntr += in dwceqos_read_mmc_counters()
2327 dwceqos_read(lp, DWC_MMC_TXLPIUSCNTR); in dwceqos_read_mmc_counters()
2329 lp->mmc_counters.txoversize_g += in dwceqos_read_mmc_counters()
2330 dwceqos_read(lp, DWC_MMC_TXOVERSIZE_G); in dwceqos_read_mmc_counters()
2332 lp->mmc_counters.txvlanpackets_g += in dwceqos_read_mmc_counters()
2333 dwceqos_read(lp, DWC_MMC_TXVLANPACKETS_G); in dwceqos_read_mmc_counters()
2335 lp->mmc_counters.txpausepackets += in dwceqos_read_mmc_counters()
2336 dwceqos_read(lp, DWC_MMC_TXPAUSEPACKETS); in dwceqos_read_mmc_counters()
2338 lp->mmc_counters.txexcessdef += in dwceqos_read_mmc_counters()
2339 dwceqos_read(lp, DWC_MMC_TXEXCESSDEF); in dwceqos_read_mmc_counters()
2341 lp->mmc_counters.txpacketcount_g += in dwceqos_read_mmc_counters()
2342 dwceqos_read(lp, DWC_MMC_TXPACKETCOUNT_G); in dwceqos_read_mmc_counters()
2344 lp->mmc_counters.txoctetcount_g += in dwceqos_read_mmc_counters()
2345 dwceqos_read(lp, DWC_MMC_TXOCTETCOUNT_G); in dwceqos_read_mmc_counters()
2347 lp->mmc_counters.txcarriererror += in dwceqos_read_mmc_counters()
2348 dwceqos_read(lp, DWC_MMC_TXCARRIERERROR); in dwceqos_read_mmc_counters()
2350 lp->mmc_counters.txexcesscol += in dwceqos_read_mmc_counters()
2351 dwceqos_read(lp, DWC_MMC_TXEXCESSCOL); in dwceqos_read_mmc_counters()
2353 lp->mmc_counters.txlatecol += in dwceqos_read_mmc_counters()
2354 dwceqos_read(lp, DWC_MMC_TXLATECOL); in dwceqos_read_mmc_counters()
2356 lp->mmc_counters.txdeferred += in dwceqos_read_mmc_counters()
2357 dwceqos_read(lp, DWC_MMC_TXDEFERRED); in dwceqos_read_mmc_counters()
2359 lp->mmc_counters.txmulticol_g += in dwceqos_read_mmc_counters()
2360 dwceqos_read(lp, DWC_MMC_TXMULTICOL_G); in dwceqos_read_mmc_counters()
2362 lp->mmc_counters.txsinglecol_g += in dwceqos_read_mmc_counters()
2363 dwceqos_read(lp, DWC_MMC_TXSINGLECOL_G); in dwceqos_read_mmc_counters()
2365 lp->mmc_counters.txunderflowerror += in dwceqos_read_mmc_counters()
2366 dwceqos_read(lp, DWC_MMC_TXUNDERFLOWERROR); in dwceqos_read_mmc_counters()
2368 lp->mmc_counters.txbroadcastpackets_gb += in dwceqos_read_mmc_counters()
2369 dwceqos_read(lp, DWC_MMC_TXBROADCASTPACKETS_GB); in dwceqos_read_mmc_counters()
2371 lp->mmc_counters.txmulticastpackets_gb += in dwceqos_read_mmc_counters()
2372 dwceqos_read(lp, DWC_MMC_TXMULTICASTPACKETS_GB); in dwceqos_read_mmc_counters()
2374 lp->mmc_counters.txunicastpackets_gb += in dwceqos_read_mmc_counters()
2375 dwceqos_read(lp, DWC_MMC_TXUNICASTPACKETS_GB); in dwceqos_read_mmc_counters()
2377 lp->mmc_counters.tx1024tomaxoctets_gb += in dwceqos_read_mmc_counters()
2378 dwceqos_read(lp, DWC_MMC_TX1024TOMAXOCTETS_GB); in dwceqos_read_mmc_counters()
2380 lp->mmc_counters.tx512to1023octets_gb += in dwceqos_read_mmc_counters()
2381 dwceqos_read(lp, DWC_MMC_TX512TO1023OCTETS_GB); in dwceqos_read_mmc_counters()
2383 lp->mmc_counters.tx256to511octets_gb += in dwceqos_read_mmc_counters()
2384 dwceqos_read(lp, DWC_MMC_TX256TO511OCTETS_GB); in dwceqos_read_mmc_counters()
2386 lp->mmc_counters.tx128to255octets_gb += in dwceqos_read_mmc_counters()
2387 dwceqos_read(lp, DWC_MMC_TX128TO255OCTETS_GB); in dwceqos_read_mmc_counters()
2389 lp->mmc_counters.tx65to127octets_gb += in dwceqos_read_mmc_counters()
2390 dwceqos_read(lp, DWC_MMC_TX65TO127OCTETS_GB); in dwceqos_read_mmc_counters()
2392 lp->mmc_counters.tx64octets_gb += in dwceqos_read_mmc_counters()
2393 dwceqos_read(lp, DWC_MMC_TX64OCTETS_GB); in dwceqos_read_mmc_counters()
2395 lp->mmc_counters.txmulticastpackets_g += in dwceqos_read_mmc_counters()
2396 dwceqos_read(lp, DWC_MMC_TXMULTICASTPACKETS_G); in dwceqos_read_mmc_counters()
2398 lp->mmc_counters.txbroadcastpackets_g += in dwceqos_read_mmc_counters()
2399 dwceqos_read(lp, DWC_MMC_TXBROADCASTPACKETS_G); in dwceqos_read_mmc_counters()
2401 lp->mmc_counters.txpacketcount_gb += in dwceqos_read_mmc_counters()
2402 dwceqos_read(lp, DWC_MMC_TXPACKETCOUNT_GB); in dwceqos_read_mmc_counters()
2404 lp->mmc_counters.txoctetcount_gb += in dwceqos_read_mmc_counters()
2405 dwceqos_read(lp, DWC_MMC_TXOCTETCOUNT_GB); in dwceqos_read_mmc_counters()
2408 lp->mmc_counters.rxlpitranscntr += in dwceqos_read_mmc_counters()
2409 dwceqos_read(lp, DWC_MMC_RXLPITRANSCNTR); in dwceqos_read_mmc_counters()
2411 lp->mmc_counters.rxlpiuscntr += in dwceqos_read_mmc_counters()
2412 dwceqos_read(lp, DWC_MMC_RXLPIUSCNTR); in dwceqos_read_mmc_counters()
2414 lp->mmc_counters.rxctrlpackets_g += in dwceqos_read_mmc_counters()
2415 dwceqos_read(lp, DWC_MMC_RXCTRLPACKETS_G); in dwceqos_read_mmc_counters()
2417 lp->mmc_counters.rxrcverror += in dwceqos_read_mmc_counters()
2418 dwceqos_read(lp, DWC_MMC_RXRCVERROR); in dwceqos_read_mmc_counters()
2420 lp->mmc_counters.rxwatchdog += in dwceqos_read_mmc_counters()
2421 dwceqos_read(lp, DWC_MMC_RXWATCHDOG); in dwceqos_read_mmc_counters()
2423 lp->mmc_counters.rxvlanpackets_gb += in dwceqos_read_mmc_counters()
2424 dwceqos_read(lp, DWC_MMC_RXVLANPACKETS_GB); in dwceqos_read_mmc_counters()
2426 lp->mmc_counters.rxfifooverflow += in dwceqos_read_mmc_counters()
2427 dwceqos_read(lp, DWC_MMC_RXFIFOOVERFLOW); in dwceqos_read_mmc_counters()
2429 lp->mmc_counters.rxpausepackets += in dwceqos_read_mmc_counters()
2430 dwceqos_read(lp, DWC_MMC_RXPAUSEPACKETS); in dwceqos_read_mmc_counters()
2432 lp->mmc_counters.rxoutofrangetype += in dwceqos_read_mmc_counters()
2433 dwceqos_read(lp, DWC_MMC_RXOUTOFRANGETYPE); in dwceqos_read_mmc_counters()
2435 lp->mmc_counters.rxlengtherror += in dwceqos_read_mmc_counters()
2436 dwceqos_read(lp, DWC_MMC_RXLENGTHERROR); in dwceqos_read_mmc_counters()
2438 lp->mmc_counters.rxunicastpackets_g += in dwceqos_read_mmc_counters()
2439 dwceqos_read(lp, DWC_MMC_RXUNICASTPACKETS_G); in dwceqos_read_mmc_counters()
2441 lp->mmc_counters.rx1024tomaxoctets_gb += in dwceqos_read_mmc_counters()
2442 dwceqos_read(lp, DWC_MMC_RX1024TOMAXOCTETS_GB); in dwceqos_read_mmc_counters()
2444 lp->mmc_counters.rx512to1023octets_gb += in dwceqos_read_mmc_counters()
2445 dwceqos_read(lp, DWC_MMC_RX512TO1023OCTETS_GB); in dwceqos_read_mmc_counters()
2447 lp->mmc_counters.rx256to511octets_gb += in dwceqos_read_mmc_counters()
2448 dwceqos_read(lp, DWC_MMC_RX256TO511OCTETS_GB); in dwceqos_read_mmc_counters()
2450 lp->mmc_counters.rx128to255octets_gb += in dwceqos_read_mmc_counters()
2451 dwceqos_read(lp, DWC_MMC_RX128TO255OCTETS_GB); in dwceqos_read_mmc_counters()
2453 lp->mmc_counters.rx65to127octets_gb += in dwceqos_read_mmc_counters()
2454 dwceqos_read(lp, DWC_MMC_RX65TO127OCTETS_GB); in dwceqos_read_mmc_counters()
2456 lp->mmc_counters.rx64octets_gb += in dwceqos_read_mmc_counters()
2457 dwceqos_read(lp, DWC_MMC_RX64OCTETS_GB); in dwceqos_read_mmc_counters()
2459 lp->mmc_counters.rxoversize_g += in dwceqos_read_mmc_counters()
2460 dwceqos_read(lp, DWC_MMC_RXOVERSIZE_G); in dwceqos_read_mmc_counters()
2462 lp->mmc_counters.rxundersize_g += in dwceqos_read_mmc_counters()
2463 dwceqos_read(lp, DWC_MMC_RXUNDERSIZE_G); in dwceqos_read_mmc_counters()
2465 lp->mmc_counters.rxjabbererror += in dwceqos_read_mmc_counters()
2466 dwceqos_read(lp, DWC_MMC_RXJABBERERROR); in dwceqos_read_mmc_counters()
2468 lp->mmc_counters.rxrunterror += in dwceqos_read_mmc_counters()
2469 dwceqos_read(lp, DWC_MMC_RXRUNTERROR); in dwceqos_read_mmc_counters()
2471 lp->mmc_counters.rxalignmenterror += in dwceqos_read_mmc_counters()
2472 dwceqos_read(lp, DWC_MMC_RXALIGNMENTERROR); in dwceqos_read_mmc_counters()
2474 lp->mmc_counters.rxcrcerror += in dwceqos_read_mmc_counters()
2475 dwceqos_read(lp, DWC_MMC_RXCRCERROR); in dwceqos_read_mmc_counters()
2477 lp->mmc_counters.rxmulticastpackets_g += in dwceqos_read_mmc_counters()
2478 dwceqos_read(lp, DWC_MMC_RXMULTICASTPACKETS_G); in dwceqos_read_mmc_counters()
2480 lp->mmc_counters.rxbroadcastpackets_g += in dwceqos_read_mmc_counters()
2481 dwceqos_read(lp, DWC_MMC_RXBROADCASTPACKETS_G); in dwceqos_read_mmc_counters()
2483 lp->mmc_counters.rxoctetcount_g += in dwceqos_read_mmc_counters()
2484 dwceqos_read(lp, DWC_MMC_RXOCTETCOUNT_G); in dwceqos_read_mmc_counters()
2486 lp->mmc_counters.rxoctetcount_gb += in dwceqos_read_mmc_counters()
2487 dwceqos_read(lp, DWC_MMC_RXOCTETCOUNT_GB); in dwceqos_read_mmc_counters()
2489 lp->mmc_counters.rxpacketcount_gb += in dwceqos_read_mmc_counters()
2490 dwceqos_read(lp, DWC_MMC_RXPACKETCOUNT_GB); in dwceqos_read_mmc_counters()
2497 struct net_local *lp = netdev_priv(ndev); in dwceqos_get_stats64() local
2498 struct dwceqos_mmc_counters *hwstats = &lp->mmc_counters; in dwceqos_get_stats64()
2500 spin_lock_irqsave(&lp->stats_lock, flags); in dwceqos_get_stats64()
2501 dwceqos_read_mmc_counters(lp, lp->mmc_rx_counters_mask, in dwceqos_get_stats64()
2502 lp->mmc_tx_counters_mask); in dwceqos_get_stats64()
2503 spin_unlock_irqrestore(&lp->stats_lock, flags); in dwceqos_get_stats64()
2519 if (lp->mmc_tx_counters_mask & BIT(21)) in dwceqos_get_stats64()
2532 struct net_local *lp = netdev_priv(ndev); in dwceqos_get_settings() local
2533 struct phy_device *phydev = lp->phy_dev; in dwceqos_get_settings()
2544 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_settings() local
2545 struct phy_device *phydev = lp->phy_dev; in dwceqos_set_settings()
2556 const struct net_local *lp = netdev_priv(ndev); in dwceqos_get_drvinfo() local
2558 strcpy(ed->driver, lp->pdev->dev.driver->name); in dwceqos_get_drvinfo()
2565 const struct net_local *lp = netdev_priv(ndev); in dwceqos_get_pauseparam() local
2567 pp->autoneg = lp->flowcontrol.autoneg; in dwceqos_get_pauseparam()
2568 pp->tx_pause = lp->flowcontrol.tx; in dwceqos_get_pauseparam()
2569 pp->rx_pause = lp->flowcontrol.rx; in dwceqos_get_pauseparam()
2575 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_pauseparam() local
2578 lp->flowcontrol.autoneg = pp->autoneg; in dwceqos_set_pauseparam()
2580 lp->phy_dev->advertising |= ADVERTISED_Pause; in dwceqos_set_pauseparam()
2581 lp->phy_dev->advertising |= ADVERTISED_Asym_Pause; in dwceqos_set_pauseparam()
2583 lp->phy_dev->advertising &= ~ADVERTISED_Pause; in dwceqos_set_pauseparam()
2584 lp->phy_dev->advertising &= ~ADVERTISED_Asym_Pause; in dwceqos_set_pauseparam()
2585 lp->flowcontrol.rx = pp->rx_pause; in dwceqos_set_pauseparam()
2586 lp->flowcontrol.tx = pp->tx_pause; in dwceqos_set_pauseparam()
2590 ret = phy_start_aneg(lp->phy_dev); in dwceqos_set_pauseparam()
2613 struct net_local *lp = netdev_priv(ndev); in dwceqos_get_ethtool_stats() local
2616 u8 *mmcstat = (u8 *)&lp->mmc_counters; in dwceqos_get_ethtool_stats()
2618 spin_lock_irqsave(&lp->stats_lock, flags); in dwceqos_get_ethtool_stats()
2619 dwceqos_read_mmc_counters(lp, lp->mmc_rx_counters_mask, in dwceqos_get_ethtool_stats()
2620 lp->mmc_tx_counters_mask); in dwceqos_get_ethtool_stats()
2621 spin_unlock_irqrestore(&lp->stats_lock, flags); in dwceqos_get_ethtool_stats()
2642 const struct net_local *lp = netdev_priv(dev); in dwceqos_get_regs() local
2650 reg_space[reg_ix] = dwceqos_read(lp, reg_offset); in dwceqos_get_regs()
2656 reg_space[reg_ix] = dwceqos_read(lp, reg_offset); in dwceqos_get_regs()
2663 reg_space[reg_ix] = dwceqos_read(lp, reg_offset); in dwceqos_get_regs()
2687 struct net_local *lp = netdev_priv(ndev); in dwceqos_get_eee() local
2691 if (!(lp->feature0 & DWCEQOS_MAC_HW_FEATURE0_EEESEL)) in dwceqos_get_eee()
2694 edata->eee_active = lp->eee_active; in dwceqos_get_eee()
2695 edata->eee_enabled = lp->eee_enabled; in dwceqos_get_eee()
2696 edata->tx_lpi_timer = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_ENTRY_TIMER); in dwceqos_get_eee()
2697 lpi_status = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_get_eee()
2701 if (netif_msg_hw(lp)) { in dwceqos_get_eee()
2704 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_get_eee()
2706 netdev_info(lp->ndev, "MAC LPI State: RX:%s TX:%s\n", in dwceqos_get_eee()
2711 return phy_ethtool_get_eee(lp->phy_dev, edata); in dwceqos_get_eee()
2716 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_eee() local
2720 if (!(lp->feature0 & DWCEQOS_MAC_HW_FEATURE0_EEESEL)) in dwceqos_set_eee()
2723 if (edata->eee_enabled && !lp->eee_active) in dwceqos_set_eee()
2732 lp->eee_enabled = edata->eee_enabled; in dwceqos_set_eee()
2735 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_ENTRY_TIMER, in dwceqos_set_eee()
2738 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_set_eee()
2739 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_set_eee()
2741 if (lp->en_tx_lpi_clockgating) in dwceqos_set_eee()
2743 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS, regval); in dwceqos_set_eee()
2744 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_set_eee()
2746 spin_lock_irqsave(&lp->hw_lock, flags); in dwceqos_set_eee()
2747 regval = dwceqos_read(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS); in dwceqos_set_eee()
2749 dwceqos_write(lp, REG_DWCEQOS_MAC_LPI_CTRL_STATUS, regval); in dwceqos_set_eee()
2750 spin_unlock_irqrestore(&lp->hw_lock, flags); in dwceqos_set_eee()
2753 return phy_ethtool_set_eee(lp->phy_dev, edata); in dwceqos_set_eee()
2758 const struct net_local *lp = netdev_priv(ndev); in dwceqos_get_msglevel() local
2760 return lp->msg_enable; in dwceqos_get_msglevel()
2765 struct net_local *lp = netdev_priv(ndev); in dwceqos_set_msglevel() local
2767 lp->msg_enable = msglevel; in dwceqos_set_msglevel()
2812 struct net_local *lp; in dwceqos_probe() local
2821 ndev = alloc_etherdev(sizeof(*lp)); in dwceqos_probe()
2829 lp = netdev_priv(ndev); in dwceqos_probe()
2830 lp->ndev = ndev; in dwceqos_probe()
2831 lp->pdev = pdev; in dwceqos_probe()
2832 lp->msg_enable = netif_msg_init(debug, DWCEQOS_MSG_DEFAULT); in dwceqos_probe()
2834 spin_lock_init(&lp->tx_lock); in dwceqos_probe()
2835 spin_lock_init(&lp->hw_lock); in dwceqos_probe()
2836 spin_lock_init(&lp->stats_lock); in dwceqos_probe()
2838 lp->apb_pclk = devm_clk_get(&pdev->dev, "apb_pclk"); in dwceqos_probe()
2839 if (IS_ERR(lp->apb_pclk)) { in dwceqos_probe()
2841 ret = PTR_ERR(lp->apb_pclk); in dwceqos_probe()
2845 ret = clk_prepare_enable(lp->apb_pclk); in dwceqos_probe()
2851 lp->baseaddr = devm_ioremap_resource(&pdev->dev, r_mem); in dwceqos_probe()
2852 if (IS_ERR(lp->baseaddr)) { in dwceqos_probe()
2854 ret = PTR_ERR(lp->baseaddr); in dwceqos_probe()
2864 dwceqos_get_hwfeatures(lp); in dwceqos_probe()
2865 dwceqos_mdio_set_csr(lp); in dwceqos_probe()
2869 if (lp->feature1 & DWCEQOS_MAC_HW_FEATURE1_TSOEN) in dwceqos_probe()
2872 if (lp->feature0 & DWCEQOS_MAC_HW_FEATURE0_TXCOESEL) in dwceqos_probe()
2875 if (lp->feature0 & DWCEQOS_MAC_HW_FEATURE0_RXCOESEL) in dwceqos_probe()
2880 netif_napi_add(ndev, &lp->napi, dwceqos_rx_poll, NAPI_POLL_WEIGHT); in dwceqos_probe()
2888 lp->phy_ref_clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); in dwceqos_probe()
2889 if (IS_ERR(lp->phy_ref_clk)) { in dwceqos_probe()
2891 ret = PTR_ERR(lp->phy_ref_clk); in dwceqos_probe()
2895 ret = clk_prepare_enable(lp->phy_ref_clk); in dwceqos_probe()
2901 lp->phy_node = of_parse_phandle(lp->pdev->dev.of_node, in dwceqos_probe()
2903 if (!lp->phy_node && of_phy_is_fixed_link(lp->pdev->dev.of_node)) { in dwceqos_probe()
2904 ret = of_phy_register_fixed_link(lp->pdev->dev.of_node); in dwceqos_probe()
2910 lp->phy_node = of_node_get(lp->pdev->dev.of_node); in dwceqos_probe()
2913 ret = of_get_phy_mode(lp->pdev->dev.of_node); in dwceqos_probe()
2915 dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); in dwceqos_probe()
2919 lp->phy_interface = ret; in dwceqos_probe()
2921 ret = dwceqos_mii_init(lp); in dwceqos_probe()
2923 dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); in dwceqos_probe()
2934 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); in dwceqos_probe()
2936 tasklet_init(&lp->tx_bdreclaim_tasklet, dwceqos_tx_reclaim, in dwceqos_probe()
2938 tasklet_disable(&lp->tx_bdreclaim_tasklet); in dwceqos_probe()
2940 lp->txtimeout_handler_wq = create_singlethread_workqueue(DRIVER_NAME); in dwceqos_probe()
2941 INIT_WORK(&lp->txtimeout_reinit, dwceqos_reinit_for_txtimeout); in dwceqos_probe()
2946 dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", in dwceqos_probe()
2950 dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", in dwceqos_probe()
2956 dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", in dwceqos_probe()
2961 if (netif_msg_probe(lp)) in dwceqos_probe()
2962 netdev_dbg(ndev, "net_local@%p\n", lp); in dwceqos_probe()
2967 clk_disable_unprepare(lp->phy_ref_clk); in dwceqos_probe()
2971 clk_disable_unprepare(lp->apb_pclk); in dwceqos_probe()
2973 of_node_put(lp->phy_node); in dwceqos_probe()
2982 struct net_local *lp; in dwceqos_remove() local
2985 lp = netdev_priv(ndev); in dwceqos_remove()
2987 if (lp->phy_dev) in dwceqos_remove()
2988 phy_disconnect(lp->phy_dev); in dwceqos_remove()
2989 mdiobus_unregister(lp->mii_bus); in dwceqos_remove()
2990 kfree(lp->mii_bus->irq); in dwceqos_remove()
2991 mdiobus_free(lp->mii_bus); in dwceqos_remove()
2995 clk_disable_unprepare(lp->phy_ref_clk); in dwceqos_remove()
2996 clk_disable_unprepare(lp->apb_pclk); in dwceqos_remove()