diff mbox series

[U-Boot,1/2] net: dm: fec: Support phy-reset-post-delay property

Message ID 20190301132755.947-2-andrejs.cainikovs@netmodule.com
State Accepted
Commit 31d4045d4be8263828689c7eb6ff4e72071ad5ce
Delegated to: Joe Hershberger
Headers show
Series Fix broken ethernet on imx8qxp-mek | expand

Commit Message

Andrejs Cainikovs March 1, 2019, 1:27 p.m. UTC
As per Linux kernel DT binding doc:
- phy-reset-post-delay : Post reset delay in milliseconds. If present then
  a delay of phy-reset-post-delay milliseconds will be observed after the
  phy-reset-gpios has been toggled. Can be omitted thus no delay is
  observed. Delay is in range of 1ms to 1000ms. Other delays are invalid.

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@netmodule.com>
---
 drivers/net/fec_mxc.c | 11 +++++++++++
 drivers/net/fec_mxc.h |  1 +
 2 files changed, 12 insertions(+)

Comments

Anatolij Gustschin March 1, 2019, 1:57 p.m. UTC | #1
On Fri, 1 Mar 2019 13:27:59 +0000
Andrejs Cainikovs Andrejs.Cainikovs@netmodule.com wrote:

> As per Linux kernel DT binding doc:
> - phy-reset-post-delay : Post reset delay in milliseconds. If present then
>   a delay of phy-reset-post-delay milliseconds will be observed after the
>   phy-reset-gpios has been toggled. Can be omitted thus no delay is
>   observed. Delay is in range of 1ms to 1000ms. Other delays are invalid.
> 
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@netmodule.com>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij
Stefano Babic March 1, 2019, 2:07 p.m. UTC | #2
On 01/03/19 14:27, Andrejs Cainikovs wrote:
> As per Linux kernel DT binding doc:
> - phy-reset-post-delay : Post reset delay in milliseconds. If present then
>   a delay of phy-reset-post-delay milliseconds will be observed after the
>   phy-reset-gpios has been toggled. Can be omitted thus no delay is
>   observed. Delay is in range of 1ms to 1000ms. Other delays are invalid.
> 
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@netmodule.com>
> ---
>  drivers/net/fec_mxc.c | 11 +++++++++++
>  drivers/net/fec_mxc.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index a14fe43a5b..7fc95fa767 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1315,6 +1315,8 @@ static void fec_gpio_reset(struct fec_priv *priv)
>  		dm_gpio_set_value(&priv->phy_reset_gpio, 1);
>  		mdelay(priv->reset_delay);
>  		dm_gpio_set_value(&priv->phy_reset_gpio, 0);
> +		if (priv->reset_post_delay)
> +			mdelay(priv->reset_post_delay);
>  	}
>  }
>  #endif
> @@ -1474,6 +1476,15 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
>  		/* property value wrong, use default value */
>  		priv->reset_delay = 1;
>  	}
> +
> +	priv->reset_post_delay = dev_read_u32_default(dev,
> +						      "phy-reset-post-delay",
> +						      0);
> +	if (priv->reset_post_delay > 1000) {
> +		printf("FEC MXC: phy reset post delay should be <= 1000ms\n");
> +		/* property value wrong, use default value */
> +		priv->reset_post_delay = 0;
> +	}
>  #endif
>  
>  	return 0;
> diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
> index e9a661f0a1..e5f2dd75c5 100644
> --- a/drivers/net/fec_mxc.h
> +++ b/drivers/net/fec_mxc.h
> @@ -258,6 +258,7 @@ struct fec_priv {
>  #ifdef CONFIG_DM_GPIO
>  	struct gpio_desc phy_reset_gpio;
>  	uint32_t reset_delay;
> +	uint32_t reset_post_delay;
>  #endif
>  #ifdef CONFIG_DM_ETH
>  	u32 interface;
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Joe Hershberger March 1, 2019, 6:49 p.m. UTC | #3
On Fri, Mar 1, 2019 at 7:28 AM Andrejs Cainikovs
<Andrejs.Cainikovs@netmodule.com> wrote:
>
> As per Linux kernel DT binding doc:
> - phy-reset-post-delay : Post reset delay in milliseconds. If present then
>   a delay of phy-reset-post-delay milliseconds will be observed after the
>   phy-reset-gpios has been toggled. Can be omitted thus no delay is
>   observed. Delay is in range of 1ms to 1000ms. Other delays are invalid.
>
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@netmodule.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Lukasz Majewski March 3, 2019, 10:18 p.m. UTC | #4
Hi Andrejs,

> As per Linux kernel DT binding doc:
> - phy-reset-post-delay : Post reset delay in milliseconds. If present
> then a delay of phy-reset-post-delay milliseconds will be observed
> after the phy-reset-gpios has been toggled. Can be omitted thus no
> delay is observed. Delay is in range of 1ms to 1000ms. Other delays
> are invalid.
> 
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@netmodule.com>
> ---
>  drivers/net/fec_mxc.c | 11 +++++++++++
>  drivers/net/fec_mxc.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index a14fe43a5b..7fc95fa767 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1315,6 +1315,8 @@ static void fec_gpio_reset(struct fec_priv
> *priv) dm_gpio_set_value(&priv->phy_reset_gpio, 1);
>  		mdelay(priv->reset_delay);
>  		dm_gpio_set_value(&priv->phy_reset_gpio, 0);
> +		if (priv->reset_post_delay)
> +			mdelay(priv->reset_post_delay);
>  	}
>  }
>  #endif
> @@ -1474,6 +1476,15 @@ static int fecmxc_ofdata_to_platdata(struct
> udevice *dev) /* property value wrong, use default value */
>  		priv->reset_delay = 1;
>  	}
> +
> +	priv->reset_post_delay = dev_read_u32_default(dev,
> +
> "phy-reset-post-delay",
> +						      0);
> +	if (priv->reset_post_delay > 1000) {
> +		printf("FEC MXC: phy reset post delay should be <=
> 1000ms\n");
> +		/* property value wrong, use default value */
> +		priv->reset_post_delay = 0;
> +	}
>  #endif
>  
>  	return 0;
> diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
> index e9a661f0a1..e5f2dd75c5 100644
> --- a/drivers/net/fec_mxc.h
> +++ b/drivers/net/fec_mxc.h
> @@ -258,6 +258,7 @@ struct fec_priv {
>  #ifdef CONFIG_DM_GPIO
>  	struct gpio_desc phy_reset_gpio;
>  	uint32_t reset_delay;
> +	uint32_t reset_post_delay;
>  #endif
>  #ifdef CONFIG_DM_ETH
>  	u32 interface;

Acked-by: Lukasz Majewski <lukma@denx.de>

(as I had similar patch somewhere  .... to fix this issue on IMX6Q).


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Joe Hershberger March 5, 2019, 6:05 p.m. UTC | #5
Hi Andrejs,

https://patchwork.ozlabs.org/patch/1050177/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
Anatolij Gustschin March 12, 2019, 9:10 a.m. UTC | #6
Hi Joe,

On Tue, 5 Mar 2019 12:05:38 -0600
Joe Hershberger joe.hershberger@ni.com wrote:

> Hi Andrejs,
> 
> https://patchwork.ozlabs.org/patch/1050177/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

This patch is not in mainline tree yet, but it is marked as accepted
on patchwork. Could you please check? This is part of a bug-fix for
broken ethernet on the board and should go into v2019.04 release.

Thanks,
Anatolij
Joe Hershberger March 12, 2019, 5:22 p.m. UTC | #7
Hi Anatolij,

On Tue, Mar 12, 2019 at 4:10 AM Anatolij Gustschin <agust@denx.de> wrote:
>
> Hi Joe,
>
> On Tue, 5 Mar 2019 12:05:38 -0600
> Joe Hershberger joe.hershberger@ni.com wrote:
>
> > Hi Andrejs,
> >
> > https://patchwork.ozlabs.org/patch/1050177/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
>
> This patch is not in mainline tree yet, but it is marked as accepted
> on patchwork. Could you please check? This is part of a bug-fix for
> broken ethernet on the board and should go into v2019.04 release.

Yes, it should go into this release. Hopefully Tom will pull it in shortly.

Thanks,
-Joe

> Thanks,
> Anatolij
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index a14fe43a5b..7fc95fa767 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1315,6 +1315,8 @@  static void fec_gpio_reset(struct fec_priv *priv)
 		dm_gpio_set_value(&priv->phy_reset_gpio, 1);
 		mdelay(priv->reset_delay);
 		dm_gpio_set_value(&priv->phy_reset_gpio, 0);
+		if (priv->reset_post_delay)
+			mdelay(priv->reset_post_delay);
 	}
 }
 #endif
@@ -1474,6 +1476,15 @@  static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 		/* property value wrong, use default value */
 		priv->reset_delay = 1;
 	}
+
+	priv->reset_post_delay = dev_read_u32_default(dev,
+						      "phy-reset-post-delay",
+						      0);
+	if (priv->reset_post_delay > 1000) {
+		printf("FEC MXC: phy reset post delay should be <= 1000ms\n");
+		/* property value wrong, use default value */
+		priv->reset_post_delay = 0;
+	}
 #endif
 
 	return 0;
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index e9a661f0a1..e5f2dd75c5 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -258,6 +258,7 @@  struct fec_priv {
 #ifdef CONFIG_DM_GPIO
 	struct gpio_desc phy_reset_gpio;
 	uint32_t reset_delay;
+	uint32_t reset_post_delay;
 #endif
 #ifdef CONFIG_DM_ETH
 	u32 interface;