netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Sebastian Frias <sf84@laposte.net>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	mason <slash.tmp@free.fr>, Daniel Mack <zonque@gmail.com>
Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB
Date: Mon, 21 Mar 2016 21:41:11 +0100	[thread overview]
Message-ID: <20160321204111.GB6191@pengutronix.de> (raw)
In-Reply-To: <56F05651.3030706@cogentembedded.com>

Hello Sergei,

On Mon, Mar 21, 2016 at 11:15:13PM +0300, Sergei Shtylyov wrote:
> On 03/16/2016 08:25 PM, Sebastian Frias wrote:
> 
> >Commit 687908c2b649 ("net: phy: at803x: simplify using
> >devm_gpiod_get_optional and its 4th argument") introduced a dependency
> >on GPIOLIB that was not there before.
> >
> >This commit removes such dependency by checking the return code and
> >comparing it against ENOSYS which is returned when GPIOLIB is not
> >selected.
> >
> >Fixes: 687908c2b649 ("net: phy: at803x: simplify using
> >devm_gpiod_get_optional and its 4th argument")
> >
> >Signed-off-by: Sebastian Frias <sf84@laposte.net>
> 
>    Do you have the PHY that requires the GPIO reset workaround?
> Askinjg because I have the patch adding the "reset-gpios" prop handling to
> phylib and your patch made me aware that I'll have to modify this driver in
> order to do that...
> 
> >---
> >  drivers/net/phy/at803x.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> >diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> >index 2174ec9..88b7ff3 100644
> >--- a/drivers/net/phy/at803x.c
> >+++ b/drivers/net/phy/at803x.c
> >@@ -252,7 +252,9 @@ static int at803x_probe(struct phy_device *phydev)
> >  		return -ENOMEM;
> >
> >  	gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> >-	if (IS_ERR(gpiod_reset))
> >+	if (PTR_ERR(gpiod_reset) == -ENOSYS)
> >+		gpiod_reset = NULL;
> >+	else if (IS_ERR(gpiod_reset))
>    		return PTR_ERR(gpiod_reset);
> 
>    My patch basically gets rid of all this code. The thing that worries me
> is that the driver assumes that the reset singal is active low, despite what
> the GPIO specifier in the device tree has for the GPIO polarity. In fact, it
> will only work correctly if the specified has GPIO_ACTIVE_HIGH -- which is
> wrong because the reset signal is active low!

Note that gpio descriptors handle the polarity just fine (i.e. the pin
is set to 0 after doing gpiod_set_value(1) if the gpio is active low).

But having said that, the driver gets it wrong.

The right sequence to reset a device using a gpio is:

	gpiod_set_value(priv->gpiod_reset, 1);
	msleep(some_time);
	gpiod_set_value(priv->gpiod_reset, 0);

and if the gpio is active low, this should be specified in the device
tree. This was done wrong in 13a56b449325 (net: phy: at803x: Add support
for hardware reset).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2016-03-21 20:41 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 17:25 [PATCH] net: phy: at803x: don't depend on GPIOLIB Sebastian Frias
2016-03-18 12:12 ` Mason
2016-03-18 12:54 ` Uwe Kleine-König
2016-03-18 15:56   ` Sebastian Frias
2016-03-18 19:12     ` Uwe Kleine-König
2016-03-18 19:31       ` Mason
2016-03-18 20:11         ` Uwe Kleine-König
2016-03-18 20:44           ` Mason
2016-03-19 10:01             ` Måns Rullgård
2016-03-21 12:48       ` Sebastian Frias
2016-03-21 13:54         ` Uwe Kleine-König
2016-03-21 15:36           ` Sebastian Frias
2016-03-21 20:12             ` Uwe Kleine-König
2016-03-22 14:34               ` Sebastian Frias
2016-03-22 19:42                 ` Uwe Kleine-König
2016-03-23 10:12                   ` Sebastian Frias
2016-03-23 10:49                     ` [PATCH] net: phy: at803x: Request 'reset' GPIO only for AT8030 PHY Sebastian Frias
2016-03-23 17:40                       ` David Miller
2016-03-23 19:42                       ` Sergei Shtylyov
2016-03-24  9:55                         ` Sebastian Frias
2016-03-24 10:10                           ` Sebastian Frias
2016-03-24 13:40                             ` Sergei Shtylyov
2016-03-23 10:17                   ` [PATCH] net: phy: at803x: don't depend on GPIOLIB Mason
2016-03-23 10:39                     ` Sergei Shtylyov
2016-03-23 10:55                       ` Sebastian Frias
2016-03-22 14:34     ` Sebastian Frias
2016-03-21 20:15 ` Sergei Shtylyov
2016-03-21 20:41   ` Uwe Kleine-König [this message]
2016-03-21 21:56     ` Sergei Shtylyov
2016-03-22 14:53     ` Sebastian Frias
2016-03-22 14:39   ` Sebastian Frias

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=20160321204111.GB6191@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=sf84@laposte.net \
    --cc=slash.tmp@free.fr \
    --cc=zonque@gmail.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;
as well as URLs for NNTP newsgroup(s).