diff mbox series

[U-Boot] net: fec_mxc: fix phy-reset-gpios logic

Message ID 20181018141442.3894-1-agust@denx.de
State Superseded
Delegated to: Joe Hershberger
Headers show
Series [U-Boot] net: fec_mxc: fix phy-reset-gpios logic | expand

Commit Message

Anatolij Gustschin Oct. 18, 2018, 2:14 p.m. UTC
'phy-reset-gpios' property is optional, don't return error when
it is missing. Read 'phy-reset-duration' property only if
'phy-reset-gpios' exists. The binding defines the duration value
in milliseconds, so use mdelay() for waiting.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/net/fec_mxc.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Comments

Joe Hershberger Oct. 22, 2018, 9:02 p.m. UTC | #1
Hi Anatolij,

On Thu, Oct 18, 2018 at 9:15 AM Anatolij Gustschin <agust@denx.de> wrote:
>
> 'phy-reset-gpios' property is optional, don't return error when
> it is missing. Read 'phy-reset-duration' property only if
> 'phy-reset-gpios' exists. The binding defines the duration value
> in milliseconds, so use mdelay() for waiting.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Joe Hershberger <joe.hershberger@ni.com>

This is already covered in https://patchwork.ozlabs.org/patch/979099/
and https://patchwork.ozlabs.org/patch/979101/
Anatolij Gustschin Oct. 22, 2018, 9:11 p.m. UTC | #2
Hi Joe,

On Mon, 22 Oct 2018 21:02:22 +0000
Joe Hershberger joe.hershberger@ni.com wrote:
...
> This is already covered in https://patchwork.ozlabs.org/patch/979099/
> and https://patchwork.ozlabs.org/patch/979101/

Okay, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index d0fdbcb771..5a1a8bc897 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1254,7 +1254,7 @@  static void fec_gpio_reset(struct fec_priv *priv)
 	debug("fec_gpio_reset: fec_gpio_reset(dev)\n");
 	if (dm_gpio_is_valid(&priv->phy_reset_gpio)) {
 		dm_gpio_set_value(&priv->phy_reset_gpio, 1);
-		udelay(priv->reset_delay);
+		mdelay(priv->reset_delay);
 		dm_gpio_set_value(&priv->phy_reset_gpio, 0);
 	}
 }
@@ -1352,22 +1352,18 @@  static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 
 #ifdef CONFIG_DM_GPIO
 	ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
-			     &priv->phy_reset_gpio, GPIOD_IS_OUT);
-	if (ret == 0) {
-		ret = dev_read_u32_array(dev, "phy-reset-duration",
-					 &priv->reset_delay, 1);
-	} else if (ret == -ENOENT) {
-		priv->reset_delay = 1000;
-		ret = 0;
-	}
+				   &priv->phy_reset_gpio, GPIOD_IS_OUT);
+	if (ret < 0)
+		return 0; /* property is optional, don't return error! */
 
+	priv->reset_delay = dev_read_u32_default(dev, "phy-reset-duration", 1);
 	if (priv->reset_delay > 1000) {
-		printf("FEX MXC: gpio reset timeout should be less the 1000\n");
-		priv->reset_delay = 1000;
+		/* property value wrong, use default value */
+		priv->reset_delay = 1;
 	}
 #endif
 
-	return ret;
+	return 0;
 }
 
 static const struct udevice_id fecmxc_ids[] = {