All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:36 ` Boris BREZILLON
  0 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:36 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, Nicolas Ferre
  Cc: devicetree, linux-arm-kernel, linux-kernel, netdev, Boris BREZILLON

Hello,

This patch series adds support for ethernet phy definition using device
tree.

This may help in moving some at91 boards to dt (some of them define an
interrupt pin).

Tested on samad31ek.

Best Regards,
Boris

Changes since v2:
 - fix wrong address of phy0 dt node

Changes since v1:
 - fix wrong macb_mii_init return code when no PHY device is discovered

Boris BREZILLON (2):
  net/cadence/macb: add support for dt phy definition
  ARM: at91/dt: define phy available on sama5d3 mother board

 arch/arm/boot/dts/sama5d3xmb.dtsi   |    8 ++++++
 drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
 2 files changed, 46 insertions(+), 10 deletions(-)

-- 
1.7.9.5


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

* [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:36 ` Boris BREZILLON
  0 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This patch series adds support for ethernet phy definition using device
tree.

This may help in moving some at91 boards to dt (some of them define an
interrupt pin).

Tested on samad31ek.

Best Regards,
Boris

Changes since v2:
 - fix wrong address of phy0 dt node

Changes since v1:
 - fix wrong macb_mii_init return code when no PHY device is discovered

Boris BREZILLON (2):
  net/cadence/macb: add support for dt phy definition
  ARM: at91/dt: define phy available on sama5d3 mother board

 arch/arm/boot/dts/sama5d3xmb.dtsi   |    8 ++++++
 drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
 2 files changed, 46 insertions(+), 10 deletions(-)

-- 
1.7.9.5

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

* [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition
  2013-08-27  7:36 ` Boris BREZILLON
@ 2013-08-27  7:37   ` Boris BREZILLON
  -1 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:37 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, Nicolas Ferre
  Cc: devicetree, linux-arm-kernel, linux-kernel, netdev, Boris BREZILLON

The macb driver only handle PHY description through platform_data
(macb_platform_data).
Thus, when using dt you cannot define phy properties like phy address or
phy irq pin.

This patch makes use of the of_mdiobus_register to add support for
phy device definition using dt.
A fallback to the autoscan procedure is added in case there is no phy
devices defined in dt.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index e866608..393afeb 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -27,6 +27,7 @@
 #include <linux/phy.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_mdio.h>
 #include <linux/of_net.h>
 #include <linux/pinctrl/consumer.h>
 
@@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
 	phydev = phy_find_first(bp->mii_bus);
 	if (!phydev) {
 		netdev_err(dev, "no PHY found\n");
-		return -1;
+		return -ENXIO;
 	}
 
 	pdata = dev_get_platdata(&bp->pdev->dev);
@@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
 int macb_mii_init(struct macb *bp)
 {
 	struct macb_platform_data *pdata;
+	struct device_node *np;
 	int err = -ENXIO, i;
 
 	/* Enable management port */
@@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
 	bp->mii_bus->parent = &bp->dev->dev;
 	pdata = bp->pdev->dev.platform_data;
 
-	if (pdata)
-		bp->mii_bus->phy_mask = pdata->phy_mask;
-
 	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!bp->mii_bus->irq) {
 		err = -ENOMEM;
 		goto err_out_free_mdiobus;
 	}
 
-	for (i = 0; i < PHY_MAX_ADDR; i++)
-		bp->mii_bus->irq[i] = PHY_POLL;
-
 	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
 
-	if (mdiobus_register(bp->mii_bus))
+	np = bp->pdev->dev.of_node;
+	if (np) {
+		/* try dt phy registration */
+		err = of_mdiobus_register(bp->mii_bus, np);
+
+		/* fallback to standard phy registration if no phy were
+		 * found during dt phy registration
+		 */
+		if (!err && !phy_find_first(bp->mii_bus)) {
+			for (i = 0; i < PHY_MAX_ADDR; i++) {
+				struct phy_device *phydev;
+
+				phydev = mdiobus_scan(bp->mii_bus, i);
+				if (IS_ERR(phydev)) {
+					err = PTR_ERR(phydev);
+					break;
+				}
+			}
+
+			if (err)
+				goto err_out_unregister_bus;
+		}
+	} else {
+		for (i = 0; i < PHY_MAX_ADDR; i++)
+			bp->mii_bus->irq[i] = PHY_POLL;
+
+		if (pdata)
+			bp->mii_bus->phy_mask = pdata->phy_mask;
+
+		err = mdiobus_register(bp->mii_bus);
+	}
+
+	if (err)
 		goto err_out_free_mdio_irq;
 
-	if (macb_mii_probe(bp->dev) != 0) {
+	err = macb_mii_probe(bp->dev);
+	if (err)
 		goto err_out_unregister_bus;
-	}
 
 	return 0;
 
-- 
1.7.9.5


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

* [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:37   ` Boris BREZILLON
  0 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:37 UTC (permalink / raw)
  To: linux-arm-kernel

The macb driver only handle PHY description through platform_data
(macb_platform_data).
Thus, when using dt you cannot define phy properties like phy address or
phy irq pin.

This patch makes use of the of_mdiobus_register to add support for
phy device definition using dt.
A fallback to the autoscan procedure is added in case there is no phy
devices defined in dt.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index e866608..393afeb 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -27,6 +27,7 @@
 #include <linux/phy.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_mdio.h>
 #include <linux/of_net.h>
 #include <linux/pinctrl/consumer.h>
 
@@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
 	phydev = phy_find_first(bp->mii_bus);
 	if (!phydev) {
 		netdev_err(dev, "no PHY found\n");
-		return -1;
+		return -ENXIO;
 	}
 
 	pdata = dev_get_platdata(&bp->pdev->dev);
@@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
 int macb_mii_init(struct macb *bp)
 {
 	struct macb_platform_data *pdata;
+	struct device_node *np;
 	int err = -ENXIO, i;
 
 	/* Enable management port */
@@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
 	bp->mii_bus->parent = &bp->dev->dev;
 	pdata = bp->pdev->dev.platform_data;
 
-	if (pdata)
-		bp->mii_bus->phy_mask = pdata->phy_mask;
-
 	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!bp->mii_bus->irq) {
 		err = -ENOMEM;
 		goto err_out_free_mdiobus;
 	}
 
-	for (i = 0; i < PHY_MAX_ADDR; i++)
-		bp->mii_bus->irq[i] = PHY_POLL;
-
 	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
 
-	if (mdiobus_register(bp->mii_bus))
+	np = bp->pdev->dev.of_node;
+	if (np) {
+		/* try dt phy registration */
+		err = of_mdiobus_register(bp->mii_bus, np);
+
+		/* fallback to standard phy registration if no phy were
+		 * found during dt phy registration
+		 */
+		if (!err && !phy_find_first(bp->mii_bus)) {
+			for (i = 0; i < PHY_MAX_ADDR; i++) {
+				struct phy_device *phydev;
+
+				phydev = mdiobus_scan(bp->mii_bus, i);
+				if (IS_ERR(phydev)) {
+					err = PTR_ERR(phydev);
+					break;
+				}
+			}
+
+			if (err)
+				goto err_out_unregister_bus;
+		}
+	} else {
+		for (i = 0; i < PHY_MAX_ADDR; i++)
+			bp->mii_bus->irq[i] = PHY_POLL;
+
+		if (pdata)
+			bp->mii_bus->phy_mask = pdata->phy_mask;
+
+		err = mdiobus_register(bp->mii_bus);
+	}
+
+	if (err)
 		goto err_out_free_mdio_irq;
 
-	if (macb_mii_probe(bp->dev) != 0) {
+	err = macb_mii_probe(bp->dev);
+	if (err)
 		goto err_out_unregister_bus;
-	}
 
 	return 0;
 
-- 
1.7.9.5

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

* [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
  2013-08-27  7:36 ` Boris BREZILLON
@ 2013-08-27  7:39   ` Boris BREZILLON
  -1 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:39 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, Nicolas Ferre
  Cc: devicetree, linux-arm-kernel, linux-kernel, netdev, Boris BREZILLON

This patch describe the phy used on atmel sama5d3 mother board:
 - phy address
 - phy interrupt pin

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 arch/arm/boot/dts/sama5d3xmb.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
index 8a9e05d..dba739b 100644
--- a/arch/arm/boot/dts/sama5d3xmb.dtsi
+++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
@@ -81,6 +81,14 @@
 
 			macb1: ethernet@f802c000 {
 				phy-mode = "rmii";
+
+				#address-cells = <1>;
+				#size-cells = <0>;
+				phy0: ethernet-phy@1 {
+					interrupt-parent = <&pioE>;
+					interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
+					reg = <1>;
+				};
 			};
 
 			pinctrl@fffff200 {
-- 
1.7.9.5


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

* [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
@ 2013-08-27  7:39   ` Boris BREZILLON
  0 siblings, 0 replies; 14+ messages in thread
From: Boris BREZILLON @ 2013-08-27  7:39 UTC (permalink / raw)
  To: linux-arm-kernel

This patch describe the phy used on atmel sama5d3 mother board:
 - phy address
 - phy interrupt pin

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 arch/arm/boot/dts/sama5d3xmb.dtsi |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
index 8a9e05d..dba739b 100644
--- a/arch/arm/boot/dts/sama5d3xmb.dtsi
+++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
@@ -81,6 +81,14 @@
 
 			macb1: ethernet at f802c000 {
 				phy-mode = "rmii";
+
+				#address-cells = <1>;
+				#size-cells = <0>;
+				phy0: ethernet-phy at 1 {
+					interrupt-parent = <&pioE>;
+					interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
+					reg = <1>;
+				};
 			};
 
 			pinctrl at fffff200 {
-- 
1.7.9.5

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

* Re: [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition
  2013-08-27  7:36 ` Boris BREZILLON
@ 2013-08-27  7:48   ` boris brezillon
  -1 siblings, 0 replies; 14+ messages in thread
From: boris brezillon @ 2013-08-27  7:48 UTC (permalink / raw)
  To: David S. Miller
  Cc: Boris BREZILLON, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, Russell King, Nicolas Ferre,
	devicetree, linux-arm-kernel, linux-kernel, netdev

Hello David,

Sorry, I forgot to add your email in the cc list.

Do you want me to send you the whole series ?

Best Regards,

Boris

On 27/08/2013 09:36, Boris BREZILLON wrote:
> Hello,
>
> This patch series adds support for ethernet phy definition using device
> tree.
>
> This may help in moving some at91 boards to dt (some of them define an
> interrupt pin).
>
> Tested on samad31ek.
>
> Best Regards,
> Boris
>
> Changes since v2:
>   - fix wrong address of phy0 dt node
>
> Changes since v1:
>   - fix wrong macb_mii_init return code when no PHY device is discovered
>
> Boris BREZILLON (2):
>    net/cadence/macb: add support for dt phy definition
>    ARM: at91/dt: define phy available on sama5d3 mother board
>
>   arch/arm/boot/dts/sama5d3xmb.dtsi   |    8 ++++++
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   2 files changed, 46 insertions(+), 10 deletions(-)
>


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

* [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:48   ` boris brezillon
  0 siblings, 0 replies; 14+ messages in thread
From: boris brezillon @ 2013-08-27  7:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hello David,

Sorry, I forgot to add your email in the cc list.

Do you want me to send you the whole series ?

Best Regards,

Boris

On 27/08/2013 09:36, Boris BREZILLON wrote:
> Hello,
>
> This patch series adds support for ethernet phy definition using device
> tree.
>
> This may help in moving some at91 boards to dt (some of them define an
> interrupt pin).
>
> Tested on samad31ek.
>
> Best Regards,
> Boris
>
> Changes since v2:
>   - fix wrong address of phy0 dt node
>
> Changes since v1:
>   - fix wrong macb_mii_init return code when no PHY device is discovered
>
> Boris BREZILLON (2):
>    net/cadence/macb: add support for dt phy definition
>    ARM: at91/dt: define phy available on sama5d3 mother board
>
>   arch/arm/boot/dts/sama5d3xmb.dtsi   |    8 ++++++
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   2 files changed, 46 insertions(+), 10 deletions(-)
>

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

* Re: [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition
  2013-08-27  7:37   ` Boris BREZILLON
  (?)
@ 2013-08-27  7:58     ` Nicolas Ferre
  -1 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  7:58 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, devicetree, linux-arm-kernel,
	linux-kernel, netdev

On 27/08/2013 09:37, Boris BREZILLON :
> The macb driver only handle PHY description through platform_data
> (macb_platform_data).
> Thus, when using dt you cannot define phy properties like phy address or
> phy irq pin.
>
> This patch makes use of the of_mdiobus_register to add support for
> phy device definition using dt.
> A fallback to the autoscan procedure is added in case there is no phy
> devices defined in dt.
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index e866608..393afeb 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -27,6 +27,7 @@
>   #include <linux/phy.h>
>   #include <linux/of.h>
>   #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
>   #include <linux/of_net.h>
>   #include <linux/pinctrl/consumer.h>
>
> @@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
>   	phydev = phy_find_first(bp->mii_bus);
>   	if (!phydev) {
>   		netdev_err(dev, "no PHY found\n");
> -		return -1;
> +		return -ENXIO;
>   	}
>
>   	pdata = dev_get_platdata(&bp->pdev->dev);
> @@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
>   int macb_mii_init(struct macb *bp)
>   {
>   	struct macb_platform_data *pdata;
> +	struct device_node *np;
>   	int err = -ENXIO, i;
>
>   	/* Enable management port */
> @@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
>   	bp->mii_bus->parent = &bp->dev->dev;
>   	pdata = bp->pdev->dev.platform_data;
>
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
>   	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>   	if (!bp->mii_bus->irq) {
>   		err = -ENOMEM;
>   		goto err_out_free_mdiobus;
>   	}
>
> -	for (i = 0; i < PHY_MAX_ADDR; i++)
> -		bp->mii_bus->irq[i] = PHY_POLL;
> -
>   	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
>
> -	if (mdiobus_register(bp->mii_bus))
> +	np = bp->pdev->dev.of_node;
> +	if (np) {
> +		/* try dt phy registration */
> +		err = of_mdiobus_register(bp->mii_bus, np);
> +
> +		/* fallback to standard phy registration if no phy were
> +		 * found during dt phy registration
> +		 */
> +		if (!err && !phy_find_first(bp->mii_bus)) {
> +			for (i = 0; i < PHY_MAX_ADDR; i++) {
> +				struct phy_device *phydev;
> +
> +				phydev = mdiobus_scan(bp->mii_bus, i);
> +				if (IS_ERR(phydev)) {
> +					err = PTR_ERR(phydev);
> +					break;
> +				}
> +			}
> +
> +			if (err)
> +				goto err_out_unregister_bus;
> +		}
> +	} else {
> +		for (i = 0; i < PHY_MAX_ADDR; i++)
> +			bp->mii_bus->irq[i] = PHY_POLL;
> +
> +		if (pdata)
> +			bp->mii_bus->phy_mask = pdata->phy_mask;
> +
> +		err = mdiobus_register(bp->mii_bus);
> +	}
> +
> +	if (err)
>   		goto err_out_free_mdio_irq;
>
> -	if (macb_mii_probe(bp->dev) != 0) {
> +	err = macb_mii_probe(bp->dev);
> +	if (err)
>   		goto err_out_unregister_bus;
> -	}
>
>   	return 0;
>
>


-- 
Nicolas Ferre

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

* Re: [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:58     ` Nicolas Ferre
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  7:58 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, devicetree, linux-arm-kernel,
	linux-kernel, netdev

On 27/08/2013 09:37, Boris BREZILLON :
> The macb driver only handle PHY description through platform_data
> (macb_platform_data).
> Thus, when using dt you cannot define phy properties like phy address or
> phy irq pin.
>
> This patch makes use of the of_mdiobus_register to add support for
> phy device definition using dt.
> A fallback to the autoscan procedure is added in case there is no phy
> devices defined in dt.
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index e866608..393afeb 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -27,6 +27,7 @@
>   #include <linux/phy.h>
>   #include <linux/of.h>
>   #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
>   #include <linux/of_net.h>
>   #include <linux/pinctrl/consumer.h>
>
> @@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
>   	phydev = phy_find_first(bp->mii_bus);
>   	if (!phydev) {
>   		netdev_err(dev, "no PHY found\n");
> -		return -1;
> +		return -ENXIO;
>   	}
>
>   	pdata = dev_get_platdata(&bp->pdev->dev);
> @@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
>   int macb_mii_init(struct macb *bp)
>   {
>   	struct macb_platform_data *pdata;
> +	struct device_node *np;
>   	int err = -ENXIO, i;
>
>   	/* Enable management port */
> @@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
>   	bp->mii_bus->parent = &bp->dev->dev;
>   	pdata = bp->pdev->dev.platform_data;
>
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
>   	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>   	if (!bp->mii_bus->irq) {
>   		err = -ENOMEM;
>   		goto err_out_free_mdiobus;
>   	}
>
> -	for (i = 0; i < PHY_MAX_ADDR; i++)
> -		bp->mii_bus->irq[i] = PHY_POLL;
> -
>   	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
>
> -	if (mdiobus_register(bp->mii_bus))
> +	np = bp->pdev->dev.of_node;
> +	if (np) {
> +		/* try dt phy registration */
> +		err = of_mdiobus_register(bp->mii_bus, np);
> +
> +		/* fallback to standard phy registration if no phy were
> +		 * found during dt phy registration
> +		 */
> +		if (!err && !phy_find_first(bp->mii_bus)) {
> +			for (i = 0; i < PHY_MAX_ADDR; i++) {
> +				struct phy_device *phydev;
> +
> +				phydev = mdiobus_scan(bp->mii_bus, i);
> +				if (IS_ERR(phydev)) {
> +					err = PTR_ERR(phydev);
> +					break;
> +				}
> +			}
> +
> +			if (err)
> +				goto err_out_unregister_bus;
> +		}
> +	} else {
> +		for (i = 0; i < PHY_MAX_ADDR; i++)
> +			bp->mii_bus->irq[i] = PHY_POLL;
> +
> +		if (pdata)
> +			bp->mii_bus->phy_mask = pdata->phy_mask;
> +
> +		err = mdiobus_register(bp->mii_bus);
> +	}
> +
> +	if (err)
>   		goto err_out_free_mdio_irq;
>
> -	if (macb_mii_probe(bp->dev) != 0) {
> +	err = macb_mii_probe(bp->dev);
> +	if (err)
>   		goto err_out_unregister_bus;
> -	}
>
>   	return 0;
>
>


-- 
Nicolas Ferre

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

* [PATCH v3 1/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-27  7:58     ` Nicolas Ferre
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  7:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 27/08/2013 09:37, Boris BREZILLON :
> The macb driver only handle PHY description through platform_data
> (macb_platform_data).
> Thus, when using dt you cannot define phy properties like phy address or
> phy irq pin.
>
> This patch makes use of the of_mdiobus_register to add support for
> phy device definition using dt.
> A fallback to the autoscan procedure is added in case there is no phy
> devices defined in dt.
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   drivers/net/ethernet/cadence/macb.c |   48 +++++++++++++++++++++++++++--------
>   1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index e866608..393afeb 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -27,6 +27,7 @@
>   #include <linux/phy.h>
>   #include <linux/of.h>
>   #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
>   #include <linux/of_net.h>
>   #include <linux/pinctrl/consumer.h>
>
> @@ -275,7 +276,7 @@ static int macb_mii_probe(struct net_device *dev)
>   	phydev = phy_find_first(bp->mii_bus);
>   	if (!phydev) {
>   		netdev_err(dev, "no PHY found\n");
> -		return -1;
> +		return -ENXIO;
>   	}
>
>   	pdata = dev_get_platdata(&bp->pdev->dev);
> @@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
>   int macb_mii_init(struct macb *bp)
>   {
>   	struct macb_platform_data *pdata;
> +	struct device_node *np;
>   	int err = -ENXIO, i;
>
>   	/* Enable management port */
> @@ -335,26 +337,52 @@ int macb_mii_init(struct macb *bp)
>   	bp->mii_bus->parent = &bp->dev->dev;
>   	pdata = bp->pdev->dev.platform_data;
>
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
>   	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>   	if (!bp->mii_bus->irq) {
>   		err = -ENOMEM;
>   		goto err_out_free_mdiobus;
>   	}
>
> -	for (i = 0; i < PHY_MAX_ADDR; i++)
> -		bp->mii_bus->irq[i] = PHY_POLL;
> -
>   	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
>
> -	if (mdiobus_register(bp->mii_bus))
> +	np = bp->pdev->dev.of_node;
> +	if (np) {
> +		/* try dt phy registration */
> +		err = of_mdiobus_register(bp->mii_bus, np);
> +
> +		/* fallback to standard phy registration if no phy were
> +		 * found during dt phy registration
> +		 */
> +		if (!err && !phy_find_first(bp->mii_bus)) {
> +			for (i = 0; i < PHY_MAX_ADDR; i++) {
> +				struct phy_device *phydev;
> +
> +				phydev = mdiobus_scan(bp->mii_bus, i);
> +				if (IS_ERR(phydev)) {
> +					err = PTR_ERR(phydev);
> +					break;
> +				}
> +			}
> +
> +			if (err)
> +				goto err_out_unregister_bus;
> +		}
> +	} else {
> +		for (i = 0; i < PHY_MAX_ADDR; i++)
> +			bp->mii_bus->irq[i] = PHY_POLL;
> +
> +		if (pdata)
> +			bp->mii_bus->phy_mask = pdata->phy_mask;
> +
> +		err = mdiobus_register(bp->mii_bus);
> +	}
> +
> +	if (err)
>   		goto err_out_free_mdio_irq;
>
> -	if (macb_mii_probe(bp->dev) != 0) {
> +	err = macb_mii_probe(bp->dev);
> +	if (err)
>   		goto err_out_unregister_bus;
> -	}
>
>   	return 0;
>
>


-- 
Nicolas Ferre

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

* Re: [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
  2013-08-27  7:39   ` Boris BREZILLON
  (?)
@ 2013-08-27  8:00     ` Nicolas Ferre
  -1 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  8:00 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, devicetree, linux-arm-kernel,
	linux-kernel, netdev

On 27/08/2013 09:39, Boris BREZILLON :
> This patch describe the phy used on atmel sama5d3 mother board:
>   - phy address
>   - phy interrupt pin
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   arch/arm/boot/dts/sama5d3xmb.dtsi |    8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
> index 8a9e05d..dba739b 100644
> --- a/arch/arm/boot/dts/sama5d3xmb.dtsi
> +++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
> @@ -81,6 +81,14 @@
>
>   			macb1: ethernet@f802c000 {
>   				phy-mode = "rmii";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				phy0: ethernet-phy@1 {
> +					interrupt-parent = <&pioE>;
> +					interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
> +					reg = <1>;
> +				};
>   			};
>
>   			pinctrl@fffff200 {
>


-- 
Nicolas Ferre

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

* Re: [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
@ 2013-08-27  8:00     ` Nicolas Ferre
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  8:00 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
	Ian Campbell, Russell King, devicetree, linux-arm-kernel,
	linux-kernel, netdev

On 27/08/2013 09:39, Boris BREZILLON :
> This patch describe the phy used on atmel sama5d3 mother board:
>   - phy address
>   - phy interrupt pin
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   arch/arm/boot/dts/sama5d3xmb.dtsi |    8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
> index 8a9e05d..dba739b 100644
> --- a/arch/arm/boot/dts/sama5d3xmb.dtsi
> +++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
> @@ -81,6 +81,14 @@
>
>   			macb1: ethernet@f802c000 {
>   				phy-mode = "rmii";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				phy0: ethernet-phy@1 {
> +					interrupt-parent = <&pioE>;
> +					interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
> +					reg = <1>;
> +				};
>   			};
>
>   			pinctrl@fffff200 {
>


-- 
Nicolas Ferre

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

* [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
@ 2013-08-27  8:00     ` Nicolas Ferre
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Ferre @ 2013-08-27  8:00 UTC (permalink / raw)
  To: linux-arm-kernel

On 27/08/2013 09:39, Boris BREZILLON :
> This patch describe the phy used on atmel sama5d3 mother board:
>   - phy address
>   - phy interrupt pin
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   arch/arm/boot/dts/sama5d3xmb.dtsi |    8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
> index 8a9e05d..dba739b 100644
> --- a/arch/arm/boot/dts/sama5d3xmb.dtsi
> +++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
> @@ -81,6 +81,14 @@
>
>   			macb1: ethernet at f802c000 {
>   				phy-mode = "rmii";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				phy0: ethernet-phy at 1 {
> +					interrupt-parent = <&pioE>;
> +					interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
> +					reg = <1>;
> +				};
>   			};
>
>   			pinctrl at fffff200 {
>


-- 
Nicolas Ferre

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

end of thread, other threads:[~2013-08-27  8:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-27  7:36 [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition Boris BREZILLON
2013-08-27  7:36 ` Boris BREZILLON
2013-08-27  7:37 ` [PATCH v3 1/2] " Boris BREZILLON
2013-08-27  7:37   ` Boris BREZILLON
2013-08-27  7:58   ` Nicolas Ferre
2013-08-27  7:58     ` Nicolas Ferre
2013-08-27  7:58     ` Nicolas Ferre
2013-08-27  7:39 ` [PATCH v3 2/2] ARM: at91/dt: define phy available on sama5d3 mother board Boris BREZILLON
2013-08-27  7:39   ` Boris BREZILLON
2013-08-27  8:00   ` Nicolas Ferre
2013-08-27  8:00     ` Nicolas Ferre
2013-08-27  8:00     ` Nicolas Ferre
2013-08-27  7:48 ` [PATCH v3 0/2] net/cadence/macb: add support for dt phy definition boris brezillon
2013-08-27  7:48   ` boris brezillon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.