aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2008-09-04 06:22:34 -0400
committerLennert Buytenhek <buytenh@marvell.com>2008-09-14 09:53:29 -0400
commit457b1d5a4b7b8c2b3b6bd032098da600c50dd6b2 (patch)
tree3c8788ee7c5343b311b751cc74bf84d8d4385fdd /drivers/net/mv643xx_eth.c
parent6b8f90c276ac25cd37f143a00d467a8ccb19c4c6 (diff)
mv643xx_eth: add support for chips without transmit bandwidth control
Add support for mv643xx_eth versions that have no transmit bandwidth control registers at all, such as the ethernet block found in the Marvell 88F6183 ARM SoC. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Diffstat (limited to 'drivers/net/mv643xx_eth.c')
-rw-r--r--drivers/net/mv643xx_eth.c89
1 files changed, 58 insertions, 31 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 6564be122acf..408827de7d3e 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -271,9 +271,13 @@ struct mv643xx_eth_shared_private {
271 */ 271 */
272 unsigned int t_clk; 272 unsigned int t_clk;
273 int extended_rx_coal_limit; 273 int extended_rx_coal_limit;
274 int tx_bw_control_moved; 274 int tx_bw_control;
275}; 275};
276 276
277#define TX_BW_CONTROL_ABSENT 0
278#define TX_BW_CONTROL_OLD_LAYOUT 1
279#define TX_BW_CONTROL_NEW_LAYOUT 2
280
277 281
278/* per-port *****************************************************************/ 282/* per-port *****************************************************************/
279struct mib_counters { 283struct mib_counters {
@@ -938,14 +942,17 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst)
938 if (bucket_size > 65535) 942 if (bucket_size > 65535)
939 bucket_size = 65535; 943 bucket_size = 65535;
940 944
941 if (mp->shared->tx_bw_control_moved) { 945 switch (mp->shared->tx_bw_control) {
942 wrl(mp, TX_BW_RATE_MOVED(mp->port_num), token_rate); 946 case TX_BW_CONTROL_OLD_LAYOUT:
943 wrl(mp, TX_BW_MTU_MOVED(mp->port_num), mtu);
944 wrl(mp, TX_BW_BURST_MOVED(mp->port_num), bucket_size);
945 } else {
946 wrl(mp, TX_BW_RATE(mp->port_num), token_rate); 947 wrl(mp, TX_BW_RATE(mp->port_num), token_rate);
947 wrl(mp, TX_BW_MTU(mp->port_num), mtu); 948 wrl(mp, TX_BW_MTU(mp->port_num), mtu);
948 wrl(mp, TX_BW_BURST(mp->port_num), bucket_size); 949 wrl(mp, TX_BW_BURST(mp->port_num), bucket_size);
950 break;
951 case TX_BW_CONTROL_NEW_LAYOUT:
952 wrl(mp, TX_BW_RATE_MOVED(mp->port_num), token_rate);
953 wrl(mp, TX_BW_MTU_MOVED(mp->port_num), mtu);
954 wrl(mp, TX_BW_BURST_MOVED(mp->port_num), bucket_size);
955 break;
949 } 956 }
950} 957}
951 958
@@ -977,14 +984,21 @@ static void txq_set_fixed_prio_mode(struct tx_queue *txq)
977 /* 984 /*
978 * Turn on fixed priority mode. 985 * Turn on fixed priority mode.
979 */ 986 */
980 if (mp->shared->tx_bw_control_moved) 987 off = 0;
981 off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num); 988 switch (mp->shared->tx_bw_control) {
982 else 989 case TX_BW_CONTROL_OLD_LAYOUT:
983 off = TXQ_FIX_PRIO_CONF(mp->port_num); 990 off = TXQ_FIX_PRIO_CONF(mp->port_num);
991 break;
992 case TX_BW_CONTROL_NEW_LAYOUT:
993 off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num);
994 break;
995 }
984 996
985 val = rdl(mp, off); 997 if (off) {
986 val |= 1 << txq->index; 998 val = rdl(mp, off);
987 wrl(mp, off, val); 999 val |= 1 << txq->index;
1000 wrl(mp, off, val);
1001 }
988} 1002}
989 1003
990static void txq_set_wrr(struct tx_queue *txq, int weight) 1004static void txq_set_wrr(struct tx_queue *txq, int weight)
@@ -996,23 +1010,30 @@ static void txq_set_wrr(struct tx_queue *txq, int weight)
996 /* 1010 /*
997 * Turn off fixed priority mode. 1011 * Turn off fixed priority mode.
998 */ 1012 */
999 if (mp->shared->tx_bw_control_moved) 1013 off = 0;
1000 off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num); 1014 switch (mp->shared->tx_bw_control) {
1001 else 1015 case TX_BW_CONTROL_OLD_LAYOUT:
1002 off = TXQ_FIX_PRIO_CONF(mp->port_num); 1016 off = TXQ_FIX_PRIO_CONF(mp->port_num);
1017 break;
1018 case TX_BW_CONTROL_NEW_LAYOUT:
1019 off = TXQ_FIX_PRIO_CONF_MOVED(mp->port_num);
1020 break;
1021 }
1003 1022
1004 val = rdl(mp, off); 1023 if (off) {
1005 val &= ~(1 << txq->index); 1024 val = rdl(mp, off);
1006 wrl(mp, off, val); 1025 val &= ~(1 << txq->index);
1026 wrl(mp, off, val);
1007 1027
1008 /* 1028 /*
1009 * Configure WRR weight for this queue. 1029 * Configure WRR weight for this queue.
1010 */ 1030 */
1011 off = TXQ_BW_WRR_CONF(mp->port_num, txq->index); 1031 off = TXQ_BW_WRR_CONF(mp->port_num, txq->index);
1012 1032
1013 val = rdl(mp, off); 1033 val = rdl(mp, off);
1014 val = (val & ~0xff) | (weight & 0xff); 1034 val = (val & ~0xff) | (weight & 0xff);
1015 wrl(mp, off, val); 1035 wrl(mp, off, val);
1036 }
1016} 1037}
1017 1038
1018 1039
@@ -2288,14 +2309,20 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
2288 msp->extended_rx_coal_limit = 0; 2309 msp->extended_rx_coal_limit = 0;
2289 2310
2290 /* 2311 /*
2291 * Check whether the TX rate control registers are in the 2312 * Check whether the MAC supports TX rate control, and if
2292 * old or the new place. 2313 * yes, whether its associated registers are in the old or
2314 * the new place.
2293 */ 2315 */
2294 writel(1, msp->base + TX_BW_MTU_MOVED(0)); 2316 writel(1, msp->base + TX_BW_MTU_MOVED(0));
2295 if (readl(msp->base + TX_BW_MTU_MOVED(0)) & 1) 2317 if (readl(msp->base + TX_BW_MTU_MOVED(0)) & 1) {
2296 msp->tx_bw_control_moved = 1; 2318 msp->tx_bw_control = TX_BW_CONTROL_NEW_LAYOUT;
2297 else 2319 } else {
2298 msp->tx_bw_control_moved = 0; 2320 writel(7, msp->base + TX_BW_RATE(0));
2321 if (readl(msp->base + TX_BW_RATE(0)) & 7)
2322 msp->tx_bw_control = TX_BW_CONTROL_OLD_LAYOUT;
2323 else
2324 msp->tx_bw_control = TX_BW_CONTROL_ABSENT;
2325 }
2299} 2326}
2300 2327
2301static int mv643xx_eth_shared_probe(struct platform_device *pdev) 2328static int mv643xx_eth_shared_probe(struct platform_device *pdev)