Lines Matching full:emac

62 static void prueth_cleanup_rx_chns(struct prueth_emac *emac,  in prueth_cleanup_rx_chns()  argument
73 static void prueth_cleanup_tx_chns(struct prueth_emac *emac) in prueth_cleanup_tx_chns() argument
77 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_cleanup_tx_chns()
78 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_cleanup_tx_chns()
93 static void prueth_ndev_del_tx_napi(struct prueth_emac *emac, int num) in prueth_ndev_del_tx_napi() argument
98 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_ndev_del_tx_napi()
142 static int emac_tx_complete_packets(struct prueth_emac *emac, int chn, in emac_tx_complete_packets() argument
145 struct net_device *ndev = emac->ndev; in emac_tx_complete_packets()
155 tx_chn = &emac->tx_chns[chn]; in emac_tx_complete_packets()
164 if (atomic_dec_and_test(&emac->tdown_cnt)) in emac_tx_complete_packets()
165 complete(&emac->tdown_complete); in emac_tx_complete_packets()
208 struct prueth_emac *emac = tx_chn->emac; in emac_napi_tx_poll() local
211 num_tx_packets = emac_tx_complete_packets(emac, tx_chn->id, budget); in emac_napi_tx_poll()
232 static int prueth_ndev_add_tx_napi(struct prueth_emac *emac) in prueth_ndev_add_tx_napi() argument
234 struct prueth *prueth = emac->prueth; in prueth_ndev_add_tx_napi()
237 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_ndev_add_tx_napi()
238 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_ndev_add_tx_napi()
240 netif_napi_add_tx(emac->ndev, &tx_chn->napi_tx, emac_napi_tx_poll); in prueth_ndev_add_tx_napi()
254 prueth_ndev_del_tx_napi(emac, i); in prueth_ndev_add_tx_napi()
258 static int prueth_init_tx_chns(struct prueth_emac *emac) in prueth_init_tx_chns() argument
267 struct device *dev = emac->prueth->dev; in prueth_init_tx_chns()
268 struct net_device *ndev = emac->ndev; in prueth_init_tx_chns()
272 slice = prueth_emac_slice(emac); in prueth_init_tx_chns()
276 init_completion(&emac->tdown_complete); in prueth_init_tx_chns()
285 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_init_tx_chns()
286 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_init_tx_chns()
292 tx_chn->emac = emac; in prueth_init_tx_chns()
334 prueth_cleanup_tx_chns(emac); in prueth_init_tx_chns()
338 static int prueth_init_rx_chns(struct prueth_emac *emac, in prueth_init_rx_chns() argument
344 struct device *dev = emac->prueth->dev; in prueth_init_rx_chns()
345 struct net_device *ndev = emac->ndev; in prueth_init_rx_chns()
349 slice = prueth_emac_slice(emac); in prueth_init_rx_chns()
388 emac->rx_flow_id_base = k3_udma_glue_rx_get_flow_id_base(rx_chn->rx_chn); in prueth_init_rx_chns()
389 netdev_dbg(ndev, "flow id base = %d\n", emac->rx_flow_id_base); in prueth_init_rx_chns()
413 rx_flow_cfg.rxfdq_cfg.mode = emac->prueth->pdata.fdqring_mode; in prueth_init_rx_chns()
438 prueth_cleanup_rx_chns(emac, rx_chn, max_rflows); in prueth_init_rx_chns()
442 static int prueth_dma_rx_push(struct prueth_emac *emac, in prueth_dma_rx_push() argument
446 struct net_device *ndev = emac->ndev; in prueth_dma_rx_push()
494 static void emac_rx_timestamp(struct prueth_emac *emac, in emac_rx_timestamp() argument
500 u32 hi_sw = readl(emac->prueth->shram.va + in emac_rx_timestamp()
510 static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id) in emac_rx_packet() argument
512 struct prueth_rx_chn *rx_chn = &emac->rx_chns; in emac_rx_packet()
514 struct net_device *ndev = emac->ndev; in emac_rx_packet()
539 if (emac->rx_ts_enabled) in emac_rx_packet()
540 emac_rx_timestamp(emac, skb, psdata); in emac_rx_packet()
564 napi_gro_receive(&emac->napi_rx, skb); in emac_rx_packet()
570 ret = prueth_dma_rx_push(emac, new_skb, &emac->rx_chns); in emac_rx_packet()
602 static int emac_get_tx_ts(struct prueth_emac *emac, in emac_get_tx_ts() argument
605 struct prueth *prueth = emac->prueth; in emac_get_tx_ts()
606 int slice = prueth_emac_slice(emac); in emac_get_tx_ts()
622 static void tx_ts_work(struct prueth_emac *emac) in tx_ts_work() argument
633 ret = emac_get_tx_ts(emac, &tsr); in tx_ts_work()
638 !emac->tx_ts_skb[tsr.cookie]) { in tx_ts_work()
639 netdev_err(emac->ndev, "Invalid TX TS cookie 0x%x\n", in tx_ts_work()
644 skb = emac->tx_ts_skb[tsr.cookie]; in tx_ts_work()
645 emac->tx_ts_skb[tsr.cookie] = NULL; /* free slot */ in tx_ts_work()
647 netdev_err(emac->ndev, "Driver Bug! got NULL skb\n"); in tx_ts_work()
651 hi_sw = readl(emac->prueth->shram.va + in tx_ts_work()
662 if (atomic_dec_and_test(&emac->tx_ts_pending)) /* no more? */ in tx_ts_work()
667 static int prueth_tx_ts_cookie_get(struct prueth_emac *emac) in prueth_tx_ts_cookie_get() argument
673 if (!emac->tx_ts_skb[i]) { in prueth_tx_ts_cookie_get()
674 emac->tx_ts_skb[i] = ERR_PTR(-EBUSY); /* reserve slot */ in prueth_tx_ts_cookie_get()
683 * emac_ndo_start_xmit - EMAC Transmit function
685 * @ndev: EMAC network adapter
688 * EMAC hardware transmit queue
697 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_start_xmit() local
711 tx_chn = &emac->tx_chns[q_idx]; in emac_ndo_start_xmit()
736 emac->tx_ts_enabled) { in emac_ndo_start_xmit()
737 tx_ts_cookie = prueth_tx_ts_cookie_get(emac); in emac_ndo_start_xmit()
743 emac->tx_ts_skb[tx_ts_cookie] = skb_get(skb); in emac_ndo_start_xmit()
752 cppi5_desc_set_tags_ids(&first_desc->hdr, 0, (emac->port_id | (q_idx << 8))); in emac_ndo_start_xmit()
810 atomic_inc(&emac->tx_ts_pending); in emac_ndo_start_xmit()
826 dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); in emac_ndo_start_xmit()
827 emac->tx_ts_skb[tx_ts_cookie] = NULL; in emac_ndo_start_xmit()
844 dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); in emac_ndo_start_xmit()
845 emac->tx_ts_skb[tx_ts_cookie] = NULL; in emac_ndo_start_xmit()
871 struct prueth_emac *emac = dev_id; in prueth_tx_ts_irq() local
874 tx_ts_work(emac); in prueth_tx_ts_irq()
881 struct prueth_emac *emac = dev_id; in prueth_rx_irq() local
884 napi_schedule(&emac->napi_rx); in prueth_rx_irq()
908 static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac) in prueth_emac_start() argument
916 slice = prueth_emac_slice(emac); in prueth_emac_start()
918 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_start()
922 ret = icssg_config(prueth, emac, slice); in prueth_emac_start()
947 emac->fw_running = 1; in prueth_emac_start()
959 static void prueth_emac_stop(struct prueth_emac *emac) in prueth_emac_stop() argument
961 struct prueth *prueth = emac->prueth; in prueth_emac_stop()
964 switch (emac->port_id) { in prueth_emac_stop()
972 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_stop()
976 emac->fw_running = 0; in prueth_emac_stop()
982 static void prueth_cleanup_tx_ts(struct prueth_emac *emac) in prueth_cleanup_tx_ts() argument
987 if (emac->tx_ts_skb[i]) { in prueth_cleanup_tx_ts()
988 dev_kfree_skb_any(emac->tx_ts_skb[i]); in prueth_cleanup_tx_ts()
989 emac->tx_ts_skb[i] = NULL; in prueth_cleanup_tx_ts()
997 struct prueth_emac *emac = netdev_priv(ndev); in emac_adjust_link() local
999 struct prueth *prueth = emac->prueth; in emac_adjust_link()
1005 if (phydev->duplex != emac->duplex) { in emac_adjust_link()
1007 emac->duplex = phydev->duplex; in emac_adjust_link()
1009 if (phydev->speed != emac->speed) { in emac_adjust_link()
1011 emac->speed = phydev->speed; in emac_adjust_link()
1013 if (!emac->link) { in emac_adjust_link()
1015 emac->link = 1; in emac_adjust_link()
1017 } else if (emac->link) { in emac_adjust_link()
1019 emac->link = 0; in emac_adjust_link()
1022 emac->speed = SPEED_1000; in emac_adjust_link()
1025 emac->duplex = DUPLEX_FULL; in emac_adjust_link()
1034 if (emac->link) { in emac_adjust_link()
1036 icssg_update_rgmii_cfg(prueth->miig_rt, emac); in emac_adjust_link()
1039 spin_lock_irqsave(&emac->lock, flags); in emac_adjust_link()
1040 icssg_config_ipg(emac); in emac_adjust_link()
1041 spin_unlock_irqrestore(&emac->lock, flags); in emac_adjust_link()
1042 icssg_config_set_speed(emac); in emac_adjust_link()
1043 emac_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD); in emac_adjust_link()
1046 emac_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); in emac_adjust_link()
1050 if (emac->link) { in emac_adjust_link()
1055 prueth_cleanup_tx_ts(emac); in emac_adjust_link()
1061 struct prueth_emac *emac = prueth_napi_to_emac(napi_rx); in emac_napi_rx_poll() local
1072 ret = emac_rx_packet(emac, flow); in emac_napi_rx_poll()
1083 enable_irq(emac->rx_chns.irq[rx_flow]); in emac_napi_rx_poll()
1088 static int prueth_prepare_rx_chan(struct prueth_emac *emac, in prueth_prepare_rx_chan() argument
1100 ret = prueth_dma_rx_push(emac, skb, chn); in prueth_prepare_rx_chan()
1102 netdev_err(emac->ndev, in prueth_prepare_rx_chan()
1113 static void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num, in prueth_reset_tx_chan() argument
1120 k3_udma_glue_reset_tx_chn(emac->tx_chns[i].tx_chn, in prueth_reset_tx_chan()
1121 &emac->tx_chns[i], in prueth_reset_tx_chan()
1123 k3_udma_glue_disable_tx_chn(emac->tx_chns[i].tx_chn); in prueth_reset_tx_chan()
1139 static int emac_phy_connect(struct prueth_emac *emac) in emac_phy_connect() argument
1141 struct prueth *prueth = emac->prueth; in emac_phy_connect()
1142 struct net_device *ndev = emac->ndev; in emac_phy_connect()
1144 ndev->phydev = of_phy_connect(emac->ndev, emac->phy_node, in emac_phy_connect()
1146 emac->phy_if); in emac_phy_connect()
1149 emac->phy_node->full_name); in emac_phy_connect()
1160 if (emac->phy_if == PHY_INTERFACE_MODE_MII) in emac_phy_connect()
1169 struct prueth_emac *emac = clockops_data; in prueth_iep_gettime() local
1170 struct prueth *prueth = emac->prueth; in prueth_iep_gettime()
1183 iepcount_hi = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
1187 iepcount_lo = icss_iep_get_count_low(emac->iep); in prueth_iep_gettime()
1190 iepcount_hi_r = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
1206 struct prueth_emac *emac = clockops_data; in prueth_iep_settime() local
1212 if (!emac->fw_running) in prueth_iep_settime()
1215 sc_descp = emac->prueth->shram.va + TIMESYNC_FW_WC_SETCLOCK_DESC_OFFSET; in prueth_iep_settime()
1239 dev_err(emac->prueth->dev, "settime timeout\n"); in prueth_iep_settime()
1246 struct prueth_emac *emac = clockops_data; in prueth_perout_enable() local
1286 writel(reduction_factor, emac->prueth->shram.va + in prueth_perout_enable()
1289 current_cycle = icssg_read_time(emac->prueth->shram.va + in prueth_perout_enable()
1295 hi_lo_writeq(start_offset, emac->prueth->shram.va + in prueth_perout_enable()
1308 * emac_ndo_open - EMAC device open
1317 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_open() local
1318 int ret, i, num_data_chn = emac->tx_ch_num; in emac_ndo_open()
1319 struct prueth *prueth = emac->prueth; in emac_ndo_open()
1320 int slice = prueth_emac_slice(emac); in emac_ndo_open()
1332 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in emac_ndo_open()
1334 icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
1335 icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
1346 init_completion(&emac->cmd_complete); in emac_ndo_open()
1347 ret = prueth_init_tx_chns(emac); in emac_ndo_open()
1354 ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", in emac_ndo_open()
1361 ret = prueth_ndev_add_tx_napi(emac); in emac_ndo_open()
1367 ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, in emac_ndo_open()
1368 IRQF_TRIGGER_HIGH, dev_name(dev), emac); in emac_ndo_open()
1375 ret = prueth_emac_start(prueth, emac); in emac_ndo_open()
1382 ret = icss_iep_init(emac->iep, &prueth_iep_clockops, in emac_ndo_open()
1383 emac, IEP_DEFAULT_CYCLE_TIME_NS); in emac_ndo_open()
1386 ret = request_threaded_irq(emac->tx_ts_irq, NULL, prueth_tx_ts_irq, in emac_ndo_open()
1387 IRQF_ONESHOT, dev_name(dev), emac); in emac_ndo_open()
1392 ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE); in emac_ndo_open()
1396 ret = k3_udma_glue_enable_rx_chn(emac->rx_chns.rx_chn); in emac_ndo_open()
1400 for (i = 0; i < emac->tx_ch_num; i++) { in emac_ndo_open()
1401 ret = k3_udma_glue_enable_tx_chn(emac->tx_chns[i].tx_chn); in emac_ndo_open()
1407 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_open()
1408 napi_enable(&emac->tx_chns[i].napi_tx); in emac_ndo_open()
1409 napi_enable(&emac->napi_rx); in emac_ndo_open()
1416 queue_work(system_long_wq, &emac->stats_work.work); in emac_ndo_open()
1424 prueth_reset_tx_chan(emac, i, false); in emac_ndo_open()
1426 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, false); in emac_ndo_open()
1428 free_irq(emac->tx_ts_irq, emac); in emac_ndo_open()
1430 prueth_emac_stop(emac); in emac_ndo_open()
1432 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_open()
1434 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_open()
1436 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_open()
1438 prueth_cleanup_tx_chns(emac); in emac_ndo_open()
1444 * emac_ndo_stop - EMAC device stop
1453 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_stop() local
1454 struct prueth *prueth = emac->prueth; in emac_ndo_stop()
1466 icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac)); in emac_ndo_stop()
1468 atomic_set(&emac->tdown_cnt, emac->tx_ch_num); in emac_ndo_stop()
1472 reinit_completion(&emac->tdown_complete); in emac_ndo_stop()
1473 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
1474 k3_udma_glue_tdown_tx_chn(emac->tx_chns[i].tx_chn, false); in emac_ndo_stop()
1476 ret = wait_for_completion_timeout(&emac->tdown_complete, in emac_ndo_stop()
1481 prueth_reset_tx_chan(emac, emac->tx_ch_num, true); in emac_ndo_stop()
1482 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
1483 napi_disable(&emac->tx_chns[i].napi_tx); in emac_ndo_stop()
1486 k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true); in emac_ndo_stop()
1488 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true); in emac_ndo_stop()
1490 napi_disable(&emac->napi_rx); in emac_ndo_stop()
1492 cancel_work_sync(&emac->rx_mode_work); in emac_ndo_stop()
1495 cancel_delayed_work_sync(&emac->stats_work); in emac_ndo_stop()
1498 prueth_emac_stop(emac); in emac_ndo_stop()
1501 icss_iep_exit(emac->iep); in emac_ndo_stop()
1504 prueth_emac_stop(emac); in emac_ndo_stop()
1506 free_irq(emac->tx_ts_irq, emac); in emac_ndo_stop()
1508 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_stop()
1509 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_stop()
1510 prueth_cleanup_tx_chns(emac); in emac_ndo_stop()
1512 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_stop()
1513 prueth_cleanup_tx_chns(emac); in emac_ndo_stop()
1527 struct prueth_emac *emac = container_of(work, struct prueth_emac, rx_mode_work); in emac_ndo_set_rx_mode_work() local
1528 struct net_device *ndev = emac->ndev; in emac_ndo_set_rx_mode_work()
1536 emac_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
1537 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
1540 emac_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
1541 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
1546 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
1551 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
1557 * emac_ndo_set_rx_mode - EMAC set receive mode function
1558 * @ndev: The EMAC network adapter
1565 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_set_rx_mode() local
1567 queue_work(emac->cmd_wq, &emac->rx_mode_work); in emac_ndo_set_rx_mode()
1572 struct prueth_emac *emac = netdev_priv(ndev); in emac_set_ts_config() local
1580 emac->tx_ts_enabled = 0; in emac_set_ts_config()
1583 emac->tx_ts_enabled = 1; in emac_set_ts_config()
1591 emac->rx_ts_enabled = 0; in emac_set_ts_config()
1608 emac->rx_ts_enabled = 1; in emac_set_ts_config()
1621 struct prueth_emac *emac = netdev_priv(ndev); in emac_get_ts_config() local
1625 config.tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in emac_get_ts_config()
1626 config.rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE; in emac_get_ts_config()
1649 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_get_stats64() local
1651 emac_update_hardware_stats(emac); in emac_ndo_get_stats64()
1653 stats->rx_packets = emac_get_stat_by_name(emac, "rx_packets"); in emac_ndo_get_stats64()
1654 stats->rx_bytes = emac_get_stat_by_name(emac, "rx_bytes"); in emac_ndo_get_stats64()
1655 stats->tx_packets = emac_get_stat_by_name(emac, "tx_packets"); in emac_ndo_get_stats64()
1656 stats->tx_bytes = emac_get_stat_by_name(emac, "tx_bytes"); in emac_ndo_get_stats64()
1657 stats->rx_crc_errors = emac_get_stat_by_name(emac, "rx_crc_errors"); in emac_ndo_get_stats64()
1658 stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors"); in emac_ndo_get_stats64()
1659 stats->multicast = emac_get_stat_by_name(emac, "rx_multicast_frames"); in emac_ndo_get_stats64()
1719 struct prueth_emac *emac; in prueth_netdev_init() local
1733 ndev = alloc_etherdev_mq(sizeof(*emac), num_tx_chn); in prueth_netdev_init()
1737 emac = netdev_priv(ndev); in prueth_netdev_init()
1738 emac->prueth = prueth; in prueth_netdev_init()
1739 emac->ndev = ndev; in prueth_netdev_init()
1740 emac->port_id = port; in prueth_netdev_init()
1741 emac->cmd_wq = create_singlethread_workqueue("icssg_cmd_wq"); in prueth_netdev_init()
1742 if (!emac->cmd_wq) { in prueth_netdev_init()
1746 INIT_WORK(&emac->rx_mode_work, emac_ndo_set_rx_mode_work); in prueth_netdev_init()
1748 INIT_DELAYED_WORK(&emac->stats_work, emac_stats_work_handler); in prueth_netdev_init()
1753 &emac->dram); in prueth_netdev_init()
1760 emac->tx_ch_num = 1; in prueth_netdev_init()
1763 if (emac->port_id == PRUETH_PORT_MII1) in prueth_netdev_init()
1765 emac->tx_ts_irq = platform_get_irq_byname_optional(prueth->pdev, irq_name); in prueth_netdev_init()
1766 if (emac->tx_ts_irq < 0) { in prueth_netdev_init()
1767 ret = dev_err_probe(prueth->dev, emac->tx_ts_irq, "could not get tx_ts_irq\n"); in prueth_netdev_init()
1772 spin_lock_init(&emac->lock); in prueth_netdev_init()
1773 mutex_init(&emac->cmd_lock); in prueth_netdev_init()
1775 emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0); in prueth_netdev_init()
1776 if (!emac->phy_node && !of_phy_is_fixed_link(eth_node)) { in prueth_netdev_init()
1788 emac->phy_node = eth_node; in prueth_netdev_init()
1791 ret = of_get_phy_mode(eth_node, &emac->phy_if); in prueth_netdev_init()
1797 if (emac->phy_if != PHY_INTERFACE_MODE_MII && in prueth_netdev_init()
1798 !phy_interface_mode_is_rgmii(emac->phy_if)) { in prueth_netdev_init()
1799 dev_err(prueth->dev, "PHY mode unsupported %s\n", phy_modes(emac->phy_if)); in prueth_netdev_init()
1809 switch (emac->phy_if) { in prueth_netdev_init()
1811 emac->phy_if = PHY_INTERFACE_MODE_RGMII_RXID; in prueth_netdev_init()
1814 emac->phy_if = PHY_INTERFACE_MODE_RGMII; in prueth_netdev_init()
1832 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in prueth_netdev_init()
1841 netif_napi_add(ndev, &emac->napi_rx, emac_napi_rx_poll); in prueth_netdev_init()
1842 prueth->emac[mac] = emac; in prueth_netdev_init()
1847 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_init()
1849 destroy_workqueue(emac->cmd_wq); in prueth_netdev_init()
1851 emac->ndev = NULL; in prueth_netdev_init()
1852 prueth->emac[mac] = NULL; in prueth_netdev_init()
1861 struct prueth_emac *emac; in prueth_netdev_exit() local
1868 emac = prueth->emac[mac]; in prueth_netdev_exit()
1869 if (!emac) in prueth_netdev_exit()
1872 if (of_phy_is_fixed_link(emac->phy_node)) in prueth_netdev_exit()
1873 of_phy_deregister_fixed_link(emac->phy_node); in prueth_netdev_exit()
1875 netif_napi_del(&emac->napi_rx); in prueth_netdev_exit()
1877 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_exit()
1878 destroy_workqueue(emac->cmd_wq); in prueth_netdev_exit()
1879 free_netdev(emac->ndev); in prueth_netdev_exit()
1880 prueth->emac[mac] = NULL; in prueth_netdev_exit()
2124 prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; in prueth_probe()
2135 prueth->emac[PRUETH_MAC1]->iep = prueth->iep0; in prueth_probe()
2140 ret = register_netdev(prueth->emac[PRUETH_MAC0]->ndev); in prueth_probe()
2146 prueth->registered_netdevs[PRUETH_MAC0] = prueth->emac[PRUETH_MAC0]->ndev; in prueth_probe()
2148 ret = emac_phy_connect(prueth->emac[PRUETH_MAC0]); in prueth_probe()
2154 phy_attached_info(prueth->emac[PRUETH_MAC0]->ndev->phydev); in prueth_probe()
2158 ret = register_netdev(prueth->emac[PRUETH_MAC1]->ndev); in prueth_probe()
2164 prueth->registered_netdevs[PRUETH_MAC1] = prueth->emac[PRUETH_MAC1]->ndev; in prueth_probe()
2165 ret = emac_phy_connect(prueth->emac[PRUETH_MAC1]); in prueth_probe()
2171 phy_attached_info(prueth->emac[PRUETH_MAC1]->ndev->phydev); in prueth_probe()
2174 dev_info(dev, "TI PRU ethernet driver initialized: %s EMAC mode\n", in prueth_probe()
2187 if (prueth->emac[i]->ndev->phydev) { in prueth_probe()
2188 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_probe()
2189 prueth->emac[i]->ndev->phydev = NULL; in prueth_probe()
2246 phy_stop(prueth->emac[i]->ndev->phydev); in prueth_remove()
2247 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_remove()
2248 prueth->emac[i]->ndev->phydev = NULL; in prueth_remove()