Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8840902ybi; Thu, 6 Jun 2019 21:48:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4M03V7BdKzQbJ3hIISydMrWe8kSyT0ynddVGuTZ+PPyLSp/GAaOKENXyR9gRfadEWYFhs X-Received: by 2002:a17:902:b682:: with SMTP id c2mr54532111pls.9.1559882938537; Thu, 06 Jun 2019 21:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559882938; cv=none; d=google.com; s=arc-20160816; b=JnkKXx0JbH4ExPKqlBKHffkmA6GNlxtiHEpcV/2sEBCNQ3j6hf4WvT3f6uIB7ucNiH M5d+ZagS/P/GQYkeCPnOkiPdccRRFKvqwHBJSwD7kGq4/DJXNDxrSoqLy5XuD4KbF3Ky 5g1+4LG9al22O06s8cLkFVLKdoB+ZqbqYeaYK5aV0HiZOuZOLVpAQLtSWCVySwZ+4L9p RzPm+ROAqprDbR01SWK5hA+RgUatLnELNm5ksT2+vRRx/NluHRDLK+1GV5vygBO1KrV0 L5SgWtijpT+9GvaBLIqfCyPZHVGzg18Oe8LnVZu1VBwq5UygyvmJ0Qw2GCTrGgAgOaNx icHQ== 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=0lMquvZFr8N9KwzJc1akq7l4rDT1SQxgVj99qRTol7M=; b=EzJBQuXfTH1fsh/97Wj4RIWfmQIMxfKyviRzBiMkwf4n6qX7CmsWSrYCCZPNJFDz2N rqTkK0iarf0rqS7hz3P9fsnbtDKwupyss7NNYbJJE/Bq4glFC4Q812pXxIL0adJ9Dk93 ai1bvsi+T0gq7s24ZTglYvQlAP6c6G1Jxx2goGJhOTzXI+8ME/Al9O69Kw4Dg2c0jx6U mI3yqaatXJ+zJej4fHGiKpSP5Z8PXJcGJoHN4HtI6H/aQhvyAH0Az07riaMU+oWBoEJa r4BWfIvva8cs8Zu8TLGqbaYWE6AlOPobX1aaRoBn/qkfdxJ/6DlaTN0v5SLEF73roeW0 l/wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NZecb40z; 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 s128si817047pfs.242.2019.06.06.21.48.30; Thu, 06 Jun 2019 21:48:58 -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=NZecb40z; 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 S1726747AbfFGEqv (ORCPT + 99 others); Fri, 7 Jun 2019 00:46:51 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45470 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfFGEqn (ORCPT ); Fri, 7 Jun 2019 00:46:43 -0400 Received: by mail-pg1-f194.google.com with SMTP id w34so464142pga.12 for ; Thu, 06 Jun 2019 21:46:43 -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=0lMquvZFr8N9KwzJc1akq7l4rDT1SQxgVj99qRTol7M=; b=NZecb40zvEyKE8KgAcakEzvjav3va4X9nd/LcYBLp/F6hfe7+GDHpyissyDVImwFeG T+oD81BcxDGo5GAMTdxrhQ919Hoa4G27tZF0LwPbdiWwsZgmPOoUtltUIXgONg4cVH8C vXrEvhxERTtIu9v+VDgmrnLRq0JJaVeZ+R0bgyKWW/BsGzqsD6SqlBSboUBMtLLiVtNi iwfYFYNHollYhvHniTOFr3faAKIwNyz9FPsAp9Eq0UF8MrDMQGNYEN2pvGJJyxDM6e2D FbZM8dsOWe/cBW7fmGetr9ItJMj7rBtjJtyrtKT1zuyfjtsEtaxYvN+RTyhX14oww6EL 2OeQ== 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=0lMquvZFr8N9KwzJc1akq7l4rDT1SQxgVj99qRTol7M=; b=NpSLGPWOVWjXD83eX4pAixCqdivZsr79Y8Kb2V8nf+hm2QJEOrJq6eTypAEh9MDvvl tQ62DfUDd6daDaB5cKHG+INNNlhIlGh5nr1+CbG3F4sOPrAcJzcd2p7DK9yEGYnhx26s pl4lPRZOXr6BiXW5x7NRFBX0eoBUHwwzron4GFJvfAuAI1sCOfC3UQ8lH7Ow6lJ3e+S4 vqIBuFd2LP/gR6/u4RBmylS1CwdUBvyn9YZiiVIpXRtXZYD5RuDdBWSycyrdYyO4jqQs KObbh3C36YPqATqzz4/8cn8rXiABfBCY6rolU6iQ/Dn4ny48IRgi6nVwdTtjd0pp0TN/ n6FQ== X-Gm-Message-State: APjAAAWEZuesayfqo/KGHoP12xU7Qp1yXPCJRgiW2fUqTrmVobrtE5Ko Ts66tPgnvCH1knB5sTRbe+s= X-Received: by 2002:a17:90a:8e86:: with SMTP id f6mr3396902pjo.66.1559882802943; Thu, 06 Jun 2019 21:46:42 -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.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 06 Jun 2019 21:46:42 -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 , Cory Tusar , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v4 11/15] drm/bridge: tc358767: Introduce tc_set_syspllparam() Date: Thu, 6 Jun 2019 21:45:46 -0700 Message-Id: <20190607044550.13361-12-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 Move common code converting clock rate to an appropriate constant and configuring SYS_PLLPARAM register into a separate routine 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: Cory Tusar Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 46 +++++++++++-------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 4bb9b15e1324..ac55b59249e3 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -581,35 +581,40 @@ static int tc_stream_clock_calc(struct tc_data *tc) return regmap_write(tc->regmap, DP0_VIDMNGEN1, 32768); } -static int tc_aux_link_setup(struct tc_data *tc) +static int tc_set_syspllparam(struct tc_data *tc) { unsigned long rate; - u32 dp0_auxcfg1; - u32 value; - int ret; + u32 pllparam = SYSCLK_SEL_LSCLK | LSCLK_DIV_2; rate = clk_get_rate(tc->refclk); switch (rate) { case 38400000: - value = REF_FREQ_38M4; + pllparam |= REF_FREQ_38M4; break; case 26000000: - value = REF_FREQ_26M; + pllparam |= REF_FREQ_26M; break; case 19200000: - value = REF_FREQ_19M2; + pllparam |= REF_FREQ_19M2; break; case 13000000: - value = REF_FREQ_13M; + pllparam |= REF_FREQ_13M; break; default: dev_err(tc->dev, "Invalid refclk rate: %lu Hz\n", rate); return -EINVAL; } + return regmap_write(tc->regmap, SYS_PLLPARAM, pllparam); +} + +static int tc_aux_link_setup(struct tc_data *tc) +{ + int ret; + u32 dp0_auxcfg1; + /* Setup DP-PHY / PLL */ - value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2; - ret = regmap_write(tc->regmap, SYS_PLLPARAM, value); + ret = tc_set_syspllparam(tc); if (ret) goto err; @@ -868,7 +873,6 @@ static int tc_main_link_enable(struct tc_data *tc) { struct drm_dp_aux *aux = &tc->aux; struct device *dev = tc->dev; - unsigned int rate; u32 dp_phy_ctrl; u32 value; int ret; @@ -896,25 +900,7 @@ static int tc_main_link_enable(struct tc_data *tc) if (ret) return ret; - rate = clk_get_rate(tc->refclk); - switch (rate) { - case 38400000: - value = REF_FREQ_38M4; - break; - case 26000000: - value = REF_FREQ_26M; - break; - case 19200000: - value = REF_FREQ_19M2; - break; - case 13000000: - value = REF_FREQ_13M; - break; - default: - return -EINVAL; - } - value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2; - ret = regmap_write(tc->regmap, SYS_PLLPARAM, value); + ret = tc_set_syspllparam(tc); if (ret) return ret; -- 2.21.0