Lines Matching +full:mii +full:- +full:rt

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
12 #include <linux/dma-mapping.h>
13 #include <linux/dma/ti-cppi5.h>
18 #include <linux/io-64-nonatomic-hi-lo.h>
34 #include "../k3-cppi-desc-pool.h"
66 if (rx_chn->desc_pool) in prueth_cleanup_rx_chns()
67 k3_cppi_desc_pool_destroy(rx_chn->desc_pool); in prueth_cleanup_rx_chns()
69 if (rx_chn->rx_chn) in prueth_cleanup_rx_chns()
70 k3_udma_glue_release_rx_chn(rx_chn->rx_chn); in prueth_cleanup_rx_chns()
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()
80 if (tx_chn->desc_pool) in prueth_cleanup_tx_chns()
81 k3_cppi_desc_pool_destroy(tx_chn->desc_pool); in prueth_cleanup_tx_chns()
83 if (tx_chn->tx_chn) in prueth_cleanup_tx_chns()
84 k3_udma_glue_release_tx_chn(tx_chn->tx_chn); in prueth_cleanup_tx_chns()
98 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_ndev_del_tx_napi()
100 if (tx_chn->irq) in prueth_ndev_del_tx_napi()
101 free_irq(tx_chn->irq, tx_chn); in prueth_ndev_del_tx_napi()
102 netif_napi_del(&tx_chn->napi_tx); in prueth_ndev_del_tx_napi()
117 k3_udma_glue_tx_cppi5_to_dma_addr(tx_chn->tx_chn, &buf_dma); in prueth_xmit_free()
119 dma_unmap_single(tx_chn->dma_dev, buf_dma, buf_dma_len, in prueth_xmit_free()
123 k3_udma_glue_tx_cppi5_to_dma_addr(tx_chn->tx_chn, &next_desc_dma); in prueth_xmit_free()
125 next_desc = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, in prueth_xmit_free()
128 k3_udma_glue_tx_cppi5_to_dma_addr(tx_chn->tx_chn, &buf_dma); in prueth_xmit_free()
130 dma_unmap_page(tx_chn->dma_dev, buf_dma, buf_dma_len, in prueth_xmit_free()
134 k3_udma_glue_tx_cppi5_to_dma_addr(tx_chn->tx_chn, &next_desc_dma); in prueth_xmit_free()
136 k3_cppi_desc_pool_free(tx_chn->desc_pool, next_desc); in prueth_xmit_free()
139 k3_cppi_desc_pool_free(tx_chn->desc_pool, first_desc); in prueth_xmit_free()
145 struct net_device *ndev = emac->ndev; in emac_tx_complete_packets()
155 tx_chn = &emac->tx_chns[chn]; in emac_tx_complete_packets()
158 res = k3_udma_glue_pop_tx_chn(tx_chn->tx_chn, &desc_dma); in emac_tx_complete_packets()
159 if (res == -ENODATA) 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()
169 desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, in emac_tx_complete_packets()
176 ndev = skb->dev; in emac_tx_complete_packets()
177 ndev->stats.tx_packets++; in emac_tx_complete_packets()
178 ndev->stats.tx_bytes += skb->len; in emac_tx_complete_packets()
179 total_bytes += skb->len; in emac_tx_complete_packets()
196 (k3_cppi_desc_pool_avail(tx_chn->desc_pool) >= in emac_tx_complete_packets()
208 struct prueth_emac *emac = tx_chn->emac; in emac_napi_tx_poll()
211 num_tx_packets = emac_tx_complete_packets(emac, tx_chn->id, budget); in emac_napi_tx_poll()
217 enable_irq(tx_chn->irq); in emac_napi_tx_poll()
227 napi_schedule(&tx_chn->napi_tx); in prueth_tx_irq()
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()
241 ret = request_irq(tx_chn->irq, prueth_tx_irq, in prueth_ndev_add_tx_napi()
242 IRQF_TRIGGER_HIGH, tx_chn->name, in prueth_ndev_add_tx_napi()
245 netif_napi_del(&tx_chn->napi_tx); in prueth_ndev_add_tx_napi()
246 dev_err(prueth->dev, "unable to request TX IRQ %d\n", in prueth_ndev_add_tx_napi()
247 tx_chn->irq); in prueth_ndev_add_tx_napi()
267 struct device *dev = emac->prueth->dev; in prueth_init_tx_chns()
268 struct net_device *ndev = emac->ndev; 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()
289 snprintf(tx_chn->name, sizeof(tx_chn->name), in prueth_init_tx_chns()
290 "tx%d-%d", slice, i); in prueth_init_tx_chns()
292 tx_chn->emac = emac; in prueth_init_tx_chns()
293 tx_chn->id = i; in prueth_init_tx_chns()
294 tx_chn->descs_num = PRUETH_MAX_TX_DESC; in prueth_init_tx_chns()
296 tx_chn->tx_chn = in prueth_init_tx_chns()
297 k3_udma_glue_request_tx_chn(dev, tx_chn->name, in prueth_init_tx_chns()
299 if (IS_ERR(tx_chn->tx_chn)) { in prueth_init_tx_chns()
300 ret = PTR_ERR(tx_chn->tx_chn); in prueth_init_tx_chns()
301 tx_chn->tx_chn = NULL; in prueth_init_tx_chns()
307 tx_chn->dma_dev = k3_udma_glue_tx_get_dma_device(tx_chn->tx_chn); in prueth_init_tx_chns()
308 tx_chn->desc_pool = in prueth_init_tx_chns()
309 k3_cppi_desc_pool_create_name(tx_chn->dma_dev, in prueth_init_tx_chns()
310 tx_chn->descs_num, in prueth_init_tx_chns()
312 tx_chn->name); in prueth_init_tx_chns()
313 if (IS_ERR(tx_chn->desc_pool)) { in prueth_init_tx_chns()
314 ret = PTR_ERR(tx_chn->desc_pool); in prueth_init_tx_chns()
315 tx_chn->desc_pool = NULL; in prueth_init_tx_chns()
320 ret = k3_udma_glue_tx_get_irq(tx_chn->tx_chn); in prueth_init_tx_chns()
325 tx_chn->irq = ret; in prueth_init_tx_chns()
327 snprintf(tx_chn->name, sizeof(tx_chn->name), "%s-tx%d", in prueth_init_tx_chns()
328 dev_name(dev), tx_chn->id); in prueth_init_tx_chns()
344 struct device *dev = emac->prueth->dev; in prueth_init_rx_chns()
345 struct net_device *ndev = emac->ndev; in prueth_init_rx_chns()
354 snprintf(rx_chn->name, sizeof(rx_chn->name), "%s%d", name, slice); in prueth_init_rx_chns()
361 rx_cfg.flow_id_base = -1; /* udmax will auto select flow id base */ in prueth_init_rx_chns()
364 rx_chn->dev = dev; in prueth_init_rx_chns()
365 rx_chn->descs_num = max_desc_num; in prueth_init_rx_chns()
367 rx_chn->rx_chn = k3_udma_glue_request_rx_chn(dev, rx_chn->name, in prueth_init_rx_chns()
369 if (IS_ERR(rx_chn->rx_chn)) { in prueth_init_rx_chns()
370 ret = PTR_ERR(rx_chn->rx_chn); in prueth_init_rx_chns()
371 rx_chn->rx_chn = NULL; in prueth_init_rx_chns()
376 rx_chn->dma_dev = k3_udma_glue_rx_get_dma_device(rx_chn->rx_chn); in prueth_init_rx_chns()
377 rx_chn->desc_pool = k3_cppi_desc_pool_create_name(rx_chn->dma_dev, in prueth_init_rx_chns()
378 rx_chn->descs_num, in prueth_init_rx_chns()
380 rx_chn->name); in prueth_init_rx_chns()
381 if (IS_ERR(rx_chn->desc_pool)) { in prueth_init_rx_chns()
382 ret = PTR_ERR(rx_chn->desc_pool); in prueth_init_rx_chns()
383 rx_chn->desc_pool = NULL; 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()
415 ret = k3_udma_glue_rx_flow_init(rx_chn->rx_chn, in prueth_init_rx_chns()
423 fdqring_id = k3_udma_glue_rx_flow_get_fdq_id(rx_chn->rx_chn, in prueth_init_rx_chns()
425 ret = k3_udma_glue_rx_get_irq(rx_chn->rx_chn, i); in prueth_init_rx_chns()
428 ret = -ENXIO; in prueth_init_rx_chns()
432 rx_chn->irq[i] = ret; in prueth_init_rx_chns()
446 struct net_device *ndev = emac->ndev; in prueth_dma_rx_push()
453 desc_rx = k3_cppi_desc_pool_alloc(rx_chn->desc_pool); in prueth_dma_rx_push()
456 return -ENOMEM; in prueth_dma_rx_push()
458 desc_dma = k3_cppi_desc_pool_virt2dma(rx_chn->desc_pool, desc_rx); in prueth_dma_rx_push()
460 buf_dma = dma_map_single(rx_chn->dma_dev, skb->data, pkt_len, DMA_FROM_DEVICE); in prueth_dma_rx_push()
461 if (unlikely(dma_mapping_error(rx_chn->dma_dev, buf_dma))) { in prueth_dma_rx_push()
462 k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx); in prueth_dma_rx_push()
464 return -EINVAL; in prueth_dma_rx_push()
469 k3_udma_glue_rx_dma_to_cppi5_addr(rx_chn->rx_chn, &buf_dma); in prueth_dma_rx_push()
475 return k3_udma_glue_push_rx_chn(rx_chn->rx_chn, 0, in prueth_dma_rx_push()
500 u32 hi_sw = readl(emac->prueth->shram.va + in emac_rx_timestamp()
507 ssh->hwtstamp = ns_to_ktime(ns); in emac_rx_timestamp()
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()
522 ret = k3_udma_glue_pop_rx_chn(rx_chn->rx_chn, flow_id, &desc_dma); in emac_rx_packet()
524 if (ret != -ENODATA) in emac_rx_packet()
532 desc_rx = k3_cppi_desc_pool_dma2virt(rx_chn->desc_pool, desc_dma); in emac_rx_packet()
539 if (emac->rx_ts_enabled) in emac_rx_packet()
543 k3_udma_glue_rx_cppi5_to_dma_addr(rx_chn->rx_chn, &buf_dma); in emac_rx_packet()
546 pkt_len -= 4; in emac_rx_packet()
547 cppi5_desc_get_tags_ids(&desc_rx->hdr, &port_id, NULL); in emac_rx_packet()
549 dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, DMA_FROM_DEVICE); in emac_rx_packet()
550 k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx); in emac_rx_packet()
552 skb->dev = ndev; in emac_rx_packet()
558 ndev->stats.rx_dropped++; in emac_rx_packet()
563 skb->protocol = eth_type_trans(skb, ndev); in emac_rx_packet()
564 napi_gro_receive(&emac->napi_rx, skb); in emac_rx_packet()
565 ndev->stats.rx_bytes += pkt_len; in emac_rx_packet()
566 ndev->stats.rx_packets++; in emac_rx_packet()
570 ret = prueth_dma_rx_push(emac, new_skb, &emac->rx_chns); in emac_rx_packet()
573 ndev->stats.rx_errors++; in emac_rx_packet()
574 ndev->stats.rx_dropped++; in emac_rx_packet()
589 desc_rx = k3_cppi_desc_pool_dma2virt(rx_chn->desc_pool, desc_dma); in prueth_rx_cleanup()
593 k3_udma_glue_rx_cppi5_to_dma_addr(rx_chn->rx_chn, &buf_dma); in prueth_rx_cleanup()
595 dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, in prueth_rx_cleanup()
597 k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx); in prueth_rx_cleanup()
605 struct prueth *prueth = emac->prueth; in emac_get_tx_ts()
614 memcpy_fromio(rsp, prueth->shram.va + addr, sizeof(*rsp)); in emac_get_tx_ts()
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()
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()
679 return -EBUSY; in prueth_tx_ts_cookie_get()
683 * emac_ndo_start_xmit - EMAC Transmit function
687 * Called by the system to transmit a packet - we queue the packet in
711 tx_chn = &emac->tx_chns[q_idx]; in emac_ndo_start_xmit()
715 buf_dma = dma_map_single(tx_chn->dma_dev, skb->data, pkt_len, DMA_TO_DEVICE); in emac_ndo_start_xmit()
716 if (dma_mapping_error(tx_chn->dma_dev, buf_dma)) { in emac_ndo_start_xmit()
722 first_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool); in emac_ndo_start_xmit()
725 dma_unmap_single(tx_chn->dma_dev, buf_dma, pkt_len, DMA_TO_DEVICE); in emac_ndo_start_xmit()
732 epib = first_desc->epib; in emac_ndo_start_xmit()
735 if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && in emac_ndo_start_xmit()
736 emac->tx_ts_enabled) { in emac_ndo_start_xmit()
739 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; 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()
753 k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &buf_dma); in emac_ndo_start_xmit()
760 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in emac_ndo_start_xmit()
761 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in emac_ndo_start_xmit()
764 next_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool); in emac_ndo_start_xmit()
771 buf_dma = skb_frag_dma_map(tx_chn->dma_dev, frag, 0, frag_size, in emac_ndo_start_xmit()
773 if (dma_mapping_error(tx_chn->dma_dev, buf_dma)) { in emac_ndo_start_xmit()
775 k3_cppi_desc_pool_free(tx_chn->desc_pool, next_desc); in emac_ndo_start_xmit()
781 k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &buf_dma); in emac_ndo_start_xmit()
785 desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, in emac_ndo_start_xmit()
787 k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &desc_dma); in emac_ndo_start_xmit()
793 WARN_ON_ONCE(pkt_len != skb->len); in emac_ndo_start_xmit()
799 desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); in emac_ndo_start_xmit()
803 ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); in emac_ndo_start_xmit()
810 atomic_inc(&emac->tx_ts_pending); in emac_ndo_start_xmit()
812 if (k3_cppi_desc_pool_avail(tx_chn->desc_pool) < MAX_SKB_FRAGS) { in emac_ndo_start_xmit()
817 if (k3_cppi_desc_pool_avail(tx_chn->desc_pool) >= 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()
837 ndev->stats.tx_dropped++; 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()
861 desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, desc_dma); in prueth_tx_cleanup()
884 napi_schedule(&emac->napi_rx); in prueth_rx_irq()
897 .pru = "ti-pruss/am65x-sr2-pru0-prueth-fw.elf",
898 .rtu = "ti-pruss/am65x-sr2-rtu0-prueth-fw.elf",
899 .txpru = "ti-pruss/am65x-sr2-txpru0-prueth-fw.elf",
902 .pru = "ti-pruss/am65x-sr2-pru1-prueth-fw.elf",
903 .rtu = "ti-pruss/am65x-sr2-rtu1-prueth-fw.elf",
904 .txpru = "ti-pruss/am65x-sr2-txpru1-prueth-fw.elf",
911 struct device *dev = prueth->dev; in prueth_emac_start()
918 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_start()
919 return -EINVAL; in prueth_emac_start()
926 ret = rproc_set_firmware(prueth->pru[slice], firmwares[slice].pru); in prueth_emac_start()
927 ret = rproc_boot(prueth->pru[slice]); in prueth_emac_start()
930 return -EINVAL; in prueth_emac_start()
933 ret = rproc_set_firmware(prueth->rtu[slice], firmwares[slice].rtu); in prueth_emac_start()
934 ret = rproc_boot(prueth->rtu[slice]); in prueth_emac_start()
940 ret = rproc_set_firmware(prueth->txpru[slice], firmwares[slice].txpru); in prueth_emac_start()
941 ret = rproc_boot(prueth->txpru[slice]); in prueth_emac_start()
947 emac->fw_running = 1; in prueth_emac_start()
951 rproc_shutdown(prueth->rtu[slice]); in prueth_emac_start()
954 rproc_shutdown(prueth->pru[slice]); in prueth_emac_start()
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()
977 rproc_shutdown(prueth->txpru[slice]); in prueth_emac_stop()
978 rproc_shutdown(prueth->rtu[slice]); in prueth_emac_stop()
979 rproc_shutdown(prueth->pru[slice]); in prueth_emac_stop()
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()
998 struct phy_device *phydev = ndev->phydev; in emac_adjust_link()
999 struct prueth *prueth = emac->prueth; in emac_adjust_link()
1003 if (phydev->link) { in emac_adjust_link()
1004 /* check the mode of operation - full/half duplex */ 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()
1031 /* update RGMII and MII configuration based on PHY negotiated 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()
1041 spin_unlock_irqrestore(&emac->lock, flags); in emac_adjust_link()
1050 if (emac->link) { in emac_adjust_link()
1068 while (flow--) { in emac_napi_rx_poll()
1069 cur_budget = budget - num_rx; in emac_napi_rx_poll()
1071 while (cur_budget--) { in emac_napi_rx_poll()
1083 enable_irq(emac->rx_chns.irq[rx_flow]); in emac_napi_rx_poll()
1095 for (i = 0; i < chn->descs_num; i++) { in prueth_prepare_rx_chan()
1098 return -ENOMEM; in prueth_prepare_rx_chan()
1102 netdev_err(emac->ndev, in prueth_prepare_rx_chan()
1104 chn->name, ret); in prueth_prepare_rx_chan()
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()
1133 k3_udma_glue_reset_rx_chn(chn->rx_chn, i, chn, in prueth_reset_rx_chan()
1136 k3_udma_glue_disable_rx_chn(chn->rx_chn); in prueth_reset_rx_chan()
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()
1147 if (!ndev->phydev) { in emac_phy_connect()
1148 dev_err(prueth->dev, "couldn't connect to phy %s\n", in emac_phy_connect()
1149 emac->phy_node->full_name); in emac_phy_connect()
1150 return -ENODEV; in emac_phy_connect()
1154 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT); in emac_phy_connect()
1155 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT); in emac_phy_connect()
1156 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT); in emac_phy_connect()
1157 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_Pause_BIT); in emac_phy_connect()
1158 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT); in emac_phy_connect()
1160 if (emac->phy_if == PHY_INTERFACE_MODE_MII) in emac_phy_connect()
1161 phy_set_max_speed(ndev->phydev, SPEED_100); in emac_phy_connect()
1170 struct prueth *prueth = emac->prueth; in prueth_iep_gettime()
1178 fw_count_hi_addr = prueth->shram.va + TIMESYNC_FW_WC_COUNT_HI_SW_OFFSET_OFFSET; in prueth_iep_gettime()
1179 fw_hi_r_count_addr = prueth->shram.va + TIMESYNC_FW_WC_HI_ROLLOVER_COUNT_OFFSET; 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()
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()
1221 sc_desc.margin = cycletime - 1000; in prueth_iep_settime()
1225 sc_desc.CMP0_current = cycletime - 4; //Count from 0 to (cycle time)-4 in prueth_iep_settime()
1229 writeb(1, &sc_descp->request); in prueth_iep_settime()
1231 timeout = 5; /* fw should take 2-3 ms */ in prueth_iep_settime()
1232 while (timeout--) { in prueth_iep_settime()
1233 if (readb(&sc_descp->acknowledgment)) in prueth_iep_settime()
1239 dev_err(emac->prueth->dev, "settime timeout\n"); in prueth_iep_settime()
1257 ts.tv_sec = req->period.sec; in prueth_perout_enable()
1258 ts.tv_nsec = req->period.nsec; in prueth_perout_enable()
1263 return -ENXIO; in prueth_perout_enable()
1280 if (offset > IEP_DEFAULT_CYCLE_TIME_NS - 8) in prueth_perout_enable()
1281 offset = IEP_DEFAULT_CYCLE_TIME_NS - 8; in prueth_perout_enable()
1283 /* we're in shadow mode so need to set upper 32-bits */ in prueth_perout_enable()
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
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()
1321 struct device *dev = prueth->dev; in emac_ndo_open()
1326 if (!prueth->emacs_initialized) { in emac_ndo_open()
1327 memset_io(prueth->msmcram.va, 0, prueth->msmcram.size); in emac_ndo_open()
1328 memset_io(prueth->shram.va, 0, ICSSG_CONFIG_OFFSET_SLICE1 * PRUETH_NUM_MACS); in emac_ndo_open()
1331 /* set h/w MAC as user might have re-configured */ 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()
1337 icssg_class_default(prueth->miig_rt, slice, 0); in emac_ndo_open()
1346 init_completion(&emac->cmd_complete); in emac_ndo_open()
1354 ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", in emac_ndo_open()
1367 ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, in emac_ndo_open()
1379 icssg_mii_update_mtu(prueth->mii_rt, slice, ndev->max_mtu); in emac_ndo_open()
1381 if (!prueth->emacs_initialized) { in emac_ndo_open()
1382 ret = icss_iep_init(emac->iep, &prueth_iep_clockops, in emac_ndo_open()
1386 ret = request_threaded_irq(emac->tx_ts_irq, NULL, prueth_tx_ts_irq, 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()
1412 phy_start(ndev->phydev); in emac_ndo_open()
1414 prueth->emacs_initialized++; in emac_ndo_open()
1416 queue_work(system_long_wq, &emac->stats_work.work); 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()
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()
1444 * emac_ndo_stop - EMAC device stop
1454 struct prueth *prueth = emac->prueth; in emac_ndo_stop()
1463 if (ndev->phydev) in emac_ndo_stop()
1464 phy_stop(ndev->phydev); 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()
1500 if (prueth->emacs_initialized == 1) in emac_ndo_stop()
1501 icss_iep_exit(emac->iep); 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()
1512 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_stop()
1515 prueth->emacs_initialized--; in emac_ndo_stop()
1522 ndev->stats.tx_errors++; in emac_ndo_tx_timeout()
1528 struct net_device *ndev = emac->ndev; in emac_ndo_set_rx_mode_work()
1534 promisc = ndev->flags & IFF_PROMISC; in emac_ndo_set_rx_mode_work()
1535 allmulti = ndev->flags & IFF_ALLMULTI; in emac_ndo_set_rx_mode_work()
1557 * emac_ndo_set_rx_mode - EMAC set receive mode function
1567 queue_work(emac->cmd_wq, &emac->rx_mode_work); in emac_ndo_set_rx_mode()
1575 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in emac_set_ts_config()
1576 return -EFAULT; in emac_set_ts_config()
1580 emac->tx_ts_enabled = 0; in emac_set_ts_config()
1583 emac->tx_ts_enabled = 1; in emac_set_ts_config()
1586 return -ERANGE; 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()
1612 return -ERANGE; in emac_set_ts_config()
1615 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? in emac_set_ts_config()
1616 -EFAULT : 0; in emac_set_ts_config()
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()
1628 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? in emac_get_ts_config()
1629 -EFAULT : 0; in emac_get_ts_config()
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()
1661 stats->rx_errors = ndev->stats.rx_errors; in emac_ndo_get_stats64()
1662 stats->rx_dropped = ndev->stats.rx_dropped; in emac_ndo_get_stats64()
1663 stats->tx_errors = ndev->stats.tx_errors; in emac_ndo_get_stats64()
1664 stats->tx_dropped = ndev->stats.tx_dropped; in emac_ndo_get_stats64()
1727 return -EINVAL; in prueth_netdev_init()
1731 return -EINVAL; in prueth_netdev_init()
1735 return -ENOMEM; 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()
1743 ret = -ENOMEM; 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()
1750 ret = pruss_request_mem_region(prueth->pruss, in prueth_netdev_init()
1753 &emac->dram); in prueth_netdev_init()
1755 dev_err(prueth->dev, "unable to get DRAM: %d\n", ret); in prueth_netdev_init()
1756 ret = -ENOMEM; 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()
1771 SET_NETDEV_DEV(ndev, prueth->dev); 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()
1777 dev_err(prueth->dev, "couldn't find phy-handle\n"); in prueth_netdev_init()
1778 ret = -ENODEV; in prueth_netdev_init()
1783 ret = dev_err_probe(prueth->dev, ret, in prueth_netdev_init()
1784 "failed to register fixed-link phy\n"); 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()
1793 dev_err(prueth->dev, "could not get phy-mode property\n"); 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()
1800 ret = -EINVAL; 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()
1818 dev_err(prueth->dev, "RGMII mode without TX delay is not supported"); in prueth_netdev_init()
1819 ret = -EINVAL; in prueth_netdev_init()
1827 if (!is_valid_ether_addr(ndev->dev_addr)) { in prueth_netdev_init()
1829 dev_warn(prueth->dev, "port %d: using random MAC addr: %pM\n", in prueth_netdev_init()
1830 port, ndev->dev_addr); in prueth_netdev_init()
1832 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in prueth_netdev_init()
1834 ndev->min_mtu = PRUETH_MIN_PKT_SIZE; in prueth_netdev_init()
1835 ndev->max_mtu = PRUETH_MAX_MTU; in prueth_netdev_init()
1836 ndev->netdev_ops = &emac_netdev_ops; in prueth_netdev_init()
1837 ndev->ethtool_ops = &icssg_ethtool_ops; in prueth_netdev_init()
1838 ndev->hw_features = NETIF_F_SG; in prueth_netdev_init()
1839 ndev->features = ndev->hw_features; 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()
1868 emac = prueth->emac[mac]; 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()
1885 struct device *dev = prueth->dev; in prueth_get_cores()
1888 int idx = -1, ret; in prueth_get_cores()
1890 np = dev->of_node; in prueth_get_cores()
1900 return -EINVAL; in prueth_get_cores()
1903 prueth->pru[slice] = pru_rproc_get(np, idx, &pruss_id); in prueth_get_cores()
1904 if (IS_ERR(prueth->pru[slice])) { in prueth_get_cores()
1905 ret = PTR_ERR(prueth->pru[slice]); in prueth_get_cores()
1906 prueth->pru[slice] = NULL; in prueth_get_cores()
1909 prueth->pru_id[slice] = pruss_id; in prueth_get_cores()
1912 prueth->rtu[slice] = pru_rproc_get(np, idx, NULL); in prueth_get_cores()
1913 if (IS_ERR(prueth->rtu[slice])) { in prueth_get_cores()
1914 ret = PTR_ERR(prueth->rtu[slice]); in prueth_get_cores()
1915 prueth->rtu[slice] = NULL; in prueth_get_cores()
1920 prueth->txpru[slice] = pru_rproc_get(np, idx, NULL); in prueth_get_cores()
1921 if (IS_ERR(prueth->txpru[slice])) { in prueth_get_cores()
1922 ret = PTR_ERR(prueth->txpru[slice]); in prueth_get_cores()
1923 prueth->txpru[slice] = NULL; in prueth_get_cores()
1932 if (prueth->txpru[slice]) in prueth_put_cores()
1933 pru_rproc_put(prueth->txpru[slice]); in prueth_put_cores()
1935 if (prueth->rtu[slice]) in prueth_put_cores()
1936 pru_rproc_put(prueth->rtu[slice]); in prueth_put_cores()
1938 if (prueth->pru[slice]) in prueth_put_cores()
1939 pru_rproc_put(prueth->pru[slice]); in prueth_put_cores()
1953 struct device *dev = &pdev->dev; in prueth_probe()
1960 np = dev->of_node; in prueth_probe()
1964 return -ENODEV; in prueth_probe()
1968 return -ENOMEM; in prueth_probe()
1971 prueth->pdev = pdev; in prueth_probe()
1972 prueth->pdata = *(const struct prueth_pdata *)match->data; in prueth_probe()
1974 prueth->dev = dev; in prueth_probe()
1975 eth_ports_node = of_get_child_by_name(np, "ethernet-ports"); in prueth_probe()
1977 return -ENOENT; in prueth_probe()
1982 if (strcmp(eth_node->name, "port")) in prueth_probe()
2014 return -ENODEV; in prueth_probe()
2020 return -ENODEV; in prueth_probe()
2023 prueth->eth_node[PRUETH_MAC0] = eth0_node; in prueth_probe()
2024 prueth->eth_node[PRUETH_MAC1] = eth1_node; in prueth_probe()
2026 prueth->miig_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-g-rt"); in prueth_probe()
2027 if (IS_ERR(prueth->miig_rt)) { in prueth_probe()
2028 dev_err(dev, "couldn't get ti,mii-g-rt syscon regmap\n"); in prueth_probe()
2029 return -ENODEV; in prueth_probe()
2032 prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt"); in prueth_probe()
2033 if (IS_ERR(prueth->mii_rt)) { in prueth_probe()
2034 dev_err(dev, "couldn't get ti,mii-rt syscon regmap\n"); in prueth_probe()
2035 return -ENODEV; in prueth_probe()
2051 prueth->pru[ICSS_SLICE0] : prueth->pru[ICSS_SLICE1]); in prueth_probe()
2058 prueth->pruss = pruss; in prueth_probe()
2061 &prueth->shram); in prueth_probe()
2067 prueth->sram_pool = of_gen_pool_get(np, "sram", 0); in prueth_probe()
2068 if (!prueth->sram_pool) { in prueth_probe()
2070 ret = -ENODEV; in prueth_probe()
2078 prueth->msmcram.va = in prueth_probe()
2079 (void __iomem *)gen_pool_alloc_algo(prueth->sram_pool, in prueth_probe()
2084 if (!prueth->msmcram.va) { in prueth_probe()
2085 ret = -ENOMEM; in prueth_probe()
2089 prueth->msmcram.pa = gen_pool_virt_to_phys(prueth->sram_pool, in prueth_probe()
2090 (unsigned long)prueth->msmcram.va); in prueth_probe()
2091 prueth->msmcram.size = msmc_ram_size; in prueth_probe()
2092 memset_io(prueth->msmcram.va, 0, msmc_ram_size); in prueth_probe()
2093 dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa, in prueth_probe()
2094 prueth->msmcram.va, prueth->msmcram.size); in prueth_probe()
2096 prueth->iep0 = icss_iep_get_idx(np, 0); in prueth_probe()
2097 if (IS_ERR(prueth->iep0)) { in prueth_probe()
2098 ret = dev_err_probe(dev, PTR_ERR(prueth->iep0), "iep0 get failed\n"); in prueth_probe()
2099 prueth->iep0 = NULL; in prueth_probe()
2103 prueth->iep1 = icss_iep_get_idx(np, 1); in prueth_probe()
2104 if (IS_ERR(prueth->iep1)) { in prueth_probe()
2105 ret = dev_err_probe(dev, PTR_ERR(prueth->iep1), "iep1 get failed\n"); in prueth_probe()
2109 if (prueth->pdata.quirk_10m_link_issue) { in prueth_probe()
2113 icss_iep_init_fw(prueth->iep1); in prueth_probe()
2121 eth0_node->name); in prueth_probe()
2124 prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; in prueth_probe()
2131 eth1_node->name); 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()
2151 "can't connect to MII0 PHY, error -%d", ret); 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()
2185 if (!prueth->registered_netdevs[i]) 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()
2191 unregister_netdev(prueth->registered_netdevs[i]); in prueth_probe()
2196 eth_node = prueth->eth_node[i]; in prueth_probe()
2204 if (prueth->pdata.quirk_10m_link_issue) in prueth_probe()
2205 icss_iep_exit_fw(prueth->iep1); in prueth_probe()
2206 icss_iep_put(prueth->iep1); in prueth_probe()
2209 icss_iep_put(prueth->iep0); in prueth_probe()
2210 prueth->iep0 = NULL; in prueth_probe()
2211 prueth->iep1 = NULL; in prueth_probe()
2214 gen_pool_free(prueth->sram_pool, in prueth_probe()
2215 (unsigned long)prueth->msmcram.va, msmc_ram_size); in prueth_probe()
2218 pruss_release_mem_region(prueth->pruss, &prueth->shram); in prueth_probe()
2221 pruss_put(prueth->pruss); in prueth_probe()
2244 if (!prueth->registered_netdevs[i]) in prueth_remove()
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()
2249 unregister_netdev(prueth->registered_netdevs[i]); in prueth_remove()
2253 eth_node = prueth->eth_node[i]; in prueth_remove()
2260 if (prueth->pdata.quirk_10m_link_issue) in prueth_remove()
2261 icss_iep_exit_fw(prueth->iep1); in prueth_remove()
2263 icss_iep_put(prueth->iep1); in prueth_remove()
2264 icss_iep_put(prueth->iep0); in prueth_remove()
2266 gen_pool_free(prueth->sram_pool, in prueth_remove()
2267 (unsigned long)prueth->msmcram.va, in prueth_remove()
2270 pruss_release_mem_region(prueth->pruss, &prueth->shram); in prueth_remove()
2272 pruss_put(prueth->pruss); in prueth_remove()
2274 if (prueth->eth_node[PRUETH_MAC1]) in prueth_remove()
2277 if (prueth->eth_node[PRUETH_MAC0]) in prueth_remove()
2289 ndev = prueth->registered_netdevs[i]; in prueth_suspend()
2314 ndev = prueth->registered_netdevs[i]; in prueth_resume()
2343 { .compatible = "ti,am654-icssg-prueth", .data = &am654_icssg_pdata },
2352 .name = "icssg-prueth",