From patchwork Wed Jun 15 11:55:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 9178247 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 3CAC1604DB for ; Wed, 15 Jun 2016 11:58:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A3C627F48 for ; Wed, 15 Jun 2016 11:58:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F42A281F6; Wed, 15 Jun 2016 11:58:32 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7BB27F48 for ; Wed, 15 Jun 2016 11:58:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932869AbcFOL4j (ORCPT ); Wed, 15 Jun 2016 07:56:39 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:50004 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753563AbcFOL4e (ORCPT ); Wed, 15 Jun 2016 07:56:34 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5FBtx19009641; Wed, 15 Jun 2016 06:55:59 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5FBuQrS009003; Wed, 15 Jun 2016 06:56:26 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 15 Jun 2016 06:56:25 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5FBuOm5023951; Wed, 15 Jun 2016 06:56:25 -0500 From: Grygorii Strashko To: "David S. Miller" , , Sekhar Nori , Mugunthan V N CC: , , Ivan Khoronzhuk , Rob Herring , , Grygorii Strashko Subject: [PATCH 10/15] drivers: net: davinci_mdio: add pm runtime callbacks Date: Wed, 15 Jun 2016 14:55:58 +0300 Message-ID: <20160615115603.4897-11-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20160615115603.4897-1-grygorii.strashko@ti.com> References: <20160615115603.4897-1-grygorii.strashko@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add PM runtime .runtime_suspend()/.runtime_resume() callbacks and perform Davinci MDIO enabling/disabling from these callbacks. This allows to reuse pm_runtime_force_suspend/resume() APIs during System suspend and required for further implementation of PM runtime autosuspend. Signed-off-by: Grygorii Strashko --- drivers/net/ethernet/ti/davinci_mdio.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index b206fd3..13f5080 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -406,8 +406,8 @@ static int davinci_mdio_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int davinci_mdio_suspend(struct device *dev) +#ifdef CONFIG_PM +static int davinci_mdio_runtime_suspend(struct device *dev) { struct davinci_mdio_data *data = dev_get_drvdata(dev); u32 ctrl; @@ -418,6 +418,28 @@ static int davinci_mdio_suspend(struct device *dev) __raw_writel(ctrl, &data->regs->control); wait_for_idle(data); + return 0; +} + +static int davinci_mdio_runtime_resume(struct device *dev) +{ + struct davinci_mdio_data *data = dev_get_drvdata(dev); + + davinci_mdio_enable(data); + return 0; +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int davinci_mdio_suspend(struct device *dev) +{ + struct davinci_mdio_data *data = dev_get_drvdata(dev); + int ret = 0; + + ret = pm_runtime_force_suspend(dev); + if (ret < 0) + return ret; + /* Select sleep pin state */ pinctrl_pm_select_sleep_state(dev); @@ -431,14 +453,15 @@ static int davinci_mdio_resume(struct device *dev) /* Select default pin state */ pinctrl_pm_select_default_state(dev); - /* restart the scan state machine */ - davinci_mdio_enable(data); + pm_runtime_force_resume(dev); return 0; } #endif static const struct dev_pm_ops davinci_mdio_pm_ops = { + SET_RUNTIME_PM_OPS(davinci_mdio_runtime_suspend, + davinci_mdio_runtime_resume, NULL) SET_LATE_SYSTEM_SLEEP_PM_OPS(davinci_mdio_suspend, davinci_mdio_resume) };