Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5407289ybi; Wed, 12 Jun 2019 01:55:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGH6nRcrTbTF4HVTecfdYRTgZOmlDYpXZ24c5t00ANJZUne/igimPCAELw3GjTotlvgieb X-Received: by 2002:aa7:81d4:: with SMTP id c20mr27666626pfn.235.1560329712733; Wed, 12 Jun 2019 01:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560329712; cv=none; d=google.com; s=arc-20160816; b=046vg2baFJUE9AJQIw7rVFhHItWSQn1/L26lOPDqnBvdZxCq5MX5dszaGXXHakAVpE D0GlhXeLX/R9FNFxh8pASh2fpSfs/pXxvdmkEKNqYDY5Cz1/qmfAFshZiCMoUyINuBEo 9qXWgdicMe/m7gfegGUWc58w6yJqtNW1JXhQnp3197muNHOjz4HptIoEDFjyaF9+z15w UnH5CeA4D4q3HGHpdah3LbTS541q44sERYHLMC7HaanmIKjDgPnRWU2yggF/MdIYmvm8 UkyDtDsR/mJTMLuopMYxfF+Ny8uTjyKmD6c7Xch5aTn50uA/J5T7IulLmXbm0ICK2fQ3 DLEg== 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=keSCKeia5rVqG04ZabahyFVQsK++406Zomkh+XqD9yQ=; b=FZ7MVtSY8DrNzI1bJYnhw9WrBVUjFFM9LbRxDkiHREcf44+9HvxRguui4QGwe+xEyH XIGx+iMon9rTgpKkxyd7tDNnd55MrrymcZt54jVla+PM71x4UplfWcp5ZxunPCuZWweh qSh+CqFgKAlSE9NzH6mjZk7jMuYEupdr1bDWw81hPACp1eaDSdND/o4nZf/qJFy22vM7 7ZdNBafqYXyYV/gEPvSpH+rSW1yjvFNoj49IB2YK3SAt85VIvOiXRj1yGHs68PUMUfiL ldXcTZZAN/ZuXvJgPvA4HKV7Dn3YrxqD57T0nNb6GDuY+flIpPEDoIGIzfhPyoD4j06c 0hqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QVByu2Ho; 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 23si5175348pjx.87.2019.06.12.01.54.56; Wed, 12 Jun 2019 01:55:12 -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=QVByu2Ho; 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 S2408652AbfFLId0 (ORCPT + 99 others); Wed, 12 Jun 2019 04:33:26 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38513 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408628AbfFLIdX (ORCPT ); Wed, 12 Jun 2019 04:33:23 -0400 Received: by mail-pl1-f194.google.com with SMTP id f97so6342025plb.5 for ; Wed, 12 Jun 2019 01:33:23 -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=keSCKeia5rVqG04ZabahyFVQsK++406Zomkh+XqD9yQ=; b=QVByu2HoT/nJlM5jE+eRfFtcHUFhKeuuqDodq0ul6OOOgMr75lXrDL3cNBmC15cZwd X3V8aj+gm0LNuwqKoV9D2Ou78mRrJwhR5nc1aMN5uw7a6ttOmvkB3no1d5UlbiERk9W2 MQ8gr1nupekFxtel9//SMGCDjzHOSCEa2u4lbE4Xa0t6tWo5VOfZ3cS50UVDVXccmvEl lGGkPoTnpBJ1z0JAM6tdwmOtEAmdnOCmIIva682+RoWyPPmvPAZbxiRL+mGu00VCsN8E h0sHAo0NxKjcPJvwDacIHL+xIWsiwRKkewUdYOR4H9lwGumfL0QBQn5QFle1HTkQxG12 qF2w== 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=keSCKeia5rVqG04ZabahyFVQsK++406Zomkh+XqD9yQ=; b=YBxTATPoQQ+OHIRcpMYHFI8QhCYslny7aqJtU7hvWO5nrcbu+6+DtPwWxkLKLg/l9H RdhPo2gmu4ANPTR/w9x4QR1aHFjnMqZwiJI+IH00Sbz5kApaLQo5r4WszLojNqvHKiaR R8twMIpz2voltUQhubFKxCDfhlFaTcGGotkdza5ARIJBiF6lSLVsJnQ4trzIiC8QaidX vhPWXhGuKS7rRvemioagp6HuketTjdNi/Kw6GK61gUA0BOeQdaHj769aGjrxIk7N4j4y Hq/OBqIR/pbQFLmOaTjJNfYy5qCErCWk768FqRUrmLDfMOINdiY/JF88/paCyOtg4ooG 0L0w== X-Gm-Message-State: APjAAAWdbzGjXTsIh4Gptq0aLUFzEe7b249Sb9wVphOo1alAV0JFGgff Gee5CUln26R/Tx1cpXP7RvGv7kMJl5E= X-Received: by 2002:a17:902:8648:: with SMTP id y8mr33003851plt.238.1560328403048; Wed, 12 Jun 2019 01:33:23 -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 d21sm18845991pfr.162.2019.06.12.01.33.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 01:33:22 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Laurent Pinchart , Andrzej Hajda , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Chris Healy , Cory Tusar , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v5 11/15] drm/bridge: tc358767: Introduce tc_set_syspllparam() Date: Wed, 12 Jun 2019 01:32:48 -0700 Message-Id: <20190612083252.15321-12-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612083252.15321-1-andrew.smirnov@gmail.com> References: <20190612083252.15321-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 Reviewed-by: Andrzej Hajda 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