From patchwork Sun May 7 14:37:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ayaka X-Patchwork-Id: 9715273 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 77A2760380 for ; Sun, 7 May 2017 14:38:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57BD9205D1 for ; Sun, 7 May 2017 14:38:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A9DF206E2; Sun, 7 May 2017 14:38:08 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9808B205D1 for ; Sun, 7 May 2017 14:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=IH8irt/wWaRJQmYFwfKo6p+rRIGQ9afVLQ97+dZTTgU=; b=ODt kMC9xS++El0eEQFQnj6WV38B5RHoVyeFcX1MYyZejuE4ytgN1EE90tpXXklB64vsU7hRTxWtj5hB7 j6oJFi6doXly1KwHQSlWQCb6xngubADCNj0mNblCGvcEg1D8pB1S0iqrjRC+tzfuWxPIMhyLbhhYH /c4zRhPYGc+fguPDSr4acC26of16kU1/2qvNAc1VlkmT2PsEo1e34MC9MkHNtPK+quBxB6v1l9ZXC KHgemAuIVIvZiCtaLy1RlBdmi8qB8pXmCkUlK7YVjK38kG6/CmryWYn13Ii5QpEk6ncVABRPiTeXb WRVbv3VBV+GSJidGfhpl9RDiZV1T+PQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d7NK0-0007mZ-Ne; Sun, 07 May 2017 14:38:04 +0000 Received: from kozue.soulik.info ([2001:19f0:7000:8404:5054:ff:fe75:428f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d7NJx-0007kZ-1G; Sun, 07 May 2017 14:38:02 +0000 Received: from misaki.sumomo.pri (unknown [IPv6:2001:470:b30d:2:3fe5:5e2:ef97:4abb]) by kozue.soulik.info (Postfix) with ESMTPA id E7AF01020E6; Sun, 7 May 2017 23:38:13 +0900 (JST) From: Randy Li To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/rockchip: analogix_dp: add supports for regulators in edp IP Date: Sun, 7 May 2017 22:37:33 +0800 Message-Id: <20170507143733.11594-1-ayaka@soulik.info> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170507_073801_308756_848F0476 X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, airlied@linux.ie, Randy Li , Randy Li , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com 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 I found if eDP_AVDD_1V0 and eDP_AVDD_1V8 are not been power at RK3288, once trying to enable the pclk clock, the kernel would dead. This patch would try to enable them first. The eDP_AVDD_1V8 is used for eDP phy, and the eDP_AVDD_1V0 are used both for eDP phy and controller. Change-Id: I4e8a34609d5b292d7da77385ff15bebbf258090c Signed-off-by: Randy Li Signed-off-by: Randy Li --- .../display/rockchip/analogix_dp-rockchip.txt | 4 ++ drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 52 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt b/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt index 47665a1..0dbbfb3 100644 --- a/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt +++ b/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt @@ -34,6 +34,10 @@ Optional property for different chips: - clock-names: from common clock binding: Required elements: "grf" +- vcc-supply: Regulator for eDP_AVDD_1V0. + +- vccio-supply: Regulator for eDP_AVDD_1V8. + For the below properties, please refer to Analogix DP binding document: * Documentation/devicetree/bindings/display/bridge/analogix_dp.txt - phys (required) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index d8fa7a9..2dad625 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,8 @@ struct rockchip_dp_device { struct clk *grfclk; struct regmap *grf; struct reset_control *rst; + struct regulator *vcc_supply; + struct regulator *vccio_supply; struct work_struct psr_work; spinlock_t psr_lock; @@ -146,6 +149,24 @@ static int rockchip_dp_poweron(struct analogix_dp_plat_data *plat_data) cancel_work_sync(&dp->psr_work); + if (!IS_ERR(dp->vcc_supply)) { + ret = regulator_enable(dp->vcc_supply); + if (ret) { + dev_err(dp->dev, + "failed to enable vcc regulator: %d\n", ret); + return ret; + } + } + + if (!IS_ERR(dp->vccio_supply)) { + ret = regulator_enable(dp->vccio_supply); + if (ret) { + dev_err(dp->dev, + "failed to enable vccio regulator: %d\n", ret); + return ret; + } + } + ret = clk_prepare_enable(dp->pclk); if (ret < 0) { dev_err(dp->dev, "failed to enable pclk %d\n", ret); @@ -168,6 +189,11 @@ static int rockchip_dp_powerdown(struct analogix_dp_plat_data *plat_data) clk_disable_unprepare(dp->pclk); + if (!IS_ERR(dp->vccio_supply)) + regulator_disable(dp->vccio_supply); + if (!IS_ERR(dp->vcc_supply)) + regulator_disable(dp->vcc_supply); + return 0; } @@ -323,6 +349,32 @@ static int rockchip_dp_init(struct rockchip_dp_device *dp) return PTR_ERR(dp->rst); } + dp->vcc_supply = devm_regulator_get_optional(dev, "vcc"); + dp->vccio_supply = devm_regulator_get_optional(dev, "vccio"); + + if (IS_ERR(dp->vcc_supply)) { + dev_err(dev, "failed to get vcc regulator: %ld\n", + PTR_ERR(dp->vcc_supply)); + } else { + ret = regulator_enable(dp->vcc_supply); + if (ret) { + dev_err(dev, + "failed to enable vcc regulator: %d\n", ret); + return ret; + } + } + if (IS_ERR(dp->vccio_supply)) { + dev_err(dev, "failed to get vccio regulator: %ld\n", + PTR_ERR(dp->vccio_supply)); + } else { + ret = regulator_enable(dp->vccio_supply); + if (ret) { + dev_err(dev, + "failed to enable vccio regulator: %d\n", ret); + return ret; + } + } + ret = clk_prepare_enable(dp->pclk); if (ret < 0) { dev_err(dp->dev, "failed to enable pclk %d\n", ret);