aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/ti/Makefile2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c54
-rw-r--r--drivers/net/ethernet/ti/cpsw_priv.c5
-rw-r--r--drivers/net/ethernet/ti/cpsw_priv.h15
4 files changed, 34 insertions, 42 deletions
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index de1561596646..0a75c1957626 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -14,7 +14,7 @@ obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
14obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o 14obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o
15obj-$(CONFIG_TI_CPTS_MOD) += cpts.o 15obj-$(CONFIG_TI_CPTS_MOD) += cpts.o
16obj-$(CONFIG_TI_CPSW) += ti_cpsw.o 16obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
17ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o 17ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o cpsw_sl.o
18 18
19obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o 19obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
20keystone_netcp-y := netcp_core.o cpsw_ale.o 20keystone_netcp-y := netcp_core.o cpsw_ale.o
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 4219b13e6a8e..4449f2eeac09 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -38,6 +38,7 @@
38#include "cpsw.h" 38#include "cpsw.h"
39#include "cpsw_ale.h" 39#include "cpsw_ale.h"
40#include "cpsw_priv.h" 40#include "cpsw_priv.h"
41#include "cpsw_sl.h"
41#include "cpts.h" 42#include "cpts.h"
42#include "davinci_cpdma.h" 43#include "davinci_cpdma.h"
43 44
@@ -826,29 +827,32 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
826 slave_port = cpsw_get_slave_port(slave->slave_num); 827 slave_port = cpsw_get_slave_port(slave->slave_num);
827 828
828 if (phy->link) { 829 if (phy->link) {
829 mac_control = cpsw->data.mac_control; 830 mac_control = CPSW_SL_CTL_GMII_EN;
830
831 /* enable forwarding */
832 cpsw_ale_control_set(cpsw->ale, slave_port,
833 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
834 831
835 if (phy->speed == 1000) 832 if (phy->speed == 1000)
836 mac_control |= BIT(7); /* GIGABITEN */ 833 mac_control |= CPSW_SL_CTL_GIG;
837 if (phy->duplex) 834 if (phy->duplex)
838 mac_control |= BIT(0); /* FULLDUPLEXEN */ 835 mac_control |= CPSW_SL_CTL_FULLDUPLEX;
839 836
840 /* set speed_in input in case RMII mode is used in 100Mbps */ 837 /* set speed_in input in case RMII mode is used in 100Mbps */
841 if (phy->speed == 100) 838 if (phy->speed == 100)
842 mac_control |= BIT(15); 839 mac_control |= CPSW_SL_CTL_IFCTL_A;
843 /* in band mode only works in 10Mbps RGMII mode */ 840 /* in band mode only works in 10Mbps RGMII mode */
844 else if ((phy->speed == 10) && phy_interface_is_rgmii(phy)) 841 else if ((phy->speed == 10) && phy_interface_is_rgmii(phy))
845 mac_control |= BIT(18); /* In Band mode */ 842 mac_control |= CPSW_SL_CTL_EXT_EN; /* In Band mode */
846 843
847 if (priv->rx_pause) 844 if (priv->rx_pause)
848 mac_control |= BIT(3); 845 mac_control |= CPSW_SL_CTL_RX_FLOW_EN;
849 846
850 if (priv->tx_pause) 847 if (priv->tx_pause)
851 mac_control |= BIT(4); 848 mac_control |= CPSW_SL_CTL_TX_FLOW_EN;
849
850 if (mac_control != slave->mac_control)
851 cpsw_sl_ctl_set(slave->mac_sl, mac_control);
852
853 /* enable forwarding */
854 cpsw_ale_control_set(cpsw->ale, slave_port,
855 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
852 856
853 *link = true; 857 *link = true;
854 858
@@ -862,12 +866,14 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
862 /* disable forwarding */ 866 /* disable forwarding */
863 cpsw_ale_control_set(cpsw->ale, slave_port, 867 cpsw_ale_control_set(cpsw->ale, slave_port,
864 ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); 868 ALE_PORT_STATE, ALE_PORT_STATE_DISABLE);
869
870 cpsw_sl_wait_for_idle(slave->mac_sl, 100);
871
872 cpsw_sl_ctl_reset(slave->mac_sl);
865 } 873 }
866 874
867 if (mac_control != slave->mac_control) { 875 if (mac_control != slave->mac_control)
868 phy_print_status(phy); 876 phy_print_status(phy);
869 writel_relaxed(mac_control, &slave->sliver->mac_control);
870 }
871 877
872 slave->mac_control = mac_control; 878 slave->mac_control = mac_control;
873} 879}
@@ -1103,24 +1109,18 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
1103 ALE_PORT_DROP_UNKNOWN_VLAN, 1); 1109 ALE_PORT_DROP_UNKNOWN_VLAN, 1);
1104} 1110}
1105 1111
1106static void soft_reset_slave(struct cpsw_slave *slave)
1107{
1108 char name[32];
1109
1110 snprintf(name, sizeof(name), "slave-%d", slave->slave_num);
1111 soft_reset(name, &slave->sliver->soft_reset);
1112}
1113
1114static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) 1112static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1115{ 1113{
1116 u32 slave_port; 1114 u32 slave_port;
1117 struct phy_device *phy; 1115 struct phy_device *phy;
1118 struct cpsw_common *cpsw = priv->cpsw; 1116 struct cpsw_common *cpsw = priv->cpsw;
1119 1117
1120 soft_reset_slave(slave); 1118 cpsw_sl_reset(slave->mac_sl, 100);
1119 cpsw_sl_ctl_reset(slave->mac_sl);
1121 1120
1122 /* setup priority mapping */ 1121 /* setup priority mapping */
1123 writel_relaxed(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); 1122 cpsw_sl_reg_write(slave->mac_sl, CPSW_SL_RX_PRI_MAP,
1123 RX_PRIORITY_MAPPING);
1124 1124
1125 switch (cpsw->version) { 1125 switch (cpsw->version) {
1126 case CPSW_VERSION_1: 1126 case CPSW_VERSION_1:
@@ -1146,7 +1146,8 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1146 } 1146 }
1147 1147
1148 /* setup max packet size, and mac address */ 1148 /* setup max packet size, and mac address */
1149 writel_relaxed(cpsw->rx_packet_max, &slave->sliver->rx_maxlen); 1149 cpsw_sl_reg_write(slave->mac_sl, CPSW_SL_RX_MAXLEN,
1150 cpsw->rx_packet_max);
1150 cpsw_set_slave_mac(slave, priv); 1151 cpsw_set_slave_mac(slave, priv);
1151 1152
1152 slave->mac_control = 0; /* no link yet */ 1153 slave->mac_control = 0; /* no link yet */
@@ -1309,7 +1310,8 @@ static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw)
1309 slave->phy = NULL; 1310 slave->phy = NULL;
1310 cpsw_ale_control_set(cpsw->ale, slave_port, 1311 cpsw_ale_control_set(cpsw->ale, slave_port,
1311 ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); 1312 ALE_PORT_STATE, ALE_PORT_STATE_DISABLE);
1312 soft_reset_slave(slave); 1313 cpsw_sl_reset(slave->mac_sl, 100);
1314 cpsw_sl_ctl_reset(slave->mac_sl);
1313} 1315}
1314 1316
1315static int cpsw_tc_to_fifo(int tc, int num_tc) 1317static int cpsw_tc_to_fifo(int tc, int num_tc)
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index d4d1e0b397bc..476d050a022c 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -16,6 +16,7 @@
16#include "cpts.h" 16#include "cpts.h"
17#include "cpsw_ale.h" 17#include "cpsw_ale.h"
18#include "cpsw_priv.h" 18#include "cpsw_priv.h"
19#include "cpsw_sl.h"
19#include "davinci_cpdma.h" 20#include "davinci_cpdma.h"
20 21
21int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs, 22int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
@@ -78,8 +79,10 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
78 slave->slave_num = i; 79 slave->slave_num = i;
79 slave->data = &cpsw->data.slave_data[i]; 80 slave->data = &cpsw->data.slave_data[i];
80 slave->regs = regs + slave_offset; 81 slave->regs = regs + slave_offset;
81 slave->sliver = regs + sliver_offset;
82 slave->port_vlan = slave->data->dual_emac_res_vlan; 82 slave->port_vlan = slave->data->dual_emac_res_vlan;
83 slave->mac_sl = cpsw_sl_get("cpsw", dev, regs + sliver_offset);
84 if (IS_ERR(slave->mac_sl))
85 return PTR_ERR(slave->mac_sl);
83 86
84 slave_offset += slave_size; 87 slave_offset += slave_size;
85 sliver_offset += SLIVER_SIZE; 88 sliver_offset += SLIVER_SIZE;
diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h
index 53bd6e020f94..fc1a8dee391e 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.h
+++ b/drivers/net/ethernet/ti/cpsw_priv.h
@@ -269,19 +269,6 @@ struct cpsw_host_regs {
269 u32 cpdma_rx_chan_map; 269 u32 cpdma_rx_chan_map;
270}; 270};
271 271
272struct cpsw_sliver_regs {
273 u32 id_ver;
274 u32 mac_control;
275 u32 mac_status;
276 u32 soft_reset;
277 u32 rx_maxlen;
278 u32 __reserved_0;
279 u32 rx_pause;
280 u32 tx_pause;
281 u32 __reserved_1;
282 u32 rx_pri_map;
283};
284
285struct cpsw_hw_stats { 272struct cpsw_hw_stats {
286 u32 rxgoodframes; 273 u32 rxgoodframes;
287 u32 rxbroadcastframes; 274 u32 rxbroadcastframes;
@@ -344,13 +331,13 @@ struct cpsw_platform_data {
344 331
345struct cpsw_slave { 332struct cpsw_slave {
346 void __iomem *regs; 333 void __iomem *regs;
347 struct cpsw_sliver_regs __iomem *sliver;
348 int slave_num; 334 int slave_num;
349 u32 mac_control; 335 u32 mac_control;
350 struct cpsw_slave_data *data; 336 struct cpsw_slave_data *data;
351 struct phy_device *phy; 337 struct phy_device *phy;
352 struct net_device *ndev; 338 struct net_device *ndev;
353 u32 port_vlan; 339 u32 port_vlan;
340 struct cpsw_sl *mac_sl;
354}; 341};
355 342
356static inline u32 slave_read(struct cpsw_slave *slave, u32 offset) 343static inline u32 slave_read(struct cpsw_slave *slave, u32 offset)