From patchwork Wed Jun 5 07:05:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10976409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF7C51515 for ; Wed, 5 Jun 2019 07:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD24428849 for ; Wed, 5 Jun 2019 07:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A16312885F; Wed, 5 Jun 2019 07:33:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 44A9328849 for ; Wed, 5 Jun 2019 07:33:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 555988961E; Wed, 5 Jun 2019 07:33:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D1B389165 for ; Wed, 5 Jun 2019 07:05:42 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id c85so5506250pfc.1 for ; Wed, 05 Jun 2019 00:05:42 -0700 (PDT) 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=tvip/xgQ+5xBVaZjlibyTgY+l9dQat39Ch/zrN6FGtEPe/sxvl8DP5BypfknF2fZye HoFWwHIBD5pmEZ3FXaNgiafWP6UTR+XfoZpSjGnYyJkZeQMM7SIVizAaYI4wptDCOtmw UbIXdPFpqgLYuUsXNbLraQtAmbG5QTm+gajJHCcBOwuqGO07/uk6Rr0UdZ5H2U8WVEYG /lEIhw1jaT/dCc27lLHpnva9gcds0CTCYR2A/uJUwuzq60DKCK0nkDWCXhU4s3WTgjFy +pbsXEqT8CIHOxtsNqiNCBChuNJNCFUczxIVwL55E7ffGn7hlFqkeZ4S9dvqpJwTvg2w yXsQ== X-Gm-Message-State: APjAAAUBHTcr3paY3+jT9FmGyzZDnhpBp0e+MutR/MwQykDwoG0B13XX 6Bg69uvjVYZf88xLcwvUs57pwTljMWc= X-Google-Smtp-Source: APXvYqyC0jx/q6tG1m6BADcPh6aQ2BVId4Gl6G3bZIAJ8W2OBXOSwnX7Pbxe8TFCZEK2BpS0Tq2X+A== 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 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 X-Mailman-Approved-At: Wed, 05 Jun 2019 07:33:23 +0000 X-Mailman-Original-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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cory Tusar , Archit Taneja , Andrey Smirnov , Andrey Gusakov , linux-kernel@vger.kernel.org, Tomi Valkeinen , Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;