Lines Matching defs:cpsw
41 #include "cpsw.h"
52 MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)");
56 MODULE_PARM_DESC(ale_ageout, "cpsw ale ageout interval (seconds)");
69 struct cpsw_common *cpsw = (priv)->cpsw; \
71 if (cpsw->data.dual_emac) \
72 (func)((cpsw)->slaves + priv->emac_port, ##arg);\
74 for (n = cpsw->data.slaves, \
75 slave = cpsw->slaves; \
80 static int cpsw_slave_index_priv(struct cpsw_common *cpsw,
83 return cpsw->data.dual_emac ? priv->emac_port : cpsw->data.active_slave;
96 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
97 struct cpsw_ale *ale = cpsw->ale;
100 if (cpsw->data.dual_emac) {
107 for (i = 0; i < cpsw->data.slaves; i++)
108 if (cpsw->slaves[i].ndev->flags & IFF_PROMISC)
131 for (i = 0; i <= cpsw->data.slaves; i++) {
159 for (i = 0; i <= cpsw->data.slaves; i++) {
182 struct cpsw_common *cpsw = priv->cpsw;
186 if (cpsw->data.dual_emac)
187 vid = cpsw->slaves[priv->emac_port].port_vlan;
192 mask = cpsw->data.dual_emac ? ALE_PORT_HOST : ALE_ALL_PORTS;
196 ret = cpsw_ale_add_mcast(cpsw->ale, addr, mask, flags, vid, 0);
198 ret = cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid);
311 struct cpsw_common *cpsw = priv->cpsw;
314 if (cpsw->data.dual_emac)
320 cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI, slave_port);
328 cpsw_ale_set_allmulti(cpsw->ale,
349 struct cpsw_common *cpsw = ndev_to_cpsw(xmeta->ndev);
350 int pkt_size = cpsw->rx_packet_max;
361 if (cpsw->data.dual_emac && status >= 0) {
364 ndev = cpsw->slaves[--port].ndev;
368 pool = cpsw->page_pool[ch];
371 if (cpsw->data.dual_emac && cpsw->usage_count &&
406 port = priv->emac_port + cpsw->data.dual_emac;
434 cpts_rx_timestamp(cpsw->cpts, skb);
450 ret = cpdma_chan_submit_mapped(cpsw->rxv[ch].ch, new_page, dma,
464 struct cpsw_common *cpsw = priv->cpsw;
496 cpsw_ale_control_set(cpsw->ale, slave_port,
509 cpsw_ale_control_set(cpsw->ale, slave_port,
526 struct cpsw_common *cpsw = priv->cpsw;
532 if (cpsw_need_resplit(cpsw))
533 cpsw_split_res(cpsw);
548 struct cpsw_common *cpsw = priv->cpsw;
551 if (cpsw->version == CPSW_VERSION_1)
555 cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask,
557 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
559 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
562 cpsw_ale_control_set(cpsw->ale, slave_port,
570 struct cpsw_common *cpsw = priv->cpsw;
579 switch (cpsw->version) {
604 cpsw->rx_packet_max);
611 if (cpsw->data.dual_emac)
614 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
653 cpsw_phy_sel(cpsw->dev, slave->phy->interface,
659 struct cpsw_common *cpsw = priv->cpsw;
660 const int vlan = cpsw->data.default_vlan;
665 reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
668 writel(vlan, &cpsw->host_port_regs->port_vlan);
670 for (i = 0; i < cpsw->data.slaves; i++)
671 slave_write(cpsw->slaves + i, vlan, reg);
678 cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS,
687 struct cpsw_common *cpsw = priv->cpsw;
690 soft_reset("cpsw", &cpsw->regs->soft_reset);
691 cpsw_ale_start(cpsw->ale);
694 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE,
696 control_reg = readl(&cpsw->regs->control);
698 writel(control_reg, &cpsw->regs->control);
699 fifo_mode = (cpsw->data.dual_emac) ? CPSW_FIFO_DUAL_MAC_MODE :
701 writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl);
705 &cpsw->host_port_regs->cpdma_tx_pri_map);
706 writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map);
708 cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
711 if (!cpsw->data.dual_emac) {
712 cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
714 cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
719 static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw)
730 cpsw_ale_control_set(cpsw->ale, slave_port,
763 struct cpsw_common *cpsw = priv->cpsw;
767 ret = pm_runtime_resume_and_get(cpsw->dev);
774 ret = netif_set_real_num_tx_queues(ndev, cpsw->tx_ch_num);
780 ret = netif_set_real_num_rx_queues(ndev, cpsw->rx_ch_num);
786 reg = cpsw->version;
788 dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n",
793 if (!cpsw->usage_count)
798 if (!cpsw->data.dual_emac)
801 cpsw_ale_add_vlan(cpsw->ale, cpsw->data.default_vlan,
805 if (!cpsw->usage_count) {
807 writel_relaxed(0, &cpsw->regs->ptype);
810 writel_relaxed(0x7, &cpsw->regs->stat_port_en);
813 writel(0x7, &cpsw->regs->flow_control);
815 napi_enable(&cpsw->napi_rx);
816 napi_enable(&cpsw->napi_tx);
818 if (cpsw->tx_irq_disabled) {
819 cpsw->tx_irq_disabled = false;
820 enable_irq(cpsw->irqs_table[1]);
823 if (cpsw->rx_irq_disabled) {
824 cpsw->rx_irq_disabled = false;
825 enable_irq(cpsw->irqs_table[0]);
831 ret = cpsw_create_xdp_rxqs(cpsw);
839 if (cpsw->cpts) {
840 if (cpts_register(cpsw->cpts))
843 writel(0x10, &cpsw->wr_regs->misc_en);
850 if (cpsw->coal_intvl != 0) {
853 coal.rx_coalesce_usecs = cpsw->coal_intvl;
857 cpdma_ctlr_start(cpsw->dma);
858 cpsw_intr_enable(cpsw);
859 cpsw->usage_count++;
864 if (!cpsw->usage_count) {
865 napi_disable(&cpsw->napi_rx);
866 napi_disable(&cpsw->napi_tx);
867 cpdma_ctlr_stop(cpsw->dma);
868 cpsw_destroy_xdp_rxqs(cpsw);
871 for_each_slave(priv, cpsw_slave_stop, cpsw);
872 pm_runtime_put_sync(cpsw->dev);
880 struct cpsw_common *cpsw = priv->cpsw;
882 cpsw_info(priv, ifdown, "shutting down cpsw device\n");
887 if (cpsw->usage_count <= 1) {
888 napi_disable(&cpsw->napi_rx);
889 napi_disable(&cpsw->napi_tx);
890 cpts_unregister(cpsw->cpts);
891 cpsw_intr_disable(cpsw);
892 cpdma_ctlr_stop(cpsw->dma);
893 cpsw_ale_stop(cpsw->ale);
894 cpsw_destroy_xdp_rxqs(cpsw);
896 for_each_slave(priv, cpsw_slave_stop, cpsw);
898 if (cpsw_need_resplit(cpsw))
899 cpsw_split_res(cpsw);
901 cpsw->usage_count--;
902 pm_runtime_put_sync(cpsw->dev);
910 struct cpsw_common *cpsw = priv->cpsw;
911 struct cpts *cpts = cpsw->cpts;
927 if (q_idx >= cpsw->tx_ch_num)
928 q_idx = q_idx % cpsw->tx_ch_num;
930 txch = cpsw->txv[q_idx].ch;
934 priv->emac_port + cpsw->data.dual_emac);
971 struct cpsw_common *cpsw = priv->cpsw;
979 ret = pm_runtime_resume_and_get(cpsw->dev);
983 if (cpsw->data.dual_emac) {
984 vid = cpsw->slaves[priv->emac_port].port_vlan;
988 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM,
990 cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM,
997 pm_runtime_put(cpsw->dev);
1009 struct cpsw_common *cpsw = priv->cpsw;
1011 if (cpsw->data.dual_emac) {
1027 ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask,
1032 ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
1037 ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
1044 cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1047 cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1055 struct cpsw_common *cpsw = priv->cpsw;
1058 if (vid == cpsw->data.default_vlan)
1061 ret = pm_runtime_resume_and_get(cpsw->dev);
1065 if (cpsw->data.dual_emac) {
1072 for (i = 0; i < cpsw->data.slaves; i++) {
1073 if (vid == cpsw->slaves[i].port_vlan) {
1083 pm_runtime_put(cpsw->dev);
1091 struct cpsw_common *cpsw = priv->cpsw;
1094 if (vid == cpsw->data.default_vlan)
1097 ret = pm_runtime_resume_and_get(cpsw->dev);
1101 if (cpsw->data.dual_emac) {
1104 for (i = 0; i < cpsw->data.slaves; i++) {
1105 if (vid == cpsw->slaves[i].port_vlan)
1111 ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0);
1112 ret |= cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
1114 ret |= cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
1116 ret |= cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid);
1118 pm_runtime_put(cpsw->dev);
1126 struct cpsw_common *cpsw = priv->cpsw;
1138 port = priv->emac_port + cpsw->data.dual_emac;
1150 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1152 cpsw_intr_disable(cpsw);
1153 cpsw_rx_interrupt(cpsw->irqs_table[0], cpsw);
1154 cpsw_tx_interrupt(cpsw->irqs_table[1], cpsw);
1155 cpsw_intr_enable(cpsw);
1166 struct cpsw_common *cpsw = priv->cpsw;
1167 int slave_no = cpsw_slave_index(cpsw, priv);
1173 phy = cpsw->slaves[slave_no].phy;
1205 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1206 struct platform_device *pdev = to_platform_device(cpsw->dev);
1208 strscpy(info->driver, "cpsw", sizeof(info->driver));
1428 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1429 struct cpsw_platform_data *data = &cpsw->data;
1457 struct cpsw_common *cpsw = priv->cpsw;
1458 struct cpsw_platform_data *data = &cpsw->data;
1463 ndev = devm_alloc_etherdev_mqs(cpsw->dev, sizeof(struct cpsw_priv),
1466 dev_err(cpsw->dev, "cpsw: error allocating net_device\n");
1471 priv_sl2->cpsw = cpsw;
1479 dev_info(cpsw->dev, "cpsw: Detected MACID = %pM\n",
1483 dev_info(cpsw->dev, "cpsw: Random MACID = %pM\n",
1489 cpsw->slaves[1].ndev = ndev;
1498 SET_NETDEV_DEV(ndev, cpsw->dev);
1499 ndev->dev.of_node = cpsw->slaves[1].data->slave_node;
1502 dev_err(cpsw->dev, "cpsw: error registering net device\n");
1508 { .compatible = "ti,cpsw"},
1509 { .compatible = "ti,am335x-cpsw"},
1510 { .compatible = "ti,am4372-cpsw"},
1511 { .compatible = "ti,dra7-cpsw"},
1532 struct cpsw_common *cpsw;
1536 cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL);
1537 if (!cpsw)
1540 platform_set_drvdata(pdev, cpsw);
1543 cpsw->dev = dev;
1558 cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000;
1563 cpsw->regs = ss_regs;
1565 cpsw->wr_regs = devm_platform_ioremap_resource(pdev, 1);
1566 if (IS_ERR(cpsw->wr_regs))
1567 return PTR_ERR(cpsw->wr_regs);
1573 cpsw->irqs_table[0] = irq;
1579 cpsw->irqs_table[1] = irq;
1585 cpsw->misc_irq = irq;
1599 ret = cpsw_probe_dt(&cpsw->data, pdev);
1605 cpsw->quirk_irq = true;
1607 data = &cpsw->data;
1608 cpsw->slaves = devm_kcalloc(dev,
1611 if (!cpsw->slaves) {
1616 cpsw->rx_packet_max = max(rx_packet_max, CPSW_MAX_PACKET_SIZE);
1617 cpsw->descs_pool_size = descs_pool_size;
1619 ret = cpsw_init_common(cpsw, ss_regs, ale_ageout,
1625 ch = cpsw->quirk_irq ? 0 : 7;
1626 cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0);
1627 if (IS_ERR(cpsw->txv[0].ch)) {
1629 ret = PTR_ERR(cpsw->txv[0].ch);
1633 cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
1634 if (IS_ERR(cpsw->rxv[0].ch)) {
1636 ret = PTR_ERR(cpsw->rxv[0].ch);
1639 cpsw_split_res(cpsw);
1651 priv->cpsw = cpsw;
1667 cpsw->slaves[0].ndev = ndev;
1673 if (!cpsw->data.dual_emac)
1678 netif_napi_add(ndev, &cpsw->napi_rx,
1679 cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll);
1680 netif_napi_add_tx(ndev, &cpsw->napi_tx,
1681 cpsw->quirk_irq ? cpsw_tx_poll : cpsw_tx_mq_poll);
1685 ndev->dev.of_node = cpsw->slaves[0].data->slave_node;
1693 if (cpsw->data.dual_emac) {
1708 ret = devm_request_irq(dev, cpsw->irqs_table[0], cpsw_rx_interrupt,
1709 0, dev_name(dev), cpsw);
1716 ret = devm_request_irq(dev, cpsw->irqs_table[1], cpsw_tx_interrupt,
1717 0, dev_name(&pdev->dev), cpsw);
1723 if (!cpsw->cpts)
1726 ret = devm_request_irq(&pdev->dev, cpsw->misc_irq, cpsw_misc_interrupt,
1727 0, dev_name(&pdev->dev), cpsw);
1734 cpts_set_irqpoll(cpsw->cpts, false);
1739 &ss_res->start, cpsw->irqs_table[0], descs_pool_size);
1748 cpts_release(cpsw->cpts);
1749 cpdma_ctlr_destroy(cpsw->dma);
1760 struct cpsw_common *cpsw = platform_get_drvdata(pdev);
1773 for (i = 0; i < cpsw->data.slaves; i++)
1774 if (cpsw->slaves[i].ndev)
1775 unregister_netdev(cpsw->slaves[i].ndev);
1777 cpts_release(cpsw->cpts);
1778 cpdma_ctlr_destroy(cpsw->dma);
1787 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1792 for (i = 0; i < cpsw->data.slaves; i++)
1793 if (cpsw->slaves[i].ndev)
1794 if (netif_running(cpsw->slaves[i].ndev))
1795 cpsw_ndo_stop(cpsw->slaves[i].ndev);
1807 struct cpsw_common *cpsw = dev_get_drvdata(dev);
1816 for (i = 0; i < cpsw->data.slaves; i++)
1817 if (cpsw->slaves[i].ndev)
1818 if (netif_running(cpsw->slaves[i].ndev))
1819 cpsw_ndo_open(cpsw->slaves[i].ndev);
1831 .name = "cpsw",