Hi David, Andrew, Florian, Simon, Magnus,
This patch series adds optional PHY reset support to phylib.
The first two patches are destined for David's net-next tree. They add
core PHY reset code, and update a driver that currently uses its own
reset code.
The last two patches are destined for Simon's renesas tree. They add
properties to describe the EthernetAVB PHY reset topology to the common
Salvator-X/XS and ULCB DTS files, which solves two issues:
1. On Salvator-XS, the enable pin of the regulator providing PHY power
is connected to PRESETn, and PSCI powers down the SoC during system
suspend. Hence a PHY reset is needed to restore network
functionality after system resume.
2. Linux should not rely on the boot loader having reset the PHY, but
should reset the PHY during driver probe.
Changes compared to v3:
- Remove Florian's Acked-by,
- Add missing #include <linux/gpio/consumer.h>,
- Re-add the gpiod check, as the dummy gpiod_set_value() for !GPIOLIB
does not ignore NULL, and calls WARN_ON(1),
- Do not reassert the reset signal if {mdio,phy}_probe() or
phy_device_register() succeeded, as that may destroy initial setup,
- Do not deassert the reset signal in {mdio,phy}_remove(), as it
should already be deasserted,
- Bring the PHY back into reset state in phy_device_remove(),
- Move/consolidate GPIO descriptor acquiring code from
of_mdiobus_register_phy() and of_mdiobus_register_device() to
mdiobus_register_device().
Note that this changes behavior slightly, in that the reset signal
is now also asserted when called from of_mdiobus_register_device().
- Add Reviewed-by,
Changes compared to v2, as sent by Sergei Shtylyov:
- Fix fwnode_get_named_gpiod() call due to added parameters (which
allowed to eliminate the gpiod_direction_output() call),
- Rebased, refreshed, reworded,
- Take over from Sergei,
- Add Acked-by,
- Remove unneeded gpiod check, as gpiod_set_value() handles NULL fine,
- Handle fwnode_get_named_gpiod() errors correctly:
- -ENOENT is ignored (the GPIO is optional), and turned into NULL,
which allowed to remove all later !IS_ERR() checks,
- Other errors (incl. -EPROBE_DEFER) are propagated,
- Extract DTS patches from series "[PATCH 0/4] ravb: Add PHY reset
support" (https://www.spinics.net/lists/netdev/msg457308.html), and
incorporate in this series, after moving reset-gpios from the
ethernet to the ethernet-phy node.
Given (1) the new reset-gpios DT property in the PHY node follows
established practises, (2) the DT binding change in the first patch has
been acked by Rob, and (3) the DTS patch does not cause any regressions
if it is applied before the PHY driver patches, the DTS patches can be
applied independently.
Thanks!
Geert Uytterhoeven (2):
arm64: dts: renesas: salvator-common: Add EthernetAVB PHY reset
arm64: dts: renesas: ulcb: Add EthernetAVB PHY reset
Sergei Shtylyov (2):
phylib: Add device reset GPIO support
macb: Kill PHY reset code
Documentation/devicetree/bindings/net/phy.txt | 2 ++
arch/arm64/boot/dts/renesas/salvator-common.dtsi | 1 +
arch/arm64/boot/dts/renesas/ulcb.dtsi | 1 +
drivers/net/ethernet/cadence/macb.h | 1 -
drivers/net/ethernet/cadence/macb_main.c | 21 ----------------
drivers/net/phy/at803x.c | 18 +++----------
drivers/net/phy/mdio_bus.c | 21 ++++++++++++++++
drivers/net/phy/mdio_device.c | 25 ++++++++++++++++--
drivers/net/phy/phy_device.c | 32 ++++++++++++++++++++++--
include/linux/mdio.h | 3 +++
include/linux/phy.h | 5 ++++
11 files changed, 89 insertions(+), 41 deletions(-)
--
2.7.4
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Describe the GPIO used to reset the Ethernet PHY for EthernetAVB.
This allows the driver to reset the PHY during probe and after system
resume.
This fixes Ethernet operation after resume from s2ram on Salvator-XS,
where the enable pin of the regulator providing PHY power is connected
to PRESETn, and PSCI powers down the SoC during system suspend.
On Salvator-X, the enable pin is always pulled high, but the driver may
still need to reset the PHY if this wasn't done by the bootloader
before.
Inspired by patches in the BSP for the individual Salvator-X/XS boards
by Kazuya Mizuguchi.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
For proper PHY reset operation during system resume, this depends on
"[PATCH v4 1/4] phylib: Add device reset GPIO support".
However, this patch can be applied independently.
v4:
- No changes,
v3:
- Extract from series "[PATCH 0/4] ravb: Add PHY reset support", and
incorporate in this series,
- Move reset-gpios from the ethernet to the ethernet-phy node.
---
arch/arm64/boot/dts/renesas/salvator-common.dtsi | 1 +
1 file changed, 1 insertion(+)
From: Sergei Shtylyov <redacted>
With the phylib now being aware of the "reset-gpios" PHY node property,
there should be no need to frob the PHY reset in this driver anymore...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Nicolas Ferre <redacted>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v4:
- Add Reviewed-by,
v3:
- Resolve rejects due to the file being renamed, refresh the patch,
- Add code to reset PHY on probe error,
- Edit patch description,
- Take over from Sergei,
- Add Acked-by,
v2:
- No changes.
---
drivers/net/ethernet/cadence/macb.h | 1 -
drivers/net/ethernet/cadence/macb_main.c | 21 ---------------------
2 files changed, 22 deletions(-)
@@ -3803,7 +3803,6 @@ static int macb_probe(struct platform_device *pdev)=macb_config->clk_init;int(*init)(structplatform_device*)=macb_config->init;structdevice_node*np=pdev->dev.of_node;-structdevice_node*phy_node;structclk*pclk,*hclk=NULL,*tx_clk=NULL,*rx_clk=NULL;unsignedintqueue_mask,num_queues;structmacb_platform_data*pdata;
@@ -3909,18 +3908,6 @@ static int macb_probe(struct platform_device *pdev)elsemacb_get_hwaddr(bp);-/* Power up the PHY if there is a GPIO reset */-phy_node=of_get_next_available_child(np,NULL);-if(phy_node){-intgpio=of_get_named_gpio(phy_node,"reset-gpios",0);--if(gpio_is_valid(gpio)){-bp->reset_gpio=gpio_to_desc(gpio);-gpiod_direction_output(bp->reset_gpio,1);-}-}-of_node_put(phy_node);-err=of_get_phy_mode(np);if(err<0){pdata=dev_get_platdata(&pdev->dev);
@@ -3967,10 +3954,6 @@ static int macb_probe(struct platform_device *pdev)of_phy_deregister_fixed_link(np);mdiobus_free(bp->mii_bus);-/* Shutdown the PHY if there is a GPIO reset */-if(bp->reset_gpio)-gpiod_set_value(bp->reset_gpio,0);-err_out_free_netdev:free_netdev(dev);
@@ -4001,10 +3984,6 @@ static int macb_remove(struct platform_device *pdev)dev->phydev=NULL;mdiobus_free(bp->mii_bus);-/* Shutdown the PHY if there is a GPIO reset */-if(bp->reset_gpio)-gpiod_set_value(bp->reset_gpio,0);-unregister_netdev(dev);clk_disable_unprepare(bp->tx_clk);clk_disable_unprepare(bp->hclk);
Describe the GPIO used to reset the Ethernet PHY for EthernetAVB.
This allows the driver to reset the PHY during probe and after system
resume.
On ULCB, the enable pin of the regulator providing PHY power is always
pulled high, but the driver may still need to reset the PHY if this
wasn't done by the bootloader before.
Inspired by patches in the BSP for the individual Salvator-X/XS boards
by Kazuya Mizuguchi.
Signed-off-by: Geert Uytterhoeven <redacted>
---
Compile-tested only.
v4:
- No changes,
v3:
- Extract from series "[PATCH 0/4] ravb: Add PHY reset support", and
incorporate in this series,
- Move reset-gpios from the ethernet to the ethernet-phy node.
---
arch/arm64/boot/dts/renesas/ulcb.dtsi | 1 +
1 file changed, 1 insertion(+)
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Sergei Shtylyov <redacted>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Rob Herring <robh@kernel.org>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v4:
- Remove Florian's Acked-by,
- Add missing #include <linux/gpio/consumer.h>,
- Re-add the gpiod check, as the dummy gpiod_set_value() for !GPIOLIB
does not ignore NULL, and calls WARN_ON(1),
- Do not reassert the reset signal if {mdio,phy}_probe() or
phy_device_register() succeeded, as that may destroy initial setup,
- Do not deassert the reset signal in {mdio,phy}_remove(), as it
should already be deasserted,
- Bring the PHY back into reset state in phy_device_remove(),
- Move/consolidate GPIO descriptor acquiring code from
of_mdiobus_register_phy() and of_mdiobus_register_device() to
mdiobus_register_device().
Note that this changes behavior slightly, in that the reset signal
is now also asserted when called from of_mdiobus_register_device().
v3:
- Fix fwnode_get_named_gpiod() call due to added parameters (which
allowed to eliminate the gpiod_direction_output() call),
- Undelete one blank line in the AT803x driver,
- Resolve rejects, refresh patch,
- Reword/reformat changelog,
- Take over from Sergei,
- Add Acked-by,
- Remove unneeded gpiod check, as gpiod_set_value() handles NULL fine,
- Handle fwnode_get_named_gpiod() errors correctly:
- -ENOENT is ignored (the GPIO is optional), and turned into NULL,
which allowed to remove all later !IS_ERR() checks,
- Other errors (incl. -EPROBE_DEFER) are propagated [*],
v2:
- Reformat changelog,
- Resolve rejects, refresh patch.
---
Documentation/devicetree/bindings/net/phy.txt | 2 ++
drivers/net/phy/at803x.c | 18 +++------------
drivers/net/phy/mdio_bus.c | 21 ++++++++++++++++++
drivers/net/phy/mdio_device.c | 25 +++++++++++++++++++--
drivers/net/phy/phy_device.c | 32 +++++++++++++++++++++++++--
include/linux/mdio.h | 3 +++
include/linux/phy.h | 5 +++++
7 files changed, 87 insertions(+), 19 deletions(-)
@@ -53,6 +53,8 @@ Optional Properties: to ensure the integrated PHY is used. The absence of this property indicates the muxers should be configured so that the external PHY is used.+- reset-gpios: The GPIO phandle and specifier for the PHY reset signal.+ Example: ethernet-phy@0 {
@@ -48,9 +49,26 @@intmdiobus_register_device(structmdio_device*mdiodev){+structgpio_desc*gpiod;+if(mdiodev->bus->mdio_map[mdiodev->addr])return-EBUSY;+/* Deassert the optional reset signal */+if(mdiodev->dev.of_node)+gpiod=fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,+"reset-gpios",0,GPIOD_OUT_LOW,+"PHY reset");+if(PTR_ERR(gpiod)==-ENOENT)+gpiod=NULL;+elseif(IS_ERR(gpiod))+returnPTR_ERR(gpiod);++mdiodev->reset=gpiod;++/* Assert the reset signal again */+mdio_device_reset(mdiodev,1);+mdiodev->bus->mdio_map[mdiodev->addr]=mdiodev;return0;
@@ -128,8 +137,16 @@ static int mdio_probe(struct device *dev)structmdio_driver*mdiodrv=to_mdio_driver(drv);interr=0;-if(mdiodrv->probe)+if(mdiodrv->probe){+/* Deassert the reset signal */+mdio_device_reset(mdiodev,0);+err=mdiodrv->probe(mdiodev);+if(err){+/* Assert the reset signal */+mdio_device_reset(mdiodev,1);+}+}returnerr;}
@@ -140,9 +157,13 @@ static int mdio_remove(struct device *dev)structdevice_driver*drv=mdiodev->dev.driver;structmdio_driver*mdiodrv=to_mdio_driver(drv);-if(mdiodrv->remove)+if(mdiodrv->remove){mdiodrv->remove(mdiodev);+/* Assert the reset signal */+mdio_device_reset(mdiodev,1);+}+return0;}
@@ -632,6 +632,9 @@ int phy_device_register(struct phy_device *phydev)if(err)returnerr;+/* Deassert the reset signal */+phy_device_reset(phydev,0);+/* Run all of the fixups for this PHY */err=phy_scan_fixups(phydev);if(err){
@@ -650,6 +653,9 @@ int phy_device_register(struct phy_device *phydev)return0;out:+/* Assert the reset signal */+phy_device_reset(phydev,1);+mdiobus_unregister_device(&phydev->mdio);returnerr;}
@@ -666,6 +672,10 @@ EXPORT_SYMBOL(phy_device_register);voidphy_device_remove(structphy_device*phydev){device_del(&phydev->mdio.dev);++/* Assert the reset signal */+phy_device_reset(phydev,1);+mdiobus_unregister_device(&phydev->mdio);}EXPORT_SYMBOL(phy_device_remove);
@@ -849,6 +859,9 @@ int phy_init_hw(struct phy_device *phydev){intret=0;+/* Deassert the reset signal */+phy_device_reset(phydev,0);+if(!phydev->drv||!phydev->drv->config_init)return0;
@@ -1126,6 +1139,9 @@ void phy_detach(struct phy_device *phydev)put_device(&phydev->mdio.dev);if(ndev_owner!=bus->owner)module_put(bus->owner);++/* Assert the reset signal */+phy_device_reset(phydev,1);}EXPORT_SYMBOL(phy_detach);
@@ -1811,8 +1827,16 @@ static int phy_probe(struct device *dev)/* Set the state to READY by default */phydev->state=PHY_READY;-if(phydev->drv->probe)+if(phydev->drv->probe){+/* Deassert the reset signal */+phy_device_reset(phydev,0);+err=phydev->drv->probe(phydev);+if(err){+/* Assert the reset signal */+phy_device_reset(phydev,1);+}+}mutex_unlock(&phydev->lock);
@@ -1829,8 +1853,12 @@ static int phy_remove(struct device *dev)phydev->state=PHY_DOWN;mutex_unlock(&phydev->lock);-if(phydev->drv&&phydev->drv->remove)+if(phydev->drv&&phydev->drv->remove){phydev->drv->remove(phydev);++/* Assert the reset signal */+phy_device_reset(phydev,1);+}phydev->drv=NULL;return0;
@@ -12,6 +12,7 @@#include<uapi/linux/mdio.h>#include<linux/mod_devicetable.h>+structgpio_desc;structmii_bus;/* Multiple levels of nesting are possible. However typically this is
@@ -39,6 +40,7 @@ struct mdio_device {/* Bus address of the MDIO device (0-31) */intaddr;intflags;+structgpio_desc*reset;};#define to_mdio_device(d) container_of(d, struct mdio_device, dev)
From: Sergei Shtylyov <redacted>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Rob Herring <robh@kernel.org>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v4.1:
- Fix uninitialized variable in mdiobus_register_device(),
v4:
- Remove Florian's Acked-by,
- Add missing #include <linux/gpio/consumer.h>,
- Re-add the gpiod check, as the dummy gpiod_set_value() for !GPIOLIB
does not ignore NULL, and calls WARN_ON(1),
- Do not reassert the reset signal if {mdio,phy}_probe() or
phy_device_register() succeeded, as that may destroy initial setup,
- Do not deassert the reset signal in {mdio,phy}_remove(), as it
should already be deasserted,
- Bring the PHY back into reset state in phy_device_remove(),
- Move/consolidate GPIO descriptor acquiring code from
of_mdiobus_register_phy() and of_mdiobus_register_device() to
mdiobus_register_device().
Note that this changes behavior slightly, in that the reset signal
is now also asserted when called from of_mdiobus_register_device().
v3:
- Fix fwnode_get_named_gpiod() call due to added parameters (which
allowed to eliminate the gpiod_direction_output() call),
- Undelete one blank line in the AT803x driver,
- Resolve rejects, refresh patch,
- Reword/reformat changelog,
- Take over from Sergei,
- Add Acked-by,
- Remove unneeded gpiod check, as gpiod_set_value() handles NULL fine,
- Handle fwnode_get_named_gpiod() errors correctly:
- -ENOENT is ignored (the GPIO is optional), and turned into NULL,
which allowed to remove all later !IS_ERR() checks,
- Other errors (incl. -EPROBE_DEFER) are propagated [*],
v2:
- Reformat changelog,
- Resolve rejects, refresh patch.
---
Documentation/devicetree/bindings/net/phy.txt | 2 ++
drivers/net/phy/at803x.c | 18 +++------------
drivers/net/phy/mdio_bus.c | 21 ++++++++++++++++++
drivers/net/phy/mdio_device.c | 25 +++++++++++++++++++--
drivers/net/phy/phy_device.c | 32 +++++++++++++++++++++++++--
include/linux/mdio.h | 3 +++
include/linux/phy.h | 5 +++++
7 files changed, 87 insertions(+), 19 deletions(-)
@@ -53,6 +53,8 @@ Optional Properties: to ensure the integrated PHY is used. The absence of this property indicates the muxers should be configured so that the external PHY is used.+- reset-gpios: The GPIO phandle and specifier for the PHY reset signal.+ Example: ethernet-phy@0 {
@@ -48,9 +49,26 @@intmdiobus_register_device(structmdio_device*mdiodev){+structgpio_desc*gpiod=NULL;+if(mdiodev->bus->mdio_map[mdiodev->addr])return-EBUSY;+/* Deassert the optional reset signal */+if(mdiodev->dev.of_node)+gpiod=fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,+"reset-gpios",0,GPIOD_OUT_LOW,+"PHY reset");+if(PTR_ERR(gpiod)==-ENOENT)+gpiod=NULL;+elseif(IS_ERR(gpiod))+returnPTR_ERR(gpiod);++mdiodev->reset=gpiod;++/* Assert the reset signal again */+mdio_device_reset(mdiodev,1);+mdiodev->bus->mdio_map[mdiodev->addr]=mdiodev;return0;
@@ -128,8 +137,16 @@ static int mdio_probe(struct device *dev)structmdio_driver*mdiodrv=to_mdio_driver(drv);interr=0;-if(mdiodrv->probe)+if(mdiodrv->probe){+/* Deassert the reset signal */+mdio_device_reset(mdiodev,0);+err=mdiodrv->probe(mdiodev);+if(err){+/* Assert the reset signal */+mdio_device_reset(mdiodev,1);+}+}returnerr;}
@@ -140,9 +157,13 @@ static int mdio_remove(struct device *dev)structdevice_driver*drv=mdiodev->dev.driver;structmdio_driver*mdiodrv=to_mdio_driver(drv);-if(mdiodrv->remove)+if(mdiodrv->remove){mdiodrv->remove(mdiodev);+/* Assert the reset signal */+mdio_device_reset(mdiodev,1);+}+return0;}
@@ -632,6 +632,9 @@ int phy_device_register(struct phy_device *phydev)if(err)returnerr;+/* Deassert the reset signal */+phy_device_reset(phydev,0);+/* Run all of the fixups for this PHY */err=phy_scan_fixups(phydev);if(err){
@@ -650,6 +653,9 @@ int phy_device_register(struct phy_device *phydev)return0;out:+/* Assert the reset signal */+phy_device_reset(phydev,1);+mdiobus_unregister_device(&phydev->mdio);returnerr;}
@@ -666,6 +672,10 @@ EXPORT_SYMBOL(phy_device_register);voidphy_device_remove(structphy_device*phydev){device_del(&phydev->mdio.dev);++/* Assert the reset signal */+phy_device_reset(phydev,1);+mdiobus_unregister_device(&phydev->mdio);}EXPORT_SYMBOL(phy_device_remove);
@@ -849,6 +859,9 @@ int phy_init_hw(struct phy_device *phydev){intret=0;+/* Deassert the reset signal */+phy_device_reset(phydev,0);+if(!phydev->drv||!phydev->drv->config_init)return0;
@@ -1126,6 +1139,9 @@ void phy_detach(struct phy_device *phydev)put_device(&phydev->mdio.dev);if(ndev_owner!=bus->owner)module_put(bus->owner);++/* Assert the reset signal */+phy_device_reset(phydev,1);}EXPORT_SYMBOL(phy_detach);
@@ -1811,8 +1827,16 @@ static int phy_probe(struct device *dev)/* Set the state to READY by default */phydev->state=PHY_READY;-if(phydev->drv->probe)+if(phydev->drv->probe){+/* Deassert the reset signal */+phy_device_reset(phydev,0);+err=phydev->drv->probe(phydev);+if(err){+/* Assert the reset signal */+phy_device_reset(phydev,1);+}+}mutex_unlock(&phydev->lock);
@@ -1829,8 +1853,12 @@ static int phy_remove(struct device *dev)phydev->state=PHY_DOWN;mutex_unlock(&phydev->lock);-if(phydev->drv&&phydev->drv->remove)+if(phydev->drv&&phydev->drv->remove){phydev->drv->remove(phydev);++/* Assert the reset signal */+phy_device_reset(phydev,1);+}phydev->drv=NULL;return0;
@@ -12,6 +12,7 @@#include<uapi/linux/mdio.h>#include<linux/mod_devicetable.h>+structgpio_desc;structmii_bus;/* Multiple levels of nesting are possible. However typically this is
@@ -39,6 +40,7 @@ struct mdio_device {/* Bus address of the MDIO device (0-31) */intaddr;intflags;+structgpio_desc*reset;};#define to_mdio_device(d) container_of(d, struct mdio_device, dev)
From: Richard Leitner <richard.leitner@skidata.com> Date: 2017-12-04 16:20:20
On 12/04/2017 01:35 PM, Geert Uytterhoeven wrote:
From: Sergei Shtylyov <redacted>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Rob Herring <robh@kernel.org>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Successfully tested this patch on a i.MX6SOLO based board containing a
LAN8710 PHY:
Tested-by: Richard Leitner <richard.leitner@skidata.com>
From: Sergei Shtylyov <hidden> Date: 2017-12-07 17:20:14
Hello!
On 12/04/2017 03:35 PM, Geert Uytterhoeven wrote:
From: Sergei Shtylyov <redacted>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Rob Herring <robh@kernel.org>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
From: Sergei Shtylyov <hidden> Date: 2017-12-07 17:40:48
On 12/07/2017 08:20 PM, Sergei Shtylyov wrote:
quoted
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Acked-by: Rob Herring <redacted>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <redacted>
@@ -48,9 +49,26 @@ int mdiobus_register_device(struct mdio_device *mdiodev) {+ struct gpio_desc *gpiod = NULL;+ if (mdiodev->bus->mdio_map[mdiodev->addr]) return -EBUSY;+ /* Deassert the optional reset signal */
Umm, but why deassert it here for such a short time?
quoted
+ if (mdiodev->dev.of_node)+ gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,+ "reset-gpios", 0, GPIOD_OUT_LOW,+ "PHY reset");+ if (PTR_ERR(gpiod) == -ENOENT)+ gpiod = NULL;+ else if (IS_ERR(gpiod))+ return PTR_ERR(gpiod);
Hm, returning on error with reset deasserted?
Oops, error means we couldn't drive the GPIO at all...
The 1st question remains though...
[...]
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Sergei,
On Thu, Dec 7, 2017 at 6:20 PM, Sergei Shtylyov
[off-list ref] wrote:
On 12/04/2017 03:35 PM, Geert Uytterhoeven wrote:
quoted
From: Sergei Shtylyov <redacted>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to
manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <redacted>
Acked-by: Rob Herring <robh@kernel.org>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
@@ -48,9 +49,26 @@ int mdiobus_register_device(struct mdio_device *mdiodev) {+ struct gpio_desc *gpiod = NULL;+ if (mdiodev->bus->mdio_map[mdiodev->addr]) return -EBUSY; + /* Deassert the optional reset signal */
Umm, but why deassert it here for such a short time?
That's a consequence of moving it from drivers/of/of_mdio.c to here.
Not that it was deasserted that much longer in drivers/of/of_mdio.c, though...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Sergei Shtylyov <hidden> Date: 2017-12-08 17:20:18
Hello!
On 12/08/2017 12:53 PM, Geert Uytterhoeven wrote:
quoted
On 12/04/2017 03:35 PM, Geert Uytterhoeven wrote:
quoted
From: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
The PHY devices sometimes do have their reset signal (maybe even power
supply?) tied to some GPIO and sometimes it also does happen that a boot
loader does not leave it deasserted. So far this issue has been attacked
from (as I believe) a wrong angle: by teaching the MAC driver to
manipulate
the GPIO in question; that solution, when applied to the device trees, led
to adding the PHY reset GPIO properties to the MAC device node, with one
exception: Cadence MACB driver which could handle the "reset-gpios" prop
in a PHY device subnode. I believe that the correct approach is to teach
the 'phylib' to get the MDIO device reset GPIO from the device tree node
corresponding to this device -- which this patch is doing...
Note that I had to modify the AT803x PHY driver as it would stop working
otherwise -- it made use of the reset GPIO for its own purposes...
Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Acked-by: Rob Herring <redacted>
[geert: Propagate actual errors from fwnode_get_named_gpiod()]
[geert: Avoid destroying initial setup]
[geert: Consolidate GPIO descriptor acquiring code]
Signed-off-by: Geert Uytterhoeven <redacted>
@@ -48,9 +49,26 @@ int mdiobus_register_device(struct mdio_device *mdiodev) {+ struct gpio_desc *gpiod = NULL;+ if (mdiodev->bus->mdio_map[mdiodev->addr]) return -EBUSY; + /* Deassert the optional reset signal */
Umm, but why deassert it here for such a short time?
That's a consequence of moving it from drivers/of/of_mdio.c to here.
Well, you shouldn't do code moves without some thinking. ;-)
Not that it was deasserted that much longer in drivers/of/of_mdio.c, though...
There it had a reason, here I'm not seeing one. Perhaps using GPIOD_ASIS (or GPIOD_OUT_HIGH) instead of GPIOD_OUT_LOW and dropping mdio_device_reset(mdiodev, 1) afterwards would make more sense here?
Gr{oetje,eeting}s,
Geert
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Simon Horman <horms@verge.net.au> Date: 2017-12-11 07:04:56
On Mon, Dec 04, 2017 at 11:34:48AM +0100, Geert Uytterhoeven wrote:
Hi David, Andrew, Florian, Simon, Magnus,
This patch series adds optional PHY reset support to phylib.
The first two patches are destined for David's net-next tree. They add
core PHY reset code, and update a driver that currently uses its own
reset code.
The last two patches are destined for Simon's renesas tree. They add
properties to describe the EthernetAVB PHY reset topology to the common
Salvator-X/XS and ULCB DTS files, which solves two issues:
1. On Salvator-XS, the enable pin of the regulator providing PHY power
is connected to PRESETn, and PSCI powers down the SoC during system
suspend. Hence a PHY reset is needed to restore network
functionality after system resume.
2. Linux should not rely on the boot loader having reset the PHY, but
should reset the PHY during driver probe.
Thanks, I have applied patches 3/4 and 4/4 for v4.16.