Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp284342img; Thu, 21 Mar 2019 20:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqza2l0M3rSPoT2CkFFTuC7StIUOK6re3vaFLf1PgylXIIbBeGxjfJL6yWlhGdEg98S36slx X-Received: by 2002:a62:e08e:: with SMTP id d14mr7143195pfm.16.1553225444997; Thu, 21 Mar 2019 20:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553225444; cv=none; d=google.com; s=arc-20160816; b=n50lvO9LcvYH61yyBELmUA0yyxYhOVnwTKDN7fvpiGVTG9t67MwflMw5pXmU/py3KY UGWsvJcfx6K2agCmQhrUTiSBmldqtMHTPyE9Fyk5pMHJpVEqwB3j/POmVVh3Yj6A+Wz5 9DurvIEnxH3RmyO1gi5ezobMYgKKpNcn3B7WlpHGxVMnnvPbZLo9ZyR5rT+oJvufywkX flPY/qepigsCD4Ah3+xp/8Yh1I9T044C8i1u+l81mwZKNQ5Rhit5GVCMDx5t05/gGdJ6 HpLwPl8rZdH/gwUccwMfbaImNmlaYMAy0/kJ50f3Iim79CeThRj58El+Qs1PJcyANz15 8I2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xgrTJQtYJ1/aH4LpCAiSuAxdXzKMohH0iux2BQdEBug=; b=DuQC1GUx/j2cRnKnfbfTNOuBkn+CNgVcXAn9JIl2h1FF1ZBK8dpSuYqmB+0vTR/rg9 L6rDCmeK/AzHfFZL7bl8zRvPDHn1PUOX0ch3zNX+QtemKAKxirjdJ9SxvASXwueC4ZT8 KskffhkDz/isaLcJ/Lh1oMhDcBEMPG4GyLLcRtn1y39xv02lGr3kVwdcDn9sC2BwcclL GOCL6LKuG0Z1fdPyYBBx8bZxBDkQvOt6IO2rD4Rpz+lBxpfWMA9OGRTsLq8U7rtY18zY ZHL6/XFHHpvJhNy7Xdjcm607oSh7HDwe+p0vHzRs3l8wHDCl75LIKfGartKk/PY1r6aD lGXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i7yFMsfy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c141si5835147pfc.169.2019.03.21.20.30.27; Thu, 21 Mar 2019 20:30:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i7yFMsfy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727751AbfCVD3f (ORCPT + 99 others); Thu, 21 Mar 2019 23:29:35 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42495 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727739AbfCVD3c (ORCPT ); Thu, 21 Mar 2019 23:29:32 -0400 Received: by mail-pf1-f195.google.com with SMTP id r15so522384pfn.9 for ; Thu, 21 Mar 2019 20:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xgrTJQtYJ1/aH4LpCAiSuAxdXzKMohH0iux2BQdEBug=; b=i7yFMsfyCuMTnPdoR87/xpAEM2URtLQqTHeIYQzc3S2cuXZQG6EGXTZF44Tj2aMiPV Jy4DBPCzutSqX3OlTHqwH3BDqNMOZYL9tvqvXIRob/UJLbYaSUx6Kir9n+wHM8r0LFdC CcI+YQWI2fX1Gs2cKByWXfehZwD0XdYcwNtsQf6zcWTUFhi5n6U8Dgv8sFj7sCa6lFSu qAGA+mIVb2UtoOb8T0I8/REWtDPyS8s6EzWOGtjftDLsuKQlMM6NNFve+g034YW8e8VV zBs5Ec5XJbmEQiHJyM6Jlo8t9RJ4IT1i8xk3FpmWn9BUgZJyORMb1oCV51mW0Kr2KC5p fdaw== 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:mime-version:content-transfer-encoding; bh=xgrTJQtYJ1/aH4LpCAiSuAxdXzKMohH0iux2BQdEBug=; b=b13MksD4HD+52WOwe49fgs3Z2igrzvOoU9Oe+sxmpFoPvM1kkyFkjgVeS7lOc+tMi4 S8ZAXuRAR7gXW01nj4XDnAvbE/lWezhUrhCXvfBR23P8m8LDqv/NuLAPrYO2NLyJkNVT s586gPNBEyG8VoevrP/Y5S3kY9R+O1KhKdx/RbjRD23YY8JxPFtkxAsJFya0h4rZedwh duoH0opNFuIhLxuzZ1v1yr703gB8ypBfwPV7GTPSqR3wIEKzXeeBRrXvzevQfKf+F/bs lYyyLKDfl9wkdX3T1chwDxKTfuQs5TqLjj5AO/NVY5sEnTzvyARCwll4hcd2ceHh01pj HbQw== X-Gm-Message-State: APjAAAVLLM1nI2Di4+fDsNd41oOqwuyjFnnv+9On5ZnyC4zbG6bDTq/Z DZLfTUX5jvNsBR8h/39QDp0= X-Received: by 2002:a63:f544:: with SMTP id e4mr6773018pgk.145.1553225370827; Thu, 21 Mar 2019 20:29:30 -0700 (PDT) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id o76sm16154476pfa.156.2019.03.21.20.29.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 20:29:30 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Laurent Pinchart , Archit Taneja , Andrzej Hajda , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v2 12/15] drm/bridge: tc358767: Introduce tc_pllupdate_pllen() Date: Thu, 21 Mar 2019 20:28:58 -0700 Message-Id: <20190322032901.12045-13-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322032901.12045-1-andrew.smirnov@gmail.com> References: <20190322032901.12045-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tc_wait_pll_lock() is always called as a follow-up for updating PLLUPDATE and PLLEN bit of a given PLL control register. To simplify things, merge the two operation into a single helper function tc_pllupdate_pllen() and convert the rest of the code to use it. No functional change intended. Signed-off-by: Andrey Smirnov Reviewed-by: Laurent Pinchart Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Tomi Valkeinen Cc: Andrey Gusakov Cc: Philipp Zabel Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 976a9861e537..f66a1c4a2047 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -447,10 +447,18 @@ static u32 tc_srcctrl(struct tc_data *tc) return reg; } -static void tc_wait_pll_lock(struct tc_data *tc) +static int tc_pllupdate_pllen(struct tc_data *tc, unsigned int pllctrl) { + int ret; + + ret = regmap_write(tc->regmap, pllctrl, PLLUPDATE | PLLEN); + if (ret) + return ret; + /* Wait for PLL to lock: up to 2.09 ms, depending on refclk */ usleep_range(3000, 6000); + + return 0; } static int tc_pxl_pll_en(struct tc_data *tc, u32 refclk, u32 pixelclock) @@ -550,13 +558,7 @@ static int tc_pxl_pll_en(struct tc_data *tc, u32 refclk, u32 pixelclock) return ret; /* Force PLL parameter update and disable bypass */ - ret = regmap_write(tc->regmap, PXL_PLLCTRL, PLLUPDATE | PLLEN); - if (ret) - return ret; - - tc_wait_pll_lock(tc); - - return 0; + return tc_pllupdate_pllen(tc, PXL_PLLCTRL); } static int tc_pxl_pll_dis(struct tc_data *tc) @@ -615,7 +617,6 @@ static int tc_set_syspllparam(struct tc_data *tc) static int tc_aux_link_setup(struct tc_data *tc) { int ret; - u32 dp_phy_ctrl; u32 dp0_auxcfg1; /* Setup DP-PHY / PLL */ @@ -630,15 +631,13 @@ static int tc_aux_link_setup(struct tc_data *tc) * Initially PLLs are in bypass. Force PLL parameter update, * disable PLL bypass, enable PLL */ - ret = regmap_write(tc->regmap, DP0_PLLCTRL, PLLUPDATE | PLLEN); + ret = tc_pllupdate_pllen(tc, DP0_PLLCTRL); if (ret) goto err; - tc_wait_pll_lock(tc); - ret = regmap_write(tc->regmap, DP1_PLLCTRL, PLLUPDATE | PLLEN); + ret = tc_pllupdate_pllen(tc, DP1_PLLCTRL); if (ret) goto err; - tc_wait_pll_lock(tc); ret = tc_poll_timeout(tc, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, 1000); if (ret == -ETIMEDOUT) { @@ -823,6 +822,7 @@ static int tc_main_link_enable(struct tc_data *tc) { struct drm_dp_aux *aux = &tc->aux; struct device *dev = tc->dev; + u32 dp_phy_ctrl; u32 value; int ret; u8 tmp[8]; @@ -858,15 +858,13 @@ static int tc_main_link_enable(struct tc_data *tc) return ret; /* PLL setup */ - ret = regmap_write(tc->regmap, DP0_PLLCTRL, PLLUPDATE | PLLEN); + ret = tc_pllupdate_pllen(tc, DP0_PLLCTRL); if (ret) return ret; - tc_wait_pll_lock(tc); - ret = regmap_write(tc->regmap, DP1_PLLCTRL, PLLUPDATE | PLLEN); + ret = tc_pllupdate_pllen(tc, DP1_PLLCTRL); if (ret) return ret; - tc_wait_pll_lock(tc); /* Reset/Enable Main Links */ dp_phy_ctrl |= DP_PHY_RST | PHY_M1_RST | PHY_M0_RST; -- 2.20.1