Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8841242ybi; Thu, 6 Jun 2019 21:49:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3Ofc5NcGAHjaAb0puUrkIh11tf/s5HtCEOpToz98y+0JcMCLPkM9QAIdtD/QUSN0kLNEy X-Received: by 2002:a65:5344:: with SMTP id w4mr1138322pgr.8.1559882971548; Thu, 06 Jun 2019 21:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559882971; cv=none; d=google.com; s=arc-20160816; b=lMLxt2Xc7Rs3vxWhvgnDPbNTlLrRHlODq7o9CjlKtZ7DCnpaBOflPz+Nj+vRLMNDqr s/XjzdIRH8lG4o56RC0gLfAoTNBvLtDfVZmVUknaxuLYy0pSC2KprH5F3rI9vx3wGHEZ H6iEUov0FVPHuRRqnexH2TeY1fow3lSx5DJs0yTNqVbb6xr+FQxWJS8a5jzh8qKY8SXB 8d3/aDhg853P1am0a+qMB2yNI2N8WMsd7BagwvV0Zmpfd9XFikWoYRTNrrryuWEblasU FaAiwrhKTGpVBFhH4fBxAIqEg1frvARAchPcFlNCMdHQmKKXGTj2mCDZR0IuA3AMsjbt K64w== 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=Q0v+BcQmulHNucpxyA52yB5gSwLum7NLCDQmJ1Ymhrs=; b=qIBvSMV0TfF5TvAnUuIcfvWLZ7UAbXKj8Lx9ETm9KB7nqaiUHyumyqY0C02JJb72iF K0xLtrQ0aqsMRNi9vw46OmPE3hbRXn7fX3jEVZPkUHMv2EI9VKMDjIHe1/cBhaD3w0ld HzbJHbbFzHHdcn1w2cXkm7GvzI1V4s+E7CCpC2QvQC6deghHHjlYPEQGxPh2h7RZuCaj jGz3Z8feUzNFxMLCRH3RviMB/P+vP7WIkj10+OdQx23V53EfSPe8aLBnN9E5sklKqYdU uer7vuvIHLf1LtF3LKFyXuhxt02wZEK9XEWpzo5wnbofvwrrr/+PUpydDAuDpa79TKIS 2L/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LTS9Fg43; 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 d11si858546plr.323.2019.06.06.21.49.15; Thu, 06 Jun 2019 21:49:31 -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=LTS9Fg43; 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 S1726934AbfFGErS (ORCPT + 99 others); Fri, 7 Jun 2019 00:47:18 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46788 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbfFGEqp (ORCPT ); Fri, 7 Jun 2019 00:46:45 -0400 Received: by mail-pf1-f195.google.com with SMTP id 81so440698pfy.13 for ; Thu, 06 Jun 2019 21:46:45 -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=Q0v+BcQmulHNucpxyA52yB5gSwLum7NLCDQmJ1Ymhrs=; b=LTS9Fg434BEKRayzjptrBJ29XhWEJGNMFsVAg3qpTKOB5bGAqjMjz7t/7CvdCFb+Mi uS8wTDThTjnehndfcu/GX8U7JWEoa16OmKqPtHJFvevcQAbDJTu2+n1PbVB55z48LNsP enwQ6MpJs7JgrRRPohn1lMpTR0BNRZj3BV7GhpFe0mR/QEDR5EZrNLdzBe+7PVBv0pys Kih2pu+r5vVOfG6Dln7BqXqXDrAbmBiavviREDBwiIkVrIdFIwzNa3Wp2Jfsn4QWlbX9 UvD81VKrFp/qQkNSeJzFIaAnLZSmsYgmiC94ewD4+tw5VG+FlTbXeacp65A5lqf279HR 1XSA== 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=Q0v+BcQmulHNucpxyA52yB5gSwLum7NLCDQmJ1Ymhrs=; b=l3UD30Mpsz9ILT5WNpElNbwSOqK7fKFUejqy/sU499XxS7SLADM7dAMRf+RCq8pbUp MjQP59JH43eKfhKbkIPkpAvVotBv9KWouCccC7cv/rCHTj52Jyz/Y2LS1hqDl9Wb8J3M RJGAeBGnuSYI9Ij/wVA71qyCGBHAWpPUxdMmXcw5u/8O4hNmqfNS9knT+IGLpP0qqAji NJMOP/avhOYn11X2CCXCnnlI1aER6TbxCa6y2IlWyScpbnmbhby/BQN4ckHJIAkNCRNA 0Vb0W3FOpwiClh2D4wNwejnOF9yELItRP+msGjp6rlb7X0P4rosysxjuptgrLPgl1DDY luwQ== X-Gm-Message-State: APjAAAVsJQoBdwdVbzkuP2ECE6VIcSbIkSxCsl99lKYgViZvEMBVMdp2 ElC23c/MjwPdsqhEXzpucCM= X-Received: by 2002:a63:5009:: with SMTP id e9mr1102316pgb.396.1559882804937; Thu, 06 Jun 2019 21:46:44 -0700 (PDT) Received: from localhost.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id o13sm919516pfh.23.2019.06.06.21.46.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 06 Jun 2019 21:46:44 -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 , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v4 12/15] drm/bridge: tc358767: Introduce tc_pllupdate_pllen() Date: Thu, 6 Jun 2019 21:45:47 -0700 Message-Id: <20190607044550.13361-13-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607044550.13361-1-andrew.smirnov@gmail.com> References: <20190607044550.13361-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: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index ac55b59249e3..c994c72eb330 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -443,10 +443,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) @@ -546,13 +554,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) @@ -626,15 +628,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) { @@ -914,15 +914,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.21.0