Re: [U-Boot] [PATCH 16/23] net: pch_gbe: Support PHY reset GPIOs

2016-09-28 Thread Bin Meng
On Tue, Sep 27, 2016 at 2:29 AM, Paul Burton  wrote:
> Add support to the pch_gbe driver for resetting the PHY using a GPIO
> specified in the device tree. This matches the support already in Linux.
>
> Signed-off-by: Paul Burton 
>
> ---
>
>  drivers/net/pch_gbe.c | 29 +++--
>  drivers/net/pch_gbe.h |  1 +
>  2 files changed, 28 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng 

Tested on Crown Bay
Tested-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 16/23] net: pch_gbe: Support PHY reset GPIOs

2016-09-26 Thread Simon Glass
Hi Paul,

On 26 September 2016 at 12:29, Paul Burton  wrote:
> Add support to the pch_gbe driver for resetting the PHY using a GPIO
> specified in the device tree. This matches the support already in Linux.
>
> Signed-off-by: Paul Burton 
>
> ---
>
>  drivers/net/pch_gbe.c | 29 +++--
>  drivers/net/pch_gbe.h |  1 +
>  2 files changed, 28 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 

>
> diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
> index 8866f66..cc3ca8b 100644
> --- a/drivers/net/pch_gbe.c
> +++ b/drivers/net/pch_gbe.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "pch_gbe.h"
>
>  #if !defined(CONFIG_PHYLIB)
> @@ -72,6 +73,14 @@ static int pch_gbe_reset(struct udevice *dev)
> priv->rx_idx = 0;
> priv->tx_idx = 0;
>
> +   if (dm_gpio_is_valid(>gpio_phy_reset)) {
> +   /* Reset the PHY */
> +   dm_gpio_set_value(>gpio_phy_reset, 1);

I'm assuming you don't check the return value because this GPIO might
not be valid / used?

Regards.
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 16/23] net: pch_gbe: Support PHY reset GPIOs

2016-09-26 Thread Paul Burton
Add support to the pch_gbe driver for resetting the PHY using a GPIO
specified in the device tree. This matches the support already in Linux.

Signed-off-by: Paul Burton 

---

 drivers/net/pch_gbe.c | 29 +++--
 drivers/net/pch_gbe.h |  1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index 8866f66..cc3ca8b 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "pch_gbe.h"
 
 #if !defined(CONFIG_PHYLIB)
@@ -72,6 +73,14 @@ static int pch_gbe_reset(struct udevice *dev)
priv->rx_idx = 0;
priv->tx_idx = 0;
 
+   if (dm_gpio_is_valid(>gpio_phy_reset)) {
+   /* Reset the PHY */
+   dm_gpio_set_value(>gpio_phy_reset, 1);
+   udelay(15000);
+   dm_gpio_set_value(>gpio_phy_reset, 0);
+   udelay(5000);
+   }
+
writel(PCH_GBE_ALL_RST, _regs->reset);
 
/*
@@ -451,6 +460,11 @@ int pch_gbe_probe(struct udevice *dev)
plat->iobase = (ulong)iobase;
priv->mac_regs = (struct pch_gbe_regs *)iobase;
 
+   err = gpio_request_by_name(dev, "phy-reset-gpios", 0,
+  >gpio_phy_reset, GPIOD_IS_OUT);
+   if (err && (err != -ENOENT))
+   return err;
+
/* Read MAC address from SROM and initialize dev->enetaddr with it */
pch_gbe_mac_read(priv->mac_regs, plat->enetaddr);
 
@@ -460,9 +474,17 @@ int pch_gbe_probe(struct udevice *dev)
 
err = pch_gbe_reset(dev);
if (err)
-   return err;
+   goto out_err;
 
-   return pch_gbe_phy_init(dev);
+   err = pch_gbe_phy_init(dev);
+   if (err)
+   goto out_err;
+
+   return 0;
+out_err:
+   if (dm_gpio_is_valid(>gpio_phy_reset))
+   dm_gpio_free(dev, >gpio_phy_reset);
+   return err;
 }
 
 int pch_gbe_remove(struct udevice *dev)
@@ -473,6 +495,9 @@ int pch_gbe_remove(struct udevice *dev)
mdio_unregister(priv->bus);
mdio_free(priv->bus);
 
+   if (dm_gpio_is_valid(>gpio_phy_reset))
+   dm_gpio_free(dev, >gpio_phy_reset);
+
return 0;
 }
 
diff --git a/drivers/net/pch_gbe.h b/drivers/net/pch_gbe.h
index 0ea0c73..1d13380 100644
--- a/drivers/net/pch_gbe.h
+++ b/drivers/net/pch_gbe.h
@@ -293,6 +293,7 @@ struct pch_gbe_priv {
struct udevice *dev;
int rx_idx;
int tx_idx;
+   struct gpio_desc gpio_phy_reset;
 };
 
 #endif /* _PCH_GBE_H_ */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot