linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Vladimir Oltean <olteanv@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Juergen Borleis <kernel@pengutronix.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: dsa: lan9303: fix reset on probe
Date: Wed, 09 Feb 2022 16:34:15 +0000	[thread overview]
Message-ID: <yw1x1r0c5794.fsf@mansr.com> (raw)
In-Reply-To: <YgPlVGclJOkvLZ1i@lunn.ch> (Andrew Lunn's message of "Wed, 9 Feb 2022 17:01:24 +0100")

Andrew Lunn <andrew@lunn.ch> writes:

> On Wed, Feb 09, 2022 at 02:54:54PM +0000, Mans Rullgard wrote:
>> The reset input to the LAN9303 chip is active low, and devicetree
>> gpio handles reflect this.  Therefore, the gpio should be requested
>> with an initial state of high in order for the reset signal to be
>> asserted.  Other uses of the gpio already use the correct polarity.
>> 
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>> ---
>>  drivers/net/dsa/lan9303-core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
>> index aa1142d6a9f5..2de67708bbd2 100644
>> --- a/drivers/net/dsa/lan9303-core.c
>> +++ b/drivers/net/dsa/lan9303-core.c
>> @@ -1301,7 +1301,7 @@ static int lan9303_probe_reset_gpio(struct lan9303 *chip,
>>  				     struct device_node *np)
>>  {
>>  	chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
>> -						   GPIOD_OUT_LOW);
>> +						   GPIOD_OUT_HIGH);
>>  	if (IS_ERR(chip->reset_gpio))
>>  		return PTR_ERR(chip->reset_gpio);
>
> lan9303_handle_reset() does a sleep and then releases the reset. I
> don't see anywhere in the driver which asserts the reset first. So is
> it actually asserted as part of this getting the GPIO? And if so, does
> not this change actually break the reset?

The GPIOD_OUT_xxx flags to gpiod_get() request that the pin be
configured as output and set to high/low initially.  The GPIOD_OUT_LOW
currently used by the lan9303 driver together with GPIO_ACTIVE_LOW in
the devicetrees results in the actual voltage being set high.  The
driver then sleeps for a bit before setting the gpio value to zero,
again translated to a high output voltage.  That is, the value set after
the sleep is the same as it was initially.  This is obviously not the
intent.

With the patch applied, I can measure the reset signal pulse low for the
configured duration when the device is probed.  Without the patch, the
reset signal remains high and no reset of the device occurs.

-- 
Måns Rullgård

  reply	other threads:[~2022-02-09 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
2022-02-09 16:01 ` Andrew Lunn
2022-02-09 16:34   ` Måns Rullgård [this message]
2022-02-11 19:28     ` Andrew Lunn
2022-02-10  2:36 ` Jakub Kicinski
2022-02-10 13:48   ` Måns Rullgård
2022-02-11 20:00 ` Florian Fainelli
2022-02-11 22:30 ` patchwork-bot+netdevbpf

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=yw1x1r0c5794.fsf@mansr.com \
    --to=mans@mansr.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@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).