Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp284611img; Thu, 21 Mar 2019 20:31:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGglJTJlV08n8B+hdAeejfrcf5oRpSbhzVfx8Kysl35dQYVURIYNs40Hr/1vVw5WNcu3W4 X-Received: by 2002:a17:902:6949:: with SMTP id k9mr6878786plt.275.1553225470132; Thu, 21 Mar 2019 20:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553225470; cv=none; d=google.com; s=arc-20160816; b=vFNEfojafCT9R+qlw1RqtbhVg0YxMXe362IR3rIxVSTfV8awhbwLcULJ16n0rpXYS1 AlNAnFToKgeK3onEbQ2IVFf9VI7oTHxX3ExfnCPc35pcpnOJKQs7vwf3b7n70Jbgs7uy H2/NJzs37h7l3BgQRBtex7JW4NavD0gkowzd2q0VyoMY7p2NeXo4Jm5qLng35/+59uHo mtwqR52fD0YN3ZU5PHS9AQqHzYyacUpTOHQ/89ZMccCxEb6/sc5rxc/hkgDLdauq82Hc klt3YolSrD7W5VHKddntMp5L70mDwPXAVFELNddPiyC6v98qH9RePr9cyaR9axIQVVy0 Q5Qg== 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=6utk7J9wv7nvQ22DGj7RjxJtV/DljhXKoSc+u7lmTcY=; b=yncE7SD4/1jSsHtn/G3BSAfm3wtIHEo7TuC7N9v+8O1OUEPWlE12py/xjYP8ObC5eM z6np9mSyUcVd4inexe9qVvlxzvbkYLe2Uw4zAJsF1vWBM7qRIIF+A5JyUKcTOeCiSxhw 6NxDZ+KVs45EEvTY7oaSQBbMsScMmq5eVJqvTmJqcP19qJczcPy3VFbG1fBm1sFKRthh imLfiKymnCV3UBaYd3Bv7px3ls3EqMj7OVBosNStjxYaL3D67IaoW9jN/Wbtk1/9BCKU Uxl8Fp4DkuLzRmDNVBj500fKfVZwhN2CUrMRrqS3PcMfjqhNkQlVitlyb/YqI95xuA52 Mydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pETWdX7E; 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 go9si5882074plb.404.2019.03.21.20.30.55; Thu, 21 Mar 2019 20:31:10 -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=pETWdX7E; 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 S1727806AbfCVD34 (ORCPT + 99 others); Thu, 21 Mar 2019 23:29:56 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42971 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727595AbfCVD3a (ORCPT ); Thu, 21 Mar 2019 23:29:30 -0400 Received: by mail-pg1-f196.google.com with SMTP id p6so488358pgh.9 for ; Thu, 21 Mar 2019 20:29:29 -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=6utk7J9wv7nvQ22DGj7RjxJtV/DljhXKoSc+u7lmTcY=; b=pETWdX7EfJiGQ9OaW2mQm36/YbOXBXYnPq3VGksq/ZpMepoLE69m2mT4eRuQhaAhrM kxpJIt6HabeQub2VbQoknDt319Xmijt0aTTYTG1CrBv4K0FJ2ZmmV+IVuvWQy5puhR3d 2kfWDD7wGtWhbrf6UUVWTIpW+Ybc7FxNFymw5ZfMp+ouK7NDWZROS6f/6fd5dzPJWVHB w4X6uh0s4bZASOoXxJoG0xLh8ZwBIZMFgpg+fV9f0XK8Q9VKr8ZBPFklbRo0pZ+DmG14 hFCV5reWpcMTZZ3MYyH+Ipes9M6r2PmQqPzq09D0IPghi3Ol6QQLf0WQ2oo6191mKU7c zxqA== 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=6utk7J9wv7nvQ22DGj7RjxJtV/DljhXKoSc+u7lmTcY=; b=cSApCLyCGb9ODz5MJ6oFq9/vcJG9ujTaYI2zLazyfptTrnXg6mrqVWF3ItQyeVmN2I n9MqkoS4EmvpS/18X3hb9uM0O/6WZpZqzWq3ONfRmLfmTFvolfE/Xp8QsB1SzmjO2b9F H1oMU+YCcrcK+x6srCxyXsJLMeleA8hePXAA7EbsFS08JquK06g0/hOYoGNiRzwiNAaf 5UieItfXYzfAHC/iIKYi1iCLWgjcw3FfEjgdYNJDhhoLEqdTmpuqQwXgWrTj7nYM280i ySrkita8cysFbeH+0XkLJUIrcMP0l54rU38JeiihuKaGKHFF3BTeuKAKOAirmJ59r2Qf RIAA== X-Gm-Message-State: APjAAAVfn0hOTqaSsQKHUMZzFmK0cMYbm2bcp5SwlSrZd9yUVEWZUMxu XStMio1BKgpoPxUJpBEot/s= X-Received: by 2002:a17:902:ba8c:: with SMTP id k12mr7268257pls.193.1553225369416; Thu, 21 Mar 2019 20:29:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 20:29:28 -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 11/15] drm/bridge: tc358767: Introduce tc_set_syspllparam() Date: Thu, 21 Mar 2019 20:28:57 -0700 Message-Id: <20190322032901.12045-12-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 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: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 48 +++++++++++-------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 768f01cc2a30..976a9861e537 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -585,35 +585,41 @@ 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 dp_phy_ctrl; + 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; @@ -817,8 +823,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; u8 tmp[8]; @@ -840,25 +844,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.20.1