mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2 v3] smc91111: add fixup for qemu phy support
@ 2013-09-22  5:12 Jean-Christophe PLAGNIOL-VILLARD
  2013-09-22  5:12 ` [PATCH 2/2 v3] versatilepb: enable qemu fixup Jean-Christophe PLAGNIOL-VILLARD
  2013-09-22 18:28 ` [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-22  5:12 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.

Only enable if qemu_fixup is set.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/net/smc91111.c | 30 +++++++++++++++++++++++++++++-
 include/net/smc91111.h | 14 ++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 include/net/smc91111.h

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index b868cbf..ba81e24 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -66,6 +66,7 @@
 #include <clock.h>
 #include <io.h>
 #include <linux/phy.h>
+#include <net/smc91111.h>
 
 /*---------------------------------------------------------------
  .
@@ -446,6 +447,7 @@ struct smc91c111_priv {
 	struct mii_bus miibus;
 	struct accessors a;
 	void __iomem *base;
+	int qemu_fixup;
 };
 
 #if (SMC_DEBUG > 2 )
@@ -882,6 +884,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);
@@ -889,8 +892,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 (priv->qemu_fixup && 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,
@@ -1286,6 +1308,12 @@ static int smc91c111_probe(struct device_d *dev)
 
 	priv = edev->priv;
 
+	if (dev->platform_data) {
+		struct smc91c111_pdata *pdata = dev->platform_data;
+
+		priv->qemu_fixup = pdata->qemu_fixup;
+	}
+
 	priv->a = access_via_32bit;
 
 	edev->init = smc91c111_init_dev;
diff --git a/include/net/smc91111.h b/include/net/smc91111.h
new file mode 100644
index 0000000..0b2d49b
--- /dev/null
+++ b/include/net/smc91111.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __SMC91111_H__
+#define __SMC91111_H__
+
+struct smc91c111_pdata {
+	int qemu_fixup;
+};
+
+#endif /* __SMC91111_H__ */
-- 
1.8.4.rc3


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

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

* [PATCH 2/2 v3] versatilepb: enable qemu fixup
  2013-09-22  5:12 [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-22  5:12 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-22 18:28 ` [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-22  5:12 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/versatile/versatilepb.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/versatile/versatilepb.c b/arch/arm/boards/versatile/versatilepb.c
index ebf3695..3df59ba 100644
--- a/arch/arm/boards/versatile/versatilepb.c
+++ b/arch/arm/boards/versatile/versatilepb.c
@@ -28,6 +28,7 @@
 #include <environment.h>
 #include <partition.h>
 #include <sizes.h>
+#include <net/smc91111.h>
 
 static int vpb_console_init(void)
 {
@@ -47,6 +48,10 @@ static int vpb_mem_init(void)
 }
 mem_initcall(vpb_mem_init);
 
+static struct smc91c111_pdata net_pdata = {
+	.qemu_fixup = 1,
+};
+
 static int vpb_devices_init(void)
 {
 	add_cfi_flash_device(DEVICE_ID_DYNAMIC, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
@@ -55,7 +60,7 @@ static int vpb_devices_init(void)
 	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
 
 	add_generic_device("smc91c111", DEVICE_ID_DYNAMIC, NULL, VERSATILE_ETH_BASE,
-			64 * 1024, IORESOURCE_MEM, NULL);
+			64 * 1024, IORESOURCE_MEM, &net_pdata);
 
 	armlinux_set_architecture(MACH_TYPE_VERSATILE_PB);
 	armlinux_set_bootparams((void *)(0x00000100));
-- 
1.8.4.rc3


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

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

* Re: [PATCH 1/2 v3] smc91111: add fixup for qemu phy support
  2013-09-22  5:12 [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Jean-Christophe PLAGNIOL-VILLARD
  2013-09-22  5:12 ` [PATCH 2/2 v3] versatilepb: enable qemu fixup Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-22 18:28 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2013-09-22 18:28 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sun, Sep 22, 2013 at 07:12:23AM +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.
> 
> Only enable if qemu_fixup is set.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Applied, thanks

Sascha

> ---
>  drivers/net/smc91111.c | 30 +++++++++++++++++++++++++++++-
>  include/net/smc91111.h | 14 ++++++++++++++
>  2 files changed, 43 insertions(+), 1 deletion(-)
>  create mode 100644 include/net/smc91111.h
> 
> diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
> index b868cbf..ba81e24 100644
> --- a/drivers/net/smc91111.c
> +++ b/drivers/net/smc91111.c
> @@ -66,6 +66,7 @@
>  #include <clock.h>
>  #include <io.h>
>  #include <linux/phy.h>
> +#include <net/smc91111.h>
>  
>  /*---------------------------------------------------------------
>   .
> @@ -446,6 +447,7 @@ struct smc91c111_priv {
>  	struct mii_bus miibus;
>  	struct accessors a;
>  	void __iomem *base;
> +	int qemu_fixup;
>  };
>  
>  #if (SMC_DEBUG > 2 )
> @@ -882,6 +884,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);
> @@ -889,8 +892,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 (priv->qemu_fixup && 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,
> @@ -1286,6 +1308,12 @@ static int smc91c111_probe(struct device_d *dev)
>  
>  	priv = edev->priv;
>  
> +	if (dev->platform_data) {
> +		struct smc91c111_pdata *pdata = dev->platform_data;
> +
> +		priv->qemu_fixup = pdata->qemu_fixup;
> +	}
> +
>  	priv->a = access_via_32bit;
>  
>  	edev->init = smc91c111_init_dev;
> diff --git a/include/net/smc91111.h b/include/net/smc91111.h
> new file mode 100644
> index 0000000..0b2d49b
> --- /dev/null
> +++ b/include/net/smc91111.h
> @@ -0,0 +1,14 @@
> +/*
> + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
> + *
> + * Under GPLv2 only
> + */
> +
> +#ifndef __SMC91111_H__
> +#define __SMC91111_H__
> +
> +struct smc91c111_pdata {
> +	int qemu_fixup;
> +};
> +
> +#endif /* __SMC91111_H__ */
> -- 
> 1.8.4.rc3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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] 3+ messages in thread

end of thread, other threads:[~2013-09-22 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-22  5:12 [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Jean-Christophe PLAGNIOL-VILLARD
2013-09-22  5:12 ` [PATCH 2/2 v3] versatilepb: enable qemu fixup Jean-Christophe PLAGNIOL-VILLARD
2013-09-22 18:28 ` [PATCH 1/2 v3] smc91111: add fixup for qemu phy support Sascha Hauer

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