Lines Matching full:emac
61 static void prueth_cleanup_rx_chns(struct prueth_emac *emac, in prueth_cleanup_rx_chns() argument
72 static void prueth_cleanup_tx_chns(struct prueth_emac *emac) in prueth_cleanup_tx_chns() argument
76 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_cleanup_tx_chns()
77 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_cleanup_tx_chns()
92 static void prueth_ndev_del_tx_napi(struct prueth_emac *emac, int num) in prueth_ndev_del_tx_napi() argument
97 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_ndev_del_tx_napi()
141 static int emac_tx_complete_packets(struct prueth_emac *emac, int chn, in emac_tx_complete_packets() argument
144 struct net_device *ndev = emac->ndev; in emac_tx_complete_packets()
154 tx_chn = &emac->tx_chns[chn]; in emac_tx_complete_packets()
163 if (atomic_dec_and_test(&emac->tdown_cnt)) in emac_tx_complete_packets()
164 complete(&emac->tdown_complete); in emac_tx_complete_packets()
207 struct prueth_emac *emac = tx_chn->emac; in emac_napi_tx_poll() local
210 num_tx_packets = emac_tx_complete_packets(emac, tx_chn->id, budget); in emac_napi_tx_poll()
231 static int prueth_ndev_add_tx_napi(struct prueth_emac *emac) in prueth_ndev_add_tx_napi() argument
233 struct prueth *prueth = emac->prueth; in prueth_ndev_add_tx_napi()
236 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_ndev_add_tx_napi()
237 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_ndev_add_tx_napi()
239 netif_napi_add_tx(emac->ndev, &tx_chn->napi_tx, emac_napi_tx_poll); in prueth_ndev_add_tx_napi()
253 prueth_ndev_del_tx_napi(emac, i); in prueth_ndev_add_tx_napi()
257 static int prueth_init_tx_chns(struct prueth_emac *emac) in prueth_init_tx_chns() argument
266 struct device *dev = emac->prueth->dev; in prueth_init_tx_chns()
267 struct net_device *ndev = emac->ndev; in prueth_init_tx_chns()
271 slice = prueth_emac_slice(emac); in prueth_init_tx_chns()
275 init_completion(&emac->tdown_complete); in prueth_init_tx_chns()
284 for (i = 0; i < emac->tx_ch_num; i++) { in prueth_init_tx_chns()
285 struct prueth_tx_chn *tx_chn = &emac->tx_chns[i]; in prueth_init_tx_chns()
291 tx_chn->emac = emac; in prueth_init_tx_chns()
333 prueth_cleanup_tx_chns(emac); in prueth_init_tx_chns()
337 static int prueth_init_rx_chns(struct prueth_emac *emac, in prueth_init_rx_chns() argument
343 struct device *dev = emac->prueth->dev; in prueth_init_rx_chns()
344 struct net_device *ndev = emac->ndev; in prueth_init_rx_chns()
348 slice = prueth_emac_slice(emac); in prueth_init_rx_chns()
387 emac->rx_flow_id_base = k3_udma_glue_rx_get_flow_id_base(rx_chn->rx_chn); in prueth_init_rx_chns()
388 netdev_dbg(ndev, "flow id base = %d\n", emac->rx_flow_id_base); in prueth_init_rx_chns()
412 rx_flow_cfg.rxfdq_cfg.mode = emac->prueth->pdata.fdqring_mode; in prueth_init_rx_chns()
435 prueth_cleanup_rx_chns(emac, rx_chn, max_rflows); in prueth_init_rx_chns()
439 static int prueth_dma_rx_push(struct prueth_emac *emac, in prueth_dma_rx_push() argument
443 struct net_device *ndev = emac->ndev; in prueth_dma_rx_push()
491 static void emac_rx_timestamp(struct prueth_emac *emac, in emac_rx_timestamp() argument
497 u32 hi_sw = readl(emac->prueth->shram.va + in emac_rx_timestamp()
507 static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id) in emac_rx_packet() argument
509 struct prueth_rx_chn *rx_chn = &emac->rx_chns; in emac_rx_packet()
511 struct net_device *ndev = emac->ndev; in emac_rx_packet()
536 if (emac->rx_ts_enabled) in emac_rx_packet()
537 emac_rx_timestamp(emac, skb, psdata); in emac_rx_packet()
561 napi_gro_receive(&emac->napi_rx, skb); in emac_rx_packet()
567 ret = prueth_dma_rx_push(emac, new_skb, &emac->rx_chns); in emac_rx_packet()
599 static int emac_get_tx_ts(struct prueth_emac *emac, in emac_get_tx_ts() argument
602 struct prueth *prueth = emac->prueth; in emac_get_tx_ts()
603 int slice = prueth_emac_slice(emac); in emac_get_tx_ts()
619 static void tx_ts_work(struct prueth_emac *emac) in tx_ts_work() argument
630 ret = emac_get_tx_ts(emac, &tsr); in tx_ts_work()
635 !emac->tx_ts_skb[tsr.cookie]) { in tx_ts_work()
636 netdev_err(emac->ndev, "Invalid TX TS cookie 0x%x\n", in tx_ts_work()
641 skb = emac->tx_ts_skb[tsr.cookie]; in tx_ts_work()
642 emac->tx_ts_skb[tsr.cookie] = NULL; /* free slot */ in tx_ts_work()
644 netdev_err(emac->ndev, "Driver Bug! got NULL skb\n"); in tx_ts_work()
648 hi_sw = readl(emac->prueth->shram.va + in tx_ts_work()
659 if (atomic_dec_and_test(&emac->tx_ts_pending)) /* no more? */ in tx_ts_work()
664 static int prueth_tx_ts_cookie_get(struct prueth_emac *emac) in prueth_tx_ts_cookie_get() argument
670 if (!emac->tx_ts_skb[i]) { in prueth_tx_ts_cookie_get()
671 emac->tx_ts_skb[i] = ERR_PTR(-EBUSY); /* reserve slot */ in prueth_tx_ts_cookie_get()
680 * emac_ndo_start_xmit - EMAC Transmit function
682 * @ndev: EMAC network adapter
685 * EMAC hardware transmit queue
694 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_start_xmit() local
708 tx_chn = &emac->tx_chns[q_idx]; in emac_ndo_start_xmit()
733 emac->tx_ts_enabled) { in emac_ndo_start_xmit()
734 tx_ts_cookie = prueth_tx_ts_cookie_get(emac); in emac_ndo_start_xmit()
740 emac->tx_ts_skb[tx_ts_cookie] = skb_get(skb); in emac_ndo_start_xmit()
749 cppi5_desc_set_tags_ids(&first_desc->hdr, 0, (emac->port_id | (q_idx << 8))); in emac_ndo_start_xmit()
807 atomic_inc(&emac->tx_ts_pending); in emac_ndo_start_xmit()
823 dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); in emac_ndo_start_xmit()
824 emac->tx_ts_skb[tx_ts_cookie] = NULL; in emac_ndo_start_xmit()
841 dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); in emac_ndo_start_xmit()
842 emac->tx_ts_skb[tx_ts_cookie] = NULL; in emac_ndo_start_xmit()
868 struct prueth_emac *emac = dev_id; in prueth_tx_ts_irq() local
871 tx_ts_work(emac); in prueth_tx_ts_irq()
878 struct prueth_emac *emac = dev_id; in prueth_rx_irq() local
881 napi_schedule(&emac->napi_rx); in prueth_rx_irq()
905 static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac) in prueth_emac_start() argument
913 slice = prueth_emac_slice(emac); in prueth_emac_start()
915 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_start()
919 ret = icssg_config(prueth, emac, slice); in prueth_emac_start()
944 emac->fw_running = 1; in prueth_emac_start()
956 static void prueth_emac_stop(struct prueth_emac *emac) in prueth_emac_stop() argument
958 struct prueth *prueth = emac->prueth; in prueth_emac_stop()
961 switch (emac->port_id) { in prueth_emac_stop()
969 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_stop()
973 emac->fw_running = 0; in prueth_emac_stop()
979 static void prueth_cleanup_tx_ts(struct prueth_emac *emac) in prueth_cleanup_tx_ts() argument
984 if (emac->tx_ts_skb[i]) { in prueth_cleanup_tx_ts()
985 dev_kfree_skb_any(emac->tx_ts_skb[i]); in prueth_cleanup_tx_ts()
986 emac->tx_ts_skb[i] = NULL; in prueth_cleanup_tx_ts()
994 struct prueth_emac *emac = netdev_priv(ndev); in emac_adjust_link() local
996 struct prueth *prueth = emac->prueth; in emac_adjust_link()
1002 if (phydev->duplex != emac->duplex) { in emac_adjust_link()
1004 emac->duplex = phydev->duplex; in emac_adjust_link()
1006 if (phydev->speed != emac->speed) { in emac_adjust_link()
1008 emac->speed = phydev->speed; in emac_adjust_link()
1010 if (!emac->link) { in emac_adjust_link()
1012 emac->link = 1; in emac_adjust_link()
1014 } else if (emac->link) { in emac_adjust_link()
1016 emac->link = 0; in emac_adjust_link()
1019 emac->speed = SPEED_1000; in emac_adjust_link()
1022 emac->duplex = DUPLEX_FULL; in emac_adjust_link()
1031 if (emac->link) { in emac_adjust_link()
1032 if (emac->duplex == DUPLEX_HALF) in emac_adjust_link()
1033 icssg_config_half_duplex(emac); in emac_adjust_link()
1035 icssg_update_rgmii_cfg(prueth->miig_rt, emac); in emac_adjust_link()
1038 spin_lock_irqsave(&emac->lock, flags); in emac_adjust_link()
1039 icssg_config_ipg(emac); in emac_adjust_link()
1040 spin_unlock_irqrestore(&emac->lock, flags); in emac_adjust_link()
1041 icssg_config_set_speed(emac); in emac_adjust_link()
1042 emac_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD); in emac_adjust_link()
1045 emac_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); in emac_adjust_link()
1049 if (emac->link) { in emac_adjust_link()
1054 prueth_cleanup_tx_ts(emac); in emac_adjust_link()
1060 struct prueth_emac *emac = prueth_napi_to_emac(napi_rx); in emac_napi_rx_poll() local
1071 ret = emac_rx_packet(emac, flow); in emac_napi_rx_poll()
1082 enable_irq(emac->rx_chns.irq[rx_flow]); in emac_napi_rx_poll()
1087 static int prueth_prepare_rx_chan(struct prueth_emac *emac, in prueth_prepare_rx_chan() argument
1099 ret = prueth_dma_rx_push(emac, skb, chn); in prueth_prepare_rx_chan()
1101 netdev_err(emac->ndev, in prueth_prepare_rx_chan()
1112 static void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num, in prueth_reset_tx_chan() argument
1119 k3_udma_glue_reset_tx_chn(emac->tx_chns[i].tx_chn, in prueth_reset_tx_chan()
1120 &emac->tx_chns[i], in prueth_reset_tx_chan()
1122 k3_udma_glue_disable_tx_chn(emac->tx_chns[i].tx_chn); in prueth_reset_tx_chan()
1138 static int emac_phy_connect(struct prueth_emac *emac) in emac_phy_connect() argument
1140 struct prueth *prueth = emac->prueth; in emac_phy_connect()
1141 struct net_device *ndev = emac->ndev; in emac_phy_connect()
1143 ndev->phydev = of_phy_connect(emac->ndev, emac->phy_node, in emac_phy_connect()
1145 emac->phy_if); in emac_phy_connect()
1148 emac->phy_node->full_name); in emac_phy_connect()
1152 if (!emac->half_duplex) { in emac_phy_connect()
1163 if (emac->phy_if == PHY_INTERFACE_MODE_MII) in emac_phy_connect()
1172 struct prueth_emac *emac = clockops_data; in prueth_iep_gettime() local
1173 struct prueth *prueth = emac->prueth; in prueth_iep_gettime()
1186 iepcount_hi = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
1190 iepcount_lo = icss_iep_get_count_low(emac->iep); in prueth_iep_gettime()
1193 iepcount_hi_r = icss_iep_get_count_hi(emac->iep); in prueth_iep_gettime()
1209 struct prueth_emac *emac = clockops_data; in prueth_iep_settime() local
1215 if (!emac->fw_running) in prueth_iep_settime()
1218 sc_descp = emac->prueth->shram.va + TIMESYNC_FW_WC_SETCLOCK_DESC_OFFSET; in prueth_iep_settime()
1242 dev_err(emac->prueth->dev, "settime timeout\n"); in prueth_iep_settime()
1249 struct prueth_emac *emac = clockops_data; in prueth_perout_enable() local
1287 writel(reduction_factor, emac->prueth->shram.va + in prueth_perout_enable()
1290 writel(0, emac->prueth->shram.va + in prueth_perout_enable()
1303 * emac_ndo_open - EMAC device open
1312 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_open() local
1313 int ret, i, num_data_chn = emac->tx_ch_num; in emac_ndo_open()
1314 struct prueth *prueth = emac->prueth; in emac_ndo_open()
1315 int slice = prueth_emac_slice(emac); in emac_ndo_open()
1327 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in emac_ndo_open()
1329 icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
1330 icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
1341 init_completion(&emac->cmd_complete); in emac_ndo_open()
1342 ret = prueth_init_tx_chns(emac); in emac_ndo_open()
1349 ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", in emac_ndo_open()
1356 ret = prueth_ndev_add_tx_napi(emac); in emac_ndo_open()
1362 ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, in emac_ndo_open()
1363 IRQF_TRIGGER_HIGH, dev_name(dev), emac); in emac_ndo_open()
1370 ret = prueth_emac_start(prueth, emac); in emac_ndo_open()
1377 ret = icss_iep_init(emac->iep, &prueth_iep_clockops, in emac_ndo_open()
1378 emac, IEP_DEFAULT_CYCLE_TIME_NS); in emac_ndo_open()
1381 ret = request_threaded_irq(emac->tx_ts_irq, NULL, prueth_tx_ts_irq, in emac_ndo_open()
1382 IRQF_ONESHOT, dev_name(dev), emac); in emac_ndo_open()
1387 ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE); in emac_ndo_open()
1391 ret = k3_udma_glue_enable_rx_chn(emac->rx_chns.rx_chn); in emac_ndo_open()
1395 for (i = 0; i < emac->tx_ch_num; i++) { in emac_ndo_open()
1396 ret = k3_udma_glue_enable_tx_chn(emac->tx_chns[i].tx_chn); in emac_ndo_open()
1402 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_open()
1403 napi_enable(&emac->tx_chns[i].napi_tx); in emac_ndo_open()
1404 napi_enable(&emac->napi_rx); in emac_ndo_open()
1411 queue_work(system_long_wq, &emac->stats_work.work); in emac_ndo_open()
1419 prueth_reset_tx_chan(emac, i, false); in emac_ndo_open()
1421 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, false); in emac_ndo_open()
1423 free_irq(emac->tx_ts_irq, emac); in emac_ndo_open()
1425 prueth_emac_stop(emac); in emac_ndo_open()
1427 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_open()
1429 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_open()
1431 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_open()
1433 prueth_cleanup_tx_chns(emac); in emac_ndo_open()
1439 * emac_ndo_stop - EMAC device stop
1448 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_stop() local
1449 struct prueth *prueth = emac->prueth; in emac_ndo_stop()
1461 icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac)); in emac_ndo_stop()
1463 atomic_set(&emac->tdown_cnt, emac->tx_ch_num); in emac_ndo_stop()
1467 reinit_completion(&emac->tdown_complete); in emac_ndo_stop()
1468 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
1469 k3_udma_glue_tdown_tx_chn(emac->tx_chns[i].tx_chn, false); in emac_ndo_stop()
1471 ret = wait_for_completion_timeout(&emac->tdown_complete, in emac_ndo_stop()
1476 prueth_reset_tx_chan(emac, emac->tx_ch_num, true); in emac_ndo_stop()
1477 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
1478 napi_disable(&emac->tx_chns[i].napi_tx); in emac_ndo_stop()
1481 k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true); in emac_ndo_stop()
1483 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true); in emac_ndo_stop()
1485 napi_disable(&emac->napi_rx); in emac_ndo_stop()
1487 cancel_work_sync(&emac->rx_mode_work); in emac_ndo_stop()
1490 cancel_delayed_work_sync(&emac->stats_work); in emac_ndo_stop()
1493 prueth_emac_stop(emac); in emac_ndo_stop()
1496 icss_iep_exit(emac->iep); in emac_ndo_stop()
1499 prueth_emac_stop(emac); in emac_ndo_stop()
1501 free_irq(emac->tx_ts_irq, emac); in emac_ndo_stop()
1503 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_stop()
1504 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_stop()
1505 prueth_cleanup_tx_chns(emac); in emac_ndo_stop()
1507 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_stop()
1508 prueth_cleanup_tx_chns(emac); in emac_ndo_stop()
1522 struct prueth_emac *emac = container_of(work, struct prueth_emac, rx_mode_work); in emac_ndo_set_rx_mode_work() local
1523 struct net_device *ndev = emac->ndev; in emac_ndo_set_rx_mode_work()
1531 emac_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
1532 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE); in emac_ndo_set_rx_mode_work()
1535 emac_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); in emac_ndo_set_rx_mode_work()
1536 emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_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()
1552 * emac_ndo_set_rx_mode - EMAC set receive mode function
1553 * @ndev: The EMAC network adapter
1560 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_set_rx_mode() local
1562 queue_work(emac->cmd_wq, &emac->rx_mode_work); in emac_ndo_set_rx_mode()
1567 struct prueth_emac *emac = netdev_priv(ndev); in emac_set_ts_config() local
1575 emac->tx_ts_enabled = 0; in emac_set_ts_config()
1578 emac->tx_ts_enabled = 1; in emac_set_ts_config()
1586 emac->rx_ts_enabled = 0; in emac_set_ts_config()
1603 emac->rx_ts_enabled = 1; in emac_set_ts_config()
1616 struct prueth_emac *emac = netdev_priv(ndev); in emac_get_ts_config() local
1620 config.tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in emac_get_ts_config()
1621 config.rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE; in emac_get_ts_config()
1644 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_get_stats64() local
1646 emac_update_hardware_stats(emac); in emac_ndo_get_stats64()
1648 stats->rx_packets = emac_get_stat_by_name(emac, "rx_packets"); in emac_ndo_get_stats64()
1649 stats->rx_bytes = emac_get_stat_by_name(emac, "rx_bytes"); in emac_ndo_get_stats64()
1650 stats->tx_packets = emac_get_stat_by_name(emac, "tx_packets"); in emac_ndo_get_stats64()
1651 stats->tx_bytes = emac_get_stat_by_name(emac, "tx_bytes"); in emac_ndo_get_stats64()
1652 stats->rx_crc_errors = emac_get_stat_by_name(emac, "rx_crc_errors"); in emac_ndo_get_stats64()
1653 stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors"); in emac_ndo_get_stats64()
1654 stats->multicast = emac_get_stat_by_name(emac, "rx_multicast_frames"); in emac_ndo_get_stats64()
1665 struct prueth_emac *emac = netdev_priv(ndev); in emac_ndo_get_phys_port_name() local
1668 ret = snprintf(name, len, "p%d", emac->port_id); in emac_ndo_get_phys_port_name()
1728 struct prueth_emac *emac; in prueth_netdev_init() local
1742 ndev = alloc_etherdev_mq(sizeof(*emac), num_tx_chn); in prueth_netdev_init()
1746 emac = netdev_priv(ndev); in prueth_netdev_init()
1747 emac->prueth = prueth; in prueth_netdev_init()
1748 emac->ndev = ndev; in prueth_netdev_init()
1749 emac->port_id = port; in prueth_netdev_init()
1750 emac->cmd_wq = create_singlethread_workqueue("icssg_cmd_wq"); in prueth_netdev_init()
1751 if (!emac->cmd_wq) { in prueth_netdev_init()
1755 INIT_WORK(&emac->rx_mode_work, emac_ndo_set_rx_mode_work); in prueth_netdev_init()
1757 INIT_DELAYED_WORK(&emac->stats_work, emac_stats_work_handler); in prueth_netdev_init()
1762 &emac->dram); in prueth_netdev_init()
1769 emac->tx_ch_num = 1; in prueth_netdev_init()
1772 if (emac->port_id == PRUETH_PORT_MII1) in prueth_netdev_init()
1774 emac->tx_ts_irq = platform_get_irq_byname_optional(prueth->pdev, irq_name); in prueth_netdev_init()
1775 if (emac->tx_ts_irq < 0) { in prueth_netdev_init()
1776 ret = dev_err_probe(prueth->dev, emac->tx_ts_irq, "could not get tx_ts_irq\n"); in prueth_netdev_init()
1781 spin_lock_init(&emac->lock); in prueth_netdev_init()
1782 mutex_init(&emac->cmd_lock); in prueth_netdev_init()
1784 emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0); in prueth_netdev_init()
1785 if (!emac->phy_node && !of_phy_is_fixed_link(eth_node)) { in prueth_netdev_init()
1797 emac->phy_node = eth_node; in prueth_netdev_init()
1800 ret = of_get_phy_mode(eth_node, &emac->phy_if); in prueth_netdev_init()
1806 if (emac->phy_if != PHY_INTERFACE_MODE_MII && in prueth_netdev_init()
1807 !phy_interface_mode_is_rgmii(emac->phy_if)) { in prueth_netdev_init()
1808 dev_err(prueth->dev, "PHY mode unsupported %s\n", phy_modes(emac->phy_if)); in prueth_netdev_init()
1818 switch (emac->phy_if) { in prueth_netdev_init()
1820 emac->phy_if = PHY_INTERFACE_MODE_RGMII_RXID; in prueth_netdev_init()
1823 emac->phy_if = PHY_INTERFACE_MODE_RGMII; in prueth_netdev_init()
1841 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in prueth_netdev_init()
1850 netif_napi_add(ndev, &emac->napi_rx, emac_napi_rx_poll); in prueth_netdev_init()
1851 prueth->emac[mac] = emac; in prueth_netdev_init()
1856 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_init()
1858 destroy_workqueue(emac->cmd_wq); in prueth_netdev_init()
1860 emac->ndev = NULL; in prueth_netdev_init()
1861 prueth->emac[mac] = NULL; in prueth_netdev_init()
1870 struct prueth_emac *emac; in prueth_netdev_exit() local
1877 emac = prueth->emac[mac]; in prueth_netdev_exit()
1878 if (!emac) in prueth_netdev_exit()
1881 if (of_phy_is_fixed_link(emac->phy_node)) in prueth_netdev_exit()
1882 of_phy_deregister_fixed_link(emac->phy_node); in prueth_netdev_exit()
1884 netif_napi_del(&emac->napi_rx); in prueth_netdev_exit()
1886 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_exit()
1887 destroy_workqueue(emac->cmd_wq); in prueth_netdev_exit()
1888 free_netdev(emac->ndev); in prueth_netdev_exit()
1889 prueth->emac[mac] = NULL; in prueth_netdev_exit()
2128 prueth->emac[PRUETH_MAC0]->half_duplex = 1; in prueth_probe()
2130 prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; in prueth_probe()
2142 prueth->emac[PRUETH_MAC1]->half_duplex = 1; in prueth_probe()
2144 prueth->emac[PRUETH_MAC1]->iep = prueth->iep0; in prueth_probe()
2149 ret = register_netdev(prueth->emac[PRUETH_MAC0]->ndev); in prueth_probe()
2155 prueth->registered_netdevs[PRUETH_MAC0] = prueth->emac[PRUETH_MAC0]->ndev; in prueth_probe()
2157 emac_phy_connect(prueth->emac[PRUETH_MAC0]); in prueth_probe()
2158 phy_attached_info(prueth->emac[PRUETH_MAC0]->ndev->phydev); in prueth_probe()
2162 ret = register_netdev(prueth->emac[PRUETH_MAC1]->ndev); in prueth_probe()
2168 prueth->registered_netdevs[PRUETH_MAC1] = prueth->emac[PRUETH_MAC1]->ndev; in prueth_probe()
2169 emac_phy_connect(prueth->emac[PRUETH_MAC1]); in prueth_probe()
2170 phy_attached_info(prueth->emac[PRUETH_MAC1]->ndev->phydev); in prueth_probe()
2173 dev_info(dev, "TI PRU ethernet driver initialized: %s EMAC mode\n", in prueth_probe()
2186 if (prueth->emac[i]->ndev->phydev) { in prueth_probe()
2187 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_probe()
2188 prueth->emac[i]->ndev->phydev = NULL; in prueth_probe()
2245 phy_stop(prueth->emac[i]->ndev->phydev); in prueth_remove()
2246 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_remove()
2247 prueth->emac[i]->ndev->phydev = NULL; in prueth_remove()