From patchwork Wed Mar 15 08:42:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9625057 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 273266048C for ; Wed, 15 Mar 2017 08:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D34623F88 for ; Wed, 15 Mar 2017 08:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 121F328604; Wed, 15 Mar 2017 08:43:38 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no 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 CF61C23F88 for ; Wed, 15 Mar 2017 08:43:37 +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:References: In-Reply-To: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:List-Owner; bh=kuPqbWDTMlwgoyFqq+PRyl0USQGl0y+uo3AId4HG1do=; b=acloX9hkRL5bXAqwpjbHHXKI3R pu5bDNpK05onV7i0Yp8RtR8LKAHjyphIuu8I950ch4Vyb162Jc/4++KoMeSNLTu9veDe0EGxAURjb VYnw4SbuaBFmchAVKbhJVog/dXY/of9IS1E+bBp42nvZThYmuqsA6AA0N4qqbwaPduGxo398gPETW uqYbcbTjVvyNnVy2wklXRoW9hwaE7Hj9C6PC6MydFzGFz+QlTg/xAzBKQDc4Os6u51xzSRG/wM5rm X0RbWCGPoi12NUfw7rgE3NakiuTy10NP3lMv+jIZ1mnZZaYSWBdWS4zillPjDGfZHLxK5ELGmFEws r2CapgOw==; 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 1co4Wu-0002wl-Jj; Wed, 15 Mar 2017 08:43:36 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1co4WO-0002Ki-AQ; Wed, 15 Mar 2017 08:43:06 +0000 Received: by mail-pg0-f66.google.com with SMTP id y17so1545291pgh.0; Wed, 15 Mar 2017 01:42:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lSQNQyRepFfvfZZveSvWS8nQ+0UWoNg14xxSGOUFBn8=; b=Nzfk8tx7PRYlKHKE5hlGf/EAXVxQwkktKxQ+0duJUKWWE9Bd4FUJdeVMEH2eN058um fP+c84vqduuMt2tlqZkWQLMxB8ZOZx7ByPN2lRXkPTXIY2T1F069b0tIyOxhtrqsW1/T wrf2JVt+mANpINgVl3mAXzTThYyfgHpwX4Lgduw0TSMiGaP4pcHhZLfq9QbayrQvQ9sT VhbpTtpNU5W+/qawIsVZG9974SEA2FpRLWHk93GhfulKT/Cll0CBYPXK3VQA11tNQ6QN kO/uPN9z3xMa5TwvVLkNVJFrr3Gt1wxFC0jtdYiTmIHYSm2KLlFhTqzd45vtuhk8ITdf UckA== X-Gm-Message-State: AFeK/H2LU0IHBrFZZxdUzmX8ClFGueFmyRjV4SK7xNPcaKh2hvbqHuMJFK3jiATFSvbuSg== X-Received: by 10.98.57.23 with SMTP id g23mr2436223pfa.32.1489567363524; Wed, 15 Mar 2017 01:42:43 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id u80sm2676171pgb.32.2017.03.15.01.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Mar 2017 01:42:43 -0700 (PDT) From: Chris Zhong To: linux-rockchip@lists.infradead.org Subject: [PATCH 2/3] drm/rockchip/dsi: enable the grf clk before writing grf registers Date: Wed, 15 Mar 2017 16:42:31 +0800 Message-Id: <1489567352-3333-2-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1489567352-3333-1-git-send-email-zyw@rock-chips.com> References: <1489567352-3333-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170315_014304_481300_BCC21219 X-CRM114-Status: GOOD ( 11.76 ) 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 Stuebner , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Chris Zhong , linux-arm-kernel@lists.infradead.org, Mark Yao 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 For RK3399, the grf clk should be enabled before writing grf registers, otherwise the register value can not be changed. Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index f84f9ae..d8f24f2 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -291,6 +291,7 @@ struct dw_mipi_dsi { struct regmap *grf_regmap; void __iomem *base; + struct clk *grf_clk; struct clk *pllref_clk; struct clk *pclk; struct clk *phy_cfg_clk; @@ -979,6 +980,16 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) dw_mipi_dsi_dphy_interface_config(dsi); dw_mipi_dsi_clear_err(dsi); + /* + * For the RK3399, the clk of grf must be enabled before writing grf + * register. + */ + ret = clk_prepare_enable(dsi->grf_clk); + if (ret) { + dev_err(dsi->dev, "Failed to enable grf_clk\n"); + return; + } + if (pdata->grf_dsi0_mode_reg) regmap_write(dsi->grf_regmap, pdata->grf_dsi0_mode_reg, pdata->grf_dsi0_mode); @@ -1003,6 +1014,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) regmap_write(dsi->grf_regmap, pdata->grf_switch_reg, val); dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG"); dsi->dpms_mode = DRM_MODE_DPMS_ON; + + clk_disable_unprepare(dsi->grf_clk); } static int @@ -1238,6 +1251,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, dev_dbg(dev, "have not phy_cfg_clk\n"); } + dsi->grf_clk = devm_clk_get(dev, "grf"); + if (IS_ERR(dsi->grf_clk)) { + ret = PTR_ERR(dsi->grf_clk); + if (ret != -ENOENT) { + dev_err(dev, "Unable to get grf_clk: %d\n", ret); + return ret; + } + dsi->grf_clk = NULL; + dev_dbg(dev, "have not grf_clk\n"); + } + ret = clk_prepare_enable(dsi->pllref_clk); if (ret) { dev_err(dev, "%s: Failed to enable pllref_clk\n", __func__);