From patchwork Wed Sep 7 18:17:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9319765 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 CA6A060752 for ; Wed, 7 Sep 2016 18:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE3E129409 for ; Wed, 7 Sep 2016 18:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A26932940E; Wed, 7 Sep 2016 18:19:45 +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=-1.8 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 3E76229409 for ; Wed, 7 Sep 2016 18:19:45 +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 1bhhQa-00005X-Im; Wed, 07 Sep 2016 18:18:28 +0000 Received: from mail-pa0-f66.google.com ([209.85.220.66]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhhQ9-0008Jb-6h; Wed, 07 Sep 2016 18:18:03 +0000 Received: by mail-pa0-f66.google.com with SMTP id h5so1241749pao.0; Wed, 07 Sep 2016 11:17:30 -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=6eHziABeqC6sqsaWAKc2S1KH30Jp/7GGcgIFO5zsc44=; b=ClpFm4AUeuJW5gGfp6+PVepKDXtBFwqOiTiXbMf64zkDUKk4z6WUEXFz8jLzS9QBZ5 BMPu4QVOq15cHoS3F7EEeTjdntvBWcBSyC9gLRV23ZhbQPcrBm7yEwCc58CFQEi9I9PV pe+jPj76x62FziYT1FDqckDEyaVc49Fah0p6Gh6KJZtZ1pABEBusNBiWLgSU03Ov6PmU iFi0y53SBOHFQ26PWedCC4Lela1JgivKyfBwV1z7IaMgh/ppv1YAJ9fojnHLfXgabNR+ Hdyp1SP7ycW6xO0C6jR3vOZk8quHE0dovOb42vP2DTj3DSLa75a1l9NEFbY1ZoTP28Jg 8jNg== X-Gm-Message-State: AE9vXwN1VwyolMa0bJ2tLE0PznRYIM6hX6C7eQAKstdqvIiX9BQB8Q5mar+c89+hckKLOA== X-Received: by 10.66.16.97 with SMTP id f1mr84248773pad.39.1473272250162; Wed, 07 Sep 2016 11:17:30 -0700 (PDT) Received: from user5-HP-Z620-Workstation.corp.google.com ([172.22.52.170]) by smtp.gmail.com with ESMTPSA id y6sm50738262pav.1.2016.09.07.11.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 11:17:28 -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] phy: rockchip-typec: add pm runtime support Date: Wed, 7 Sep 2016 11:17:25 -0700 Message-Id: <1473272245-28841-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_111801_330998_1EA94939 X-CRM114-Status: GOOD ( 11.22 ) 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 --- drivers/phy/phy-rockchip-typec.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/phy/phy-rockchip-typec.c b/drivers/phy/phy-rockchip-typec.c index fb58a27..e1a07aa 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); @@ -602,6 +608,7 @@ static int tcphy_phy_init(struct rockchip_typec_phy *tcphy, u8 mode) err_wait_pma: 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 +617,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 +995,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 +1016,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,