diff options
author | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> | 2016-08-09 19:22:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-10 20:27:41 -0400 |
commit | 2a05a622d88a8e195adaab3ab83aaba317a2e5cf (patch) | |
tree | b3e3c874a87f07190d9191c44e274b382085b301 /drivers/net/ethernet/ti | |
parent | dbc4ec522d2ee2b3fa24d329a7a63594aba3b069 (diff) |
net: ethernet: ti: cpsw: move ale, cpts and drivers params under cpsw_common
The ale, cpts, version, rx_packet_max, bus_freq, interrupt pacing
parameters are common per net device that uses the same h/w. So,
move them to common driver structure.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 235 |
1 files changed, 106 insertions, 129 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 2c2e36a416c1..b4d3b410c32a 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -373,28 +373,28 @@ struct cpsw_common { | |||
373 | struct cpsw_wr_regs __iomem *wr_regs; | 373 | struct cpsw_wr_regs __iomem *wr_regs; |
374 | u8 __iomem *hw_stats; | 374 | u8 __iomem *hw_stats; |
375 | struct cpsw_host_regs __iomem *host_port_regs; | 375 | struct cpsw_host_regs __iomem *host_port_regs; |
376 | u32 version; | ||
377 | u32 coal_intvl; | ||
378 | u32 bus_freq_mhz; | ||
379 | int rx_packet_max; | ||
376 | struct cpsw_slave *slaves; | 380 | struct cpsw_slave *slaves; |
377 | struct cpdma_ctlr *dma; | 381 | struct cpdma_ctlr *dma; |
378 | struct cpdma_chan *txch, *rxch; | 382 | struct cpdma_chan *txch, *rxch; |
383 | struct cpsw_ale *ale; | ||
379 | bool quirk_irq; | 384 | bool quirk_irq; |
380 | bool rx_irq_disabled; | 385 | bool rx_irq_disabled; |
381 | bool tx_irq_disabled; | 386 | bool tx_irq_disabled; |
382 | u32 irqs_table[IRQ_NUM]; | 387 | u32 irqs_table[IRQ_NUM]; |
388 | struct cpts *cpts; | ||
383 | }; | 389 | }; |
384 | 390 | ||
385 | struct cpsw_priv { | 391 | struct cpsw_priv { |
386 | struct net_device *ndev; | 392 | struct net_device *ndev; |
387 | struct device *dev; | 393 | struct device *dev; |
388 | u32 msg_enable; | 394 | u32 msg_enable; |
389 | u32 version; | ||
390 | u32 coal_intvl; | ||
391 | u32 bus_freq_mhz; | ||
392 | int rx_packet_max; | ||
393 | u8 mac_addr[ETH_ALEN]; | 395 | u8 mac_addr[ETH_ALEN]; |
394 | struct cpsw_ale *ale; | ||
395 | bool rx_pause; | 396 | bool rx_pause; |
396 | bool tx_pause; | 397 | bool tx_pause; |
397 | struct cpts *cpts; | ||
398 | u32 emac_port; | 398 | u32 emac_port; |
399 | struct cpsw_common *cpsw; | 399 | struct cpsw_common *cpsw; |
400 | }; | 400 | }; |
@@ -502,22 +502,16 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = { | |||
502 | n; n--) \ | 502 | n; n--) \ |
503 | (func)(slave++, ##arg); \ | 503 | (func)(slave++, ##arg); \ |
504 | } while (0) | 504 | } while (0) |
505 | #define cpsw_get_slave_priv(cpsw, __slave_no__) \ | ||
506 | (((__slave_no__ < cpsw->data.slaves) && \ | ||
507 | (cpsw->slaves[__slave_no__].ndev)) ? \ | ||
508 | netdev_priv(cpsw->slaves[__slave_no__].ndev) : NULL) \ | ||
509 | 505 | ||
510 | #define cpsw_dual_emac_src_port_detect(cpsw, status, priv, ndev, skb) \ | 506 | #define cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb) \ |
511 | do { \ | 507 | do { \ |
512 | if (!cpsw->data.dual_emac) \ | 508 | if (!cpsw->data.dual_emac) \ |
513 | break; \ | 509 | break; \ |
514 | if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ | 510 | if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ |
515 | ndev = cpsw->slaves[0].ndev; \ | 511 | ndev = cpsw->slaves[0].ndev; \ |
516 | priv = netdev_priv(ndev); \ | ||
517 | skb->dev = ndev; \ | 512 | skb->dev = ndev; \ |
518 | } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ | 513 | } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ |
519 | ndev = cpsw->slaves[1].ndev; \ | 514 | ndev = cpsw->slaves[1].ndev; \ |
520 | priv = netdev_priv(ndev); \ | ||
521 | skb->dev = ndev; \ | 515 | skb->dev = ndev; \ |
522 | } \ | 516 | } \ |
523 | } while (0) | 517 | } while (0) |
@@ -528,11 +522,11 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = { | |||
528 | priv->emac_port; \ | 522 | priv->emac_port; \ |
529 | int slave_port = cpsw_get_slave_port( \ | 523 | int slave_port = cpsw_get_slave_port( \ |
530 | slave->slave_num); \ | 524 | slave->slave_num); \ |
531 | cpsw_ale_add_mcast(priv->ale, addr, \ | 525 | cpsw_ale_add_mcast(cpsw->ale, addr, \ |
532 | 1 << slave_port | ALE_PORT_HOST, \ | 526 | 1 << slave_port | ALE_PORT_HOST, \ |
533 | ALE_VLAN, slave->port_vlan, 0); \ | 527 | ALE_VLAN, slave->port_vlan, 0); \ |
534 | } else { \ | 528 | } else { \ |
535 | cpsw_ale_add_mcast(priv->ale, addr, \ | 529 | cpsw_ale_add_mcast(cpsw->ale, addr, \ |
536 | ALE_ALL_PORTS, \ | 530 | ALE_ALL_PORTS, \ |
537 | 0, 0, 0); \ | 531 | 0, 0, 0); \ |
538 | } \ | 532 | } \ |
@@ -545,9 +539,8 @@ static inline int cpsw_get_slave_port(u32 slave_num) | |||
545 | 539 | ||
546 | static void cpsw_set_promiscious(struct net_device *ndev, bool enable) | 540 | static void cpsw_set_promiscious(struct net_device *ndev, bool enable) |
547 | { | 541 | { |
548 | struct cpsw_priv *priv = netdev_priv(ndev); | 542 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
549 | struct cpsw_common *cpsw = priv->cpsw; | 543 | struct cpsw_ale *ale = cpsw->ale; |
550 | struct cpsw_ale *ale = priv->ale; | ||
551 | int i; | 544 | int i; |
552 | 545 | ||
553 | if (cpsw->data.dual_emac) { | 546 | if (cpsw->data.dual_emac) { |
@@ -633,7 +626,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev) | |||
633 | if (ndev->flags & IFF_PROMISC) { | 626 | if (ndev->flags & IFF_PROMISC) { |
634 | /* Enable promiscuous mode */ | 627 | /* Enable promiscuous mode */ |
635 | cpsw_set_promiscious(ndev, true); | 628 | cpsw_set_promiscious(ndev, true); |
636 | cpsw_ale_set_allmulti(priv->ale, IFF_ALLMULTI); | 629 | cpsw_ale_set_allmulti(cpsw->ale, IFF_ALLMULTI); |
637 | return; | 630 | return; |
638 | } else { | 631 | } else { |
639 | /* Disable promiscuous mode */ | 632 | /* Disable promiscuous mode */ |
@@ -641,10 +634,10 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev) | |||
641 | } | 634 | } |
642 | 635 | ||
643 | /* Restore allmulti on vlans if necessary */ | 636 | /* Restore allmulti on vlans if necessary */ |
644 | cpsw_ale_set_allmulti(priv->ale, priv->ndev->flags & IFF_ALLMULTI); | 637 | cpsw_ale_set_allmulti(cpsw->ale, priv->ndev->flags & IFF_ALLMULTI); |
645 | 638 | ||
646 | /* Clear all mcast from ALE */ | 639 | /* Clear all mcast from ALE */ |
647 | cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS, vid); | 640 | cpsw_ale_flush_multicast(cpsw->ale, ALE_ALL_PORTS, vid); |
648 | 641 | ||
649 | if (!netdev_mc_empty(ndev)) { | 642 | if (!netdev_mc_empty(ndev)) { |
650 | struct netdev_hw_addr *ha; | 643 | struct netdev_hw_addr *ha; |
@@ -678,14 +671,14 @@ static void cpsw_tx_handler(void *token, int len, int status) | |||
678 | { | 671 | { |
679 | struct sk_buff *skb = token; | 672 | struct sk_buff *skb = token; |
680 | struct net_device *ndev = skb->dev; | 673 | struct net_device *ndev = skb->dev; |
681 | struct cpsw_priv *priv = netdev_priv(ndev); | 674 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
682 | 675 | ||
683 | /* Check whether the queue is stopped due to stalled tx dma, if the | 676 | /* Check whether the queue is stopped due to stalled tx dma, if the |
684 | * queue is stopped then start the queue as we have free desc for tx | 677 | * queue is stopped then start the queue as we have free desc for tx |
685 | */ | 678 | */ |
686 | if (unlikely(netif_queue_stopped(ndev))) | 679 | if (unlikely(netif_queue_stopped(ndev))) |
687 | netif_wake_queue(ndev); | 680 | netif_wake_queue(ndev); |
688 | cpts_tx_timestamp(priv->cpts, skb); | 681 | cpts_tx_timestamp(cpsw->cpts, skb); |
689 | ndev->stats.tx_packets++; | 682 | ndev->stats.tx_packets++; |
690 | ndev->stats.tx_bytes += len; | 683 | ndev->stats.tx_bytes += len; |
691 | dev_kfree_skb_any(skb); | 684 | dev_kfree_skb_any(skb); |
@@ -696,11 +689,10 @@ static void cpsw_rx_handler(void *token, int len, int status) | |||
696 | struct sk_buff *skb = token; | 689 | struct sk_buff *skb = token; |
697 | struct sk_buff *new_skb; | 690 | struct sk_buff *new_skb; |
698 | struct net_device *ndev = skb->dev; | 691 | struct net_device *ndev = skb->dev; |
699 | struct cpsw_priv *priv = netdev_priv(ndev); | ||
700 | int ret = 0; | 692 | int ret = 0; |
701 | struct cpsw_common *cpsw = priv->cpsw; | 693 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
702 | 694 | ||
703 | cpsw_dual_emac_src_port_detect(cpsw, status, priv, ndev, skb); | 695 | cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb); |
704 | 696 | ||
705 | if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { | 697 | if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { |
706 | bool ndev_status = false; | 698 | bool ndev_status = false; |
@@ -730,10 +722,10 @@ static void cpsw_rx_handler(void *token, int len, int status) | |||
730 | return; | 722 | return; |
731 | } | 723 | } |
732 | 724 | ||
733 | new_skb = netdev_alloc_skb_ip_align(ndev, priv->rx_packet_max); | 725 | new_skb = netdev_alloc_skb_ip_align(ndev, cpsw->rx_packet_max); |
734 | if (new_skb) { | 726 | if (new_skb) { |
735 | skb_put(skb, len); | 727 | skb_put(skb, len); |
736 | cpts_rx_timestamp(priv->cpts, skb); | 728 | cpts_rx_timestamp(cpsw->cpts, skb); |
737 | skb->protocol = eth_type_trans(skb, ndev); | 729 | skb->protocol = eth_type_trans(skb, ndev); |
738 | netif_receive_skb(skb); | 730 | netif_receive_skb(skb); |
739 | ndev->stats.rx_bytes += len; | 731 | ndev->stats.rx_bytes += len; |
@@ -858,7 +850,7 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave, | |||
858 | mac_control = cpsw->data.mac_control; | 850 | mac_control = cpsw->data.mac_control; |
859 | 851 | ||
860 | /* enable forwarding */ | 852 | /* enable forwarding */ |
861 | cpsw_ale_control_set(priv->ale, slave_port, | 853 | cpsw_ale_control_set(cpsw->ale, slave_port, |
862 | ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); | 854 | ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); |
863 | 855 | ||
864 | if (phy->speed == 1000) | 856 | if (phy->speed == 1000) |
@@ -882,7 +874,7 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave, | |||
882 | } else { | 874 | } else { |
883 | mac_control = 0; | 875 | mac_control = 0; |
884 | /* disable forwarding */ | 876 | /* disable forwarding */ |
885 | cpsw_ale_control_set(priv->ale, slave_port, | 877 | cpsw_ale_control_set(cpsw->ale, slave_port, |
886 | ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); | 878 | ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); |
887 | } | 879 | } |
888 | 880 | ||
@@ -914,9 +906,9 @@ static void cpsw_adjust_link(struct net_device *ndev) | |||
914 | static int cpsw_get_coalesce(struct net_device *ndev, | 906 | static int cpsw_get_coalesce(struct net_device *ndev, |
915 | struct ethtool_coalesce *coal) | 907 | struct ethtool_coalesce *coal) |
916 | { | 908 | { |
917 | struct cpsw_priv *priv = netdev_priv(ndev); | 909 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
918 | 910 | ||
919 | coal->rx_coalesce_usecs = priv->coal_intvl; | 911 | coal->rx_coalesce_usecs = cpsw->coal_intvl; |
920 | return 0; | 912 | return 0; |
921 | } | 913 | } |
922 | 914 | ||
@@ -934,7 +926,7 @@ static int cpsw_set_coalesce(struct net_device *ndev, | |||
934 | coal_intvl = coal->rx_coalesce_usecs; | 926 | coal_intvl = coal->rx_coalesce_usecs; |
935 | 927 | ||
936 | int_ctrl = readl(&cpsw->wr_regs->int_control); | 928 | int_ctrl = readl(&cpsw->wr_regs->int_control); |
937 | prescale = priv->bus_freq_mhz * 4; | 929 | prescale = cpsw->bus_freq_mhz * 4; |
938 | 930 | ||
939 | if (!coal->rx_coalesce_usecs) { | 931 | if (!coal->rx_coalesce_usecs) { |
940 | int_ctrl &= ~(CPSW_INTPRESCALE_MASK | CPSW_INTPACEEN); | 932 | int_ctrl &= ~(CPSW_INTPRESCALE_MASK | CPSW_INTPACEEN); |
@@ -973,16 +965,7 @@ update_return: | |||
973 | writel(int_ctrl, &cpsw->wr_regs->int_control); | 965 | writel(int_ctrl, &cpsw->wr_regs->int_control); |
974 | 966 | ||
975 | cpsw_notice(priv, timer, "Set coalesce to %d usecs.\n", coal_intvl); | 967 | cpsw_notice(priv, timer, "Set coalesce to %d usecs.\n", coal_intvl); |
976 | if (cpsw->data.dual_emac) { | 968 | cpsw->coal_intvl = coal_intvl; |
977 | int i; | ||
978 | |||
979 | for (i = 0; i < cpsw->data.slaves; i++) { | ||
980 | priv = netdev_priv(cpsw->slaves[i].ndev); | ||
981 | priv->coal_intvl = coal_intvl; | ||
982 | } | ||
983 | } else { | ||
984 | priv->coal_intvl = coal_intvl; | ||
985 | } | ||
986 | 969 | ||
987 | return 0; | 970 | return 0; |
988 | } | 971 | } |
@@ -1078,18 +1061,20 @@ static inline void cpsw_add_dual_emac_def_ale_entries( | |||
1078 | struct cpsw_priv *priv, struct cpsw_slave *slave, | 1061 | struct cpsw_priv *priv, struct cpsw_slave *slave, |
1079 | u32 slave_port) | 1062 | u32 slave_port) |
1080 | { | 1063 | { |
1064 | struct cpsw_common *cpsw = priv->cpsw; | ||
1081 | u32 port_mask = 1 << slave_port | ALE_PORT_HOST; | 1065 | u32 port_mask = 1 << slave_port | ALE_PORT_HOST; |
1082 | 1066 | ||
1083 | if (priv->version == CPSW_VERSION_1) | 1067 | if (cpsw->version == CPSW_VERSION_1) |
1084 | slave_write(slave, slave->port_vlan, CPSW1_PORT_VLAN); | 1068 | slave_write(slave, slave->port_vlan, CPSW1_PORT_VLAN); |
1085 | else | 1069 | else |
1086 | slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN); | 1070 | slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN); |
1087 | cpsw_ale_add_vlan(priv->ale, slave->port_vlan, port_mask, | 1071 | cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, |
1088 | port_mask, port_mask, 0); | 1072 | port_mask, port_mask, 0); |
1089 | cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, | 1073 | cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, |
1090 | port_mask, ALE_VLAN, slave->port_vlan, 0); | 1074 | port_mask, ALE_VLAN, slave->port_vlan, 0); |
1091 | cpsw_ale_add_ucast(priv->ale, priv->mac_addr, | 1075 | cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, |
1092 | HOST_PORT_NUM, ALE_VLAN | ALE_SECURE, slave->port_vlan); | 1076 | HOST_PORT_NUM, ALE_VLAN | |
1077 | ALE_SECURE, slave->port_vlan); | ||
1093 | } | 1078 | } |
1094 | 1079 | ||
1095 | static void soft_reset_slave(struct cpsw_slave *slave) | 1080 | static void soft_reset_slave(struct cpsw_slave *slave) |
@@ -1110,7 +1095,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) | |||
1110 | /* setup priority mapping */ | 1095 | /* setup priority mapping */ |
1111 | __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); | 1096 | __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); |
1112 | 1097 | ||
1113 | switch (priv->version) { | 1098 | switch (cpsw->version) { |
1114 | case CPSW_VERSION_1: | 1099 | case CPSW_VERSION_1: |
1115 | slave_write(slave, TX_PRIORITY_MAPPING, CPSW1_TX_PRI_MAP); | 1100 | slave_write(slave, TX_PRIORITY_MAPPING, CPSW1_TX_PRI_MAP); |
1116 | break; | 1101 | break; |
@@ -1122,7 +1107,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) | |||
1122 | } | 1107 | } |
1123 | 1108 | ||
1124 | /* setup max packet size, and mac address */ | 1109 | /* setup max packet size, and mac address */ |
1125 | __raw_writel(priv->rx_packet_max, &slave->sliver->rx_maxlen); | 1110 | __raw_writel(cpsw->rx_packet_max, &slave->sliver->rx_maxlen); |
1126 | cpsw_set_slave_mac(slave, priv); | 1111 | cpsw_set_slave_mac(slave, priv); |
1127 | 1112 | ||
1128 | slave->mac_control = 0; /* no link yet */ | 1113 | slave->mac_control = 0; /* no link yet */ |
@@ -1132,7 +1117,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) | |||
1132 | if (cpsw->data.dual_emac) | 1117 | if (cpsw->data.dual_emac) |
1133 | cpsw_add_dual_emac_def_ale_entries(priv, slave, slave_port); | 1118 | cpsw_add_dual_emac_def_ale_entries(priv, slave, slave_port); |
1134 | else | 1119 | else |
1135 | cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, | 1120 | cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, |
1136 | 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); | 1121 | 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); |
1137 | 1122 | ||
1138 | if (slave->data->phy_node) { | 1123 | if (slave->data->phy_node) { |
@@ -1173,7 +1158,7 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) | |||
1173 | int i; | 1158 | int i; |
1174 | int unreg_mcast_mask; | 1159 | int unreg_mcast_mask; |
1175 | 1160 | ||
1176 | reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : | 1161 | reg = (cpsw->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : |
1177 | CPSW2_PORT_VLAN; | 1162 | CPSW2_PORT_VLAN; |
1178 | 1163 | ||
1179 | writel(vlan, &cpsw->host_port_regs->port_vlan); | 1164 | writel(vlan, &cpsw->host_port_regs->port_vlan); |
@@ -1186,7 +1171,7 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) | |||
1186 | else | 1171 | else |
1187 | unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2; | 1172 | unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2; |
1188 | 1173 | ||
1189 | cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS, | 1174 | cpsw_ale_add_vlan(cpsw->ale, vlan, ALE_ALL_PORTS, |
1190 | ALE_ALL_PORTS, ALE_ALL_PORTS, | 1175 | ALE_ALL_PORTS, ALE_ALL_PORTS, |
1191 | unreg_mcast_mask); | 1176 | unreg_mcast_mask); |
1192 | } | 1177 | } |
@@ -1199,10 +1184,10 @@ static void cpsw_init_host_port(struct cpsw_priv *priv) | |||
1199 | 1184 | ||
1200 | /* soft reset the controller and initialize ale */ | 1185 | /* soft reset the controller and initialize ale */ |
1201 | soft_reset("cpsw", &cpsw->regs->soft_reset); | 1186 | soft_reset("cpsw", &cpsw->regs->soft_reset); |
1202 | cpsw_ale_start(priv->ale); | 1187 | cpsw_ale_start(cpsw->ale); |
1203 | 1188 | ||
1204 | /* switch to vlan unaware mode */ | 1189 | /* switch to vlan unaware mode */ |
1205 | cpsw_ale_control_set(priv->ale, HOST_PORT_NUM, ALE_VLAN_AWARE, | 1190 | cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_VLAN_AWARE, |
1206 | CPSW_ALE_VLAN_AWARE); | 1191 | CPSW_ALE_VLAN_AWARE); |
1207 | control_reg = readl(&cpsw->regs->control); | 1192 | control_reg = readl(&cpsw->regs->control); |
1208 | control_reg |= CPSW_VLAN_AWARE; | 1193 | control_reg |= CPSW_VLAN_AWARE; |
@@ -1216,18 +1201,18 @@ static void cpsw_init_host_port(struct cpsw_priv *priv) | |||
1216 | &cpsw->host_port_regs->cpdma_tx_pri_map); | 1201 | &cpsw->host_port_regs->cpdma_tx_pri_map); |
1217 | __raw_writel(0, &cpsw->host_port_regs->cpdma_rx_chan_map); | 1202 | __raw_writel(0, &cpsw->host_port_regs->cpdma_rx_chan_map); |
1218 | 1203 | ||
1219 | cpsw_ale_control_set(priv->ale, HOST_PORT_NUM, | 1204 | cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, |
1220 | ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); | 1205 | ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); |
1221 | 1206 | ||
1222 | if (!cpsw->data.dual_emac) { | 1207 | if (!cpsw->data.dual_emac) { |
1223 | cpsw_ale_add_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM, | 1208 | cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, |
1224 | 0, 0); | 1209 | 0, 0); |
1225 | cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, | 1210 | cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, |
1226 | ALE_PORT_HOST, 0, 0, ALE_MCAST_FWD_2); | 1211 | ALE_PORT_HOST, 0, 0, ALE_MCAST_FWD_2); |
1227 | } | 1212 | } |
1228 | } | 1213 | } |
1229 | 1214 | ||
1230 | static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv) | 1215 | static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw) |
1231 | { | 1216 | { |
1232 | u32 slave_port; | 1217 | u32 slave_port; |
1233 | 1218 | ||
@@ -1238,7 +1223,7 @@ static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv) | |||
1238 | phy_stop(slave->phy); | 1223 | phy_stop(slave->phy); |
1239 | phy_disconnect(slave->phy); | 1224 | phy_disconnect(slave->phy); |
1240 | slave->phy = NULL; | 1225 | slave->phy = NULL; |
1241 | cpsw_ale_control_set(priv->ale, slave_port, | 1226 | cpsw_ale_control_set(cpsw->ale, slave_port, |
1242 | ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); | 1227 | ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); |
1243 | soft_reset_slave(slave); | 1228 | soft_reset_slave(slave); |
1244 | } | 1229 | } |
@@ -1260,7 +1245,7 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1260 | cpsw_intr_disable(cpsw); | 1245 | cpsw_intr_disable(cpsw); |
1261 | netif_carrier_off(ndev); | 1246 | netif_carrier_off(ndev); |
1262 | 1247 | ||
1263 | reg = priv->version; | 1248 | reg = cpsw->version; |
1264 | 1249 | ||
1265 | dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n", | 1250 | dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n", |
1266 | CPSW_MAJOR_VERSION(reg), CPSW_MINOR_VERSION(reg), | 1251 | CPSW_MAJOR_VERSION(reg), CPSW_MINOR_VERSION(reg), |
@@ -1275,7 +1260,7 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1275 | if (!cpsw->data.dual_emac) | 1260 | if (!cpsw->data.dual_emac) |
1276 | cpsw_add_default_vlan(priv); | 1261 | cpsw_add_default_vlan(priv); |
1277 | else | 1262 | else |
1278 | cpsw_ale_add_vlan(priv->ale, cpsw->data.default_vlan, | 1263 | cpsw_ale_add_vlan(cpsw->ale, cpsw->data.default_vlan, |
1279 | ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); | 1264 | ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); |
1280 | 1265 | ||
1281 | if (!cpsw_common_res_usage_state(cpsw)) { | 1266 | if (!cpsw_common_res_usage_state(cpsw)) { |
@@ -1313,7 +1298,7 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1313 | 1298 | ||
1314 | ret = -ENOMEM; | 1299 | ret = -ENOMEM; |
1315 | skb = __netdev_alloc_skb_ip_align(priv->ndev, | 1300 | skb = __netdev_alloc_skb_ip_align(priv->ndev, |
1316 | priv->rx_packet_max, GFP_KERNEL); | 1301 | cpsw->rx_packet_max, GFP_KERNEL); |
1317 | if (!skb) | 1302 | if (!skb) |
1318 | goto err_cleanup; | 1303 | goto err_cleanup; |
1319 | ret = cpdma_chan_submit(cpsw->rxch, skb, skb->data, | 1304 | ret = cpdma_chan_submit(cpsw->rxch, skb, skb->data, |
@@ -1328,7 +1313,7 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1328 | */ | 1313 | */ |
1329 | cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); | 1314 | cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); |
1330 | 1315 | ||
1331 | if (cpts_register(cpsw->dev, priv->cpts, | 1316 | if (cpts_register(cpsw->dev, cpsw->cpts, |
1332 | cpsw->data.cpts_clock_mult, | 1317 | cpsw->data.cpts_clock_mult, |
1333 | cpsw->data.cpts_clock_shift)) | 1318 | cpsw->data.cpts_clock_shift)) |
1334 | dev_err(priv->dev, "error registering cpts device\n"); | 1319 | dev_err(priv->dev, "error registering cpts device\n"); |
@@ -1336,10 +1321,10 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1336 | } | 1321 | } |
1337 | 1322 | ||
1338 | /* Enable Interrupt pacing if configured */ | 1323 | /* Enable Interrupt pacing if configured */ |
1339 | if (priv->coal_intvl != 0) { | 1324 | if (cpsw->coal_intvl != 0) { |
1340 | struct ethtool_coalesce coal; | 1325 | struct ethtool_coalesce coal; |
1341 | 1326 | ||
1342 | coal.rx_coalesce_usecs = priv->coal_intvl; | 1327 | coal.rx_coalesce_usecs = cpsw->coal_intvl; |
1343 | cpsw_set_coalesce(ndev, &coal); | 1328 | cpsw_set_coalesce(ndev, &coal); |
1344 | } | 1329 | } |
1345 | 1330 | ||
@@ -1352,7 +1337,7 @@ static int cpsw_ndo_open(struct net_device *ndev) | |||
1352 | 1337 | ||
1353 | err_cleanup: | 1338 | err_cleanup: |
1354 | cpdma_ctlr_stop(cpsw->dma); | 1339 | cpdma_ctlr_stop(cpsw->dma); |
1355 | for_each_slave(priv, cpsw_slave_stop, priv); | 1340 | for_each_slave(priv, cpsw_slave_stop, cpsw); |
1356 | pm_runtime_put_sync(cpsw->dev); | 1341 | pm_runtime_put_sync(cpsw->dev); |
1357 | netif_carrier_off(priv->ndev); | 1342 | netif_carrier_off(priv->ndev); |
1358 | return ret; | 1343 | return ret; |
@@ -1370,12 +1355,12 @@ static int cpsw_ndo_stop(struct net_device *ndev) | |||
1370 | if (cpsw_common_res_usage_state(cpsw) <= 1) { | 1355 | if (cpsw_common_res_usage_state(cpsw) <= 1) { |
1371 | napi_disable(&cpsw->napi_rx); | 1356 | napi_disable(&cpsw->napi_rx); |
1372 | napi_disable(&cpsw->napi_tx); | 1357 | napi_disable(&cpsw->napi_tx); |
1373 | cpts_unregister(priv->cpts); | 1358 | cpts_unregister(cpsw->cpts); |
1374 | cpsw_intr_disable(cpsw); | 1359 | cpsw_intr_disable(cpsw); |
1375 | cpdma_ctlr_stop(cpsw->dma); | 1360 | cpdma_ctlr_stop(cpsw->dma); |
1376 | cpsw_ale_stop(priv->ale); | 1361 | cpsw_ale_stop(cpsw->ale); |
1377 | } | 1362 | } |
1378 | for_each_slave(priv, cpsw_slave_stop, priv); | 1363 | for_each_slave(priv, cpsw_slave_stop, cpsw); |
1379 | pm_runtime_put_sync(cpsw->dev); | 1364 | pm_runtime_put_sync(cpsw->dev); |
1380 | if (cpsw->data.dual_emac) | 1365 | if (cpsw->data.dual_emac) |
1381 | cpsw->slaves[priv->emac_port].open_stat = false; | 1366 | cpsw->slaves[priv->emac_port].open_stat = false; |
@@ -1398,7 +1383,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, | |||
1398 | } | 1383 | } |
1399 | 1384 | ||
1400 | if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && | 1385 | if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && |
1401 | priv->cpts->tx_enable) | 1386 | cpsw->cpts->tx_enable) |
1402 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | 1387 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; |
1403 | 1388 | ||
1404 | skb_tx_timestamp(skb); | 1389 | skb_tx_timestamp(skb); |
@@ -1424,13 +1409,12 @@ fail: | |||
1424 | 1409 | ||
1425 | #ifdef CONFIG_TI_CPTS | 1410 | #ifdef CONFIG_TI_CPTS |
1426 | 1411 | ||
1427 | static void cpsw_hwtstamp_v1(struct cpsw_priv *priv) | 1412 | static void cpsw_hwtstamp_v1(struct cpsw_common *cpsw) |
1428 | { | 1413 | { |
1429 | struct cpsw_common *cpsw = priv->cpsw; | ||
1430 | struct cpsw_slave *slave = &cpsw->slaves[cpsw->data.active_slave]; | 1414 | struct cpsw_slave *slave = &cpsw->slaves[cpsw->data.active_slave]; |
1431 | u32 ts_en, seq_id; | 1415 | u32 ts_en, seq_id; |
1432 | 1416 | ||
1433 | if (!priv->cpts->tx_enable && !priv->cpts->rx_enable) { | 1417 | if (!cpsw->cpts->tx_enable && !cpsw->cpts->rx_enable) { |
1434 | slave_write(slave, 0, CPSW1_TS_CTL); | 1418 | slave_write(slave, 0, CPSW1_TS_CTL); |
1435 | return; | 1419 | return; |
1436 | } | 1420 | } |
@@ -1438,10 +1422,10 @@ static void cpsw_hwtstamp_v1(struct cpsw_priv *priv) | |||
1438 | seq_id = (30 << CPSW_V1_SEQ_ID_OFS_SHIFT) | ETH_P_1588; | 1422 | seq_id = (30 << CPSW_V1_SEQ_ID_OFS_SHIFT) | ETH_P_1588; |
1439 | ts_en = EVENT_MSG_BITS << CPSW_V1_MSG_TYPE_OFS; | 1423 | ts_en = EVENT_MSG_BITS << CPSW_V1_MSG_TYPE_OFS; |
1440 | 1424 | ||
1441 | if (priv->cpts->tx_enable) | 1425 | if (cpsw->cpts->tx_enable) |
1442 | ts_en |= CPSW_V1_TS_TX_EN; | 1426 | ts_en |= CPSW_V1_TS_TX_EN; |
1443 | 1427 | ||
1444 | if (priv->cpts->rx_enable) | 1428 | if (cpsw->cpts->rx_enable) |
1445 | ts_en |= CPSW_V1_TS_RX_EN; | 1429 | ts_en |= CPSW_V1_TS_RX_EN; |
1446 | 1430 | ||
1447 | slave_write(slave, ts_en, CPSW1_TS_CTL); | 1431 | slave_write(slave, ts_en, CPSW1_TS_CTL); |
@@ -1460,24 +1444,24 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv) | |||
1460 | slave = &cpsw->slaves[cpsw->data.active_slave]; | 1444 | slave = &cpsw->slaves[cpsw->data.active_slave]; |
1461 | 1445 | ||
1462 | ctrl = slave_read(slave, CPSW2_CONTROL); | 1446 | ctrl = slave_read(slave, CPSW2_CONTROL); |
1463 | switch (priv->version) { | 1447 | switch (cpsw->version) { |
1464 | case CPSW_VERSION_2: | 1448 | case CPSW_VERSION_2: |
1465 | ctrl &= ~CTRL_V2_ALL_TS_MASK; | 1449 | ctrl &= ~CTRL_V2_ALL_TS_MASK; |
1466 | 1450 | ||
1467 | if (priv->cpts->tx_enable) | 1451 | if (cpsw->cpts->tx_enable) |
1468 | ctrl |= CTRL_V2_TX_TS_BITS; | 1452 | ctrl |= CTRL_V2_TX_TS_BITS; |
1469 | 1453 | ||
1470 | if (priv->cpts->rx_enable) | 1454 | if (cpsw->cpts->rx_enable) |
1471 | ctrl |= CTRL_V2_RX_TS_BITS; | 1455 | ctrl |= CTRL_V2_RX_TS_BITS; |
1472 | break; | 1456 | break; |
1473 | case CPSW_VERSION_3: | 1457 | case CPSW_VERSION_3: |
1474 | default: | 1458 | default: |
1475 | ctrl &= ~CTRL_V3_ALL_TS_MASK; | 1459 | ctrl &= ~CTRL_V3_ALL_TS_MASK; |
1476 | 1460 | ||
1477 | if (priv->cpts->tx_enable) | 1461 | if (cpsw->cpts->tx_enable) |
1478 | ctrl |= CTRL_V3_TX_TS_BITS; | 1462 | ctrl |= CTRL_V3_TX_TS_BITS; |
1479 | 1463 | ||
1480 | if (priv->cpts->rx_enable) | 1464 | if (cpsw->cpts->rx_enable) |
1481 | ctrl |= CTRL_V3_RX_TS_BITS; | 1465 | ctrl |= CTRL_V3_RX_TS_BITS; |
1482 | break; | 1466 | break; |
1483 | } | 1467 | } |
@@ -1492,12 +1476,13 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv) | |||
1492 | static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) | 1476 | static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) |
1493 | { | 1477 | { |
1494 | struct cpsw_priv *priv = netdev_priv(dev); | 1478 | struct cpsw_priv *priv = netdev_priv(dev); |
1495 | struct cpts *cpts = priv->cpts; | ||
1496 | struct hwtstamp_config cfg; | 1479 | struct hwtstamp_config cfg; |
1480 | struct cpsw_common *cpsw = priv->cpsw; | ||
1481 | struct cpts *cpts = cpsw->cpts; | ||
1497 | 1482 | ||
1498 | if (priv->version != CPSW_VERSION_1 && | 1483 | if (cpsw->version != CPSW_VERSION_1 && |
1499 | priv->version != CPSW_VERSION_2 && | 1484 | cpsw->version != CPSW_VERSION_2 && |
1500 | priv->version != CPSW_VERSION_3) | 1485 | cpsw->version != CPSW_VERSION_3) |
1501 | return -EOPNOTSUPP; | 1486 | return -EOPNOTSUPP; |
1502 | 1487 | ||
1503 | if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) | 1488 | if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) |
@@ -1537,9 +1522,9 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) | |||
1537 | 1522 | ||
1538 | cpts->tx_enable = cfg.tx_type == HWTSTAMP_TX_ON; | 1523 | cpts->tx_enable = cfg.tx_type == HWTSTAMP_TX_ON; |
1539 | 1524 | ||
1540 | switch (priv->version) { | 1525 | switch (cpsw->version) { |
1541 | case CPSW_VERSION_1: | 1526 | case CPSW_VERSION_1: |
1542 | cpsw_hwtstamp_v1(priv); | 1527 | cpsw_hwtstamp_v1(cpsw); |
1543 | break; | 1528 | break; |
1544 | case CPSW_VERSION_2: | 1529 | case CPSW_VERSION_2: |
1545 | case CPSW_VERSION_3: | 1530 | case CPSW_VERSION_3: |
@@ -1554,13 +1539,13 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) | |||
1554 | 1539 | ||
1555 | static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) | 1540 | static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) |
1556 | { | 1541 | { |
1557 | struct cpsw_priv *priv = netdev_priv(dev); | 1542 | struct cpsw_common *cpsw = ndev_to_cpsw(dev); |
1558 | struct cpts *cpts = priv->cpts; | 1543 | struct cpts *cpts = cpsw->cpts; |
1559 | struct hwtstamp_config cfg; | 1544 | struct hwtstamp_config cfg; |
1560 | 1545 | ||
1561 | if (priv->version != CPSW_VERSION_1 && | 1546 | if (cpsw->version != CPSW_VERSION_1 && |
1562 | priv->version != CPSW_VERSION_2 && | 1547 | cpsw->version != CPSW_VERSION_2 && |
1563 | priv->version != CPSW_VERSION_3) | 1548 | cpsw->version != CPSW_VERSION_3) |
1564 | return -EOPNOTSUPP; | 1549 | return -EOPNOTSUPP; |
1565 | 1550 | ||
1566 | cfg.flags = 0; | 1551 | cfg.flags = 0; |
@@ -1632,9 +1617,9 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) | |||
1632 | flags = ALE_VLAN; | 1617 | flags = ALE_VLAN; |
1633 | } | 1618 | } |
1634 | 1619 | ||
1635 | cpsw_ale_del_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM, | 1620 | cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, |
1636 | flags, vid); | 1621 | flags, vid); |
1637 | cpsw_ale_add_ucast(priv->ale, addr->sa_data, HOST_PORT_NUM, | 1622 | cpsw_ale_add_ucast(cpsw->ale, addr->sa_data, HOST_PORT_NUM, |
1638 | flags, vid); | 1623 | flags, vid); |
1639 | 1624 | ||
1640 | memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); | 1625 | memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); |
@@ -1680,27 +1665,27 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv, | |||
1680 | unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2; | 1665 | unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2; |
1681 | } | 1666 | } |
1682 | 1667 | ||
1683 | ret = cpsw_ale_add_vlan(priv->ale, vid, port_mask, 0, port_mask, | 1668 | ret = cpsw_ale_add_vlan(cpsw->ale, vid, port_mask, 0, port_mask, |
1684 | unreg_mcast_mask); | 1669 | unreg_mcast_mask); |
1685 | if (ret != 0) | 1670 | if (ret != 0) |
1686 | return ret; | 1671 | return ret; |
1687 | 1672 | ||
1688 | ret = cpsw_ale_add_ucast(priv->ale, priv->mac_addr, | 1673 | ret = cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, |
1689 | HOST_PORT_NUM, ALE_VLAN, vid); | 1674 | HOST_PORT_NUM, ALE_VLAN, vid); |
1690 | if (ret != 0) | 1675 | if (ret != 0) |
1691 | goto clean_vid; | 1676 | goto clean_vid; |
1692 | 1677 | ||
1693 | ret = cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, | 1678 | ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, |
1694 | port_mask, ALE_VLAN, vid, 0); | 1679 | port_mask, ALE_VLAN, vid, 0); |
1695 | if (ret != 0) | 1680 | if (ret != 0) |
1696 | goto clean_vlan_ucast; | 1681 | goto clean_vlan_ucast; |
1697 | return 0; | 1682 | return 0; |
1698 | 1683 | ||
1699 | clean_vlan_ucast: | 1684 | clean_vlan_ucast: |
1700 | cpsw_ale_del_ucast(priv->ale, priv->mac_addr, | 1685 | cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, |
1701 | HOST_PORT_NUM, ALE_VLAN, vid); | 1686 | HOST_PORT_NUM, ALE_VLAN, vid); |
1702 | clean_vid: | 1687 | clean_vid: |
1703 | cpsw_ale_del_vlan(priv->ale, vid, 0); | 1688 | cpsw_ale_del_vlan(cpsw->ale, vid, 0); |
1704 | return ret; | 1689 | return ret; |
1705 | } | 1690 | } |
1706 | 1691 | ||
@@ -1766,16 +1751,16 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, | |||
1766 | } | 1751 | } |
1767 | 1752 | ||
1768 | dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid); | 1753 | dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid); |
1769 | ret = cpsw_ale_del_vlan(priv->ale, vid, 0); | 1754 | ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0); |
1770 | if (ret != 0) | 1755 | if (ret != 0) |
1771 | return ret; | 1756 | return ret; |
1772 | 1757 | ||
1773 | ret = cpsw_ale_del_ucast(priv->ale, priv->mac_addr, | 1758 | ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, |
1774 | HOST_PORT_NUM, ALE_VLAN, vid); | 1759 | HOST_PORT_NUM, ALE_VLAN, vid); |
1775 | if (ret != 0) | 1760 | if (ret != 0) |
1776 | return ret; | 1761 | return ret; |
1777 | 1762 | ||
1778 | ret = cpsw_ale_del_mcast(priv->ale, priv->ndev->broadcast, | 1763 | ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, |
1779 | 0, ALE_VLAN, vid); | 1764 | 0, ALE_VLAN, vid); |
1780 | pm_runtime_put(cpsw->dev); | 1765 | pm_runtime_put(cpsw->dev); |
1781 | return ret; | 1766 | return ret; |
@@ -1808,13 +1793,13 @@ static int cpsw_get_regs_len(struct net_device *ndev) | |||
1808 | static void cpsw_get_regs(struct net_device *ndev, | 1793 | static void cpsw_get_regs(struct net_device *ndev, |
1809 | struct ethtool_regs *regs, void *p) | 1794 | struct ethtool_regs *regs, void *p) |
1810 | { | 1795 | { |
1811 | struct cpsw_priv *priv = netdev_priv(ndev); | ||
1812 | u32 *reg = p; | 1796 | u32 *reg = p; |
1797 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); | ||
1813 | 1798 | ||
1814 | /* update CPSW IP version */ | 1799 | /* update CPSW IP version */ |
1815 | regs->version = priv->version; | 1800 | regs->version = cpsw->version; |
1816 | 1801 | ||
1817 | cpsw_ale_dump(priv->ale, reg); | 1802 | cpsw_ale_dump(cpsw->ale, reg); |
1818 | } | 1803 | } |
1819 | 1804 | ||
1820 | static void cpsw_get_drvinfo(struct net_device *ndev, | 1805 | static void cpsw_get_drvinfo(struct net_device *ndev, |
@@ -1844,7 +1829,7 @@ static int cpsw_get_ts_info(struct net_device *ndev, | |||
1844 | struct ethtool_ts_info *info) | 1829 | struct ethtool_ts_info *info) |
1845 | { | 1830 | { |
1846 | #ifdef CONFIG_TI_CPTS | 1831 | #ifdef CONFIG_TI_CPTS |
1847 | struct cpsw_priv *priv = netdev_priv(ndev); | 1832 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
1848 | 1833 | ||
1849 | info->so_timestamping = | 1834 | info->so_timestamping = |
1850 | SOF_TIMESTAMPING_TX_HARDWARE | | 1835 | SOF_TIMESTAMPING_TX_HARDWARE | |
@@ -1853,7 +1838,7 @@ static int cpsw_get_ts_info(struct net_device *ndev, | |||
1853 | SOF_TIMESTAMPING_RX_SOFTWARE | | 1838 | SOF_TIMESTAMPING_RX_SOFTWARE | |
1854 | SOF_TIMESTAMPING_SOFTWARE | | 1839 | SOF_TIMESTAMPING_SOFTWARE | |
1855 | SOF_TIMESTAMPING_RAW_HARDWARE; | 1840 | SOF_TIMESTAMPING_RAW_HARDWARE; |
1856 | info->phc_index = priv->cpts->phc_index; | 1841 | info->phc_index = cpsw->cpts->phc_index; |
1857 | info->tx_types = | 1842 | info->tx_types = |
1858 | (1 << HWTSTAMP_TX_OFF) | | 1843 | (1 << HWTSTAMP_TX_OFF) | |
1859 | (1 << HWTSTAMP_TX_ON); | 1844 | (1 << HWTSTAMP_TX_ON); |
@@ -2188,7 +2173,6 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv) | |||
2188 | priv_sl2->ndev = ndev; | 2173 | priv_sl2->ndev = ndev; |
2189 | priv_sl2->dev = &ndev->dev; | 2174 | priv_sl2->dev = &ndev->dev; |
2190 | priv_sl2->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); | 2175 | priv_sl2->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); |
2191 | priv_sl2->rx_packet_max = max(rx_packet_max, 128); | ||
2192 | 2176 | ||
2193 | if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { | 2177 | if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { |
2194 | memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, | 2178 | memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, |
@@ -2202,13 +2186,8 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv) | |||
2202 | } | 2186 | } |
2203 | memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); | 2187 | memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); |
2204 | 2188 | ||
2205 | priv_sl2->coal_intvl = 0; | ||
2206 | priv_sl2->bus_freq_mhz = priv->bus_freq_mhz; | ||
2207 | priv_sl2->ale = priv->ale; | ||
2208 | priv_sl2->emac_port = 1; | 2189 | priv_sl2->emac_port = 1; |
2209 | cpsw->slaves[1].ndev = ndev; | 2190 | cpsw->slaves[1].ndev = ndev; |
2210 | priv_sl2->cpts = priv->cpts; | ||
2211 | priv_sl2->version = priv->version; | ||
2212 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | 2191 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; |
2213 | 2192 | ||
2214 | ndev->netdev_ops = &cpsw_netdev_ops; | 2193 | ndev->netdev_ops = &cpsw_netdev_ops; |
@@ -2296,9 +2275,9 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2296 | priv->ndev = ndev; | 2275 | priv->ndev = ndev; |
2297 | priv->dev = &ndev->dev; | 2276 | priv->dev = &ndev->dev; |
2298 | priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); | 2277 | priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); |
2299 | priv->rx_packet_max = max(rx_packet_max, 128); | 2278 | cpsw->rx_packet_max = max(rx_packet_max, 128); |
2300 | priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL); | 2279 | cpsw->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL); |
2301 | if (!priv->cpts) { | 2280 | if (!cpsw->cpts) { |
2302 | dev_err(&pdev->dev, "error allocating cpts\n"); | 2281 | dev_err(&pdev->dev, "error allocating cpts\n"); |
2303 | ret = -ENOMEM; | 2282 | ret = -ENOMEM; |
2304 | goto clean_ndev_ret; | 2283 | goto clean_ndev_ret; |
@@ -2355,8 +2334,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2355 | ret = -ENODEV; | 2334 | ret = -ENODEV; |
2356 | goto clean_runtime_disable_ret; | 2335 | goto clean_runtime_disable_ret; |
2357 | } | 2336 | } |
2358 | priv->coal_intvl = 0; | 2337 | cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; |
2359 | priv->bus_freq_mhz = clk_get_rate(clk) / 1000000; | ||
2360 | 2338 | ||
2361 | ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2339 | ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2362 | ss_regs = devm_ioremap_resource(&pdev->dev, ss_res); | 2340 | ss_regs = devm_ioremap_resource(&pdev->dev, ss_res); |
@@ -2374,7 +2352,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2374 | pm_runtime_put_noidle(&pdev->dev); | 2352 | pm_runtime_put_noidle(&pdev->dev); |
2375 | goto clean_runtime_disable_ret; | 2353 | goto clean_runtime_disable_ret; |
2376 | } | 2354 | } |
2377 | priv->version = readl(&cpsw->regs->id_ver); | 2355 | cpsw->version = readl(&cpsw->regs->id_ver); |
2378 | pm_runtime_put_sync(&pdev->dev); | 2356 | pm_runtime_put_sync(&pdev->dev); |
2379 | 2357 | ||
2380 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 2358 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
@@ -2387,10 +2365,10 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2387 | memset(&dma_params, 0, sizeof(dma_params)); | 2365 | memset(&dma_params, 0, sizeof(dma_params)); |
2388 | memset(&ale_params, 0, sizeof(ale_params)); | 2366 | memset(&ale_params, 0, sizeof(ale_params)); |
2389 | 2367 | ||
2390 | switch (priv->version) { | 2368 | switch (cpsw->version) { |
2391 | case CPSW_VERSION_1: | 2369 | case CPSW_VERSION_1: |
2392 | cpsw->host_port_regs = ss_regs + CPSW1_HOST_PORT_OFFSET; | 2370 | cpsw->host_port_regs = ss_regs + CPSW1_HOST_PORT_OFFSET; |
2393 | priv->cpts->reg = ss_regs + CPSW1_CPTS_OFFSET; | 2371 | cpsw->cpts->reg = ss_regs + CPSW1_CPTS_OFFSET; |
2394 | cpsw->hw_stats = ss_regs + CPSW1_HW_STATS; | 2372 | cpsw->hw_stats = ss_regs + CPSW1_HW_STATS; |
2395 | dma_params.dmaregs = ss_regs + CPSW1_CPDMA_OFFSET; | 2373 | dma_params.dmaregs = ss_regs + CPSW1_CPDMA_OFFSET; |
2396 | dma_params.txhdp = ss_regs + CPSW1_STATERAM_OFFSET; | 2374 | dma_params.txhdp = ss_regs + CPSW1_STATERAM_OFFSET; |
@@ -2404,7 +2382,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2404 | case CPSW_VERSION_3: | 2382 | case CPSW_VERSION_3: |
2405 | case CPSW_VERSION_4: | 2383 | case CPSW_VERSION_4: |
2406 | cpsw->host_port_regs = ss_regs + CPSW2_HOST_PORT_OFFSET; | 2384 | cpsw->host_port_regs = ss_regs + CPSW2_HOST_PORT_OFFSET; |
2407 | priv->cpts->reg = ss_regs + CPSW2_CPTS_OFFSET; | 2385 | cpsw->cpts->reg = ss_regs + CPSW2_CPTS_OFFSET; |
2408 | cpsw->hw_stats = ss_regs + CPSW2_HW_STATS; | 2386 | cpsw->hw_stats = ss_regs + CPSW2_HW_STATS; |
2409 | dma_params.dmaregs = ss_regs + CPSW2_CPDMA_OFFSET; | 2387 | dma_params.dmaregs = ss_regs + CPSW2_CPDMA_OFFSET; |
2410 | dma_params.txhdp = ss_regs + CPSW2_STATERAM_OFFSET; | 2388 | dma_params.txhdp = ss_regs + CPSW2_STATERAM_OFFSET; |
@@ -2416,7 +2394,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2416 | (u32 __force) ss_res->start + CPSW2_BD_OFFSET; | 2394 | (u32 __force) ss_res->start + CPSW2_BD_OFFSET; |
2417 | break; | 2395 | break; |
2418 | default: | 2396 | default: |
2419 | dev_err(priv->dev, "unknown version 0x%08x\n", priv->version); | 2397 | dev_err(priv->dev, "unknown version 0x%08x\n", cpsw->version); |
2420 | ret = -ENODEV; | 2398 | ret = -ENODEV; |
2421 | goto clean_runtime_disable_ret; | 2399 | goto clean_runtime_disable_ret; |
2422 | } | 2400 | } |
@@ -2466,8 +2444,8 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2466 | ale_params.ale_entries = data->ale_entries; | 2444 | ale_params.ale_entries = data->ale_entries; |
2467 | ale_params.ale_ports = data->slaves; | 2445 | ale_params.ale_ports = data->slaves; |
2468 | 2446 | ||
2469 | priv->ale = cpsw_ale_create(&ale_params); | 2447 | cpsw->ale = cpsw_ale_create(&ale_params); |
2470 | if (!priv->ale) { | 2448 | if (!cpsw->ale) { |
2471 | dev_err(priv->dev, "error initializing ale engine\n"); | 2449 | dev_err(priv->dev, "error initializing ale engine\n"); |
2472 | ret = -ENODEV; | 2450 | ret = -ENODEV; |
2473 | goto clean_dma_ret; | 2451 | goto clean_dma_ret; |
@@ -2555,7 +2533,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2555 | return 0; | 2533 | return 0; |
2556 | 2534 | ||
2557 | clean_ale_ret: | 2535 | clean_ale_ret: |
2558 | cpsw_ale_destroy(priv->ale); | 2536 | cpsw_ale_destroy(cpsw->ale); |
2559 | clean_dma_ret: | 2537 | clean_dma_ret: |
2560 | cpdma_ctlr_destroy(cpsw->dma); | 2538 | cpdma_ctlr_destroy(cpsw->dma); |
2561 | clean_runtime_disable_ret: | 2539 | clean_runtime_disable_ret: |
@@ -2568,8 +2546,7 @@ clean_ndev_ret: | |||
2568 | static int cpsw_remove(struct platform_device *pdev) | 2546 | static int cpsw_remove(struct platform_device *pdev) |
2569 | { | 2547 | { |
2570 | struct net_device *ndev = platform_get_drvdata(pdev); | 2548 | struct net_device *ndev = platform_get_drvdata(pdev); |
2571 | struct cpsw_priv *priv = netdev_priv(ndev); | 2549 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); |
2572 | struct cpsw_common *cpsw = priv->cpsw; | ||
2573 | int ret; | 2550 | int ret; |
2574 | 2551 | ||
2575 | ret = pm_runtime_get_sync(&pdev->dev); | 2552 | ret = pm_runtime_get_sync(&pdev->dev); |
@@ -2582,7 +2559,7 @@ static int cpsw_remove(struct platform_device *pdev) | |||
2582 | unregister_netdev(cpsw->slaves[1].ndev); | 2559 | unregister_netdev(cpsw->slaves[1].ndev); |
2583 | unregister_netdev(ndev); | 2560 | unregister_netdev(ndev); |
2584 | 2561 | ||
2585 | cpsw_ale_destroy(priv->ale); | 2562 | cpsw_ale_destroy(cpsw->ale); |
2586 | cpdma_ctlr_destroy(cpsw->dma); | 2563 | cpdma_ctlr_destroy(cpsw->dma); |
2587 | of_platform_depopulate(&pdev->dev); | 2564 | of_platform_depopulate(&pdev->dev); |
2588 | pm_runtime_put_sync(&pdev->dev); | 2565 | pm_runtime_put_sync(&pdev->dev); |