Netdev Archive on lore.kernel.org
 help / color / Atom feed
From: Bruno Thomsen <bruno.thomsen@gmail.com>
To: netdev <netdev@vger.kernel.org>
Cc: Bruno Thomsen <bruno.thomsen@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>, Fabio Estevam <festevam@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Lars Alex Pedersen <laa@kamstrup.com>,
	Bruno Thomsen <bth@kamstrup.com>
Subject: [PATCH v2 3/4 net-next] net: mdiobus: add reset-post-delay-us handling
Date: Thu, 30 Jul 2020 21:57:48 +0200
Message-ID: <20200730195749.4922-4-bruno.thomsen@gmail.com> (raw)
In-Reply-To: <20200730195749.4922-1-bruno.thomsen@gmail.com>

Load new "reset-post-delay-us" value from MDIO properties,
and if configured to a greater then zero delay do a
flexible sleeping delay after MDIO bus reset deassert.
This allows devices to exit reset state before start
bus communication.

Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
---
 drivers/net/phy/mdio_bus.c | 2 ++
 drivers/of/of_mdio.c       | 2 ++
 include/linux/phy.h        | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 5df3782b05b4..0af20faad69d 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -556,6 +556,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
 		gpiod_set_value_cansleep(gpiod, 1);
 		fsleep(bus->reset_delay_us);
 		gpiod_set_value_cansleep(gpiod, 0);
+		if (bus->reset_post_delay_us > 0)
+			fsleep(bus->reset_post_delay_us);
 	}
 
 	if (bus->reset) {
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index eb84507de28a..cb32d7ef4938 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -268,6 +268,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 	/* Get bus level PHY reset GPIO details */
 	mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY;
 	of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us);
+	mdio->reset_post_delay_us = 0;
+	of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us);
 
 	/* Register the MDIO bus */
 	rc = mdiobus_register(mdio);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 0403eb799913..3a09d2bf69ea 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -293,6 +293,8 @@ struct mii_bus {
 
 	/* GPIO reset pulse width in microseconds */
 	int reset_delay_us;
+	/* GPIO reset deassert delay in microseconds */
+	int reset_post_delay_us;
 	/* RESET GPIO descriptor pointer */
 	struct gpio_desc *reset_gpiod;
 
-- 
2.26.2


  parent reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 19:57 [PATCH v2 0/4 net-next] Improve MDIO Ethernet PHY reset Bruno Thomsen
2020-07-30 19:57 ` [PATCH v2 1/4 net-next] dt-bindings: net: mdio: add reset-post-delay-us property Bruno Thomsen
2020-08-02 16:46   ` Andrew Lunn
2020-08-02 20:16   ` Florian Fainelli
2020-07-30 19:57 ` [PATCH v2 2/4 net-next] net: mdiobus: use flexible sleeping for reset-delay-us Bruno Thomsen
2020-08-02 16:46   ` Andrew Lunn
2020-08-02 20:17   ` Florian Fainelli
2020-07-30 19:57 ` Bruno Thomsen [this message]
2020-08-02 16:47   ` [PATCH v2 3/4 net-next] net: mdiobus: add reset-post-delay-us handling Andrew Lunn
2020-08-02 20:18   ` Florian Fainelli
2020-07-30 19:57 ` [PATCH v2 4/4 net-next] net: mdio device: use flexible sleeping in reset function Bruno Thomsen
2020-08-02 16:48   ` Andrew Lunn
2020-08-02 20:19   ` Florian Fainelli
2020-08-03 22:01 ` [PATCH v2 0/4 net-next] Improve MDIO Ethernet PHY reset David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200730195749.4922-4-bruno.thomsen@gmail.com \
    --to=bruno.thomsen@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bth@kamstrup.com \
    --cc=f.fainelli@gmail.com \
    --cc=festevam@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=laa@kamstrup.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git