* [PATCH v2 0/2] net/cadence/macb: add support for dt phy definition
@ 2013-08-26 12:33 Boris BREZILLON
2013-08-26 12:34 ` [PATCH v2 1/2] " Boris BREZILLON
2013-08-26 12:35 ` [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board Boris BREZILLON
0 siblings, 2 replies; 5+ messages in thread
From: Boris BREZILLON @ 2013-08-26 12:33 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 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 | 47 +++++++++++++++++++++++++++--------
2 files changed, 45 insertions(+), 10 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] net/cadence/macb: add support for dt phy definition
2013-08-26 12:33 [PATCH v2 0/2] net/cadence/macb: add support for dt phy definition Boris BREZILLON
@ 2013-08-26 12:34 ` Boris BREZILLON
2013-08-26 12:35 ` [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board Boris BREZILLON
1 sibling, 0 replies; 5+ messages in thread
From: Boris BREZILLON @ 2013-08-26 12:34 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 | 47 +++++++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index e866608..7660c45 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,51 @@ 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] 5+ messages in thread
* [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
2013-08-26 12:33 [PATCH v2 0/2] net/cadence/macb: add support for dt phy definition Boris BREZILLON
2013-08-26 12:34 ` [PATCH v2 1/2] " Boris BREZILLON
@ 2013-08-26 12:35 ` Boris BREZILLON
2013-08-26 13:21 ` Sergei Shtylyov
1 sibling, 1 reply; 5+ messages in thread
From: Boris BREZILLON @ 2013-08-26 12:35 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..e9521d5 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@0 {
+ interrupt-parent = <&pioE>;
+ interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
+ reg = <1>;
+ };
};
pinctrl@fffff200 {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
2013-08-26 12:35 ` [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board Boris BREZILLON
@ 2013-08-26 13:21 ` Sergei Shtylyov
2013-08-26 13:33 ` boris brezillon
0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2013-08-26 13:21 UTC (permalink / raw)
To: Boris BREZILLON
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Russell King, Nicolas Ferre, devicetree,
linux-arm-kernel, linux-kernel, netdev
Hello.
On 26-08-2013 16:35, Boris BREZILLON wrote:
> 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..e9521d5 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@0 {
Address part of the node name doesn't match the "reg" property.
> + interrupt-parent = <&pioE>;
> + interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
> + reg = <1>;
> + };
WBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board
2013-08-26 13:21 ` Sergei Shtylyov
@ 2013-08-26 13:33 ` boris brezillon
0 siblings, 0 replies; 5+ messages in thread
From: boris brezillon @ 2013-08-26 13:33 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Russell King, Nicolas Ferre, devicetree,
linux-arm-kernel, linux-kernel, netdev
Hello Sergei,
On 26/08/2013 15:21, Sergei Shtylyov wrote:
> Hello.
>
> On 26-08-2013 16:35, Boris BREZILLON wrote:
>
>> 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..e9521d5 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@0 {
>
> Address part of the node name doesn't match the "reg" property.
Indeed, I based my definition on arch/arc/boot/dts/angel4.dts where phy
is registered like this :
phy0: ethernet-phy@0 {
reg = <1>;
};
I think it's buggy there too, because I checked other dts files and they
all put the same address
after @ and in reg register.
I'll fix this fot the next version.
Thanks
Best Regards,
Boris
>
>> + interrupt-parent = <&pioE>;
>> + interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
>> + reg = <1>;
>> + };
>
> WBR, Sergei
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-26 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-26 12:33 [PATCH v2 0/2] net/cadence/macb: add support for dt phy definition Boris BREZILLON
2013-08-26 12:34 ` [PATCH v2 1/2] " Boris BREZILLON
2013-08-26 12:35 ` [PATCH v2 2/2] ARM: at91/dt: define phy available on sama5d3 mother board Boris BREZILLON
2013-08-26 13:21 ` Sergei Shtylyov
2013-08-26 13:33 ` boris brezillon
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).