aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tsi108_eth.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-19 10:52:45 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-19 10:52:45 -0500
commit07ce198a1eb3431d04a6d59ea9fb7b71f21e33b1 (patch)
treefe6e6208bdcdfb7bbb0c81923efcb75bf73a299b /drivers/net/tsi108_eth.c
parent4bc87e62775052aac0be7574d5f84ff06f61c6b4 (diff)
parenta442585952f137bd4cdb1f2f3166e4157d383b82 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (60 commits) [NIU]: Bump driver version and release date. [NIU]: Fix BMAC alternate MAC address indexing. net: fix kernel-doc warnings in header files [IPV6]: Use BUG_ON instead of if + BUG in fib6_del_route. [IPV6]: dst_entry leak in ip4ip6_err. (resend) bluetooth: do not move child device other than rfcomm bluetooth: put hci dev after del conn [NET]: Elminate spurious print_mac() calls. [BLUETOOTH] hci_sysfs.c: Kill build warning. [NET]: Remove MAC_FMT net/8021q/vlan_dev.c: Use print_mac. [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer(). [BLUETOOTH] net/bluetooth/hci_core.c: Use time_* macros [IPV6]: Fix hardcoded removing of old module code [NETLABEL]: Move some initialization code into __init section. [NETLABEL]: Shrink the genl-ops registration code. [AX25] ax25_out: check skb for NULL in ax25_kick() [TCP]: Fix tcp_v4_send_synack() comment [IPV4]: fix alignment of IP-Config output Documentation: fix tcp.txt ...
Diffstat (limited to 'drivers/net/tsi108_eth.c')
-rw-r--r--drivers/net/tsi108_eth.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index 35d15e850075..6f33f84d37b0 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -36,6 +36,7 @@
36#include <linux/net.h> 36#include <linux/net.h>
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include <linux/etherdevice.h> 38#include <linux/etherdevice.h>
39#include <linux/ethtool.h>
39#include <linux/skbuff.h> 40#include <linux/skbuff.h>
40#include <linux/slab.h> 41#include <linux/slab.h>
41#include <linux/spinlock.h> 42#include <linux/spinlock.h>
@@ -297,18 +298,11 @@ static void tsi108_check_phy(struct net_device *dev)
297 u32 speed; 298 u32 speed;
298 unsigned long flags; 299 unsigned long flags;
299 300
300 /* Do a dummy read, as for some reason the first read
301 * after a link becomes up returns link down, even if
302 * it's been a while since the link came up.
303 */
304
305 spin_lock_irqsave(&phy_lock, flags); 301 spin_lock_irqsave(&phy_lock, flags);
306 302
307 if (!data->phy_ok) 303 if (!data->phy_ok)
308 goto out; 304 goto out;
309 305
310 tsi108_read_mii(data, MII_BMSR);
311
312 duplex = mii_check_media(&data->mii_if, netif_msg_link(data), data->init_media); 306 duplex = mii_check_media(&data->mii_if, netif_msg_link(data), data->init_media);
313 data->init_media = 0; 307 data->init_media = 0;
314 308
@@ -345,22 +339,21 @@ static void tsi108_check_phy(struct net_device *dev)
345 339
346 TSI_WRITE(TSI108_MAC_CFG2, mac_cfg2_reg); 340 TSI_WRITE(TSI108_MAC_CFG2, mac_cfg2_reg);
347 TSI_WRITE(TSI108_EC_PORTCTRL, portctrl_reg); 341 TSI_WRITE(TSI108_EC_PORTCTRL, portctrl_reg);
342 }
348 343
349 if (data->link_up == 0) { 344 if (data->link_up == 0) {
350 /* The manual says it can take 3-4 usecs for the speed change 345 /* The manual says it can take 3-4 usecs for the speed change
351 * to take effect. 346 * to take effect.
352 */ 347 */
353 udelay(5); 348 udelay(5);
354 349
355 spin_lock(&data->txlock); 350 spin_lock(&data->txlock);
356 if (is_valid_ether_addr(dev->dev_addr) && data->txfree) 351 if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
357 netif_wake_queue(dev); 352 netif_wake_queue(dev);
358 353
359 data->link_up = 1; 354 data->link_up = 1;
360 spin_unlock(&data->txlock); 355 spin_unlock(&data->txlock);
361 }
362 } 356 }
363
364 } else { 357 } else {
365 if (data->link_up == 1) { 358 if (data->link_up == 1) {
366 netif_stop_queue(dev); 359 netif_stop_queue(dev);
@@ -1274,12 +1267,11 @@ static void tsi108_init_phy(struct net_device *dev)
1274 * PHY_STAT register before the link up status bit is set. 1267 * PHY_STAT register before the link up status bit is set.
1275 */ 1268 */
1276 1269
1277 data->link_up = 1; 1270 data->link_up = 0;
1278 1271
1279 while (!((phyval = tsi108_read_mii(data, MII_BMSR)) & 1272 while (!((phyval = tsi108_read_mii(data, MII_BMSR)) &
1280 BMSR_LSTATUS)) { 1273 BMSR_LSTATUS)) {
1281 if (i++ > (MII_READ_DELAY / 10)) { 1274 if (i++ > (MII_READ_DELAY / 10)) {
1282 data->link_up = 0;
1283 break; 1275 break;
1284 } 1276 }
1285 spin_unlock_irqrestore(&phy_lock, flags); 1277 spin_unlock_irqrestore(&phy_lock, flags);
@@ -1287,6 +1279,7 @@ static void tsi108_init_phy(struct net_device *dev)
1287 spin_lock_irqsave(&phy_lock, flags); 1279 spin_lock_irqsave(&phy_lock, flags);
1288 } 1280 }
1289 1281
1282 data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
1290 printk(KERN_DEBUG "PHY_STAT reg contains %08x\n", phyval); 1283 printk(KERN_DEBUG "PHY_STAT reg contains %08x\n", phyval);
1291 data->phy_ok = 1; 1284 data->phy_ok = 1;
1292 data->init_media = 1; 1285 data->init_media = 1;
@@ -1527,12 +1520,46 @@ static void tsi108_init_mac(struct net_device *dev)
1527 TSI_WRITE(TSI108_EC_INTMASK, ~0); 1520 TSI_WRITE(TSI108_EC_INTMASK, ~0);
1528} 1521}
1529 1522
1523static int tsi108_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1524{
1525 struct tsi108_prv_data *data = netdev_priv(dev);
1526 unsigned long flags;
1527 int rc;
1528
1529 spin_lock_irqsave(&data->txlock, flags);
1530 rc = mii_ethtool_gset(&data->mii_if, cmd);
1531 spin_unlock_irqrestore(&data->txlock, flags);
1532
1533 return rc;
1534}
1535
1536static int tsi108_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1537{
1538 struct tsi108_prv_data *data = netdev_priv(dev);
1539 unsigned long flags;
1540 int rc;
1541
1542 spin_lock_irqsave(&data->txlock, flags);
1543 rc = mii_ethtool_sset(&data->mii_if, cmd);
1544 spin_unlock_irqrestore(&data->txlock, flags);
1545
1546 return rc;
1547}
1548
1530static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1549static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1531{ 1550{
1532 struct tsi108_prv_data *data = netdev_priv(dev); 1551 struct tsi108_prv_data *data = netdev_priv(dev);
1552 if (!netif_running(dev))
1553 return -EINVAL;
1533 return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL); 1554 return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
1534} 1555}
1535 1556
1557static const struct ethtool_ops tsi108_ethtool_ops = {
1558 .get_link = ethtool_op_get_link,
1559 .get_settings = tsi108_get_settings,
1560 .set_settings = tsi108_set_settings,
1561};
1562
1536static int 1563static int
1537tsi108_init_one(struct platform_device *pdev) 1564tsi108_init_one(struct platform_device *pdev)
1538{ 1565{
@@ -1584,7 +1611,6 @@ tsi108_init_one(struct platform_device *pdev)
1584 data->mii_if.phy_id = einfo->phy; 1611 data->mii_if.phy_id = einfo->phy;
1585 data->mii_if.phy_id_mask = 0x1f; 1612 data->mii_if.phy_id_mask = 0x1f;
1586 data->mii_if.reg_num_mask = 0x1f; 1613 data->mii_if.reg_num_mask = 0x1f;
1587 data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
1588 1614
1589 data->phy = einfo->phy; 1615 data->phy = einfo->phy;
1590 data->phy_type = einfo->phy_type; 1616 data->phy_type = einfo->phy_type;
@@ -1598,6 +1624,7 @@ tsi108_init_one(struct platform_device *pdev)
1598 dev->get_stats = tsi108_get_stats; 1624 dev->get_stats = tsi108_get_stats;
1599 netif_napi_add(dev, &data->napi, tsi108_poll, 64); 1625 netif_napi_add(dev, &data->napi, tsi108_poll, 64);
1600 dev->do_ioctl = tsi108_do_ioctl; 1626 dev->do_ioctl = tsi108_do_ioctl;
1627 dev->ethtool_ops = &tsi108_ethtool_ops;
1601 1628
1602 /* Apparently, the Linux networking code won't use scatter-gather 1629 /* Apparently, the Linux networking code won't use scatter-gather
1603 * if the hardware doesn't do checksums. However, it's faster 1630 * if the hardware doesn't do checksums. However, it's faster
@@ -1629,6 +1656,7 @@ tsi108_init_one(struct platform_device *pdev)
1629 goto register_fail; 1656 goto register_fail;
1630 } 1657 }
1631 1658
1659 platform_set_drvdata(pdev, dev);
1632 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %s\n", 1660 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %s\n",
1633 dev->name, print_mac(mac, dev->dev_addr)); 1661 dev->name, print_mac(mac, dev->dev_addr));
1634#ifdef DEBUG 1662#ifdef DEBUG