Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6400715ybi; Wed, 5 Jun 2019 00:07:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZJ/ove87V9YcEIecq/3ZAfuirKLtQJJS5Do0XUTt92AQqNxb88RB5sWyM1ytfO6dPtZ3X X-Received: by 2002:a17:902:b191:: with SMTP id s17mr3141426plr.238.1559718448689; Wed, 05 Jun 2019 00:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559718448; cv=none; d=google.com; s=arc-20160816; b=b0EqZcOCmIgZ5Xcil/+6CSk04e5MgEnV2jP5WAYMgYMuWz02OwCrTb5cFUz5x9jnOC p/ZvgSh4GGHv3caCUAbZmmGQ8eItvEny+oGT92L3SK2/9IDT79ucYtnrmt1AX3p8kVkU nSQ6VKEAnfKG3Cx1y84RP3hp4oMMAH1SWR2e0dUpehIU+uy+xRcvQJXtRy/zNFM7tKFy PkQ88TWTpJxk78AAwGB5NFzExeNdGmO1E2kMeFTXBm3I6mLc+MpR3hgwi7tDUv6zKH67 PJhumPRHaeJkYR82AyIi18sw9OnqJYct0gvRKkr68lTp4KxA9ovf4RAAnuev2s+c9D7j aQ5w== 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=wEdoucIRvOwXz8lKtgT8K+SiuGv6C9zcqCSBrAPMFTE=; b=Pj8Ab9vzrg07s6PzIEIb8HT+Ja3xqjd9qTlA/wUor4jEzsjMxQ3Xeaxqw5OQVWrpcq wguNTIWhnHNakd4OpSoM5u0RShGMp6dlrj1fM+uiHcLnVMVwL51gQhnwr+8YNWDEP4Oq RxvAqPG2kFaJAaKxaAQyVK4OZokNXfS2HncQ7+fzIOXBh0i38e02TmUg7MAEvEnw4xMb Iv7W9MFl+CZTz8jzJLxoHepMaC2OAPYc8rNxr1OecDKOSbTUL9vzdZl31/n0/NnpBe2o 6PdlS+anJN5YCstXonseQZ6cLyl3jVn1R5k3h+F2Ha9PLtK73E0e4MrNc8MEnITFQkz1 ImRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I5dqH+Tz; 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 c12si25705409pgq.533.2019.06.05.00.07.11; Wed, 05 Jun 2019 00:07:28 -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=I5dqH+Tz; 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 S1726861AbfFEHFn (ORCPT + 99 others); Wed, 5 Jun 2019 03:05:43 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37302 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfFEHFk (ORCPT ); Wed, 5 Jun 2019 03:05:40 -0400 Received: by mail-pf1-f194.google.com with SMTP id a23so14309226pff.4 for ; Wed, 05 Jun 2019 00:05:40 -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=wEdoucIRvOwXz8lKtgT8K+SiuGv6C9zcqCSBrAPMFTE=; b=I5dqH+TzNTJpgyNOOv9015vJ6/TMkO+Gmn883gqBvMlxT+ruw8egkE0RFMPqfHjE5J Zlg/pZzS3ilmWxi961+ILbRS/x47rDCdqyx9DwVjIAibiFmMug99/LDJP/cIOvVye6m+ HqcEfb/OwX/GNSWtkk8qnjnjQdKPi4qXFsGZwothUAkYWWk7M8P7FPrF1ijbcaN+tY4L KLk8R+QW8OXw+egbz7OhQcF/o9P1d2+x478Dn9K1iwnCOeFS84p0uP/XdwTFIDuERx96 GCAgff0Dj+Ruh/xDVSjSUdZE9g7E1jArSLwNUgK2Ahcky0taniezp/8IzqSYNwczZ/5R 7fwQ== 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=wEdoucIRvOwXz8lKtgT8K+SiuGv6C9zcqCSBrAPMFTE=; b=ItrQYUyz/PiQKEXYm8kAn6Lp0+uZ4r9NLgMd6WF9Lg7t4EAfaH3Q+Ck4Serm1OfOUN W4vlZyc7AcRN9iZlgXowfBJYRT31hHMBI9BKtOPZaMAudjejsIi8aeooO26qXMULkU1k QR9GCWROnE8sYWXylxo4ne8vpEGcJ9L4BJlqk8CsER2gUoPVRVkWDo1P4jjEm1tOSSsX Fafei1vyubkeunECi9GIIsTiOp1sHFZSdXAmg03ht7E2dfOcsVCEoV5qeS7GOBdMehKD t9oJ0PeRXySR/Ldw0gkTpuOS5ThMnMq48J1O33Bi7JNhG9/4R2MCpinyifWyh4Tg/Uhp Uw0w== X-Gm-Message-State: APjAAAUvsb56CXa39P3PPXTB0fy/wsIbGVNWEycg3krXi3TOgvplJfTW PPjnBokOuJ74Zfoic/oDdz6r3nl9+3A= X-Received: by 2002:a17:90a:d151:: with SMTP id t17mr28732792pjw.60.1559718339752; Wed, 05 Jun 2019 00:05:39 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:05:39 -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 v3 11/15] drm/bridge: tc358767: Introduce tc_set_syspllparam() Date: Wed, 5 Jun 2019 00:05:03 -0700 Message-Id: <20190605070507.11417-12-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 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 7b84fbb72973..c58714daa0a1 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -601,35 +601,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; @@ -887,7 +892,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; @@ -915,25 +919,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