All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Welling <mwelling@emacinc.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg KH <gregkh@linuxfoundation.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>
Subject: Re: GPIO registration for external Ethernet PHY oscillator enable/disable
Date: Tue, 7 Oct 2014 11:38:44 -0500	[thread overview]
Message-ID: <20141007163844.GB6123@sysresccd> (raw)
In-Reply-To: <CACRpkdarM1Ae1Xa7kLC-+4A8i4JcU+c4YazppgA1YHvVRtdeQw@mail.gmail.com>

On Tue, Oct 07, 2014 at 04:09:45PM +0200, Linus Walleij wrote:
> On Fri, Sep 26, 2014 at 10:04 PM, Michael Welling <mwelling@emacinc.com> wrote:
> > On Fri, Sep 26, 2014 at 10:16:51AM -0700, Florian Fainelli wrote:
> >>
> >> Yes and no, this might feel like the wrong place, but ultimately, the
> >> Ethernet MAC is a consumer of the PHY device, and is in control, through
> >> the PHY library of how and when the PHY gets to be powered off.
> >>
> >
> > So here is the patch that I made that hooks into the macb driver.
> >
> > Please look it over and tell me if we are on the same page.
> >
> > The thing that bothers me about this solution is that it will only work with the macb driver.
> > So everytime I use the same PHY/OSC combo with a different SoC I will have to do another patch.
> >
> > diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> > index e4e34b6..8cd363f 100644
> > --- a/drivers/net/ethernet/cadence/macb.c
> > +++ b/drivers/net/ethernet/cadence/macb.c
> > @@ -28,6 +28,7 @@
> >  #include <linux/of.h>
> >  #include <linux/of_device.h>
> >  #include <linux/of_net.h>
> > +#include <linux/of_gpio.h>
> 
> No please,
> #include <linux/gpio/consumer.h>
> 
> > @@ -1833,6 +1834,16 @@ static int __init macb_probe(struct platform_device *pdev)
> >                 bp->phy_interface = err;
> >         }
> >
> > +       bp->phy_osc_gpio = of_get_named_gpio(pdev->dev.of_node, "osc-gpio", 0);
> > +
> > +       if (gpio_is_valid(bp->phy_osc_gpio))
> > +       {
> > +               if (gpio_request(bp->phy_osc_gpio, "osc-gpio") != 0) {
> > +                       pr_info("Oscillator GPIO not available.\n");
> > +                       bp->phy_osc_gpio = 0;
> > +               }
> > +       }
> 
> 
> No,
> bp->phy_osc_gpiod = devm_gpiod_get(&pdev->dev, "osc-gpio", 0);
> 
> And error handling.
> 
> > +       if (gpio_is_valid(bp->phy_osc_gpio))
> > +               gpio_set_value_cansleep(bp->phy_osc_gpio, 0);
> > +
> 
> if (bp->phy_osc_gpiod)
>   gpiod_set_...
> 
> > +       if (gpio_is_valid(bp->phy_osc_gpio))
> > +               gpio_set_value_cansleep(bp->phy_osc_gpio, 1);
> 
> Dito.
> 
> >         phy_interface_t         phy_interface;
> > +       int                     phy_osc_gpio;
> 
> struct gpio_desc *phy_osc_gpiod;

Thank you for clearifying the preferred/correct interface.

This version was not even functional and I had to update it 
such that it was.

I will, of course, follow the above suggestions if/when I submit an
actual patch.

I am still not sure the MAC driver is the best place for this
registration.

> 
> Yours,
> Linus Walleij

  reply	other threads:[~2014-10-07 16:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 21:52 GPIO registration for external Ethernet PHY oscillator enable/disable Michael Welling
2014-09-25 19:17 ` Michael Welling
2014-09-25 19:56   ` Florian Fainelli
2014-09-26 16:59     ` Michael Welling
2014-09-26 17:16       ` Florian Fainelli
2014-09-26 17:32         ` Michael Welling
2014-09-26 20:04         ` Michael Welling
2014-10-07 14:09           ` Linus Walleij
2014-10-07 16:38             ` Michael Welling [this message]
2014-10-07 14:04   ` Linus Walleij
2014-10-07 16:30     ` Michael Welling

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=20141007163844.GB6123@sysresccd \
    --to=mwelling@emacinc.com \
    --cc=f.fainelli@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.