Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6400815ybi; Wed, 5 Jun 2019 00:07:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw46TJYgwwmho4Rcmy8QhaH6+zRj8KSflpM6x3mFzpUOLDxhAs8ctP7uYmSQEZD7Lr2QovV X-Received: by 2002:a17:902:76c6:: with SMTP id j6mr16756400plt.263.1559718453838; Wed, 05 Jun 2019 00:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559718453; cv=none; d=google.com; s=arc-20160816; b=W3uwUvC47GRMwoGN7gOK+kIDfBeZtTW2/iguMm00JsccRE5eswJlZFK0huphlkrYVm 0Y/g94LGZuuaMFvmieEvKDiQZA0V4Vwnfc1RNdlZAPq/2I0c6w5zk6Bw1Oa5YG9Se7V6 AwCTUrd5AKggeLVV/AaCEIXK+uHvwzD42atjtcxjxSVQ79hgpSM4BCxUs787uXIBxF/K tZnT9DplmzGp+eIGhjHwOQlN2dTQ1nFLTHz7/7UAoo5rTXmhcpYwppbBAOtnebZ3UE1Z D+PZWgDeSi03jbOap2CHq7e6/qNd7A7cuPbT+ceku7PPfidZistAFiNGUukdXoqfO7yY /8GQ== 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=BFvuIRi7rsk2TFp/SSh+b+ezX83xyjP/0LBIMVGRR1U=; b=t7T5indZ+6A8ju1UE/FbJqXdqyo6y0iPVTqXD8K52E9/nF2BSH/mYOM+DF50lNU+PR WAdGomT3Bwf1FUr8lBDnF821SX+1L0rNUfhjy6gbdahgsoiAm/cSg2parVclYWreG5ql FRDrFhnKeLAI2J5XS3vqUNcXmhEkH0Fsuu42owLbLA9vq31QjRBy22ecQLBPJLW8Mh01 gNsf1Pt8qu9bScs/ylJwOr2RF+OJIUuQTZArHfsKJf8gYcAmKJWne2GwKuFNSSow+7tP mwWpLzkQNpq/hd6apVxGIo2qbwbJe9XRyNCT0jPvRBg0IZfMj9Q4wvIQ6kq6aP+AZLlc Mf/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Y8ygajd/"; 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 z76si25493257pgz.182.2019.06.05.00.07.16; Wed, 05 Jun 2019 00:07:33 -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="Y8ygajd/"; 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 S1726879AbfFEHFp (ORCPT + 99 others); Wed, 5 Jun 2019 03:05:45 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42846 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726836AbfFEHFm (ORCPT ); Wed, 5 Jun 2019 03:05:42 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so4080152pff.9 for ; Wed, 05 Jun 2019 00:05:42 -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=BFvuIRi7rsk2TFp/SSh+b+ezX83xyjP/0LBIMVGRR1U=; b=Y8ygajd/pjZ28xsj4PsaLG4FFFLwbaEUuRrDRgc4vDF7ppGFNWbPFagSK4DqAMuUu5 /J2cc4UsilVprscnxjgKd6fxkcYXAiPUiM56qskqgpo0/aSUZMKmK2EjkM7KVWMoeLot TZ7N8EoHd2L6MCi7KCXKnusi7HD+v+8JyjGlNjx4z9GiuL530XkqO9obPthSurPEBvMO fl5lhqy+ya6nwz/hAKr4ORU3NRIPUzf9L7f3k4CkPhqR7T4nKNZPr8JYG3Y+cdqEuwjg afR5FTISTBTeYhf/UtpUBCTyvseuCopW25sEeLcMON22zcbahZLzTyqTElCzxRG66v2h Lobw== 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=BFvuIRi7rsk2TFp/SSh+b+ezX83xyjP/0LBIMVGRR1U=; b=SwV+mCRMivXn/E7XUaQY0KgvL4bK6MOqDnqijGRGFKRXHqoSQW42ecgb+qp3q6d623 0G/lpaZ413pKgHntVg4VWSdtPxKBnW/LW26iA/0kgCMRVkiR0cezNT5Q66pPrLQK8SrI GZ4T76gpnGJ4Pt4hDCTuhnvYwPZCHwElBrJaBk/jDim2p2I/rT/pqqwWZiwB8H/t8pND N+9spNstQyHkdL9dgnte+xOI2nEpylKuvs2Rc0y/geS4EN0VMBNqt8u7p9V24zW2NLCW 2UiiofXG+PylgBrp9/3pk2jNuBOUP8CXZrGTdWcWldI5z5QPY5/TgM0VPODMtoTkCYRf qkRA== X-Gm-Message-State: APjAAAXPf2XAJgfC1anEc6wYLDJ3wjCNQx4a/TCxcyCJ81mnkBfLFuu4 SzE3rBdSwX2c2QLcQyGBFPY= X-Received: by 2002:a17:90a:b104:: with SMTP id z4mr20745515pjq.102.1559718341700; Wed, 05 Jun 2019 00:05:41 -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 d132sm6527348pfd.61.2019.06.05.00.05.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:05:40 -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 v3 12/15] drm/bridge: tc358767: Introduce tc_pllupdate_pllen() Date: Wed, 5 Jun 2019 00:05:04 -0700 Message-Id: <20190605070507.11417-13-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190605070507.11417-1-andrew.smirnov@gmail.com> References: <20190605070507.11417-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 c58714daa0a1..a04401cf2a92 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -463,10 +463,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) @@ -566,13 +574,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) @@ -645,15 +647,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) { @@ -933,15 +933,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