Lines Matching +full:ti +full:- +full:pruss
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
21 #include <linux/remoteproc/pruss.h>
26 #include "../k3-cppi-desc-pool.h"
28 #define PRUETH_MODULE_DESCRIPTION "PRUSS ICSSG SR1.0 Ethernet driver"
34 * situation. So use Q0-Q2 as data queues and Q3 as management queue
62 config.addr_lo = cpu_to_le32(lower_32_bits(prueth->msmcram.pa)); in icssg_config_sr1()
63 config.addr_hi = cpu_to_le32(upper_32_bits(prueth->msmcram.pa)); in icssg_config_sr1()
64 config.rx_flow_id = cpu_to_le32(emac->rx_flow_id_base); /* flow id for host port */ in icssg_config_sr1()
65 config.rx_mgr_flow_id = cpu_to_le32(emac->rx_mgm_flow_id_base); /* for mgm ch */ in icssg_config_sr1()
69 index = i - PRUETH_EMAC_BUF_POOL_START_SR1; in icssg_config_sr1()
73 va = prueth->shram.va + slice * ICSSG_CONFIG_OFFSET_SLICE1; in icssg_config_sr1()
76 emac->speed = SPEED_1000; in icssg_config_sr1()
77 emac->duplex = DUPLEX_FULL; in icssg_config_sr1()
83 u32 pkt_len = sizeof(emac->cmd_data); in emac_send_command_sr1()
84 __le32 *data = emac->cmd_data; in emac_send_command_sr1()
91 netdev_dbg(emac->ndev, "Sending cmd %x\n", cmd); in emac_send_command_sr1()
94 mutex_lock(&emac->cmd_lock); in emac_send_command_sr1()
98 tx_chn = &emac->tx_chns[emac->tx_ch_num - 1]; in emac_send_command_sr1()
101 buf_dma = dma_map_single(tx_chn->dma_dev, data, pkt_len, DMA_TO_DEVICE); in emac_send_command_sr1()
102 if (dma_mapping_error(tx_chn->dma_dev, buf_dma)) { in emac_send_command_sr1()
103 netdev_err(emac->ndev, "cmd %x: failed to map cmd buffer\n", cmd); in emac_send_command_sr1()
104 ret = -EINVAL; in emac_send_command_sr1()
108 first_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool); in emac_send_command_sr1()
110 netdev_err(emac->ndev, "cmd %x: failed to allocate descriptor\n", cmd); in emac_send_command_sr1()
111 dma_unmap_single(tx_chn->dma_dev, buf_dma, pkt_len, DMA_TO_DEVICE); in emac_send_command_sr1()
112 ret = -ENOMEM; in emac_send_command_sr1()
119 epib = first_desc->epib; in emac_send_command_sr1()
128 desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); in emac_send_command_sr1()
131 reinit_completion(&emac->cmd_complete); in emac_send_command_sr1()
132 ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); in emac_send_command_sr1()
134 netdev_err(emac->ndev, "cmd %x: push failed: %d\n", cmd, ret); in emac_send_command_sr1()
137 ret = wait_for_completion_timeout(&emac->cmd_complete, msecs_to_jiffies(100)); in emac_send_command_sr1()
139 netdev_err(emac->ndev, "cmd %x: completion timeout\n", cmd); in emac_send_command_sr1()
141 mutex_unlock(&emac->cmd_lock); in emac_send_command_sr1()
147 mutex_unlock(&emac->cmd_lock); in emac_send_command_sr1()
155 struct prueth *prueth = emac->prueth; in icssg_config_set_speed_sr1()
158 val = icssg_rgmii_get_speed(prueth->miig_rt, slice); in icssg_config_set_speed_sr1()
159 /* firmware expects speed settings in bit 2-1 */ in icssg_config_set_speed_sr1()
163 val = icssg_rgmii_get_fullduplex(prueth->miig_rt, slice); in icssg_config_set_speed_sr1()
175 struct phy_device *phydev = ndev->phydev; in emac_adjust_link_sr1()
176 struct prueth *prueth = emac->prueth; in emac_adjust_link_sr1()
180 if (phydev->link) { in emac_adjust_link_sr1()
181 /* check the mode of operation - full/half duplex */ in emac_adjust_link_sr1()
182 if (phydev->duplex != emac->duplex) { in emac_adjust_link_sr1()
184 emac->duplex = phydev->duplex; in emac_adjust_link_sr1()
186 if (phydev->speed != emac->speed) { in emac_adjust_link_sr1()
188 emac->speed = phydev->speed; in emac_adjust_link_sr1()
190 if (!emac->link) { in emac_adjust_link_sr1()
192 emac->link = 1; in emac_adjust_link_sr1()
194 } else if (emac->link) { in emac_adjust_link_sr1()
196 emac->link = 0; in emac_adjust_link_sr1()
199 emac->speed = SPEED_1000; in emac_adjust_link_sr1()
202 emac->duplex = DUPLEX_FULL; in emac_adjust_link_sr1()
211 if (emac->link) { in emac_adjust_link_sr1()
213 icssg_update_rgmii_cfg(prueth->miig_rt, emac); in emac_adjust_link_sr1()
216 spin_lock_irqsave(&emac->lock, flags); in emac_adjust_link_sr1()
218 spin_unlock_irqrestore(&emac->lock, flags); in emac_adjust_link_sr1()
223 if (emac->link) { in emac_adjust_link_sr1()
234 struct prueth *prueth = emac->prueth; in emac_phy_connect()
235 struct net_device *ndev = emac->ndev; in emac_phy_connect()
237 ndev->phydev = of_phy_connect(emac->ndev, emac->phy_node, in emac_phy_connect()
239 emac->phy_if); in emac_phy_connect()
240 if (!ndev->phydev) { in emac_phy_connect()
241 dev_err(prueth->dev, "couldn't connect to phy %s\n", in emac_phy_connect()
242 emac->phy_node->full_name); in emac_phy_connect()
243 return -ENODEV; in emac_phy_connect()
246 if (!emac->half_duplex) { in emac_phy_connect()
247 dev_dbg(prueth->dev, "half duplex mode is not supported\n"); in emac_phy_connect()
248 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT); in emac_phy_connect()
251 /* Remove 100Mbits half-duplex due to RGMII misreporting connection in emac_phy_connect()
253 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT); in emac_phy_connect()
256 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT); in emac_phy_connect()
257 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_Pause_BIT); in emac_phy_connect()
258 phy_remove_link_mode(ndev->phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT); in emac_phy_connect()
260 if (emac->phy_if == PHY_INTERFACE_MODE_MII) in emac_phy_connect()
261 phy_set_max_speed(ndev->phydev, SPEED_100); in emac_phy_connect()
274 struct prueth_rx_chn *rx_chn = &emac->rx_mgm_chn; in prueth_process_rx_mgm()
275 struct net_device *ndev = emac->ndev; in prueth_process_rx_mgm()
283 ret = k3_udma_glue_pop_rx_chn(rx_chn->rx_chn, flow_id, &desc_dma); in prueth_process_rx_mgm()
285 if (ret != -ENODATA) in prueth_process_rx_mgm()
293 desc_rx = k3_cppi_desc_pool_dma2virt(rx_chn->desc_pool, desc_dma); in prueth_process_rx_mgm()
306 dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, DMA_FROM_DEVICE); in prueth_process_rx_mgm()
307 k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx); in prueth_process_rx_mgm()
325 ret = prueth_dma_rx_push(emac, new_skb, &emac->rx_mgm_chn); in prueth_process_rx_mgm()
340 hi_ts = le32_to_cpu(tsr->hi_ts); in prueth_tx_ts_sr1()
341 lo_ts = le32_to_cpu(tsr->lo_ts); in prueth_tx_ts_sr1()
345 cookie = le32_to_cpu(tsr->cookie); in prueth_tx_ts_sr1()
347 netdev_dbg(emac->ndev, "Invalid TX TS cookie 0x%x\n", in prueth_tx_ts_sr1()
352 skb = emac->tx_ts_skb[cookie]; in prueth_tx_ts_sr1()
353 emac->tx_ts_skb[cookie] = NULL; /* free slot */ in prueth_tx_ts_sr1()
371 prueth_tx_ts_sr1(emac, (void *)skb->data); in prueth_rx_mgm_ts_thread_sr1()
388 rsp = le32_to_cpu(*(__le32 *)skb->data) & 0xffff0000; in prueth_rx_mgm_rsp_thread()
390 netdev_dbg(emac->ndev, "f/w Shutdown cmd resp %x\n", rsp); in prueth_rx_mgm_rsp_thread()
391 complete(&emac->cmd_complete); in prueth_rx_mgm_rsp_thread()
393 netdev_dbg(emac->ndev, "f/w Speed/Duplex cmd rsp %x\n", rsp); in prueth_rx_mgm_rsp_thread()
394 complete(&emac->cmd_complete); in prueth_rx_mgm_rsp_thread()
404 .pru = "ti-pruss/am65x-pru0-prueth-fw.elf",
405 .rtu = "ti-pruss/am65x-rtu0-prueth-fw.elf",
408 .pru = "ti-pruss/am65x-pru1-prueth-fw.elf",
409 .rtu = "ti-pruss/am65x-rtu1-prueth-fw.elf",
416 struct device *dev = prueth->dev; in prueth_emac_start()
423 netdev_err(emac->ndev, "invalid port\n"); in prueth_emac_start()
424 return -EINVAL; in prueth_emac_start()
429 ret = rproc_set_firmware(prueth->pru[slice], firmwares[slice].pru); in prueth_emac_start()
430 ret = rproc_boot(prueth->pru[slice]); in prueth_emac_start()
433 return -EINVAL; in prueth_emac_start()
436 ret = rproc_set_firmware(prueth->rtu[slice], firmwares[slice].rtu); in prueth_emac_start()
437 ret = rproc_boot(prueth->rtu[slice]); in prueth_emac_start()
443 emac->fw_running = 1; in prueth_emac_start()
447 rproc_shutdown(prueth->pru[slice]); in prueth_emac_start()
453 * emac_ndo_open - EMAC device open
463 int num_data_chn = emac->tx_ch_num - 1; in emac_ndo_open()
464 struct prueth *prueth = emac->prueth; in emac_ndo_open()
466 struct device *dev = prueth->dev; in emac_ndo_open()
471 if (!prueth->emacs_initialized) { in emac_ndo_open()
472 memset_io(prueth->msmcram.va, 0, prueth->msmcram.size); in emac_ndo_open()
473 memset_io(prueth->shram.va, 0, ICSSG_CONFIG_OFFSET_SLICE1 * PRUETH_NUM_MACS); in emac_ndo_open()
476 /* set h/w MAC as user might have re-configured */ in emac_ndo_open()
477 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in emac_ndo_open()
479 icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); in emac_ndo_open()
481 icssg_class_default(prueth->miig_rt, slice, 0, true); in emac_ndo_open()
490 init_completion(&emac->cmd_complete); in emac_ndo_open()
498 ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", in emac_ndo_open()
505 ret = prueth_init_rx_chns(emac, &emac->rx_mgm_chn, "rxmgm", in emac_ndo_open()
520 ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, in emac_ndo_open()
527 ret = request_threaded_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE_SR1], in emac_ndo_open()
536 ret = request_threaded_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1], in emac_ndo_open()
550 icssg_mii_update_mtu(prueth->mii_rt, slice, ndev->max_mtu); in emac_ndo_open()
553 ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE); in emac_ndo_open()
557 ret = prueth_prepare_rx_chan(emac, &emac->rx_mgm_chn, 64); in emac_ndo_open()
561 ret = k3_udma_glue_enable_rx_chn(emac->rx_mgm_chn.rx_chn); in emac_ndo_open()
565 ret = k3_udma_glue_enable_rx_chn(emac->rx_chns.rx_chn); in emac_ndo_open()
569 for (i = 0; i < emac->tx_ch_num; i++) { in emac_ndo_open()
570 ret = k3_udma_glue_enable_tx_chn(emac->tx_chns[i].tx_chn); in emac_ndo_open()
576 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_open()
577 napi_enable(&emac->tx_chns[i].napi_tx); in emac_ndo_open()
578 napi_enable(&emac->napi_rx); in emac_ndo_open()
581 phy_start(ndev->phydev); in emac_ndo_open()
583 prueth->emacs_initialized++; in emac_ndo_open()
585 queue_work(system_long_wq, &emac->stats_work.work); in emac_ndo_open()
595 prueth_reset_rx_chan(&emac->rx_mgm_chn, in emac_ndo_open()
598 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, false); in emac_ndo_open()
602 free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1], in emac_ndo_open()
605 free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE_SR1], in emac_ndo_open()
608 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_open()
610 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_open()
612 prueth_cleanup_rx_chns(emac, &emac->rx_mgm_chn, in emac_ndo_open()
615 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_open()
623 * emac_ndo_stop - EMAC device stop
634 struct prueth *prueth = emac->prueth; in emac_ndo_stop()
642 if (ndev->phydev) in emac_ndo_stop()
643 phy_stop(ndev->phydev); in emac_ndo_stop()
645 icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac)); in emac_ndo_stop()
649 atomic_set(&emac->tdown_cnt, emac->tx_ch_num); in emac_ndo_stop()
653 reinit_completion(&emac->tdown_complete); in emac_ndo_stop()
654 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
655 k3_udma_glue_tdown_tx_chn(emac->tx_chns[i].tx_chn, false); in emac_ndo_stop()
657 ret = wait_for_completion_timeout(&emac->tdown_complete, in emac_ndo_stop()
662 prueth_reset_tx_chan(emac, emac->tx_ch_num, true); in emac_ndo_stop()
663 for (i = 0; i < emac->tx_ch_num; i++) in emac_ndo_stop()
664 napi_disable(&emac->tx_chns[i].napi_tx); in emac_ndo_stop()
667 k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true); in emac_ndo_stop()
669 prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true); in emac_ndo_stop()
671 k3_udma_glue_tdown_rx_chn(emac->rx_mgm_chn.rx_chn, true); in emac_ndo_stop()
672 prueth_reset_rx_chan(&emac->rx_mgm_chn, in emac_ndo_stop()
675 napi_disable(&emac->napi_rx); in emac_ndo_stop()
678 cancel_delayed_work_sync(&emac->stats_work); in emac_ndo_stop()
683 free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1], emac); in emac_ndo_stop()
684 free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE_SR1], emac); in emac_ndo_stop()
685 free_irq(emac->rx_chns.irq[rx_flow], emac); in emac_ndo_stop()
686 prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); in emac_ndo_stop()
689 prueth_cleanup_rx_chns(emac, &emac->rx_mgm_chn, PRUETH_MAX_RX_MGM_FLOWS_SR1); in emac_ndo_stop()
690 prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); in emac_ndo_stop()
692 prueth->emacs_initialized--; in emac_ndo_stop()
700 bool allmulti = ndev->flags & IFF_ALLMULTI; in emac_ndo_set_rx_mode_sr1()
701 bool promisc = ndev->flags & IFF_PROMISC; in emac_ndo_set_rx_mode_sr1()
702 struct prueth *prueth = emac->prueth; in emac_ndo_set_rx_mode_sr1()
706 icssg_class_promiscuous_sr1(prueth->miig_rt, slice); in emac_ndo_set_rx_mode_sr1()
711 icssg_class_default(prueth->miig_rt, slice, 1, true); in emac_ndo_set_rx_mode_sr1()
715 icssg_class_default(prueth->miig_rt, slice, 0, true); in emac_ndo_set_rx_mode_sr1()
718 icssg_class_add_mcast_sr1(prueth->miig_rt, slice, ndev); in emac_ndo_set_rx_mode_sr1()
749 return -EINVAL; in prueth_netdev_init()
753 return -EINVAL; in prueth_netdev_init()
757 return -ENOMEM; in prueth_netdev_init()
760 emac->is_sr1 = 1; in prueth_netdev_init()
761 emac->prueth = prueth; in prueth_netdev_init()
762 emac->ndev = ndev; in prueth_netdev_init()
763 emac->port_id = port; in prueth_netdev_init()
764 emac->cmd_wq = create_singlethread_workqueue("icssg_cmd_wq"); in prueth_netdev_init()
765 if (!emac->cmd_wq) { in prueth_netdev_init()
766 ret = -ENOMEM; in prueth_netdev_init()
770 INIT_DELAYED_WORK(&emac->stats_work, icssg_stats_work_handler); in prueth_netdev_init()
772 ret = pruss_request_mem_region(prueth->pruss, in prueth_netdev_init()
775 &emac->dram); in prueth_netdev_init()
777 dev_err(prueth->dev, "unable to get DRAM: %d\n", ret); in prueth_netdev_init()
778 ret = -ENOMEM; in prueth_netdev_init()
785 emac->tx_ch_num = 2; in prueth_netdev_init()
787 SET_NETDEV_DEV(ndev, prueth->dev); in prueth_netdev_init()
788 spin_lock_init(&emac->lock); in prueth_netdev_init()
789 mutex_init(&emac->cmd_lock); in prueth_netdev_init()
791 emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0); in prueth_netdev_init()
792 if (!emac->phy_node && !of_phy_is_fixed_link(eth_node)) { in prueth_netdev_init()
793 dev_err(prueth->dev, "couldn't find phy-handle\n"); in prueth_netdev_init()
794 ret = -ENODEV; in prueth_netdev_init()
799 ret = dev_err_probe(prueth->dev, ret, in prueth_netdev_init()
800 "failed to register fixed-link phy\n"); in prueth_netdev_init()
804 emac->phy_node = eth_node; in prueth_netdev_init()
807 ret = of_get_phy_mode(eth_node, &emac->phy_if); in prueth_netdev_init()
809 dev_err(prueth->dev, "could not get phy-mode property\n"); in prueth_netdev_init()
813 if (emac->phy_if != PHY_INTERFACE_MODE_MII && in prueth_netdev_init()
814 !phy_interface_mode_is_rgmii(emac->phy_if)) { in prueth_netdev_init()
815 dev_err(prueth->dev, "PHY mode unsupported %s\n", phy_modes(emac->phy_if)); in prueth_netdev_init()
816 ret = -EINVAL; in prueth_netdev_init()
825 switch (emac->phy_if) { in prueth_netdev_init()
827 emac->phy_if = PHY_INTERFACE_MODE_RGMII_RXID; in prueth_netdev_init()
830 emac->phy_if = PHY_INTERFACE_MODE_RGMII; in prueth_netdev_init()
834 dev_err(prueth->dev, "RGMII mode without TX delay is not supported"); in prueth_netdev_init()
835 ret = -EINVAL; in prueth_netdev_init()
843 if (!is_valid_ether_addr(ndev->dev_addr)) { in prueth_netdev_init()
845 dev_warn(prueth->dev, "port %d: using random MAC addr: %pM\n", in prueth_netdev_init()
846 port, ndev->dev_addr); in prueth_netdev_init()
848 ether_addr_copy(emac->mac_addr, ndev->dev_addr); in prueth_netdev_init()
850 ndev->dev.of_node = eth_node; in prueth_netdev_init()
851 ndev->min_mtu = PRUETH_MIN_PKT_SIZE; in prueth_netdev_init()
852 ndev->max_mtu = PRUETH_MAX_MTU; in prueth_netdev_init()
853 ndev->netdev_ops = &emac_netdev_ops; in prueth_netdev_init()
854 ndev->ethtool_ops = &icssg_ethtool_ops; in prueth_netdev_init()
855 ndev->hw_features = NETIF_F_SG; in prueth_netdev_init()
856 ndev->features = ndev->hw_features; in prueth_netdev_init()
858 netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll); in prueth_netdev_init()
859 prueth->emac[mac] = emac; in prueth_netdev_init()
864 pruss_release_mem_region(prueth->pruss, &emac->dram); in prueth_netdev_init()
866 destroy_workqueue(emac->cmd_wq); in prueth_netdev_init()
868 emac->ndev = NULL; in prueth_netdev_init()
869 prueth->emac[mac] = NULL; in prueth_netdev_init()
880 struct device *dev = &pdev->dev; in prueth_probe()
883 struct pruss *pruss; in prueth_probe() local
887 np = dev->of_node; in prueth_probe()
891 return -ENOMEM; in prueth_probe()
894 prueth->pdev = pdev; in prueth_probe()
895 prueth->pdata = *(const struct prueth_pdata *)device_get_match_data(dev); in prueth_probe()
897 prueth->dev = dev; in prueth_probe()
898 eth_ports_node = of_get_child_by_name(np, "ethernet-ports"); in prueth_probe()
900 return -ENOENT; in prueth_probe()
905 if (strcmp(eth_node->name, "port")) in prueth_probe()
937 return -ENODEV; in prueth_probe()
943 return -ENODEV; in prueth_probe()
946 prueth->eth_node[PRUETH_MAC0] = eth0_node; in prueth_probe()
947 prueth->eth_node[PRUETH_MAC1] = eth1_node; in prueth_probe()
949 prueth->miig_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-g-rt"); in prueth_probe()
950 if (IS_ERR(prueth->miig_rt)) { in prueth_probe()
951 dev_err(dev, "couldn't get ti,mii-g-rt syscon regmap\n"); in prueth_probe()
952 return -ENODEV; in prueth_probe()
955 prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt"); in prueth_probe()
956 if (IS_ERR(prueth->mii_rt)) { in prueth_probe()
957 dev_err(dev, "couldn't get ti,mii-rt syscon regmap\n"); in prueth_probe()
958 return -ENODEV; in prueth_probe()
973 pruss = pruss_get(eth0_node ? in prueth_probe()
974 prueth->pru[ICSS_SLICE0] : prueth->pru[ICSS_SLICE1]); in prueth_probe()
975 if (IS_ERR(pruss)) { in prueth_probe()
976 ret = PTR_ERR(pruss); in prueth_probe()
977 dev_err(dev, "unable to get pruss handle\n"); in prueth_probe()
981 prueth->pruss = pruss; in prueth_probe()
983 ret = pruss_request_mem_region(pruss, PRUSS_MEM_SHRD_RAM2, in prueth_probe()
984 &prueth->shram); in prueth_probe()
986 dev_err(dev, "unable to get PRUSS SHRD RAM2: %d\n", ret); in prueth_probe()
990 prueth->sram_pool = of_gen_pool_get(np, "sram", 0); in prueth_probe()
991 if (!prueth->sram_pool) { in prueth_probe()
993 ret = -ENODEV; in prueth_probe()
1000 prueth->msmcram.va = (void __iomem *)gen_pool_alloc(prueth->sram_pool, in prueth_probe()
1003 if (!prueth->msmcram.va) { in prueth_probe()
1004 ret = -ENOMEM; in prueth_probe()
1008 prueth->msmcram.pa = gen_pool_virt_to_phys(prueth->sram_pool, in prueth_probe()
1009 (unsigned long)prueth->msmcram.va); in prueth_probe()
1010 prueth->msmcram.size = msmc_ram_size; in prueth_probe()
1011 memset_io(prueth->msmcram.va, 0, msmc_ram_size); in prueth_probe()
1012 dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa, in prueth_probe()
1013 prueth->msmcram.va, prueth->msmcram.size); in prueth_probe()
1015 prueth->iep0 = icss_iep_get_idx(np, 0); in prueth_probe()
1016 if (IS_ERR(prueth->iep0)) { in prueth_probe()
1017 ret = dev_err_probe(dev, PTR_ERR(prueth->iep0), in prueth_probe()
1022 prueth->iep1 = icss_iep_get_idx(np, 1); in prueth_probe()
1023 if (IS_ERR(prueth->iep1)) { in prueth_probe()
1024 ret = dev_err_probe(dev, PTR_ERR(prueth->iep1), in prueth_probe()
1029 ret = icss_iep_init(prueth->iep0, NULL, NULL, 0); in prueth_probe()
1035 ret = icss_iep_init(prueth->iep1, NULL, NULL, 0); in prueth_probe()
1045 eth0_node->name); in prueth_probe()
1049 prueth->emac[PRUETH_MAC0]->half_duplex = in prueth_probe()
1050 of_property_read_bool(eth0_node, "ti,half-duplex-capable"); in prueth_probe()
1052 prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; in prueth_probe()
1059 eth1_node->name); in prueth_probe()
1063 prueth->emac[PRUETH_MAC1]->half_duplex = in prueth_probe()
1064 of_property_read_bool(eth1_node, "ti,half-duplex-capable"); in prueth_probe()
1066 prueth->emac[PRUETH_MAC1]->iep = prueth->iep1; in prueth_probe()
1071 ret = register_netdev(prueth->emac[PRUETH_MAC0]->ndev); in prueth_probe()
1077 prueth->registered_netdevs[PRUETH_MAC0] = prueth->emac[PRUETH_MAC0]->ndev; in prueth_probe()
1078 emac_phy_connect(prueth->emac[PRUETH_MAC0]); in prueth_probe()
1079 phy_attached_info(prueth->emac[PRUETH_MAC0]->ndev->phydev); in prueth_probe()
1083 ret = register_netdev(prueth->emac[PRUETH_MAC1]->ndev); in prueth_probe()
1089 prueth->registered_netdevs[PRUETH_MAC1] = prueth->emac[PRUETH_MAC1]->ndev; in prueth_probe()
1090 emac_phy_connect(prueth->emac[PRUETH_MAC1]); in prueth_probe()
1091 phy_attached_info(prueth->emac[PRUETH_MAC1]->ndev->phydev); in prueth_probe()
1094 dev_info(dev, "TI PRU SR1.0 ethernet driver initialized: %s EMAC mode\n", in prueth_probe()
1106 if (!prueth->registered_netdevs[i]) in prueth_probe()
1109 if (prueth->emac[i]->ndev->phydev) { in prueth_probe()
1110 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_probe()
1111 prueth->emac[i]->ndev->phydev = NULL; in prueth_probe()
1113 unregister_netdev(prueth->registered_netdevs[i]); in prueth_probe()
1118 eth_node = prueth->eth_node[i]; in prueth_probe()
1126 icss_iep_exit(prueth->iep1); in prueth_probe()
1128 icss_iep_exit(prueth->iep0); in prueth_probe()
1131 icss_iep_put(prueth->iep1); in prueth_probe()
1134 icss_iep_put(prueth->iep0); in prueth_probe()
1135 prueth->iep0 = NULL; in prueth_probe()
1136 prueth->iep1 = NULL; in prueth_probe()
1139 gen_pool_free(prueth->sram_pool, in prueth_probe()
1140 (unsigned long)prueth->msmcram.va, msmc_ram_size); in prueth_probe()
1143 pruss_release_mem_region(prueth->pruss, &prueth->shram); in prueth_probe()
1146 pruss_put(prueth->pruss); in prueth_probe()
1169 if (!prueth->registered_netdevs[i]) in prueth_remove()
1171 phy_stop(prueth->emac[i]->ndev->phydev); in prueth_remove()
1172 phy_disconnect(prueth->emac[i]->ndev->phydev); in prueth_remove()
1173 prueth->emac[i]->ndev->phydev = NULL; in prueth_remove()
1174 unregister_netdev(prueth->registered_netdevs[i]); in prueth_remove()
1178 eth_node = prueth->eth_node[i]; in prueth_remove()
1185 icss_iep_exit(prueth->iep1); in prueth_remove()
1186 icss_iep_exit(prueth->iep0); in prueth_remove()
1188 icss_iep_put(prueth->iep1); in prueth_remove()
1189 icss_iep_put(prueth->iep0); in prueth_remove()
1191 gen_pool_free(prueth->sram_pool, in prueth_remove()
1192 (unsigned long)prueth->msmcram.va, in prueth_remove()
1195 pruss_release_mem_region(prueth->pruss, &prueth->shram); in prueth_remove()
1197 pruss_put(prueth->pruss); in prueth_remove()
1199 if (prueth->eth_node[PRUETH_MAC1]) in prueth_remove()
1202 if (prueth->eth_node[PRUETH_MAC0]) in prueth_remove()
1211 { .compatible = "ti,am654-sr1-icssg-prueth", .data = &am654_sr1_icssg_pdata },
1220 .name = "icssg-prueth-sr1",
1227 MODULE_AUTHOR("Roger Quadros <rogerq@ti.com>");
1228 MODULE_AUTHOR("Md Danish Anwar <danishanwar@ti.com>");