From patchwork Sat Nov 5 13:04:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Eastwood X-Patchwork-Id: 9413663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5ADC560724 for ; Sat, 5 Nov 2016 13:05:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB7928D97 for ; Sat, 5 Nov 2016 13:05:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4131928DC7; Sat, 5 Nov 2016 13:05:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5C592996F for ; Sat, 5 Nov 2016 13:05:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c30fC-0003Lt-Ci; Sat, 05 Nov 2016 13:05:38 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c30f8-0002SO-Ru for linux-rockchip@lists.infradead.org; Sat, 05 Nov 2016 13:05:35 +0000 Received: by mail-lf0-x243.google.com with SMTP id p100so6148219lfg.2 for ; Sat, 05 Nov 2016 06:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h8nH88wm0082k6wBVfuzj8p67y63Vbn1xlXaujnEx8k=; b=XJ6OQx/T108kklj7pFwOBaqG/E/BsMdKmvLSW2aYmTXL/EV9kYoxBI5d7+r2H2+qvh /aBVWH1bkJayu4qInwN3LwFVJWvA7Y5eZEsmp6eobLhzzGpblorkchp2WFSyJOH6i7xZ Fy88GlztNZN3NrFgPImK1rsBtvm/GQtyLBODTYuOKcy2I/381V27I1DiPi8wVTJs9mtJ VTCa8UTLQ3N403BboF/fLXzP8DTPxiEZVpLxfwEKvRApaSFnas4zw5TzMH8XykGs5eex unfZkyzfCmJxYGamzbtIsH9iDfDctT4jt+4+mIrmwQRYEI+T6FyVu4teEdUTb8QvUtIV hvHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h8nH88wm0082k6wBVfuzj8p67y63Vbn1xlXaujnEx8k=; b=g80C6z0F/FM7Z6T4FiVo7gVxXn37Fglt7IRHsEo1w8Ut8tK1u2zl9IHHxubpkny9JS qZltBN39qvskhIDhNJOD527rCvcpZKUevarC3RgVaaD7WxAWqvRK3JxmvRY1KBaQeWDR 3z9rUHn+ZH/nv3GqfwaV/2i+sZgxKnYhprARttP3agO3+D/h3W2BTo18Y0oDEq7Q3rMT DRYv6zEoIaYVhNDVr/F9QuhZCo8ZsK1iE74Ce+0b+xaV3b3bbIUe6Y1XUy6Wj7u7cjvN PMkM4cxTvRkt8Y95P7DOkYEILDB86O5nlCSLB6H5fOi3/q79ARvS0InrBNPmvKsCPOyo Kxyg== X-Gm-Message-State: ABUngvebIWul1PBicIdgxSIkjKI0KjJIMZbEU4jbKJjkx74zuIWpAyMrwRq0JvWGo3f5FA== X-Received: by 10.25.162.204 with SMTP id l195mr12605540lfe.42.1478351112568; Sat, 05 Nov 2016 06:05:12 -0700 (PDT) Received: from archthink.lan (244.89-11-254.nextgentel.com. [89.11.254.244]) by smtp.gmail.com with ESMTPSA id p3sm3221994lfe.1.2016.11.05.06.05.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Nov 2016 06:05:11 -0700 (PDT) From: Joachim Eastwood To: davem@davemloft.net Subject: [PATCH net-next 1/4] stmmac: dwmac-rk: turn resume/suspend into standard PM callbacks Date: Sat, 5 Nov 2016 14:04:49 +0100 Message-Id: <20161105130452.24226-2-manabian@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161105130452.24226-1-manabian@gmail.com> References: <20161105130452.24226-1-manabian@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161105_060535_166130_0E3E31B8 X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vpalatin@chromium.org, heiko@sntech.de, netdev@vger.kernel.org, Joachim Eastwood , linux-rockchip@lists.infradead.org, peppe.cavallaro@st.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use standard PM resume/suspend callbacks instead of the hooks in stmmac_platform. This gives the driver more control and flexibility when implementing PM functionality. The hooks in stmmac_platform also doesn't buy us anything extra. Signed-off-by: Joachim Eastwood --- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 59 ++++++++++++++------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 3740a44..d91acd5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -915,30 +915,6 @@ static void rk_gmac_exit(struct platform_device *pdev, void *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); - bsp_priv->suspended = true; -} - -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->suspended) - return; - - rk_gmac_powerup(bsp_priv); - bsp_priv->suspended = false; -} - static void rk_fix_speed(void *priv, unsigned int speed) { struct rk_priv_data *bsp_priv = priv; @@ -977,8 +953,6 @@ 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)) @@ -991,6 +965,37 @@ static int rk_gmac_probe(struct platform_device *pdev) return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } +#ifdef CONFIG_PM_SLEEP +static int rk_gmac_suspend(struct device *dev) +{ + struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev); + int ret = stmmac_suspend(dev); + + /* Keep the PHY up if we use Wake-on-Lan. */ + if (!device_may_wakeup(dev)) { + rk_gmac_powerdown(bsp_priv); + bsp_priv->suspended = true; + } + + return ret; +} + +static int rk_gmac_resume(struct device *dev) +{ + struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev); + + /* The PHY was up for Wake-on-Lan. */ + if (bsp_priv->suspended) { + rk_gmac_powerup(bsp_priv); + bsp_priv->suspended = false; + } + + return stmmac_resume(dev); +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(rk_gmac_pm_ops, rk_gmac_suspend, rk_gmac_resume); + static const struct of_device_id rk_gmac_dwmac_match[] = { { .compatible = "rockchip,rk3228-gmac", .data = &rk3228_ops }, { .compatible = "rockchip,rk3288-gmac", .data = &rk3288_ops }, @@ -1006,7 +1011,7 @@ static struct platform_driver rk_gmac_dwmac_driver = { .remove = stmmac_pltfr_remove, .driver = { .name = "rk_gmac-dwmac", - .pm = &stmmac_pltfr_pm_ops, + .pm = &rk_gmac_pm_ops, .of_match_table = rk_gmac_dwmac_match, }, };