mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] smc91111: add fixup for qemu phy support
@ 2013-09-19 11:41 Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  6:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-19 11:41 UTC (permalink / raw)
  To: barebox

as today qemu does not support phy, it will return always 0x0 to any read
on the mii bus. So the phy_id is 0 and the link is donw.

To have the norwork running on versatilpb & other qenu board for the link up
at 100Mbps.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/net/smc91111.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 48183dd..8c7a343 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -886,6 +886,7 @@ static void smc91c111_enable(struct eth_device *edev)
 static int smc91c111_eth_open(struct eth_device *edev)
 {
 	struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv;
+	int ret;
 
 	/* Configure the Receive/Phy Control register */
 	SMC_SELECT_BANK(priv, 0);
@@ -893,8 +894,27 @@ static int smc91c111_eth_open(struct eth_device *edev)
 
 	smc91c111_enable(edev);
 
-	return phy_device_connect(edev, &priv->miibus, 0, NULL,
+	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
 				 0, PHY_INTERFACE_MODE_NA);
+
+	if (ret)
+		return ret;
+
+	if (edev->phydev->phy_id == 0x00000000) {
+		struct phy_device *dev = edev->phydev;
+
+		dev->speed = SPEED_100;
+		dev->duplex = DUPLEX_FULL;
+		dev->autoneg = !AUTONEG_ENABLE;
+		dev->force = 1;
+		dev->link = 1;
+
+		dev_info(edev->parent, "phy with id 0x%08x detected this might be qemu\n",
+			dev->phy_id);
+		dev_info(edev->parent, "force link at 100Mpbs\n");
+	}
+
+	return 0;
 }
 
 static int smc91c111_eth_send(struct eth_device *edev, void *packet,
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/1] smc91111: add fixup for qemu phy support
  2013-09-19 11:41 [PATCH 1/1] smc91111: add fixup for qemu phy support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  6:50 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-09-20  6:50 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Sep 19, 2013 at 01:41:13PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as today qemu does not support phy, it will return always 0x0 to any read
> on the mii bus. So the phy_id is 0 and the link is donw.
> 
> To have the norwork running on versatilpb & other qenu board for the link up
> at 100Mbps.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  drivers/net/smc91111.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
> index 48183dd..8c7a343 100644
> --- a/drivers/net/smc91111.c
> +++ b/drivers/net/smc91111.c
> @@ -886,6 +886,7 @@ static void smc91c111_enable(struct eth_device *edev)
>  static int smc91c111_eth_open(struct eth_device *edev)
>  {
>  	struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv;
> +	int ret;
>  
>  	/* Configure the Receive/Phy Control register */
>  	SMC_SELECT_BANK(priv, 0);
> @@ -893,8 +894,27 @@ static int smc91c111_eth_open(struct eth_device *edev)
>  
>  	smc91c111_enable(edev);
>  
> -	return phy_device_connect(edev, &priv->miibus, 0, NULL,
> +	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
>  				 0, PHY_INTERFACE_MODE_NA);
> +
> +	if (ret)
> +		return ret;
> +
> +	if (edev->phydev->phy_id == 0x00000000) {

Can we make this test more explicit by adding a flag to platform_data?
Normally reading 0x0 from a phy means something is really wrong. Just
assuming everything is fine since it might be qemu is imo not good,

> +
> +		dev_info(edev->parent, "phy with id 0x%08x detected this might be qemu\n",
> +			dev->phy_id);

even if there's a warning message.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-09-20  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-19 11:41 [PATCH 1/1] smc91111: add fixup for qemu phy support Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  6:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox