From: Heiko Stuebner <heiko@sntech.de>
To: Vincent Palatin <vpalatin@chromium.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Lunn <andrew@lunn.ch>,
Douglas Anderson <dianders@chromium.org>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Shunqian Zheng <zhengsq@rock-chips.com>
Subject: Re: [PATCH 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL
Date: Sat, 11 Jun 2016 03:57:44 +0200 [thread overview]
Message-ID: <2847430.O0lKQgdM0K@phil> (raw)
In-Reply-To: <1465606839-7722-3-git-send-email-vpalatin@chromium.org>
Am Freitag, 10. Juni 2016, 18:00:38 schrieb Vincent Palatin:
> When suspending the machine, do not shutdown the external PHY by cutting
> its regulator in the mac platform driver suspend code if Wake-on-Lan is
> enabled, else it cannot wake us up.
> In order to do this, split the suspend/resume callbacks from the
> init/exit callbacks, so we can condition the power-down on the lack of
> need to wake-up from the LAN but do it unconditionally when unloading the
> module.
>
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 49
> +++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5
> deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 0cd3ecf..fa05771
> 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -46,6 +46,7 @@ struct rk_priv_data {
> struct platform_device *pdev;
> int phy_iface;
> struct regulator *regulator;
> + bool powered_down;
> const struct rk_gmac_ops *ops;
>
> bool clk_enabled;
> @@ -529,9 +530,8 @@ static struct rk_priv_data *rk_gmac_setup(struct
> platform_device *pdev, return bsp_priv;
> }
>
> -static int rk_gmac_init(struct platform_device *pdev, void *priv)
> +static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
> {
> - struct rk_priv_data *bsp_priv = priv;
> int ret;
>
> ret = phy_power_on(bsp_priv, true);
> @@ -542,15 +542,52 @@ static int rk_gmac_init(struct platform_device
> *pdev, void *priv) if (ret)
> return ret;
>
> + bsp_priv->powered_down = true;
> +
> return 0;
> }
>
> -static void rk_gmac_exit(struct platform_device *pdev, void *priv)
> +static void rk_gmac_powerdown(struct rk_priv_data *gmac)
> {
> - struct rk_priv_data *gmac = priv;
> -
> phy_power_on(gmac, false);
> gmac_clk_enable(gmac, false);
> + gmac->powered_down = true;
naming it gmac->suspended and doing all accesses in the suspend/resume
callback might provide a nicer way? Now the check is in resume while the
powerdown callback is setting it.
> +}
> +
> +static int rk_gmac_init(struct platform_device *pdev, void *priv)
> +{
> + struct rk_priv_data *bsp_priv = priv;
> +
> + return rk_gmac_powerup(bsp_priv);
> +}
> +
> +static void rk_gmac_exit(struct platform_device *pdev, void *priv)
> +{
> + struct rk_priv_data *bsp_priv = priv;
> +
> + rk_gmac_powerdown(bsp_priv);
> +}
> +
> +static void rk_gmac_suspend(struct platform_device *pdev, void *priv)
> +{
> + struct rk_priv_data *bsp_priv = priv;
> +
> + /* Keep the PHY up if we use Wake-on-Lan. */
> + if (device_may_wakeup(&pdev->dev))
> + return;
> +
> + rk_gmac_powerdown(bsp_priv);
aka do
bsp_priv->suspended = true;
here
> +}
> +
> +static void rk_gmac_resume(struct platform_device *pdev, void *priv)
> +{
> + struct rk_priv_data *bsp_priv = priv;
> +
> + /* The PHY was up for Wake-on-Lan. */
> + if (!bsp_priv->powered_down)
> + return;
> +
> + rk_gmac_powerup(bsp_priv);
missing something like
bsp_priv->suspended = false;
Right now it looks like your bsp_priv->powered_down will always be true
after the first suspend with powerdown.
> }
>
> static void rk_fix_speed(void *priv, unsigned int speed)
> @@ -591,6 +628,8 @@ static int rk_gmac_probe(struct platform_device *pdev)
> plat_dat->init = rk_gmac_init;
> plat_dat->exit = rk_gmac_exit;
> plat_dat->fix_mac_speed = rk_fix_speed;
> + plat_dat->suspend = rk_gmac_suspend;
> + plat_dat->resume = rk_gmac_resume;
>
> plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
> if (IS_ERR(plat_dat->bsp_priv))
> --
> 2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-06-11 1:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 17:29 [PATCH] net: stmmac: dwmac-rk: keep PHY up for WoL Vincent Palatin
2016-06-06 20:45 ` Heiko Stübner
2016-06-06 21:00 ` Vincent Palatin
2016-06-07 7:23 ` Giuseppe CAVALLARO
2016-06-08 22:25 ` Vincent Palatin
2016-06-09 0:17 ` Andrew Lunn
2016-06-09 23:00 ` Vincent Palatin
2016-06-10 12:29 ` Giuseppe CAVALLARO
2016-06-11 1:00 ` net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-11 1:00 ` [PATCH 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks Vincent Palatin
2016-06-11 1:16 ` David Miller
2016-06-11 1:00 ` [PATCH 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin
2016-06-11 1:57 ` Heiko Stuebner [this message]
2016-06-15 16:03 ` Vincent Palatin
2016-06-15 18:32 ` [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-15 18:32 ` [PATCH v2 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks Vincent Palatin
2016-06-15 18:32 ` [PATCH v2 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin
2016-06-15 18:32 ` [PATCH v2 3/3] ARM: dts: rockchip: add interrupt for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-16 21:15 ` [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes " David Miller
2016-06-11 1:00 ` [PATCH 3/3] ARM: dts: rockchip: add interrupt " Vincent Palatin
2016-06-11 1:16 ` net: stmmac: dwmac-rk: fixes " David Miller
2016-06-13 6:46 ` Giuseppe CAVALLARO
2016-06-15 17:04 ` Vincent Palatin
2016-06-16 13:37 ` Giuseppe CAVALLARO
2016-06-16 14:51 ` Vincent Palatin
2016-06-17 5:38 ` Giuseppe CAVALLARO
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=2847430.O0lKQgdM0K@phil \
--to=heiko@sntech.de \
--cc=andrew@lunn.ch \
--cc=dianders@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=vpalatin@chromium.org \
--cc=zhengsq@rock-chips.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 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.