aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dm9000.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-06-24 17:16:04 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-06-24 22:58:07 -0400
commitf8dd0ecbb74d4b220b105d77c0633945ebb5453e (patch)
tree967cf1edddd83c99f3b579747dd2f70c7f96aadc /drivers/net/dm9000.c
parentaa1eb452e8d8a97ee65ace0054e7a733ae12cf6d (diff)
DM9000: Allow the use of the NSR register to get link status.
The DM9000's internal PHY reports a copy of the link status in the NSR register of the chip. Reading the status when polling for link status is faster as it eliminates the need to sleep, but does not print as much information. Add an platform flag to force this behaviour, and a Kconfig option to allow it to be forced to the faster method always. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/dm9000.c')
-rw-r--r--drivers/net/dm9000.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 7c38f6129b55..5ad2ec537684 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -552,15 +552,48 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
552 .set_eeprom = dm9000_set_eeprom, 552 .set_eeprom = dm9000_set_eeprom,
553}; 553};
554 554
555static void dm9000_show_carrier(board_info_t *db,
556 unsigned carrier, unsigned nsr)
557{
558 struct net_device *ndev = db->ndev;
559 unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
560
561 if (carrier)
562 dev_info(db->dev, "%s: link up, %dMbps, %s-duplex, no LPA\n",
563 ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
564 (ncr & NCR_FDX) ? "full" : "half");
565 else
566 dev_info(db->dev, "%s: link down\n", ndev->name);
567}
568
555static void 569static void
556dm9000_poll_work(struct work_struct *w) 570dm9000_poll_work(struct work_struct *w)
557{ 571{
558 struct delayed_work *dw = container_of(w, struct delayed_work, work); 572 struct delayed_work *dw = container_of(w, struct delayed_work, work);
559 board_info_t *db = container_of(dw, board_info_t, phy_poll); 573 board_info_t *db = container_of(dw, board_info_t, phy_poll);
574 struct net_device *ndev = db->ndev;
575
576 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
577 !(db->flags & DM9000_PLATF_EXT_PHY)) {
578 unsigned nsr = dm9000_read_locked(db, DM9000_NSR);
579 unsigned old_carrier = netif_carrier_ok(ndev) ? 1 : 0;
580 unsigned new_carrier;
560 581
561 mii_check_media(&db->mii, netif_msg_link(db), 0); 582 new_carrier = (nsr & NSR_LINKST) ? 1 : 0;
583
584 if (old_carrier != new_carrier) {
585 if (netif_msg_link(db))
586 dm9000_show_carrier(db, new_carrier, nsr);
587
588 if (!new_carrier)
589 netif_carrier_off(ndev);
590 else
591 netif_carrier_on(ndev);
592 }
593 } else
594 mii_check_media(&db->mii, netif_msg_link(db), 0);
562 595
563 if (netif_running(db->ndev)) 596 if (netif_running(ndev))
564 dm9000_schedule_poll(db); 597 dm9000_schedule_poll(db);
565} 598}
566 599
@@ -1267,6 +1300,10 @@ dm9000_probe(struct platform_device *pdev)
1267 db->flags = pdata->flags; 1300 db->flags = pdata->flags;
1268 } 1301 }
1269 1302
1303#ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
1304 db->flags |= DM9000_PLATF_SIMPLE_PHY;
1305#endif
1306
1270 dm9000_reset(db); 1307 dm9000_reset(db);
1271 1308
1272 /* try multiple times, DM9000 sometimes gets the read wrong */ 1309 /* try multiple times, DM9000 sometimes gets the read wrong */