netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: dm9000: Read GPR, modify and write
@ 2014-01-22  3:20 Chris Ruehl
  2014-01-22  3:20 ` [PATCH 2/2] net: dm9000: Only call PHY reset for TYPE-B on shutdown Chris Ruehl
  2014-01-22  7:15 ` [PATCH 1/2] net: dm9000: Read GPR, modify and write David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Ruehl @ 2014-01-22  3:20 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, davem, Chris Ruehl

The GPR register should be read, modified and write to
activate the PHY. A simple write 0 to the GPR might override
other register values with needs to keep.
Some codestyle fixes (mostly leading spaces)

Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
---
 drivers/net/ethernet/davicom/dm9000.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 7080ad6..0349b91 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -745,9 +745,9 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
 	.get_link		= dm9000_get_link,
 	.get_wol		= dm9000_get_wol,
 	.set_wol		= dm9000_set_wol,
- 	.get_eeprom_len		= dm9000_get_eeprom_len,
- 	.get_eeprom		= dm9000_get_eeprom,
- 	.set_eeprom		= dm9000_set_eeprom,
+	.get_eeprom_len		= dm9000_get_eeprom_len,
+	.get_eeprom		= dm9000_get_eeprom,
+	.set_eeprom		= dm9000_set_eeprom,
 };
 
 static void dm9000_show_carrier(board_info_t *db,
@@ -795,7 +795,7 @@ dm9000_poll_work(struct work_struct *w)
 		}
 	} else
 		mii_check_media(&db->mii, netif_msg_link(db), 0);
-	
+
 	if (netif_running(ndev))
 		dm9000_schedule_poll(db);
 }
@@ -1286,6 +1286,7 @@ dm9000_open(struct net_device *dev)
 {
 	board_info_t *db = netdev_priv(dev);
 	unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
+	int gprval;
 
 	if (netif_msg_ifup(db))
 		dev_dbg(db->dev, "enabling %s\n", dev->name);
@@ -1298,9 +1299,15 @@ dm9000_open(struct net_device *dev)
 
 	irqflags |= IRQF_SHARED;
 
+	gprval = ior(db, DM9000_GPR);
+
 	/* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
-	iow(db, DM9000_GPR, 0);	/* REG_1F bit0 activate phyxcer */
-	mdelay(1); /* delay needs by DM9000B */
+	if (gprval & (1<<0)) {
+		dev_dbg(db->dev, "Activate PHY GPR: 0x%x\n", gprval);
+		gprval = gprval & ~(1<<0);
+		iow(db, DM9000_GPR, gprval);	/* REG_1F bit0 activate phyxcer */
+		mdelay(1); /* delay needs by DM9000B */
+	}
 
 	/* Initialize DM9000 board */
 	dm9000_reset(db);
@@ -1314,7 +1321,7 @@ dm9000_open(struct net_device *dev)
 
 	mii_check_media(&db->mii, netif_msg_link(db), 1);
 	netif_start_queue(dev);
-	
+
 	dm9000_schedule_poll(db);
 
 	return 0;
@@ -1628,7 +1635,7 @@ dm9000_probe(struct platform_device *pdev)
 
 	if (!is_valid_ether_addr(ndev->dev_addr)) {
 		/* try reading from mac */
-		
+
 		mac_src = "chip";
 		for (i = 0; i < 6; i++)
 			ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
-- 
1.7.10.4

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

* [PATCH 2/2] net: dm9000: Only call PHY reset for TYPE-B on shutdown
  2014-01-22  3:20 [PATCH 1/2] net: dm9000: Read GPR, modify and write Chris Ruehl
@ 2014-01-22  3:20 ` Chris Ruehl
  2014-01-22  7:15 ` [PATCH 1/2] net: dm9000: Read GPR, modify and write David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Chris Ruehl @ 2014-01-22  3:20 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, davem, Chris Ruehl

Unconditional call of PHY reset can triggers a fault to detect
the link for DM9000A on reboot, only a hard reset can solve it.
This patch check the version of the chip and call the PHY reset
only for the B version of the chip.

Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
---
 drivers/net/ethernet/davicom/dm9000.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 0349b91..55a2e9c 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -1333,7 +1333,8 @@ dm9000_shutdown(struct net_device *dev)
 	board_info_t *db = netdev_priv(dev);
 
 	/* RESET device */
-	dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET);	/* PHY RESET */
+	if (db->type == TYPE_DM9000B)
+		dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET);	/* PHY RESET */
 	iow(db, DM9000_GPR, 0x01);	/* Power-Down PHY */
 	iow(db, DM9000_IMR, IMR_PAR);	/* Disable all interrupt */
 	iow(db, DM9000_RCR, 0x00);	/* Disable RX */
-- 
1.7.10.4

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

* Re: [PATCH 1/2] net: dm9000: Read GPR, modify and write
  2014-01-22  3:20 [PATCH 1/2] net: dm9000: Read GPR, modify and write Chris Ruehl
  2014-01-22  3:20 ` [PATCH 2/2] net: dm9000: Only call PHY reset for TYPE-B on shutdown Chris Ruehl
@ 2014-01-22  7:15 ` David Miller
  2014-01-22  7:41   ` Chris Ruehl
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-01-22  7:15 UTC (permalink / raw)
  To: chris.ruehl; +Cc: netdev, linux-kernel


Please do not mix coding style and functional changes.

Please resubmit this entire series once you have addressed
all feedback.

Thank you.

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

* Re: [PATCH 1/2] net: dm9000: Read GPR, modify and write
  2014-01-22  7:15 ` [PATCH 1/2] net: dm9000: Read GPR, modify and write David Miller
@ 2014-01-22  7:41   ` Chris Ruehl
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Ruehl @ 2014-01-22  7:41 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

On Wednesday, January 22, 2014 03:15 PM, David Miller wrote:
> Please do not mix coding style and functional changes.
>
> Please resubmit this entire series once you have addressed
> all feedback.
>
> Thank you.
Thanks for the advice. I will do.

Chris

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

end of thread, other threads:[~2014-01-22  7:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-22  3:20 [PATCH 1/2] net: dm9000: Read GPR, modify and write Chris Ruehl
2014-01-22  3:20 ` [PATCH 2/2] net: dm9000: Only call PHY reset for TYPE-B on shutdown Chris Ruehl
2014-01-22  7:15 ` [PATCH 1/2] net: dm9000: Read GPR, modify and write David Miller
2014-01-22  7:41   ` Chris Ruehl

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).