linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: f.fainelli@gmail.com (Florian Fainelli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1] net: phy: micrel: Add specific suspend
Date: Wed, 3 Aug 2016 20:33:08 -0700	[thread overview]
Message-ID: <11f70064-11d6-47b9-6ec1-83b7b0dc5419@gmail.com> (raw)
In-Reply-To: <1470270095-13131-1-git-send-email-wenyou.yang@atmel.com>

On 03/08/2016 17:21, Wenyou Yang wrote:
> Disable all interrupts when suspend, they will be enabled
> when resume. Otherwise, the suspend/resume process will be
> blocked occasionally.

This seems like something fairly generic actually, we could imagine
having the core library do something like this:

- if interrupts are valid and enabled for the PHY, call
phydrv->config_intr() with PHY_INTERRUPT_DISABLED
- call genphy_suspend

Of course if none of this fits the generic model, the PHY driver can
still provide a suspend callback. Might be worth auditing other drivers
for that pattern and look at those that need specific handling like
keeping specific interrupt sources active for e.g: wake-on-LAN.

> 
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> 
>  drivers/net/phy/micrel.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 5a8fefc..8cb778a 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -647,6 +647,23 @@ static void kszphy_get_stats(struct phy_device *phydev,
>  		data[i] = kszphy_get_stat(phydev, i);
>  }
>  
> +int kszphy_suspend(struct phy_device *phydev)
> +{
> +	int value;
> +
> +	mutex_lock(&phydev->lock);
> +
> +	/* disable interrupts */
> +	phy_write(phydev, MII_KSZPHY_INTCS, 0x0);
> +
> +	value = phy_read(phydev, MII_BMCR);
> +	phy_write(phydev, MII_BMCR, value | BMCR_PDOWN);
> +
> +	mutex_unlock(&phydev->lock);
> +
> +	return 0;
> +}
> +
>  static int kszphy_resume(struct phy_device *phydev)
>  {
>  	int value;
> @@ -870,7 +887,7 @@ static struct phy_driver ksphy_driver[] = {
>  	.get_sset_count = kszphy_get_sset_count,
>  	.get_strings	= kszphy_get_strings,
>  	.get_stats	= kszphy_get_stats,
> -	.suspend	= genphy_suspend,
> +	.suspend	= kszphy_suspend,
>  	.resume		= kszphy_resume,
>  }, {
>  	.phy_id		= PHY_ID_KSZ8061,
> 

  reply	other threads:[~2016-08-04  3:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  0:21 [PATCH v1] net: phy: micrel: Add specific suspend Wenyou Yang
2016-08-04  3:33 ` Florian Fainelli [this message]
2016-08-05  6:18   ` Wenyou.Yang at microchip.com

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=11f70064-11d6-47b9-6ec1-83b7b0dc5419@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).