netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] dm9000 improvements
@ 2013-10-16  8:41 Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 1/4] dm9000: during init reset phy only for dm9000b Nikita Kiryanov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Nikita Kiryanov @ 2013-10-16  8:41 UTC (permalink / raw)
  To: netdev
  Cc: Nikita Kiryanov, David S. Miller, Jingoo Han, Mugunthan V N,
	Michael Abbott, Igor Grinberg

This is a collection of improvements and bug fixes for dm9000, mostly
related to its startup and resume-from-suspend sequences.

Patch "Implement full reset of DM9000 network device" was submitted to the
linux-kernel mailing list but never applied.
An archive of the submission and the following conversation can be found here:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/02817.html

Cc: David S. Miller <davem@davemloft.net>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Michael Abbott <michael.abbott@diamond.ac.uk>
Cc: Igor Grinberg <grinberg@compulab.co.il>

Michael Abbott (1):
  dm9000: Implement full reset of DM9000 network device

Nikita Kiryanov (3):
  dm9000: during init reset phy only for dm9000b
  dm9000: take phy out of reset during init
  dm9000: report the correct LPA

 drivers/net/ethernet/davicom/dm9000.c | 56 ++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 18 deletions(-)

-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] dm9000: during init reset phy only for dm9000b
  2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
@ 2013-10-16  8:41 ` Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 2/4] dm9000: take phy out of reset during init Nikita Kiryanov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nikita Kiryanov @ 2013-10-16  8:41 UTC (permalink / raw)
  To: netdev
  Cc: Nikita Kiryanov, David S. Miller, Jingoo Han, Mugunthan V N,
	Igor Grinberg

Some of the changes introduced in commit 6741f40 (DM9000B: driver
initialization upgrade) break functionality on DM9000A
(error message during NFS boot: "dm9000 dm9000.0: eth0: link down")

Since the changes were meant to serve only DM9000B, make them
dependent on the chip type.

Cc: David S. Miller <davem@davemloft.net>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
 drivers/net/ethernet/davicom/dm9000.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 5f5896e..912983b 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -891,8 +891,13 @@ dm9000_init_dm9000(struct net_device *dev)
 
 	iow(db, DM9000_GPCR, GPCR_GEP_CNTL);	/* Let GPIO0 output */
 
-	dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
-	dm9000_phy_write(dev, 0, MII_DM_DSPCR, DSPCR_INIT_PARAM); /* Init */
+	/* If we are dealing with DM9000B, some extra steps are required: a
+	 * manual phy reset, and setting init params.
+	 */
+	if (db->type == TYPE_DM9000B) {
+		dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET);
+		dm9000_phy_write(dev, 0, MII_DM_DSPCR, DSPCR_INIT_PARAM);
+	}
 
 	ncr = (db->flags & DM9000_PLATF_EXT_PHY) ? NCR_EXT_PHY : 0;
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] dm9000: take phy out of reset during init
  2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 1/4] dm9000: during init reset phy only for dm9000b Nikita Kiryanov
@ 2013-10-16  8:41 ` Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 3/4] dm9000: Implement full reset of DM9000 network device Nikita Kiryanov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nikita Kiryanov @ 2013-10-16  8:41 UTC (permalink / raw)
  To: netdev
  Cc: Nikita Kiryanov, David S. Miller, Jingoo Han, Mugunthan V N,
	Igor Grinberg

Take the phy out of reset explicitly during system resume to avoid
losing network connectivity.

Cc: David S. Miller <davem@davemloft.net>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
 drivers/net/ethernet/davicom/dm9000.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 912983b..3f650ce 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -890,6 +890,7 @@ dm9000_init_dm9000(struct net_device *dev)
 			(dev->features & NETIF_F_RXCSUM) ? RCSR_CSUM : 0);
 
 	iow(db, DM9000_GPCR, GPCR_GEP_CNTL);	/* Let GPIO0 output */
+	iow(db, DM9000_GPR, 0);
 
 	/* If we are dealing with DM9000B, some extra steps are required: a
 	 * manual phy reset, and setting init params.
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] dm9000: Implement full reset of DM9000 network device
  2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 1/4] dm9000: during init reset phy only for dm9000b Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 2/4] dm9000: take phy out of reset during init Nikita Kiryanov
@ 2013-10-16  8:41 ` Nikita Kiryanov
  2013-10-16  8:41 ` [PATCH 4/4] dm9000: report the correct LPA Nikita Kiryanov
  2013-10-17 17:36 ` [PATCH 0/4] dm9000 improvements David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Nikita Kiryanov @ 2013-10-16  8:41 UTC (permalink / raw)
  To: netdev; +Cc: Michael Abbott, David S. Miller, Jingoo Han, Mugunthan V N

From: Michael Abbott <michael.abbott@diamond.ac.uk>

A Davicom application note for the DM9000 network device recommends
performing software reset twice to correctly initialise the device.
Without this reset some devices fail to initialise correctly on
system startup.

Cc: David S. Miller <davem@davemloft.net>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Michael Abbott <michael.abbott@diamond.ac.uk>
---
 drivers/net/ethernet/davicom/dm9000.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 3f650ce..a179f81 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -158,18 +158,6 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev)
 
 /* DM9000 network board routine ---------------------------- */
 
-static void
-dm9000_reset(board_info_t * db)
-{
-	dev_dbg(db->dev, "resetting device\n");
-
-	/* RESET device */
-	writeb(DM9000_NCR, db->io_addr);
-	udelay(200);
-	writeb(NCR_RST, db->io_data);
-	udelay(200);
-}
-
 /*
  *   Read a byte from I/O port
  */
@@ -191,6 +179,27 @@ iow(board_info_t * db, int reg, int value)
 	writeb(value, db->io_data);
 }
 
+static void
+dm9000_reset(board_info_t *db)
+{
+	dev_dbg(db->dev, "resetting device\n");
+
+	/* Reset DM9000, see DM9000 Application Notes V1.22 Jun 11, 2004 page 29
+	 * The essential point is that we have to do a double reset, and the
+	 * instruction is to set LBK into MAC internal loopback mode.
+	 */
+	iow(db, DM9000_NCR, 0x03);
+	udelay(100); /* Application note says at least 20 us */
+	if (ior(db, DM9000_NCR) & 1)
+		dev_err(db->dev, "dm9000 did not respond to first reset\n");
+
+	iow(db, DM9000_NCR, 0);
+	iow(db, DM9000_NCR, 0x03);
+	udelay(100);
+	if (ior(db, DM9000_NCR) & 1)
+		dev_err(db->dev, "dm9000 did not respond to second reset\n");
+}
+
 /* routines for sending block to chip */
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] dm9000: report the correct LPA
  2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
                   ` (2 preceding siblings ...)
  2013-10-16  8:41 ` [PATCH 3/4] dm9000: Implement full reset of DM9000 network device Nikita Kiryanov
@ 2013-10-16  8:41 ` Nikita Kiryanov
  2013-10-17 17:36 ` [PATCH 0/4] dm9000 improvements David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Nikita Kiryanov @ 2013-10-16  8:41 UTC (permalink / raw)
  To: netdev
  Cc: Nikita Kiryanov, David S. Miller, Jingoo Han, Mugunthan V N,
	Igor Grinberg

Report the LPA by checking mii_if_info, instead of just saying "no LPA" every
time.

Cc: David S. Miller <davem@davemloft.net>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
 drivers/net/ethernet/davicom/dm9000.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index a179f81..a7a941b 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -753,15 +753,20 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
 static void dm9000_show_carrier(board_info_t *db,
 				unsigned carrier, unsigned nsr)
 {
+	int lpa;
 	struct net_device *ndev = db->ndev;
+	struct mii_if_info *mii = &db->mii;
 	unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
 
-	if (carrier)
-		dev_info(db->dev, "%s: link up, %dMbps, %s-duplex, no LPA\n",
+	if (carrier) {
+		lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA);
+		dev_info(db->dev,
+			 "%s: link up, %dMbps, %s-duplex, lpa 0x%04X\n",
 			 ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
-			 (ncr & NCR_FDX) ? "full" : "half");
-	else
+			 (ncr & NCR_FDX) ? "full" : "half", lpa);
+	} else {
 		dev_info(db->dev, "%s: link down\n", ndev->name);
+	}
 }
 
 static void
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] dm9000 improvements
  2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
                   ` (3 preceding siblings ...)
  2013-10-16  8:41 ` [PATCH 4/4] dm9000: report the correct LPA Nikita Kiryanov
@ 2013-10-17 17:36 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-10-17 17:36 UTC (permalink / raw)
  To: nikita; +Cc: netdev, jg1.han, mugunthanvnm, michael.abbott, grinberg

From: Nikita Kiryanov <nikita@compulab.co.il>
Date: Wed, 16 Oct 2013 11:41:30 +0300

> This is a collection of improvements and bug fixes for dm9000, mostly
> related to its startup and resume-from-suspend sequences.
> 
> Patch "Implement full reset of DM9000 network device" was submitted to the
> linux-kernel mailing list but never applied.
> An archive of the submission and the following conversation can be found here:
> http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/02817.html

Series applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-17 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16  8:41 [PATCH 0/4] dm9000 improvements Nikita Kiryanov
2013-10-16  8:41 ` [PATCH 1/4] dm9000: during init reset phy only for dm9000b Nikita Kiryanov
2013-10-16  8:41 ` [PATCH 2/4] dm9000: take phy out of reset during init Nikita Kiryanov
2013-10-16  8:41 ` [PATCH 3/4] dm9000: Implement full reset of DM9000 network device Nikita Kiryanov
2013-10-16  8:41 ` [PATCH 4/4] dm9000: report the correct LPA Nikita Kiryanov
2013-10-17 17:36 ` [PATCH 0/4] dm9000 improvements David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).