From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: netdev@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-amlogic@lists.infradead.org, linus.walleij@linaro.org,
bgolaszewski@baylibre.com, peppe.cavallaro@st.com,
alexandre.torgue@st.com, joabreu@synopsys.com
Cc: devicetree@vger.kernel.org, narmstrong@baylibre.com,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
khilman@baylibre.com, linux-kernel@vger.kernel.org,
davem@davemloft.net, linux-arm-kernel@lists.infradead.org
Subject: [RFC next v1 3/5] net: stmmac: use GPIO descriptors in stmmac_mdio_reset
Date: Sun, 9 Jun 2019 20:06:19 +0200 [thread overview]
Message-ID: <20190609180621.7607-4-martin.blumenstingl@googlemail.com> (raw)
In-Reply-To: <20190609180621.7607-1-martin.blumenstingl@googlemail.com>
Switch stmmac_mdio_reset to use GPIO descriptors. GPIO core handles the
"snps,reset-gpio" for GPIO descriptors so we don't need to take care of
it inside the driver anymore.
The advantage of this is that we now preserve the GPIO flags which are
passed via devicetree. This is required on some newer Amlogic boards
which use an Open Drain pin for the reset GPIO. This pin can only output
a LOW signal or switch to input mode but it cannot output a HIGH signal.
There are already devicetree bindings for these special cases and GPIO
core already takes care of them but only if we use GPIO descriptors
instead of GPIO numbers.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 27 +++++++++----------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index cb9aad090cc9..21bbe3ba3e8e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -20,11 +20,11 @@
Maintainer: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/
+#include <linux/gpio/consumer.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/mii.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/of_mdio.h>
#include <linux/phy.h>
#include <linux/slab.h>
@@ -251,34 +251,33 @@ int stmmac_mdio_reset(struct mii_bus *bus)
#ifdef CONFIG_OF
if (priv->device->of_node) {
+ struct gpio_desc *reset_gpio;
+
if (data->reset_gpio < 0) {
struct device_node *np = priv->device->of_node;
- data->reset_gpio = of_get_named_gpio(np,
- "snps,reset-gpio", 0);
- if (data->reset_gpio < 0)
- return 0;
+ reset_gpio = devm_gpiod_get_optional(priv->device,
+ "snps,reset",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(reset_gpio))
+ return PTR_ERR(reset_gpio);
- data->active_low = of_property_read_bool(np,
- "snps,reset-active-low");
of_property_read_u32_array(np,
"snps,reset-delays-us", data->delays, 3);
+ } else {
+ reset_gpio = gpio_to_desc(data->reset_gpio);
- if (devm_gpio_request(priv->device, data->reset_gpio,
- "mdio-reset"))
- return 0;
+ gpiod_direction_output(reset_gpio, 0);
}
- gpio_direction_output(data->reset_gpio,
- data->active_low ? 1 : 0);
if (data->delays[0])
msleep(DIV_ROUND_UP(data->delays[0], 1000));
- gpio_set_value(data->reset_gpio, data->active_low ? 0 : 1);
+ gpiod_set_value_cansleep(reset_gpio, 1);
if (data->delays[1])
msleep(DIV_ROUND_UP(data->delays[1], 1000));
- gpio_set_value(data->reset_gpio, data->active_low ? 1 : 0);
+ gpiod_set_value_cansleep(reset_gpio, 0);
if (data->delays[2])
msleep(DIV_ROUND_UP(data->delays[2], 1000));
}
--
2.21.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2019-06-09 18:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-09 18:06 [RFC next v1 0/5] stmmac: honor the GPIO flags for the PHY reset GPIO Martin Blumenstingl
2019-06-09 18:06 ` [RFC next v1 1/5] net: stmmac: drop redundant check in stmmac_mdio_reset Martin Blumenstingl
2019-06-09 18:06 ` [RFC next v1 2/5] gpio: of: parse stmmac PHY reset line specific active-low property Martin Blumenstingl
2019-06-09 20:38 ` Andrew Lunn
2019-06-09 21:21 ` Martin Blumenstingl
2019-06-09 21:29 ` Linus Walleij
2019-06-09 18:06 ` Martin Blumenstingl [this message]
2019-06-09 20:52 ` [RFC next v1 3/5] net: stmmac: use GPIO descriptors in stmmac_mdio_reset Andrew Lunn
2019-06-09 21:50 ` Linus Walleij
2019-06-09 18:06 ` [RFC next v1 4/5] net: stmmac: use device_property_read_u32_array to read the reset delays Martin Blumenstingl
2019-06-09 18:06 ` [RFC next v1 5/5] arm64: dts: meson: g12a: x96-max: fix the Ethernet PHY reset line Martin Blumenstingl
2019-06-09 21:17 ` Linus Walleij
2019-06-09 21:36 ` Martin Blumenstingl
2019-06-09 22:06 ` Linus Walleij
2019-06-09 22:28 ` Martin Blumenstingl
2019-06-09 20:45 ` [RFC next v1 0/5] stmmac: honor the GPIO flags for the PHY reset GPIO Andrew Lunn
2019-06-09 21:52 ` Linus Walleij
2019-06-09 22:32 ` Martin Blumenstingl
2019-06-10 11:47 ` Maxime Ripard
2019-06-10 12:31 ` Martin Blumenstingl
2019-06-10 13:25 ` Andrew Lunn
2019-06-10 15:52 ` Martin Blumenstingl
2019-06-10 13:51 ` Maxime Ripard
2019-06-10 15:51 ` Martin Blumenstingl
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=20190609180621.7607-4-martin.blumenstingl@googlemail.com \
--to=martin.blumenstingl@googlemail.com \
--cc=alexandre.torgue@st.com \
--cc=bgolaszewski@baylibre.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=joabreu@synopsys.com \
--cc=khilman@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=narmstrong@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®