Netdev List
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, Tobias Klauser <tklauser@distanz.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Jarod Wilson <jarod@redhat.com>, <linux-mips@linux-mips.org>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH v3 2/7] net: pch_gbe: Pull PHY GPIO handling out of Minnow code
Date: Mon, 5 Jun 2017 10:21:50 -0700	[thread overview]
Message-ID: <4378321.AjzBvRIWiG@np-p-burton> (raw)
In-Reply-To: <20170603175200.GC17099@lunn.ch>

[-- Attachment #1: Type: text/plain, Size: 3262 bytes --]

Hi Andrew,

On Saturday, 3 June 2017 10:52:00 PDT Andrew Lunn wrote:
> > diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> > b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index
> > d38198718005..cb9b904786e4 100644
> > --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> > +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> > @@ -360,6 +360,16 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw
> > *hw, u8 * addr, u32 index)> 
> >  	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
> >  
> >  }
> > 
> > +static void pch_gbe_phy_set_reset(struct pch_gbe_hw *hw, int value)
> > +{
> > +	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
> > +
> > +	if (!adapter->pdata || !adapter->pdata->phy_reset_gpio)
> > +		return;
> > +
> > +	gpiod_set_value(adapter->pdata->phy_reset_gpio, value);
> 
> Hi Paul
> 
> Since you are using the gpiod_ API, the core will take notice of the
> active low/active high flag when performing this set.

Correct, and as desired.

> >  	ret = devm_gpio_request_one(&pdev->dev, gpio, flags,
> >  	
> >  				    "minnow_phy_reset");
> > 
> > -	if (ret) {
> > +	if (!ret)
> > +		pdata->phy_reset_gpio = gpio_to_desc(gpio);
> 
> Here however, you are using the gpio_ API, which ignores the active
> high/low flag in device tree. And in your binding patch, you give the
> example:
> 
> +               phy-reset-gpios = <&eg20t_gpio 6
> +                                  GPIO_ACTIVE_LOW>;
> 
> This active low is totally ignored.

First of all, this path is for the existing Minnow platform, which doesn't use 
the device tree. That is, this code is the non-DT path so looking at what 
happens to flags in the device tree here makes no sense.

If you want to examine what happens in the DT case then please look at 
pch_gbe_get_priv() which uses devm_gpiod_get() which should honor the flags 
provided by the DT.

> I personally would say this is all messed up, and going to result in
> problems for somebody with a board which actually needs an
> GPIO_ACTIVE_HIGH.

It's a path which only applies to the Minnow board, which is always active 
low. Before patch 1 of this series that was done without the GPIOF_ACTIVE_LOW 
flag by setting GPIO values to reflect the physical GPIO line low/high rather 
than the logical active/not-active. After patch 1 this path began using 
GPIOF_ACTIVE_LOW such that the rest of the code can use logical active/not-
active values which work with either active low or active high GPIOs. In this 
Minnow-specific path GPIOF_ACTIVE_LOW is hardcoded, but again only applies to 
the Minnow board which doesn't take the GPIO value from device tree.

> Please use the gpiod_ API through out and respect the flags in the
> device tree binding.

The gpiod_ API, quite rightly, retrieves GPIOs associated with a device - for 
example via the device tree. The Minnow board, which is what the driver 
already supports in-tree, does not do this but instead hardcodes a GPIO number 
(MINNOW_PHY_RESET_GPIO). I don't own, use or care about the Minnow platform so 
that is not something that I can change. In the path that my patch does add, 
the path which is used with DT, I already do use the gpiod_ API & respect 
flags from the DT.

Thanks,
    Paul

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-06-05 17:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 23:40 [PATCH v3 0/7] net: pch_gbe: Fixes & MIPS support Paul Burton
2017-06-02 23:40 ` [PATCH v3 1/7] net: pch_gbe: Mark Minnow PHY reset GPIO active low Paul Burton
2017-06-02 23:40 ` [PATCH v3 2/7] net: pch_gbe: Pull PHY GPIO handling out of Minnow code Paul Burton
2017-06-03 17:52   ` Andrew Lunn
2017-06-05 17:21     ` Paul Burton [this message]
2017-06-05 18:43       ` Andrew Lunn
     [not found] ` <20170602234042.22782-1-paul.burton-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2017-06-02 23:40   ` [PATCH v3 3/7] dt-bindings: net: Document Intel pch_gbe binding Paul Burton
2017-06-02 23:40 ` [PATCH v3 4/7] net: pch_gbe: Add device tree support Paul Burton
2017-06-03  6:36   ` [PATCH] net: pch_gbe: fix err_cast.cocci warnings kbuild test robot
2017-06-03  6:36   ` [PATCH v3 4/7] net: pch_gbe: Add device tree support kbuild test robot
2017-06-02 23:40 ` [PATCH v3 5/7] net: pch_gbe: Always reset PHY along with MAC Paul Burton
2017-06-02 23:40 ` [PATCH v3 6/7] net: pch_gbe: Allow longer for resets Paul Burton
2017-06-06 14:10   ` Marcin Nowakowski
2017-06-02 23:40 ` [PATCH v3 7/7] net: pch_gbe: Allow build on MIPS platforms Paul Burton
2017-06-05 17:31 ` [PATCH v4 0/7] net: pch_gbe: Fixes & MIPS support Paul Burton
2017-06-05 17:31   ` [PATCH v4 1/7] net: pch_gbe: Mark Minnow PHY reset GPIO active low Paul Burton
2017-06-05 17:31   ` [PATCH v4 2/7] net: pch_gbe: Pull PHY GPIO handling out of Minnow code Paul Burton
2017-06-05 18:55     ` Andrew Lunn
     [not found]   ` <20170605173136.10795-1-paul.burton-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2017-06-05 17:31     ` [PATCH v4 3/7] dt-bindings: net: Document Intel pch_gbe binding Paul Burton
     [not found]       ` <20170605173136.10795-4-paul.burton-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2017-06-05 18:45         ` Sergei Shtylyov
2017-06-09 13:21         ` Rob Herring
2017-06-05 17:31   ` [PATCH v4 4/7] net: pch_gbe: Add device tree support Paul Burton
2017-06-05 18:54     ` Andrew Lunn
2017-06-05 17:31   ` [PATCH v4 5/7] net: pch_gbe: Always reset PHY along with MAC Paul Burton
2017-06-05 17:31   ` [PATCH v4 6/7] net: pch_gbe: Allow longer for resets Paul Burton
2017-06-05 17:31   ` [PATCH v4 7/7] net: pch_gbe: Allow build on MIPS platforms Paul Burton

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=4378321.AjzBvRIWiG@np-p-burton \
    --to=paul.burton@imgtec.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jarod@redhat.com \
    --cc=linux-mips@linux-mips.org \
    --cc=netdev@vger.kernel.org \
    --cc=tklauser@distanz.ch \
    /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