From patchwork Wed Sep 7 23:06:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9320211 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 C4D5A607D3 for ; Wed, 7 Sep 2016 23:08:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD4D629419 for ; Wed, 7 Sep 2016 23:08:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0E832943A; Wed, 7 Sep 2016 23:08:20 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable 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 4908029419 for ; Wed, 7 Sep 2016 23:08:20 +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 1bhlvh-0005Cy-7z; Wed, 07 Sep 2016 23:06:53 +0000 Received: from mail-pa0-f67.google.com ([209.85.220.67]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhlva-00058i-1m; Wed, 07 Sep 2016 23:06:47 +0000 Received: by mail-pa0-f67.google.com with SMTP id ez1so1492984pab.3; Wed, 07 Sep 2016 16:06:25 -0700 (PDT) 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; bh=ItbPWXTiw+CeztCMz57c3KPyZONLuxEF9XCM1d9q2Go=; b=huPzIApmXzCUBABUngRnYX/nit9KiaX5TxYGiu8EP+CkE4VudR3PqCJOVb1E11m2IB uO0AoDFrxwE3OiK+yhD0Lpy15CJI9FP7dPblMzYaETQBQBo6N62fJa8DkvIFCwz8P5vs dvBsgoFHcX535BgdbM4WCUe4lZ7+p+sh1u1m+EDyRJyB3iLE1jPpY/LR/TChAyzz6m+Y HU+qnTXNUNy9fmTCSH5p5+bGw3qHbfLmg952Uw6Ac9nQAZC0ULrvsG+aUSsrscWR/+RS UweuXLtiW2eUyYArzfhiQXybYrJR1inGUcwpiiovCBV1AXRG+uTziV/i4843xJaUR/gX yzvw== X-Gm-Message-State: AE9vXwO29K15U/UgGLBuA2LrXVO0JvKnheF+OPDUEy7ciDJBPkyDDntDK1si9RrLV0fNPg== X-Received: by 10.66.25.228 with SMTP id f4mr87839505pag.157.1473289584957; Wed, 07 Sep 2016 16:06:24 -0700 (PDT) Received: from user5-HP-Z620-Workstation.corp.google.com ([172.22.52.170]) by smtp.gmail.com with ESMTPSA id v89sm15594778pfa.53.2016.09.07.16.06.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 16:06:23 -0700 (PDT) From: Chris Zhong To: kishon@ti.com, groeck@chromium.org, wulf@rock-chips.com, briannorris@chromium.org, heiko@sntech.de, dianders@chromium.org, kever.yang@rock-chips.com Subject: [PATCH v2 1/2] phy: rockchip-typec: add pm runtime support Date: Wed, 7 Sep 2016 16:06:16 -0700 Message-Id: <1473289577-14101-1-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160907_160646_147543_D8CA9C11 X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Zhong , linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Adds pm_runtime support for rockchip Type-C, so that power domain is enabled only when there is a transaction going on to help save power. Signed-off-by: Chris Zhong --- Changes in v2: -- add pm_runtime_put_sync in err case drivers/phy/phy-rockchip-typec.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/phy/phy-rockchip-typec.c b/drivers/phy/phy-rockchip-typec.c index fb58a27..0b2f528 100644 --- a/drivers/phy/phy-rockchip-typec.c +++ b/drivers/phy/phy-rockchip-typec.c @@ -552,6 +552,12 @@ static int tcphy_phy_init(struct rockchip_typec_phy *tcphy, u8 mode) goto err_clk_core; } + ret = pm_runtime_get_sync(tcphy->dev); + if (ret < 0) { + dev_err(tcphy->dev, "cannot get pm runtime %d\n", ret); + goto err_clk_ref; + } + reset_control_deassert(tcphy->tcphy_rst); property_enable(tcphy, &cfg->typec_conn_dir, tcphy->flip); @@ -600,8 +606,10 @@ static int tcphy_phy_init(struct rockchip_typec_phy *tcphy, u8 mode) return 0; err_wait_pma: + pm_runtime_put_sync(tcphy->dev); reset_control_assert(tcphy->uphy_rst); reset_control_assert(tcphy->tcphy_rst); +err_clk_ref: clk_disable_unprepare(tcphy->clk_ref); err_clk_core: clk_disable_unprepare(tcphy->clk_core); @@ -610,6 +618,7 @@ err_clk_core: static void tcphy_phy_deinit(struct rockchip_typec_phy *tcphy) { + pm_runtime_put_sync(tcphy->dev); reset_control_assert(tcphy->tcphy_rst); reset_control_assert(tcphy->uphy_rst); reset_control_assert(tcphy->pipe_rst); @@ -987,6 +996,15 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev) return PTR_ERR(phy_provider); } + pm_runtime_enable(dev); + + return 0; +} + +static int rockchip_typec_phy_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + return 0; } @@ -999,6 +1017,7 @@ MODULE_DEVICE_TABLE(of, rockchip_typec_phy_dt_ids); static struct platform_driver rockchip_typec_phy_driver = { .probe = rockchip_typec_phy_probe, + .remove = rockchip_typec_phy_remove, .driver = { .name = "rockchip-typec-phy", .of_match_table = rockchip_typec_phy_dt_ids,