aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-08-09 19:22:42 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-10 20:27:40 -0400
commit606f39939595a4d4540406bfc11f265b2036af6d (patch)
tree9f2352b5856917877129abd7d518213b6a8b9bd8 /drivers/net/ethernet/ti
parente38b5a3db84c75c418d8c08863e005bda077f382 (diff)
net: ethernet: ti: cpsw: move platform data and slaves info to cpsw_common
These data are common for net devs in dual_emac mode. No need to hold it for every priv instance, so move them under cpsw_common. 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.c265
1 files changed, 137 insertions, 128 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index b2482b668044..ab5488b0cbae 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -140,9 +140,9 @@ do { \
140#define CPSW_CMINTMAX_INTVL (1000 / CPSW_CMINTMIN_CNT) 140#define CPSW_CMINTMAX_INTVL (1000 / CPSW_CMINTMIN_CNT)
141#define CPSW_CMINTMIN_INTVL ((1000 / CPSW_CMINTMAX_CNT) + 1) 141#define CPSW_CMINTMIN_INTVL ((1000 / CPSW_CMINTMAX_CNT) + 1)
142 142
143#define cpsw_slave_index(priv) \ 143#define cpsw_slave_index(cpsw, priv) \
144 ((priv->data.dual_emac) ? priv->emac_port : \ 144 ((cpsw->data.dual_emac) ? priv->emac_port : \
145 priv->data.active_slave) 145 cpsw->data.active_slave)
146#define IRQ_NUM 2 146#define IRQ_NUM 2
147 147
148static int debug_level; 148static int debug_level;
@@ -366,10 +366,12 @@ static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset)
366 366
367struct cpsw_common { 367struct cpsw_common {
368 struct device *dev; 368 struct device *dev;
369 struct cpsw_platform_data data;
369 struct cpsw_ss_regs __iomem *regs; 370 struct cpsw_ss_regs __iomem *regs;
370 struct cpsw_wr_regs __iomem *wr_regs; 371 struct cpsw_wr_regs __iomem *wr_regs;
371 u8 __iomem *hw_stats; 372 u8 __iomem *hw_stats;
372 struct cpsw_host_regs __iomem *host_port_regs; 373 struct cpsw_host_regs __iomem *host_port_regs;
374 struct cpsw_slave *slaves;
373 struct cpdma_ctlr *dma; 375 struct cpdma_ctlr *dma;
374 struct cpdma_chan *txch, *rxch; 376 struct cpdma_chan *txch, *rxch;
375 bool quirk_irq; 377 bool quirk_irq;
@@ -383,14 +385,12 @@ struct cpsw_priv {
383 struct napi_struct napi_rx; 385 struct napi_struct napi_rx;
384 struct napi_struct napi_tx; 386 struct napi_struct napi_tx;
385 struct device *dev; 387 struct device *dev;
386 struct cpsw_platform_data data;
387 u32 msg_enable; 388 u32 msg_enable;
388 u32 version; 389 u32 version;
389 u32 coal_intvl; 390 u32 coal_intvl;
390 u32 bus_freq_mhz; 391 u32 bus_freq_mhz;
391 int rx_packet_max; 392 int rx_packet_max;
392 u8 mac_addr[ETH_ALEN]; 393 u8 mac_addr[ETH_ALEN];
393 struct cpsw_slave *slaves;
394 struct cpsw_ale *ale; 394 struct cpsw_ale *ale;
395 bool rx_pause; 395 bool rx_pause;
396 bool tx_pause; 396 bool tx_pause;
@@ -492,38 +492,39 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
492#define for_each_slave(priv, func, arg...) \ 492#define for_each_slave(priv, func, arg...) \
493 do { \ 493 do { \
494 struct cpsw_slave *slave; \ 494 struct cpsw_slave *slave; \
495 struct cpsw_common *cpsw = (priv)->cpsw; \
495 int n; \ 496 int n; \
496 if (priv->data.dual_emac) \ 497 if (cpsw->data.dual_emac) \
497 (func)((priv)->slaves + priv->emac_port, ##arg);\ 498 (func)((cpsw)->slaves + priv->emac_port, ##arg);\
498 else \ 499 else \
499 for (n = (priv)->data.slaves, \ 500 for (n = cpsw->data.slaves, \
500 slave = (priv)->slaves; \ 501 slave = cpsw->slaves; \
501 n; n--) \ 502 n; n--) \
502 (func)(slave++, ##arg); \ 503 (func)(slave++, ##arg); \
503 } while (0) 504 } while (0)
504#define cpsw_get_slave_priv(priv, __slave_no__) \ 505#define cpsw_get_slave_priv(cpsw, __slave_no__) \
505 (((__slave_no__ < priv->data.slaves) && \ 506 (((__slave_no__ < cpsw->data.slaves) && \
506 (priv->slaves[__slave_no__].ndev)) ? \ 507 (cpsw->slaves[__slave_no__].ndev)) ? \
507 netdev_priv(priv->slaves[__slave_no__].ndev) : NULL) \ 508 netdev_priv(cpsw->slaves[__slave_no__].ndev) : NULL) \
508 509
509#define cpsw_dual_emac_src_port_detect(status, priv, ndev, skb) \ 510#define cpsw_dual_emac_src_port_detect(cpsw, status, priv, ndev, skb) \
510 do { \ 511 do { \
511 if (!priv->data.dual_emac) \ 512 if (!cpsw->data.dual_emac) \
512 break; \ 513 break; \
513 if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ 514 if (CPDMA_RX_SOURCE_PORT(status) == 1) { \
514 ndev = priv->slaves[0].ndev; \ 515 ndev = cpsw->slaves[0].ndev; \
515 priv = netdev_priv(ndev); \ 516 priv = netdev_priv(ndev); \
516 skb->dev = ndev; \ 517 skb->dev = ndev; \
517 } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ 518 } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \
518 ndev = priv->slaves[1].ndev; \ 519 ndev = cpsw->slaves[1].ndev; \
519 priv = netdev_priv(ndev); \ 520 priv = netdev_priv(ndev); \
520 skb->dev = ndev; \ 521 skb->dev = ndev; \
521 } \ 522 } \
522 } while (0) 523 } while (0)
523#define cpsw_add_mcast(priv, addr) \ 524#define cpsw_add_mcast(cpsw, priv, addr) \
524 do { \ 525 do { \
525 if (priv->data.dual_emac) { \ 526 if (cpsw->data.dual_emac) { \
526 struct cpsw_slave *slave = priv->slaves + \ 527 struct cpsw_slave *slave = cpsw->slaves + \
527 priv->emac_port; \ 528 priv->emac_port; \
528 int slave_port = cpsw_get_slave_port( \ 529 int slave_port = cpsw_get_slave_port( \
529 slave->slave_num); \ 530 slave->slave_num); \
@@ -545,18 +546,19 @@ static inline int cpsw_get_slave_port(u32 slave_num)
545static void cpsw_set_promiscious(struct net_device *ndev, bool enable) 546static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
546{ 547{
547 struct cpsw_priv *priv = netdev_priv(ndev); 548 struct cpsw_priv *priv = netdev_priv(ndev);
549 struct cpsw_common *cpsw = priv->cpsw;
548 struct cpsw_ale *ale = priv->ale; 550 struct cpsw_ale *ale = priv->ale;
549 int i; 551 int i;
550 552
551 if (priv->data.dual_emac) { 553 if (cpsw->data.dual_emac) {
552 bool flag = false; 554 bool flag = false;
553 555
554 /* Enabling promiscuous mode for one interface will be 556 /* Enabling promiscuous mode for one interface will be
555 * common for both the interface as the interface shares 557 * common for both the interface as the interface shares
556 * the same hardware resource. 558 * the same hardware resource.
557 */ 559 */
558 for (i = 0; i < priv->data.slaves; i++) 560 for (i = 0; i < cpsw->data.slaves; i++)
559 if (priv->slaves[i].ndev->flags & IFF_PROMISC) 561 if (cpsw->slaves[i].ndev->flags & IFF_PROMISC)
560 flag = true; 562 flag = true;
561 563
562 if (!enable && flag) { 564 if (!enable && flag) {
@@ -579,7 +581,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
579 unsigned long timeout = jiffies + HZ; 581 unsigned long timeout = jiffies + HZ;
580 582
581 /* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */ 583 /* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */
582 for (i = 0; i <= priv->data.slaves; i++) { 584 for (i = 0; i <= cpsw->data.slaves; i++) {
583 cpsw_ale_control_set(ale, i, 585 cpsw_ale_control_set(ale, i,
584 ALE_PORT_NOLEARN, 1); 586 ALE_PORT_NOLEARN, 1);
585 cpsw_ale_control_set(ale, i, 587 cpsw_ale_control_set(ale, i,
@@ -606,7 +608,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
606 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); 608 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
607 609
608 /* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */ 610 /* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */
609 for (i = 0; i <= priv->data.slaves; i++) { 611 for (i = 0; i <= cpsw->data.slaves; i++) {
610 cpsw_ale_control_set(ale, i, 612 cpsw_ale_control_set(ale, i,
611 ALE_PORT_NOLEARN, 0); 613 ALE_PORT_NOLEARN, 0);
612 cpsw_ale_control_set(ale, i, 614 cpsw_ale_control_set(ale, i,
@@ -620,12 +622,13 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
620static void cpsw_ndo_set_rx_mode(struct net_device *ndev) 622static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
621{ 623{
622 struct cpsw_priv *priv = netdev_priv(ndev); 624 struct cpsw_priv *priv = netdev_priv(ndev);
625 struct cpsw_common *cpsw = priv->cpsw;
623 int vid; 626 int vid;
624 627
625 if (priv->data.dual_emac) 628 if (cpsw->data.dual_emac)
626 vid = priv->slaves[priv->emac_port].port_vlan; 629 vid = cpsw->slaves[priv->emac_port].port_vlan;
627 else 630 else
628 vid = priv->data.default_vlan; 631 vid = cpsw->data.default_vlan;
629 632
630 if (ndev->flags & IFF_PROMISC) { 633 if (ndev->flags & IFF_PROMISC) {
631 /* Enable promiscuous mode */ 634 /* Enable promiscuous mode */
@@ -648,7 +651,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
648 651
649 /* program multicast address list into ALE register */ 652 /* program multicast address list into ALE register */
650 netdev_for_each_mc_addr(ha, ndev) { 653 netdev_for_each_mc_addr(ha, ndev) {
651 cpsw_add_mcast(priv, (u8 *)ha->addr); 654 cpsw_add_mcast(cpsw, priv, (u8 *)ha->addr);
652 } 655 }
653 } 656 }
654} 657}
@@ -697,16 +700,16 @@ static void cpsw_rx_handler(void *token, int len, int status)
697 int ret = 0; 700 int ret = 0;
698 struct cpsw_common *cpsw = priv->cpsw; 701 struct cpsw_common *cpsw = priv->cpsw;
699 702
700 cpsw_dual_emac_src_port_detect(status, priv, ndev, skb); 703 cpsw_dual_emac_src_port_detect(cpsw, status, priv, ndev, skb);
701 704
702 if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { 705 if (unlikely(status < 0) || unlikely(!netif_running(ndev))) {
703 bool ndev_status = false; 706 bool ndev_status = false;
704 struct cpsw_slave *slave = priv->slaves; 707 struct cpsw_slave *slave = cpsw->slaves;
705 int n; 708 int n;
706 709
707 if (priv->data.dual_emac) { 710 if (cpsw->data.dual_emac) {
708 /* In dual emac mode check for all interfaces */ 711 /* In dual emac mode check for all interfaces */
709 for (n = priv->data.slaves; n; n--, slave++) 712 for (n = cpsw->data.slaves; n; n--, slave++)
710 if (netif_running(slave->ndev)) 713 if (netif_running(slave->ndev))
711 ndev_status = true; 714 ndev_status = true;
712 } 715 }
@@ -848,6 +851,7 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
848 struct phy_device *phy = slave->phy; 851 struct phy_device *phy = slave->phy;
849 u32 mac_control = 0; 852 u32 mac_control = 0;
850 u32 slave_port; 853 u32 slave_port;
854 struct cpsw_common *cpsw = priv->cpsw;
851 855
852 if (!phy) 856 if (!phy)
853 return; 857 return;
@@ -855,7 +859,7 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
855 slave_port = cpsw_get_slave_port(slave->slave_num); 859 slave_port = cpsw_get_slave_port(slave->slave_num);
856 860
857 if (phy->link) { 861 if (phy->link) {
858 mac_control = priv->data.mac_control; 862 mac_control = cpsw->data.mac_control;
859 863
860 /* enable forwarding */ 864 /* enable forwarding */
861 cpsw_ale_control_set(priv->ale, slave_port, 865 cpsw_ale_control_set(priv->ale, slave_port,
@@ -973,11 +977,11 @@ update_return:
973 writel(int_ctrl, &cpsw->wr_regs->int_control); 977 writel(int_ctrl, &cpsw->wr_regs->int_control);
974 978
975 cpsw_notice(priv, timer, "Set coalesce to %d usecs.\n", coal_intvl); 979 cpsw_notice(priv, timer, "Set coalesce to %d usecs.\n", coal_intvl);
976 if (priv->data.dual_emac) { 980 if (cpsw->data.dual_emac) {
977 int i; 981 int i;
978 982
979 for (i = 0; i < priv->data.slaves; i++) { 983 for (i = 0; i < cpsw->data.slaves; i++) {
980 priv = netdev_priv(priv->slaves[i].ndev); 984 priv = netdev_priv(cpsw->slaves[i].ndev);
981 priv->coal_intvl = coal_intvl; 985 priv->coal_intvl = coal_intvl;
982 } 986 }
983 } else { 987 } else {
@@ -1050,16 +1054,16 @@ static void cpsw_get_ethtool_stats(struct net_device *ndev,
1050 } 1054 }
1051} 1055}
1052 1056
1053static int cpsw_common_res_usage_state(struct cpsw_priv *priv) 1057static int cpsw_common_res_usage_state(struct cpsw_common *cpsw)
1054{ 1058{
1055 u32 i; 1059 u32 i;
1056 u32 usage_count = 0; 1060 u32 usage_count = 0;
1057 1061
1058 if (!priv->data.dual_emac) 1062 if (!cpsw->data.dual_emac)
1059 return 0; 1063 return 0;
1060 1064
1061 for (i = 0; i < priv->data.slaves; i++) 1065 for (i = 0; i < cpsw->data.slaves; i++)
1062 if (priv->slaves[i].open_stat) 1066 if (cpsw->slaves[i].open_stat)
1063 usage_count++; 1067 usage_count++;
1064 1068
1065 return usage_count; 1069 return usage_count;
@@ -1071,7 +1075,7 @@ static inline int cpsw_tx_packet_submit(struct cpsw_priv *priv,
1071 struct cpsw_common *cpsw = priv->cpsw; 1075 struct cpsw_common *cpsw = priv->cpsw;
1072 1076
1073 return cpdma_chan_submit(cpsw->txch, skb, skb->data, skb->len, 1077 return cpdma_chan_submit(cpsw->txch, skb, skb->data, skb->len,
1074 priv->emac_port + priv->data.dual_emac); 1078 priv->emac_port + cpsw->data.dual_emac);
1075} 1079}
1076 1080
1077static inline void cpsw_add_dual_emac_def_ale_entries( 1081static inline void cpsw_add_dual_emac_def_ale_entries(
@@ -1129,7 +1133,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1129 1133
1130 slave_port = cpsw_get_slave_port(slave->slave_num); 1134 slave_port = cpsw_get_slave_port(slave->slave_num);
1131 1135
1132 if (priv->data.dual_emac) 1136 if (cpsw->data.dual_emac)
1133 cpsw_add_dual_emac_def_ale_entries(priv, slave, slave_port); 1137 cpsw_add_dual_emac_def_ale_entries(priv, slave, slave_port);
1134 else 1138 else
1135 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1139 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
@@ -1167,19 +1171,19 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1167 1171
1168static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) 1172static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
1169{ 1173{
1170 const int vlan = priv->data.default_vlan; 1174 struct cpsw_common *cpsw = priv->cpsw;
1175 const int vlan = cpsw->data.default_vlan;
1171 u32 reg; 1176 u32 reg;
1172 int i; 1177 int i;
1173 int unreg_mcast_mask; 1178 int unreg_mcast_mask;
1174 struct cpsw_common *cpsw = priv->cpsw;
1175 1179
1176 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : 1180 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
1177 CPSW2_PORT_VLAN; 1181 CPSW2_PORT_VLAN;
1178 1182
1179 writel(vlan, &cpsw->host_port_regs->port_vlan); 1183 writel(vlan, &cpsw->host_port_regs->port_vlan);
1180 1184
1181 for (i = 0; i < priv->data.slaves; i++) 1185 for (i = 0; i < cpsw->data.slaves; i++)
1182 slave_write(priv->slaves + i, vlan, reg); 1186 slave_write(cpsw->slaves + i, vlan, reg);
1183 1187
1184 if (priv->ndev->flags & IFF_ALLMULTI) 1188 if (priv->ndev->flags & IFF_ALLMULTI)
1185 unreg_mcast_mask = ALE_ALL_PORTS; 1189 unreg_mcast_mask = ALE_ALL_PORTS;
@@ -1207,7 +1211,7 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
1207 control_reg = readl(&cpsw->regs->control); 1211 control_reg = readl(&cpsw->regs->control);
1208 control_reg |= CPSW_VLAN_AWARE; 1212 control_reg |= CPSW_VLAN_AWARE;
1209 writel(control_reg, &cpsw->regs->control); 1213 writel(control_reg, &cpsw->regs->control);
1210 fifo_mode = (priv->data.dual_emac) ? CPSW_FIFO_DUAL_MAC_MODE : 1214 fifo_mode = (cpsw->data.dual_emac) ? CPSW_FIFO_DUAL_MAC_MODE :
1211 CPSW_FIFO_NORMAL_MODE; 1215 CPSW_FIFO_NORMAL_MODE;
1212 writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl); 1216 writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl);
1213 1217
@@ -1219,7 +1223,7 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
1219 cpsw_ale_control_set(priv->ale, HOST_PORT_NUM, 1223 cpsw_ale_control_set(priv->ale, HOST_PORT_NUM,
1220 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); 1224 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
1221 1225
1222 if (!priv->data.dual_emac) { 1226 if (!cpsw->data.dual_emac) {
1223 cpsw_ale_add_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM, 1227 cpsw_ale_add_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM,
1224 0, 0); 1228 0, 0);
1225 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1229 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
@@ -1256,7 +1260,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
1256 return ret; 1260 return ret;
1257 } 1261 }
1258 1262
1259 if (!cpsw_common_res_usage_state(priv)) 1263 if (!cpsw_common_res_usage_state(cpsw))
1260 cpsw_intr_disable(cpsw); 1264 cpsw_intr_disable(cpsw);
1261 netif_carrier_off(ndev); 1265 netif_carrier_off(ndev);
1262 1266
@@ -1267,19 +1271,19 @@ static int cpsw_ndo_open(struct net_device *ndev)
1267 CPSW_RTL_VERSION(reg)); 1271 CPSW_RTL_VERSION(reg));
1268 1272
1269 /* initialize host and slave ports */ 1273 /* initialize host and slave ports */
1270 if (!cpsw_common_res_usage_state(priv)) 1274 if (!cpsw_common_res_usage_state(cpsw))
1271 cpsw_init_host_port(priv); 1275 cpsw_init_host_port(priv);
1272 for_each_slave(priv, cpsw_slave_open, priv); 1276 for_each_slave(priv, cpsw_slave_open, priv);
1273 1277
1274 /* Add default VLAN */ 1278 /* Add default VLAN */
1275 if (!priv->data.dual_emac) 1279 if (!cpsw->data.dual_emac)
1276 cpsw_add_default_vlan(priv); 1280 cpsw_add_default_vlan(priv);
1277 else 1281 else
1278 cpsw_ale_add_vlan(priv->ale, priv->data.default_vlan, 1282 cpsw_ale_add_vlan(priv->ale, cpsw->data.default_vlan,
1279 ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0); 1283 ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);
1280 1284
1281 if (!cpsw_common_res_usage_state(priv)) { 1285 if (!cpsw_common_res_usage_state(cpsw)) {
1282 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0); 1286 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(cpsw, 0);
1283 int buf_num; 1287 int buf_num;
1284 1288
1285 /* setup tx dma to fixed prio and zero offset */ 1289 /* setup tx dma to fixed prio and zero offset */
@@ -1330,8 +1334,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
1330 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); 1334 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i);
1331 1335
1332 if (cpts_register(cpsw->dev, priv->cpts, 1336 if (cpts_register(cpsw->dev, priv->cpts,
1333 priv->data.cpts_clock_mult, 1337 cpsw->data.cpts_clock_mult,
1334 priv->data.cpts_clock_shift)) 1338 cpsw->data.cpts_clock_shift))
1335 dev_err(priv->dev, "error registering cpts device\n"); 1339 dev_err(priv->dev, "error registering cpts device\n");
1336 1340
1337 } 1341 }
@@ -1347,8 +1351,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
1347 cpdma_ctlr_start(cpsw->dma); 1351 cpdma_ctlr_start(cpsw->dma);
1348 cpsw_intr_enable(cpsw); 1352 cpsw_intr_enable(cpsw);
1349 1353
1350 if (priv->data.dual_emac) 1354 if (cpsw->data.dual_emac)
1351 priv->slaves[priv->emac_port].open_stat = true; 1355 cpsw->slaves[priv->emac_port].open_stat = true;
1352 return 0; 1356 return 0;
1353 1357
1354err_cleanup: 1358err_cleanup:
@@ -1368,8 +1372,8 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1368 netif_stop_queue(priv->ndev); 1372 netif_stop_queue(priv->ndev);
1369 netif_carrier_off(priv->ndev); 1373 netif_carrier_off(priv->ndev);
1370 1374
1371 if (cpsw_common_res_usage_state(priv) <= 1) { 1375 if (cpsw_common_res_usage_state(cpsw) <= 1) {
1372 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0); 1376 struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(cpsw, 0);
1373 1377
1374 napi_disable(&priv_sl0->napi_rx); 1378 napi_disable(&priv_sl0->napi_rx);
1375 napi_disable(&priv_sl0->napi_tx); 1379 napi_disable(&priv_sl0->napi_tx);
@@ -1380,8 +1384,8 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1380 } 1384 }
1381 for_each_slave(priv, cpsw_slave_stop, priv); 1385 for_each_slave(priv, cpsw_slave_stop, priv);
1382 pm_runtime_put_sync(cpsw->dev); 1386 pm_runtime_put_sync(cpsw->dev);
1383 if (priv->data.dual_emac) 1387 if (cpsw->data.dual_emac)
1384 priv->slaves[priv->emac_port].open_stat = false; 1388 cpsw->slaves[priv->emac_port].open_stat = false;
1385 return 0; 1389 return 0;
1386} 1390}
1387 1391
@@ -1429,7 +1433,8 @@ fail:
1429 1433
1430static void cpsw_hwtstamp_v1(struct cpsw_priv *priv) 1434static void cpsw_hwtstamp_v1(struct cpsw_priv *priv)
1431{ 1435{
1432 struct cpsw_slave *slave = &priv->slaves[priv->data.active_slave]; 1436 struct cpsw_common *cpsw = priv->cpsw;
1437 struct cpsw_slave *slave = &cpsw->slaves[cpsw->data.active_slave];
1433 u32 ts_en, seq_id; 1438 u32 ts_en, seq_id;
1434 1439
1435 if (!priv->cpts->tx_enable && !priv->cpts->rx_enable) { 1440 if (!priv->cpts->tx_enable && !priv->cpts->rx_enable) {
@@ -1456,10 +1461,10 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
1456 struct cpsw_common *cpsw = priv->cpsw; 1461 struct cpsw_common *cpsw = priv->cpsw;
1457 u32 ctrl, mtype; 1462 u32 ctrl, mtype;
1458 1463
1459 if (priv->data.dual_emac) 1464 if (cpsw->data.dual_emac)
1460 slave = &priv->slaves[priv->emac_port]; 1465 slave = &cpsw->slaves[priv->emac_port];
1461 else 1466 else
1462 slave = &priv->slaves[priv->data.active_slave]; 1467 slave = &cpsw->slaves[cpsw->data.active_slave];
1463 1468
1464 ctrl = slave_read(slave, CPSW2_CONTROL); 1469 ctrl = slave_read(slave, CPSW2_CONTROL);
1465 switch (priv->version) { 1470 switch (priv->version) {
@@ -1578,7 +1583,8 @@ static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
1578static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 1583static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1579{ 1584{
1580 struct cpsw_priv *priv = netdev_priv(dev); 1585 struct cpsw_priv *priv = netdev_priv(dev);
1581 int slave_no = cpsw_slave_index(priv); 1586 struct cpsw_common *cpsw = priv->cpsw;
1587 int slave_no = cpsw_slave_index(cpsw, priv);
1582 1588
1583 if (!netif_running(dev)) 1589 if (!netif_running(dev))
1584 return -EINVAL; 1590 return -EINVAL;
@@ -1592,9 +1598,9 @@ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1592#endif 1598#endif
1593 } 1599 }
1594 1600
1595 if (!priv->slaves[slave_no].phy) 1601 if (!cpsw->slaves[slave_no].phy)
1596 return -EOPNOTSUPP; 1602 return -EOPNOTSUPP;
1597 return phy_mii_ioctl(priv->slaves[slave_no].phy, req, cmd); 1603 return phy_mii_ioctl(cpsw->slaves[slave_no].phy, req, cmd);
1598} 1604}
1599 1605
1600static void cpsw_ndo_tx_timeout(struct net_device *ndev) 1606static void cpsw_ndo_tx_timeout(struct net_device *ndev)
@@ -1628,8 +1634,8 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
1628 return ret; 1634 return ret;
1629 } 1635 }
1630 1636
1631 if (priv->data.dual_emac) { 1637 if (cpsw->data.dual_emac) {
1632 vid = priv->slaves[priv->emac_port].port_vlan; 1638 vid = cpsw->slaves[priv->emac_port].port_vlan;
1633 flags = ALE_VLAN; 1639 flags = ALE_VLAN;
1634 } 1640 }
1635 1641
@@ -1666,8 +1672,9 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
1666 int ret; 1672 int ret;
1667 int unreg_mcast_mask = 0; 1673 int unreg_mcast_mask = 0;
1668 u32 port_mask; 1674 u32 port_mask;
1675 struct cpsw_common *cpsw = priv->cpsw;
1669 1676
1670 if (priv->data.dual_emac) { 1677 if (cpsw->data.dual_emac) {
1671 port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST; 1678 port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST;
1672 1679
1673 if (priv->ndev->flags & IFF_ALLMULTI) 1680 if (priv->ndev->flags & IFF_ALLMULTI)
@@ -1712,7 +1719,7 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
1712 struct cpsw_common *cpsw = priv->cpsw; 1719 struct cpsw_common *cpsw = priv->cpsw;
1713 int ret; 1720 int ret;
1714 1721
1715 if (vid == priv->data.default_vlan) 1722 if (vid == cpsw->data.default_vlan)
1716 return 0; 1723 return 0;
1717 1724
1718 ret = pm_runtime_get_sync(cpsw->dev); 1725 ret = pm_runtime_get_sync(cpsw->dev);
@@ -1721,15 +1728,15 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
1721 return ret; 1728 return ret;
1722 } 1729 }
1723 1730
1724 if (priv->data.dual_emac) { 1731 if (cpsw->data.dual_emac) {
1725 /* In dual EMAC, reserved VLAN id should not be used for 1732 /* In dual EMAC, reserved VLAN id should not be used for
1726 * creating VLAN interfaces as this can break the dual 1733 * creating VLAN interfaces as this can break the dual
1727 * EMAC port separation 1734 * EMAC port separation
1728 */ 1735 */
1729 int i; 1736 int i;
1730 1737
1731 for (i = 0; i < priv->data.slaves; i++) { 1738 for (i = 0; i < cpsw->data.slaves; i++) {
1732 if (vid == priv->slaves[i].port_vlan) 1739 if (vid == cpsw->slaves[i].port_vlan)
1733 return -EINVAL; 1740 return -EINVAL;
1734 } 1741 }
1735 } 1742 }
@@ -1748,7 +1755,7 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
1748 struct cpsw_common *cpsw = priv->cpsw; 1755 struct cpsw_common *cpsw = priv->cpsw;
1749 int ret; 1756 int ret;
1750 1757
1751 if (vid == priv->data.default_vlan) 1758 if (vid == cpsw->data.default_vlan)
1752 return 0; 1759 return 0;
1753 1760
1754 ret = pm_runtime_get_sync(cpsw->dev); 1761 ret = pm_runtime_get_sync(cpsw->dev);
@@ -1757,11 +1764,11 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
1757 return ret; 1764 return ret;
1758 } 1765 }
1759 1766
1760 if (priv->data.dual_emac) { 1767 if (cpsw->data.dual_emac) {
1761 int i; 1768 int i;
1762 1769
1763 for (i = 0; i < priv->data.slaves; i++) { 1770 for (i = 0; i < cpsw->data.slaves; i++) {
1764 if (vid == priv->slaves[i].port_vlan) 1771 if (vid == cpsw->slaves[i].port_vlan)
1765 return -EINVAL; 1772 return -EINVAL;
1766 } 1773 }
1767 } 1774 }
@@ -1801,9 +1808,9 @@ static const struct net_device_ops cpsw_netdev_ops = {
1801 1808
1802static int cpsw_get_regs_len(struct net_device *ndev) 1809static int cpsw_get_regs_len(struct net_device *ndev)
1803{ 1810{
1804 struct cpsw_priv *priv = netdev_priv(ndev); 1811 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
1805 1812
1806 return priv->data.ale_entries * ALE_ENTRY_WORDS * sizeof(u32); 1813 return cpsw->data.ale_entries * ALE_ENTRY_WORDS * sizeof(u32);
1807} 1814}
1808 1815
1809static void cpsw_get_regs(struct net_device *ndev, 1816static void cpsw_get_regs(struct net_device *ndev,
@@ -1877,10 +1884,11 @@ static int cpsw_get_settings(struct net_device *ndev,
1877 struct ethtool_cmd *ecmd) 1884 struct ethtool_cmd *ecmd)
1878{ 1885{
1879 struct cpsw_priv *priv = netdev_priv(ndev); 1886 struct cpsw_priv *priv = netdev_priv(ndev);
1880 int slave_no = cpsw_slave_index(priv); 1887 struct cpsw_common *cpsw = priv->cpsw;
1888 int slave_no = cpsw_slave_index(cpsw, priv);
1881 1889
1882 if (priv->slaves[slave_no].phy) 1890 if (cpsw->slaves[slave_no].phy)
1883 return phy_ethtool_gset(priv->slaves[slave_no].phy, ecmd); 1891 return phy_ethtool_gset(cpsw->slaves[slave_no].phy, ecmd);
1884 else 1892 else
1885 return -EOPNOTSUPP; 1893 return -EOPNOTSUPP;
1886} 1894}
@@ -1888,10 +1896,11 @@ static int cpsw_get_settings(struct net_device *ndev,
1888static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) 1896static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
1889{ 1897{
1890 struct cpsw_priv *priv = netdev_priv(ndev); 1898 struct cpsw_priv *priv = netdev_priv(ndev);
1891 int slave_no = cpsw_slave_index(priv); 1899 struct cpsw_common *cpsw = priv->cpsw;
1900 int slave_no = cpsw_slave_index(cpsw, priv);
1892 1901
1893 if (priv->slaves[slave_no].phy) 1902 if (cpsw->slaves[slave_no].phy)
1894 return phy_ethtool_sset(priv->slaves[slave_no].phy, ecmd); 1903 return phy_ethtool_sset(cpsw->slaves[slave_no].phy, ecmd);
1895 else 1904 else
1896 return -EOPNOTSUPP; 1905 return -EOPNOTSUPP;
1897} 1906}
@@ -1899,22 +1908,24 @@ static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
1899static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) 1908static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
1900{ 1909{
1901 struct cpsw_priv *priv = netdev_priv(ndev); 1910 struct cpsw_priv *priv = netdev_priv(ndev);
1902 int slave_no = cpsw_slave_index(priv); 1911 struct cpsw_common *cpsw = priv->cpsw;
1912 int slave_no = cpsw_slave_index(cpsw, priv);
1903 1913
1904 wol->supported = 0; 1914 wol->supported = 0;
1905 wol->wolopts = 0; 1915 wol->wolopts = 0;
1906 1916
1907 if (priv->slaves[slave_no].phy) 1917 if (cpsw->slaves[slave_no].phy)
1908 phy_ethtool_get_wol(priv->slaves[slave_no].phy, wol); 1918 phy_ethtool_get_wol(cpsw->slaves[slave_no].phy, wol);
1909} 1919}
1910 1920
1911static int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) 1921static int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
1912{ 1922{
1913 struct cpsw_priv *priv = netdev_priv(ndev); 1923 struct cpsw_priv *priv = netdev_priv(ndev);
1914 int slave_no = cpsw_slave_index(priv); 1924 struct cpsw_common *cpsw = priv->cpsw;
1925 int slave_no = cpsw_slave_index(cpsw, priv);
1915 1926
1916 if (priv->slaves[slave_no].phy) 1927 if (cpsw->slaves[slave_no].phy)
1917 return phy_ethtool_set_wol(priv->slaves[slave_no].phy, wol); 1928 return phy_ethtool_set_wol(cpsw->slaves[slave_no].phy, wol);
1918 else 1929 else
1919 return -EOPNOTSUPP; 1930 return -EOPNOTSUPP;
1920} 1931}
@@ -1990,13 +2001,12 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
1990 .complete = cpsw_ethtool_op_complete, 2001 .complete = cpsw_ethtool_op_complete,
1991}; 2002};
1992 2003
1993static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, 2004static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_common *cpsw,
1994 u32 slave_reg_ofs, u32 sliver_reg_ofs) 2005 u32 slave_reg_ofs, u32 sliver_reg_ofs)
1995{ 2006{
1996 struct cpsw_common *cpsw = priv->cpsw;
1997 void __iomem *regs = cpsw->regs; 2007 void __iomem *regs = cpsw->regs;
1998 int slave_num = slave->slave_num; 2008 int slave_num = slave->slave_num;
1999 struct cpsw_slave_data *data = priv->data.slave_data + slave_num; 2009 struct cpsw_slave_data *data = cpsw->data.slave_data + slave_num;
2000 2010
2001 slave->data = data; 2011 slave->data = data;
2002 slave->regs = regs + slave_reg_ofs; 2012 slave->regs = regs + slave_reg_ofs;
@@ -2169,11 +2179,11 @@ no_phy_slave:
2169 2179
2170static int cpsw_probe_dual_emac(struct cpsw_priv *priv) 2180static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
2171{ 2181{
2172 struct cpsw_platform_data *data = &priv->data; 2182 struct cpsw_common *cpsw = priv->cpsw;
2183 struct cpsw_platform_data *data = &cpsw->data;
2173 struct net_device *ndev; 2184 struct net_device *ndev;
2174 struct cpsw_priv *priv_sl2; 2185 struct cpsw_priv *priv_sl2;
2175 int ret = 0; 2186 int ret = 0;
2176 struct cpsw_common *cpsw = priv->cpsw;
2177 2187
2178 ndev = alloc_etherdev(sizeof(struct cpsw_priv)); 2188 ndev = alloc_etherdev(sizeof(struct cpsw_priv));
2179 if (!ndev) { 2189 if (!ndev) {
@@ -2182,8 +2192,7 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
2182 } 2192 }
2183 2193
2184 priv_sl2 = netdev_priv(ndev); 2194 priv_sl2 = netdev_priv(ndev);
2185 priv_sl2->cpsw = priv->cpsw; 2195 priv_sl2->cpsw = cpsw;
2186 priv_sl2->data = *data;
2187 priv_sl2->ndev = ndev; 2196 priv_sl2->ndev = ndev;
2188 priv_sl2->dev = &ndev->dev; 2197 priv_sl2->dev = &ndev->dev;
2189 priv_sl2->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); 2198 priv_sl2->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG);
@@ -2201,12 +2210,11 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
2201 } 2210 }
2202 memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); 2211 memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN);
2203 2212
2204 priv_sl2->slaves = priv->slaves;
2205 priv_sl2->coal_intvl = 0; 2213 priv_sl2->coal_intvl = 0;
2206 priv_sl2->bus_freq_mhz = priv->bus_freq_mhz; 2214 priv_sl2->bus_freq_mhz = priv->bus_freq_mhz;
2207 priv_sl2->ale = priv->ale; 2215 priv_sl2->ale = priv->ale;
2208 priv_sl2->emac_port = 1; 2216 priv_sl2->emac_port = 1;
2209 priv->slaves[1].ndev = ndev; 2217 cpsw->slaves[1].ndev = ndev;
2210 priv_sl2->cpts = priv->cpts; 2218 priv_sl2->cpts = priv->cpts;
2211 priv_sl2->version = priv->version; 2219 priv_sl2->version = priv->version;
2212 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 2220 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
@@ -2319,12 +2327,12 @@ static int cpsw_probe(struct platform_device *pdev)
2319 /* Select default pin state */ 2327 /* Select default pin state */
2320 pinctrl_pm_select_default_state(&pdev->dev); 2328 pinctrl_pm_select_default_state(&pdev->dev);
2321 2329
2322 if (cpsw_probe_dt(&priv->data, pdev)) { 2330 if (cpsw_probe_dt(&cpsw->data, pdev)) {
2323 dev_err(&pdev->dev, "cpsw: platform data missing\n"); 2331 dev_err(&pdev->dev, "cpsw: platform data missing\n");
2324 ret = -ENODEV; 2332 ret = -ENODEV;
2325 goto clean_runtime_disable_ret; 2333 goto clean_runtime_disable_ret;
2326 } 2334 }
2327 data = &priv->data; 2335 data = &cpsw->data;
2328 2336
2329 if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { 2337 if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
2330 memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN); 2338 memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
@@ -2336,17 +2344,17 @@ static int cpsw_probe(struct platform_device *pdev)
2336 2344
2337 memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); 2345 memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
2338 2346
2339 priv->slaves = devm_kzalloc(&pdev->dev, 2347 cpsw->slaves = devm_kzalloc(&pdev->dev,
2340 sizeof(struct cpsw_slave) * data->slaves, 2348 sizeof(struct cpsw_slave) * data->slaves,
2341 GFP_KERNEL); 2349 GFP_KERNEL);
2342 if (!priv->slaves) { 2350 if (!cpsw->slaves) {
2343 ret = -ENOMEM; 2351 ret = -ENOMEM;
2344 goto clean_runtime_disable_ret; 2352 goto clean_runtime_disable_ret;
2345 } 2353 }
2346 for (i = 0; i < data->slaves; i++) 2354 for (i = 0; i < data->slaves; i++)
2347 priv->slaves[i].slave_num = i; 2355 cpsw->slaves[i].slave_num = i;
2348 2356
2349 priv->slaves[0].ndev = ndev; 2357 cpsw->slaves[0].ndev = ndev;
2350 priv->emac_port = 0; 2358 priv->emac_port = 0;
2351 2359
2352 clk = devm_clk_get(&pdev->dev, "fck"); 2360 clk = devm_clk_get(&pdev->dev, "fck");
@@ -2420,9 +2428,10 @@ static int cpsw_probe(struct platform_device *pdev)
2420 ret = -ENODEV; 2428 ret = -ENODEV;
2421 goto clean_runtime_disable_ret; 2429 goto clean_runtime_disable_ret;
2422 } 2430 }
2423 for (i = 0; i < priv->data.slaves; i++) { 2431 for (i = 0; i < cpsw->data.slaves; i++) {
2424 struct cpsw_slave *slave = &priv->slaves[i]; 2432 struct cpsw_slave *slave = &cpsw->slaves[i];
2425 cpsw_slave_init(slave, priv, slave_offset, sliver_offset); 2433
2434 cpsw_slave_init(slave, cpsw, slave_offset, sliver_offset);
2426 slave_offset += slave_size; 2435 slave_offset += slave_size;
2427 sliver_offset += SLIVER_SIZE; 2436 sliver_offset += SLIVER_SIZE;
2428 } 2437 }
@@ -2543,7 +2552,7 @@ static int cpsw_probe(struct platform_device *pdev)
2543 cpsw_notice(priv, probe, "initialized device (regs %pa, irq %d)\n", 2552 cpsw_notice(priv, probe, "initialized device (regs %pa, irq %d)\n",
2544 &ss_res->start, ndev->irq); 2553 &ss_res->start, ndev->irq);
2545 2554
2546 if (priv->data.dual_emac) { 2555 if (cpsw->data.dual_emac) {
2547 ret = cpsw_probe_dual_emac(priv); 2556 ret = cpsw_probe_dual_emac(priv);
2548 if (ret) { 2557 if (ret) {
2549 cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); 2558 cpsw_err(priv, probe, "error probe slave 2 emac interface\n");
@@ -2577,8 +2586,8 @@ static int cpsw_remove(struct platform_device *pdev)
2577 return ret; 2586 return ret;
2578 } 2587 }
2579 2588
2580 if (priv->data.dual_emac) 2589 if (cpsw->data.dual_emac)
2581 unregister_netdev(priv->slaves[1].ndev); 2590 unregister_netdev(cpsw->slaves[1].ndev);
2582 unregister_netdev(ndev); 2591 unregister_netdev(ndev);
2583 2592
2584 cpsw_ale_destroy(priv->ale); 2593 cpsw_ale_destroy(priv->ale);
@@ -2586,8 +2595,8 @@ static int cpsw_remove(struct platform_device *pdev)
2586 of_platform_depopulate(&pdev->dev); 2595 of_platform_depopulate(&pdev->dev);
2587 pm_runtime_put_sync(&pdev->dev); 2596 pm_runtime_put_sync(&pdev->dev);
2588 pm_runtime_disable(&pdev->dev); 2597 pm_runtime_disable(&pdev->dev);
2589 if (priv->data.dual_emac) 2598 if (cpsw->data.dual_emac)
2590 free_netdev(priv->slaves[1].ndev); 2599 free_netdev(cpsw->slaves[1].ndev);
2591 free_netdev(ndev); 2600 free_netdev(ndev);
2592 return 0; 2601 return 0;
2593} 2602}
@@ -2597,14 +2606,14 @@ static int cpsw_suspend(struct device *dev)
2597{ 2606{
2598 struct platform_device *pdev = to_platform_device(dev); 2607 struct platform_device *pdev = to_platform_device(dev);
2599 struct net_device *ndev = platform_get_drvdata(pdev); 2608 struct net_device *ndev = platform_get_drvdata(pdev);
2600 struct cpsw_priv *priv = netdev_priv(ndev); 2609 struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
2601 2610
2602 if (priv->data.dual_emac) { 2611 if (cpsw->data.dual_emac) {
2603 int i; 2612 int i;
2604 2613
2605 for (i = 0; i < priv->data.slaves; i++) { 2614 for (i = 0; i < cpsw->data.slaves; i++) {
2606 if (netif_running(priv->slaves[i].ndev)) 2615 if (netif_running(cpsw->slaves[i].ndev))
2607 cpsw_ndo_stop(priv->slaves[i].ndev); 2616 cpsw_ndo_stop(cpsw->slaves[i].ndev);
2608 } 2617 }
2609 } else { 2618 } else {
2610 if (netif_running(ndev)) 2619 if (netif_running(ndev))
@@ -2621,17 +2630,17 @@ static int cpsw_resume(struct device *dev)
2621{ 2630{
2622 struct platform_device *pdev = to_platform_device(dev); 2631 struct platform_device *pdev = to_platform_device(dev);
2623 struct net_device *ndev = platform_get_drvdata(pdev); 2632 struct net_device *ndev = platform_get_drvdata(pdev);
2624 struct cpsw_priv *priv = netdev_priv(ndev); 2633 struct cpsw_common *cpsw = netdev_priv(ndev);
2625 2634
2626 /* Select default pin state */ 2635 /* Select default pin state */
2627 pinctrl_pm_select_default_state(dev); 2636 pinctrl_pm_select_default_state(dev);
2628 2637
2629 if (priv->data.dual_emac) { 2638 if (cpsw->data.dual_emac) {
2630 int i; 2639 int i;
2631 2640
2632 for (i = 0; i < priv->data.slaves; i++) { 2641 for (i = 0; i < cpsw->data.slaves; i++) {
2633 if (netif_running(priv->slaves[i].ndev)) 2642 if (netif_running(cpsw->slaves[i].ndev))
2634 cpsw_ndo_open(priv->slaves[i].ndev); 2643 cpsw_ndo_open(cpsw->slaves[i].ndev);
2635 } 2644 }
2636 } else { 2645 } else {
2637 if (netif_running(ndev)) 2646 if (netif_running(ndev))