public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@marvell.com>
To: Jane Li <jiel@marvell.com>
Cc: <thomas.petazzoni@free-electrons.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: mvneta: support suspend and resume
Date: Wed, 15 Mar 2017 15:18:43 +0800	[thread overview]
Message-ID: <20170315151843.258f214f@xhacker> (raw)
In-Reply-To: <1489561714-2368-1-git-send-email-jiel@marvell.com>

Hi Jane,

On Wed, 15 Mar 2017 15:08:34 +0800 Jane Li  wrote:

> Add basic support for handling suspend and resume.
> 
> Signed-off-by: Jane Li <jiel@marvell.com>
> ---
>  drivers/net/ethernet/marvell/mvneta.c | 44 +++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index 61dd446..4f16342 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -4405,6 +4405,49 @@ static int mvneta_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int mvneta_suspend(struct device *device)
> +{
> +	struct net_device *dev = dev_get_drvdata(device);
> +	struct mvneta_port *pp = netdev_priv(dev);
> +
> +	if (netif_running(dev))
> +		mvneta_stop(dev);
> +	netif_device_detach(dev);
> +	clk_disable_unprepare(pp->clk_bus);
> +	clk_disable_unprepare(pp->clk);
> +	return 0;
> +}
> +
> +static int mvneta_resume(struct device *device)
> +{
> +	struct net_device *dev = dev_get_drvdata(device);
> +	struct mvneta_port *pp = netdev_priv(dev);
> +	int err;
> +
> +	clk_prepare_enable(pp->clk);
> +	clk_prepare_enable(pp->clk_bus);

we may miss the necessary registers setting in mvneta_bm_port_init() and
mvneta_conf_mbus_windows(). those registers also need to be restored.


> +	mvneta_defaults_set(pp);

before restore the default setting, is it safer to mvneta_port_disable()?

Thanks,
Jisheng

> +	err = mvneta_port_power_up(pp, pp->phy_interface);
> +	if (err < 0) {
> +		dev_err(device, "can't power up port\n");
> +		return err;
> +	}
> +
> +	if (pp->use_inband_status)
> +		mvneta_fixed_link_update(pp, dev->phydev);
> +
> +	netif_device_attach(dev);
> +	if (netif_running(dev))
> +		mvneta_open(dev);
> +	return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops mvneta_pm_ops = {
> +	SET_LATE_SYSTEM_SLEEP_PM_OPS(mvneta_suspend, mvneta_resume)
> +};
> +
>  static const struct of_device_id mvneta_match[] = {
>  	{ .compatible = "marvell,armada-370-neta" },
>  	{ .compatible = "marvell,armada-xp-neta" },
> @@ -4419,6 +4462,7 @@ static int mvneta_remove(struct platform_device *pdev)
>  	.driver = {
>  		.name = MVNETA_DRIVER_NAME,
>  		.of_match_table = mvneta_match,
> +		.pm = &mvneta_pm_ops,
>  	},
>  };
>  

  reply	other threads:[~2017-03-15  7:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15  7:08 [PATCH] net: mvneta: support suspend and resume Jane Li
2017-03-15  7:18 ` Jisheng Zhang [this message]
2017-03-16  3:23   ` Jane Li

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=20170315151843.258f214f@xhacker \
    --to=jszhang@marvell.com \
    --cc=jiel@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.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