From patchwork Tue Feb 26 19:36:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831427 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 A30B713B5 for ; Wed, 27 Feb 2019 08:56:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED392B002 for ; Wed, 27 Feb 2019 08:56:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 832742C162; Wed, 27 Feb 2019 08:56:42 +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 3C4E52B002 for ; Wed, 27 Feb 2019 08:56:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B53FC6E037; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id B95826E01B for ; Tue, 26 Feb 2019 19:36:28 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id q3so6720197pll.4 for ; Tue, 26 Feb 2019 11:36:28 -0800 (PST) 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=YVXBfapIBPv9u2kzIyOKvGLdHh31BstlJtoKLehz/ro=; b=EzGRjm7xotFoSR7BqT8pqRnaqQVbECioUs+gN+wxcsFP5HNnZty4HmR1Aa+66cpWBF 4Iay4qKI9SiHLrwZDC74p41lG+WFf8avd2LcuDna8Cirr7zhcTTAFRVdwQpK7AY8Q1no uTGmvMsWpMo7BXoEMBJY42uom0qTNn91GUdcxANRekEatp4vx4PGVYuUp0z1xdWUxqr1 SaECdYazdU+1aCEtKRGHU+rGsaP9MywNvCOcj28H84QFvNVcxYny/qC5QTn6FcjSR1PX SsyGUVY8tWBcx6nA7gnFkjV48b6XxB2SHel9LooB40RTWU9CjVmJM7gSZahnM9yhe/9d jcwQ== X-Gm-Message-State: AHQUAuZcUbzR2cwrwBsTJYpFMbITGEE+Ykf+0MLozqSAapWE4dYirjrT bvzv3PdxZCFJ1HxnVygoOHyLCC6kI5c= X-Google-Smtp-Source: AHgI3IYLOxDuyqQ8mbfqACEV3AngV+icEFTS1xsMJdZHGpimzvUBJXiQXvv8hLtOugAL7eLnbUyOog== X-Received: by 2002:a17:902:bd06:: with SMTP id p6mr6006380pls.130.1551209787748; Tue, 26 Feb 2019 11:36:27 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:26 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/9] drm/bridge: tc358767: Simplify tc_poll_timeout() Date: Tue, 26 Feb 2019 11:36:01 -0800 Message-Id: <20190226193609.9862-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=YVXBfapIBPv9u2kzIyOKvGLdHh31BstlJtoKLehz/ro=; b=qZS6HpZMXIb4jSEp5ugOY+XQYJL3OF29uRIh7vTNcXnJt95jSpFxGSXZPy5b4BPJdn ex5rSQemwGkSj9lMe4Ir6DTBf9LlcWvvKpINvUinoWXunfuklh+dSO7V4dtn4BTuh/ns 7aHRE+ZwGQ5wSTB2aAKfPSS84LLpqu7GXJe2R86Vp6mebrjCyvdFwiDTJdJrasZoU3do zus5suIVvq73t3tDJ3He0mJyu0zA9DB1zlYBaicP/y5nHiJAns410fTDx5uL+zDu+5u5 MDPIj9vFbAYct3BXdxnaPnLVdjJ0ppCwIYyH3lmHD8wmHpTc6ArvaDrzOxv8Z4qtYJ5k BysA== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Implementation of tc_poll_timeout() is almost a 100% copy-and-paste of the code for regmap_read_poll_timeout(). Replace copied code with a call to the original. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Andrzej Hajda Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/bridge/tc358767.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index e6403b9549f1..b0f8264a1285 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -252,24 +252,11 @@ static inline int tc_poll_timeout(struct regmap *map, unsigned int addr, unsigned int cond_value, unsigned long sleep_us, u64 timeout_us) { - ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); unsigned int val; - int ret; - for (;;) { - ret = regmap_read(map, addr, &val); - if (ret) - break; - if ((val & cond_mask) == cond_value) - break; - if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { - ret = regmap_read(map, addr, &val); - break; - } - if (sleep_us) - usleep_range((sleep_us >> 2) + 1, sleep_us); - } - return ret ?: (((val & cond_mask) == cond_value) ? 0 : -ETIMEDOUT); + return regmap_read_poll_timeout(map, addr, val, + (val & cond_mask) == cond_value, + sleep_us, timeout_us); } static int tc_aux_wait_busy(struct tc_data *tc, unsigned int timeout_ms) From patchwork Tue Feb 26 19:36:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831451 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 655461390 for ; Wed, 27 Feb 2019 08:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 520D92B002 for ; Wed, 27 Feb 2019 08:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 467542C162; Wed, 27 Feb 2019 08:57:16 +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 E39772B002 for ; Wed, 27 Feb 2019 08:57:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8945E6E0A4; Wed, 27 Feb 2019 08:56:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1ECCF6E01C for ; Tue, 26 Feb 2019 19:36:30 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id u9so6731007pfn.1 for ; Tue, 26 Feb 2019 11:36:30 -0800 (PST) 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=zo1rOGgP1tAuDyRwTfd/XEth0y5njkvD5lYeSdDXZAc=; b=CYjY+tmjtLgwIBFNmkjedq1UgB5a1mLwAQBiV12nd1DhLR9XlYYhuvv2Xc4NoWFvG+ XusBPmu/4mTQpRZ0nBuGHvA+W4MH2JVb/vkVa85yw32x0mXEzLJ3DdB0yEiV/1h2LDQq +4SVnviqWq8K5Ek0QXigSnEy6nx608BelEMpOhKrAUYJEjMym6lKUlx+s1OiGJkgqzrv 58Ql8NsOofCqD7JcgFLScFgpHwQ/1ElA9RzucOxwqxUyVRD24Mj6lWkKZr7bGLBSEiJD jXmfIk/itx9mLp2RuvqOeXOrBf4HbhKAVmwaLucDxCmicYHcrnQdYtYZijy+jD/ykk8d sgzA== X-Gm-Message-State: AHQUAua99XF5lhk2Ol24ALVoxDHFRfEWVuS8/U+EqND9pgkOhNl9RbUP cN8367r32q/gvWK7hpqCGQYP0j8GC9U= X-Google-Smtp-Source: AHgI3IYgfhBMhvIRNXR3hr3JMt3zWE7NydpqBa/LlgW/jZEPxDBlX56DtUTPTEdJQJoBTzEmef3kjQ== X-Received: by 2002:a63:455f:: with SMTP id u31mr17194203pgk.241.1551209789266; Tue, 26 Feb 2019 11:36:29 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:28 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/9] drm/bridge: tc358767: Simplify tc_stream_clock_calc() Date: Tue, 26 Feb 2019 11:36:02 -0800 Message-Id: <20190226193609.9862-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=zo1rOGgP1tAuDyRwTfd/XEth0y5njkvD5lYeSdDXZAc=; b=Wa8DVPoMfPYg1dc+cJWAkL3aOSAlBxfag0TNEmf7VqJBb7f/zd51WuGFKK7L4IbG0s iMZAnjWoeyPd1ElYSctYbTEFzTaWrgnHYVB8Le4hD57BxqCAh3sLN24kBw8ZcMkTCC2h bF2hcQsr6nASsAumgG/DU+bYhNZOsRRZV2yf2mE6svuqLArobsfDL8NMaLDSDyBze7jD OxUtO02DoDVF4hSmu2QwNetAzsYGFISJmfLH58NS4Cqtuw3+ItQJZkp3aFicgYgpDhrv sWUzOwlRCKgmdVMJ9Mbv6yQGytaUdARlF9RKOOaNAZy4rqtoASe7CJA7I+YdbypEMf2n ItKA== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Drop the use of tc_write() as well as "magicly" used "ret" and "err:" and replace it with a simple call to regmap_write(). No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index b0f8264a1285..86ebd49194b7 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -504,7 +504,6 @@ static int tc_pxl_pll_dis(struct tc_data *tc) static int tc_stream_clock_calc(struct tc_data *tc) { - int ret; /* * If the Stream clock and Link Symbol clock are * asynchronous with each other, the value of M changes over @@ -520,11 +519,7 @@ static int tc_stream_clock_calc(struct tc_data *tc) * M/N = f_STRMCLK / f_LSCLK * */ - tc_write(DP0_VIDMNGEN1, 32768); - - return 0; -err: - return ret; + return regmap_write(tc->regmap, DP0_VIDMNGEN1, 32768); } static int tc_aux_link_setup(struct tc_data *tc) From patchwork Tue Feb 26 19:36:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831431 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 3CD3913B5 for ; Wed, 27 Feb 2019 08:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 274E62B002 for ; Wed, 27 Feb 2019 08:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B6CF2C162; Wed, 27 Feb 2019 08:56:48 +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 924052B002 for ; Wed, 27 Feb 2019 08:56:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DE1C6E032; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 590C36E01D for ; Tue, 26 Feb 2019 19:36:31 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id u9so6731028pfn.1 for ; Tue, 26 Feb 2019 11:36:31 -0800 (PST) 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=CHCWP+rKo+1bipESnROXwjb4cL5WEAepx8uQ8cIY+0E=; b=IGA1gQnoTYq3Lh4EBh+im4FB8kKruA5TIGnFiW4T3rnfZBUEpblFEDZ5pq9bDhBtnM 0GK9opT0Ivn3fLct/jgsgJ6ig6m10OJJrKHTZD6SzcxmqD00vTyR1Q0jj6lbYp2/XkLd OQ79ix8LFgIIwDx8ejmfkqv+HwLuPo42f543A6zsRwMhq1lsqzy61IbvHK2VJAjGRpDP zPzentJ7KCHDW80qABBtb4+ly/6xv2/77c5u/fJJAt/ijUgnUGvFV8nyGknwgdGyBWnC Fx2l5ilCnYSoLXUdBfxoINIdQX4+l83a5tFdoLzgbj9HlF+wibY7ohV0PhXHEgk01wcP a3EA== X-Gm-Message-State: AHQUAubHY9FWnu40QE1ASNk1cqxexjqv+xzii5Ree0l9hFml+qPby57W WV0ynp4C+0aCdG7iTiTBipBkCd/ieA0= X-Google-Smtp-Source: AHgI3Ia11o68LXeakQsz1TtH0H/RD8+5qUrHGKhV/wonBpm1qTmSRvwvotxf36RK+SpbEQIks/PG+w== X-Received: by 2002:a65:62c2:: with SMTP id m2mr13668924pgv.348.1551209790530; Tue, 26 Feb 2019 11:36:30 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:29 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/9] drm/bridge: tc358767: Simplify tc_set_video_mode() Date: Tue, 26 Feb 2019 11:36:03 -0800 Message-Id: <20190226193609.9862-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=CHCWP+rKo+1bipESnROXwjb4cL5WEAepx8uQ8cIY+0E=; b=JmCRIwh+JgmbxP6kU/5wLPoU3642zolf+13Qj4p4hocBVokN2injt4C0wS8dDcf9zI KDnhoIIHOA5JD0997v7ZDddSjQPJm0mNlWHJyfb/awXPKr8Gvoc/opWs3R+M7mNFCSsB isWnhKsrYSnVnswoXsEEnBmLZP2hdEeK6h6HYScGdk0awMdAFSdUt2wYi76DJqEqzbRM rt01tcXvBn6CLOI+neDaQ6LQUGwNsGsIxZkdvd8FIxOw5L/KbxQDmaWbxh8n0F57PSAz Sh1t8D5FZtr1jhmgfMSyNHZFnK6g28LznwePkmFC+1wtn4fLcmtEMaWVifdVk8v8rwyW LvtQ== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Simplify tc_set_video_mode() by replacing repreated calls to tc_write()/regmap_write() with a single call regmap_multi_reg_write(). No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 125 ++++++++++++++++-------------- 1 file changed, 65 insertions(+), 60 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 86ebd49194b7..c85468fcc157 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -641,10 +641,6 @@ static int tc_get_display_props(struct tc_data *tc) static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) { - int ret; - int vid_sync_dly; - int max_tu_symbol; - int left_margin = mode->htotal - mode->hsync_end; int right_margin = mode->hsync_start - mode->hdisplay; int hsync_len = mode->hsync_end - mode->hsync_start; @@ -653,76 +649,85 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) int vsync_len = mode->vsync_end - mode->vsync_start; /* - * Recommended maximum number of symbols transferred in a transfer unit: + * Recommended maximum number of symbols transferred in a + * transfer unit: * DIV_ROUND_UP((input active video bandwidth in bytes) * tu_size, * (output active video bandwidth in bytes)) * Must be less than tu_size. */ - max_tu_symbol = TU_SIZE_RECOMMENDED - 1; - - dev_dbg(tc->dev, "set mode %dx%d\n", - mode->hdisplay, mode->vdisplay); - dev_dbg(tc->dev, "H margin %d,%d sync %d\n", - left_margin, right_margin, hsync_len); - dev_dbg(tc->dev, "V margin %d,%d sync %d\n", - upper_margin, lower_margin, vsync_len); - dev_dbg(tc->dev, "total: %dx%d\n", mode->htotal, mode->vtotal); - + int max_tu_symbol = TU_SIZE_RECOMMENDED - 1; + /* DP Main Stream Attributes */ + int vid_sync_dly = hsync_len + left_margin + mode->hdisplay; /* * LCD Ctl Frame Size * datasheet is not clear of vsdelay in case of DPI * assume we do not need any delay when DPI is a source of * sync signals */ - tc_write(VPCTRL0, (0 << 20) /* VSDELAY */ | - OPXLFMT_RGB888 | FRMSYNC_DISABLED | MSF_DISABLED); - tc_write(HTIM01, (ALIGN(left_margin, 2) << 16) | /* H back porch */ - (ALIGN(hsync_len, 2) << 0)); /* Hsync */ - tc_write(HTIM02, (ALIGN(right_margin, 2) << 16) | /* H front porch */ - (ALIGN(mode->hdisplay, 2) << 0)); /* width */ - tc_write(VTIM01, (upper_margin << 16) | /* V back porch */ - (vsync_len << 0)); /* Vsync */ - tc_write(VTIM02, (lower_margin << 16) | /* V front porch */ - (mode->vdisplay << 0)); /* height */ - tc_write(VFUEN0, VFUEN); /* update settings */ - + u32 vpctrl0 = (0 << 20) /* VSDELAY */ | + OPXLFMT_RGB888 | FRMSYNC_DISABLED | + MSF_DISABLED; + u32 htim01 = (ALIGN(left_margin, 2) << 16) | /* H back porch */ + (ALIGN(hsync_len, 2) << 0); /* Hsync */ + u32 htim02 = (ALIGN(right_margin, 2) << 16) | /* H front porch */ + (ALIGN(mode->hdisplay, 2) << 0); /* width */ + u32 vtim01 = (upper_margin << 16) | /* V back porch */ + (vsync_len << 0); /* Vsync */ + u32 vtim02 = (lower_margin << 16) | /* V front porch */ + (mode->vdisplay << 0); /* height */ /* Test pattern settings */ - tc_write(TSTCTL, - (120 << 24) | /* Red Color component value */ - (20 << 16) | /* Green Color component value */ - (99 << 8) | /* Blue Color component value */ - (1 << 4) | /* Enable I2C Filter */ - (2 << 0) | /* Color bar Mode */ - 0); - - /* DP Main Stream Attributes */ - vid_sync_dly = hsync_len + left_margin + mode->hdisplay; - tc_write(DP0_VIDSYNCDELAY, - (max_tu_symbol << 16) | /* thresh_dly */ - (vid_sync_dly << 0)); + u32 tstctl = (120 << 24) | /* Red Color component value */ + (20 << 16) | /* Green Color component value */ + (99 << 8) | /* Blue Color component value */ + (1 << 4) | /* Enable I2C Filter */ + (2 << 0); /* Color bar Mode */ + u32 dp0_vidsyncdelay = (max_tu_symbol << 16) | /* thresh_dly */ + (vid_sync_dly << 0); + u32 dp0_totalval = (mode->vtotal << 16) | (mode->htotal); + u32 dp0_startval = ((upper_margin + vsync_len) << 16) | + ((left_margin + hsync_len) << 0); + u32 dp0_activeval = (mode->vdisplay << 16) | (mode->hdisplay); + u32 dp0_syncval = (vsync_len << 16) | (hsync_len << 0) | + (mode->flags & DRM_MODE_FLAG_NHSYNC) ? + SYNCVAL_HS_POL_ACTIVE_LOW : 0 | + (mode->flags & DRM_MODE_FLAG_NVSYNC) ? + SYNCVAL_VS_POL_ACTIVE_LOW : 0; + u32 dpipxlfmt = VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW | + DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | + DPI_BPP_RGB888; + u32 dp0_misc = (max_tu_symbol << 23) | + (TU_SIZE_RECOMMENDED << 16) | + BPC_8; + + const struct reg_sequence video_mode_settings[] = { + { VPCTRL0, vpctrl0 }, + { HTIM01, htim01 }, + { HTIM02, htim02 }, + { VTIM01, vtim01 }, + { VTIM02, vtim02 }, + { VFUEN0, VFUEN }, /* update settings */ + { TSTCTL, tstctl }, + { DP0_VIDSYNCDELAY, dp0_vidsyncdelay }, + { DP0_TOTALVAL, dp0_totalval }, + { DP0_STARTVAL, dp0_startval }, + { DP0_ACTIVEVAL, dp0_activeval }, + { DP0_SYNCVAL, dp0_syncval }, + { DPIPXLFMT, dpipxlfmt }, + { DP0_MISC, dp0_misc }, + }; - tc_write(DP0_TOTALVAL, (mode->vtotal << 16) | (mode->htotal)); - - tc_write(DP0_STARTVAL, - ((upper_margin + vsync_len) << 16) | - ((left_margin + hsync_len) << 0)); - - tc_write(DP0_ACTIVEVAL, (mode->vdisplay << 16) | (mode->hdisplay)); - - tc_write(DP0_SYNCVAL, (vsync_len << 16) | (hsync_len << 0) | - ((mode->flags & DRM_MODE_FLAG_NHSYNC) ? SYNCVAL_HS_POL_ACTIVE_LOW : 0) | - ((mode->flags & DRM_MODE_FLAG_NVSYNC) ? SYNCVAL_VS_POL_ACTIVE_LOW : 0)); - - tc_write(DPIPXLFMT, VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW | - DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | DPI_BPP_RGB888); - - tc_write(DP0_MISC, (max_tu_symbol << 23) | (TU_SIZE_RECOMMENDED << 16) | - BPC_8); + dev_dbg(tc->dev, "set mode %dx%d\n", + mode->hdisplay, mode->vdisplay); + dev_dbg(tc->dev, "H margin %d,%d sync %d\n", + left_margin, right_margin, hsync_len); + dev_dbg(tc->dev, "V margin %d,%d sync %d\n", + upper_margin, lower_margin, vsync_len); + dev_dbg(tc->dev, "total: %dx%d\n", mode->htotal, mode->vtotal); - return 0; -err: - return ret; + return regmap_multi_reg_write(tc->regmap, + video_mode_settings, + ARRAY_SIZE(video_mode_settings)); } static int tc_link_training(struct tc_data *tc, int pattern) From patchwork Tue Feb 26 19:36: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: 10831435 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 C31AA1390 for ; Wed, 27 Feb 2019 08:56:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF13F2B002 for ; Wed, 27 Feb 2019 08:56:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A36402C162; Wed, 27 Feb 2019 08:56:51 +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 6221F2B002 for ; Wed, 27 Feb 2019 08:56:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C6D9C6E03A; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 330076E01F for ; Tue, 26 Feb 2019 19:36:33 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id p19so6723410plo.2 for ; Tue, 26 Feb 2019 11:36:33 -0800 (PST) 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=ICgFrTld9JRHTgnIIEzO9Y6X45uTsmJMMuA3yPbCJ84=; b=g33DOt+u1Vwt8WHniBoyLxAYRWD2xt/B/9AU0Ev5z7GHMfCmrECjnCGTbUNGRkGnXV tKjZgMciDuNosMASl6Cl8YI+18wMQUPcjj3ku0tWzNxXDb4lC30yspeGZ5sMyh8ayAfw JrEDLdJ9EAnqHDwAGYATibDFyFNXhpI/PwuzwTPzkx6vVIGvjHCB/HbdIZrfoqMP9NnO W8wC2xA3TwSz/KIswLSHjh8izLLhu3tRQ29p8OWazrgoqOs+2ypK3jT+EECY/SMsVoFW bcc9c2H/laaw8Mv6MEY8spBqHwVM/ypZ7U/vJtUJkn5NpDfslNNkpblLgguY+gWUUFat tKzQ== X-Gm-Message-State: AHQUAuYSV4y04LRaRD60gutyDyRjZCGahv1en5fR1PHXmIDHXeF96ytf ttTE9fv56Lt6BdRQlt00RqIjKBc3orQ= X-Google-Smtp-Source: AHgI3IYrdozcRXu7rccU9mHllRR136wgVElc55P0euzyBFsvrKiwM8g/8mNo4n1Wzi6cXG/2Qagarg== X-Received: by 2002:a17:902:6949:: with SMTP id k9mr28310371plt.188.1551209792387; Tue, 26 Feb 2019 11:36:32 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:31 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/9] drm/bridge: tc358767: Simplify polling in tc_main_link_setup() Date: Tue, 26 Feb 2019 11:36:04 -0800 Message-Id: <20190226193609.9862-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=ICgFrTld9JRHTgnIIEzO9Y6X45uTsmJMMuA3yPbCJ84=; b=HHPycQ3kzU+Y2D8FPejN9JFINOdXQLaHw64LcLJD2HuungpnukAEhQMSynAGX2zfII L0tK0ZXwYH7oIjlor8PlP8fkIcC2Ar6tbmksTaRRCIoegXUIpLMvtMW8fAzcyCJXWYk7 Yn0EwA4nrM0P4JQhE0Kmef5cLfpk6Aa7DxlbT69NI3cLL0fRAn9z8ab8ZWKDpwCFNH9X 3yRMQFHQxqYAhqyR51a0cxUMLnx8v606OTDuMkThmdB0oBwaXXdDhGK0DA7r44vbtCyI kDBKUE7jSPQyMX+18+YHhc8Sy4dk6bD4ubV3dipOUMXpCQ3H078T7MbGppXq0CrmC4Ix a8Rg== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace explicit polling loop with equivalent call to regmap_read_poll_timeout() for simplicity. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/bridge/tc358767.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index c85468fcc157..6455e6484722 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -882,15 +882,11 @@ static int tc_main_link_setup(struct tc_data *tc) dp_phy_ctrl &= ~(DP_PHY_RST | PHY_M1_RST | PHY_M0_RST); tc_write(DP_PHY_CTRL, dp_phy_ctrl); - timeout = 1000; - do { - tc_read(DP_PHY_CTRL, &value); - udelay(1); - } while ((!(value & PHY_RDY)) && (--timeout)); - - if (timeout == 0) { + ret = regmap_read_poll_timeout(tc->regmap, DP_PHY_CTRL, value, + value & PHY_RDY, 1, 1000); + if (ret) { dev_err(dev, "timeout waiting for phy become ready"); - return -ETIMEDOUT; + return ret; } /* Set misc: 8 bits per color */ From patchwork Tue Feb 26 19:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831429 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 85FEC1390 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71EAD2B002 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6657A2C162; Wed, 27 Feb 2019 08:56:44 +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 1EF5F2B002 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8C976E03B; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68CD06E020 for ; Tue, 26 Feb 2019 19:36:34 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id q206so6687250pgq.4 for ; Tue, 26 Feb 2019 11:36:34 -0800 (PST) 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=ZD8IznxWy7CqeE4Azr2UQLZvJTlUTz8IeNFsGWvGXF8=; b=uQ+hf2lsyTmqOKjJL66E6pqG/qWinNXCmUHa09MzA+Yqf/IUveo0U6NF4KqH/SElpP O8P0zRAmm9BEzuxCwP95dofRFz611dKcyFJ3a6cXK5Fuq4Ulq39aY0HxXHkMJmHdHkGX Qe7tfWUhQpdbiJQJfWuYz3+s7aCbFDXyLzKvdoBkJct50IROhxQTZNiOvHUhno7u8THc kzVHoOgVWqiZHebvnUDWA13QZq+q3MHhw15HY6gJycwkyOsSsA7dlB9ZrFrMAWZRfDNx w22G6S2o/ky7XinnSFy5B5kzlm2eeD1k1/iJc+yTC3c+VpRiUaegTOV7MDKV6N+wiGbQ GNZw== X-Gm-Message-State: AHQUAuZD1yjyfJykhV2oQG+0AW+YQ5IEE/LtshBFYLPrEoHOzFwZ6j/f qvz1eWXMEf3Mp2Loy45gKdeJE9M4chA= X-Google-Smtp-Source: AHgI3IbXRwVqDQxRzoxQGu32bhQ3aNhR3RbMzJH7j0vuVh6N/rMuNaUuRED/IT6Ld/RAlD50PH+xFA== X-Received: by 2002:a63:295:: with SMTP id 143mr25173772pgc.362.1551209793568; Tue, 26 Feb 2019 11:36:33 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:32 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/9] drm/bridge: tc358767: Simplify polling in tc_link_training() Date: Tue, 26 Feb 2019 11:36:05 -0800 Message-Id: <20190226193609.9862-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=ZD8IznxWy7CqeE4Azr2UQLZvJTlUTz8IeNFsGWvGXF8=; b=LV03iVYNnCMB0G8raqGDzG20KEeQp3RHnwMz2e39Efl7rwsHJC3PGJxRVdtdUuTaRL ATxr/pcl9WPt4QL0WuqecylqPAjq5Uuk6NK0qk7heD7D3I0TskQokT8eWyG+Mt+4N2vr MagL11g9Fx1t1X1jh2z1svXL7ulX3+7uMyNAgCrSH2AtBRbG49xnvO8YRNw9gUhwYz4a E5XE7oDlwAgUPd78/3HAbFiJirTh5YpygzhE9akTutFBfe7dc5purIYEd3w7g6fM1SVk ukI7+kH43p499Q3gwCqFolrCfaAc2Zw8dTrJBzhfLG/XDtymHmCwWYLFZ0pLqzK5NyJu kGrw== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace explicit polling in tc_link_training() with equivalent call to regmap_read_poll_timeout() for simplicity. No functional change intended (not including slightly altered debug output). Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 6455e6484722..ea30cec4a0c3 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -735,7 +735,6 @@ static int tc_link_training(struct tc_data *tc, int pattern) const char * const *errors; u32 srcctrl = tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_AUTOCORRECT; - int timeout; int retry; u32 value; int ret; @@ -765,20 +764,17 @@ static int tc_link_training(struct tc_data *tc, int pattern) tc_write(DP0CTL, DP_EN); /* wait */ - timeout = 1000; - do { - tc_read(DP0_LTSTAT, &value); - udelay(1); - } while ((!(value & LT_LOOPDONE)) && (--timeout)); - if (timeout == 0) { + ret = regmap_read_poll_timeout(tc->regmap, DP0_LTSTAT, value, + value & LT_LOOPDONE, 1, 1000); + if (ret) { dev_err(tc->dev, "Link training timeout!\n"); } else { int pattern = (value >> 11) & 0x3; int error = (value >> 8) & 0x7; dev_dbg(tc->dev, - "Link training phase %d done after %d uS: %s\n", - pattern, 1000 - timeout, errors[error]); + "Link training phase %d done: %s\n", + pattern, errors[error]); if (pattern == DP_TRAINING_PATTERN_1 && error == 0) break; if (pattern == DP_TRAINING_PATTERN_2) { From patchwork Tue Feb 26 19:36:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831445 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 A02121390 for ; Wed, 27 Feb 2019 08:57:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B2602B002 for ; Wed, 27 Feb 2019 08:57:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2DD2C162; Wed, 27 Feb 2019 08:57:12 +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 3D4532B002 for ; Wed, 27 Feb 2019 08:57:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 134666E088; Wed, 27 Feb 2019 08:56:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id A784F6E021 for ; Tue, 26 Feb 2019 19:36:35 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id a3so6705930pff.11 for ; Tue, 26 Feb 2019 11:36:35 -0800 (PST) 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=Zxy0XxA1MxzsropNeklSR3wb+dlQlnhChJjlQro53Yk=; b=PG4P1UVNrCZ9LPane18Px8hiwqWKb9ohvuvjbEsXQGSBDdB1A2uqEFE9a/rq1iMhcK ARt5xh/LqBG8B4wuiqtSnA3ZRhUvJ7Pcv7+fUa9nAbOBn6vXa3L4dLyjA3KoeMclUI/c +DcZgHwfjdIAUi9TIktBtip5wnIzd2mBRzFMB8tZVSeGQpefQ4hItQ4VPlkpUmHRQuI/ 5ovZkivZiG1m1cI0hvdejLpwheUKgXc7HZLQlyW/qcO2S+/8GY6u5l1HSFbv48UXFg0k XAJ2I3hHCsYd1xhWE72CZIBTz0S+FYQDP6eZSKX8fdfnLVhpEK+FRs6G5IIrpwjoN8Wc efLg== X-Gm-Message-State: AHQUAuYkpMrE4L6GJgaNGofZYzdtJVfzZF/OUXyDdHTzYlzI8+fx3HzB aLCV2IEQ01ug0G/x0TsyB/Guw2XUyLQ= X-Google-Smtp-Source: AHgI3IZT9yKG8Xkr/0a+hzS3sbn6XFUn51XO6ZefgSuVbDnQlZ7ft839js2vRYXAJogFoNo4PnQtew== X-Received: by 2002:a63:2ad4:: with SMTP id q203mr26606392pgq.43.1551209794912; Tue, 26 Feb 2019 11:36:34 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:34 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/9] drm/bridge: tc358767: Simplify error check in tc_aux_linx_setup() Date: Tue, 26 Feb 2019 11:36:06 -0800 Message-Id: <20190226193609.9862-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=Zxy0XxA1MxzsropNeklSR3wb+dlQlnhChJjlQro53Yk=; b=ujvWRXMgJdu1SG4HYPw1wKyEkMT7mYayCL5beQCpVSQc2sbYmc+5d3qG3bGcXJZuIy g6btJvd2T1GwQq4QioFb7yZguBI140NCIA7ohfvtEm4Bf42GaK2JAGY9xvRAdOh9iu2E +DwxlaJZo7ccCcHyKOysRdPiDuxIbynPTnkufVZHlHmRs51B98z0MbngyyqsBZ6BXZQA x2+Aw6ShDGzbCy4g0m0DmnjIhb7IW0GaOiNQT6TIclDijWVqsvVBuvk64Pz2E17y92Kd YUvFTxDKvh1WdD4q4YjmnAX7re5LibMDj5PZyDmrcIsJX6wIM0wIvK2R5bgbxNWHoXx8 LxXA== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Tc_poll_timeout() can only return -ETIMEDOUT, so checking for other errors is not necessary. Drop it. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index ea30cec4a0c3..54ff95f66e30 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -569,11 +569,10 @@ static int tc_aux_link_setup(struct tc_data *tc) ret = tc_poll_timeout(tc->regmap, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, 1000); - if (ret == -ETIMEDOUT) { + if (ret) { dev_err(tc->dev, "Timeout waiting for PHY to become ready"); return ret; - } else if (ret) - goto err; + } /* Setup AUX link */ tc_write(DP0_AUXCFG1, AUX_RX_FILTER_EN | From patchwork Tue Feb 26 19:36:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831449 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 46AF213B5 for ; Wed, 27 Feb 2019 08:57:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31CFE2B002 for ; Wed, 27 Feb 2019 08:57:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 263672C162; Wed, 27 Feb 2019 08:57:15 +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 C1B512B002 for ; Wed, 27 Feb 2019 08:57:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1BE906E075; Wed, 27 Feb 2019 08:56:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 691656E01B for ; Tue, 26 Feb 2019 19:36:37 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id e17so4636910pgd.2 for ; Tue, 26 Feb 2019 11:36:37 -0800 (PST) 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=m4Hu2QCxn5OJqL1KMoylJ0W+atiXbfqxwE6Hc3/RGaw=; b=Mav2RsERluMKFyztra0HNpvtGH+4eP13lpU7+tOHUyJXGNplmtfXk0PD9jLhSeVyaZ /WGXnOtnVVYh+5oPc/X5W4DvEeP8hnvnih7JK/Jkp96MOob+RxM+PJjj7MaP4jueKDA1 mpOJ6ZgxDaweuLVfMgFmmWyFbXRZxLpkr1onc/6R10cQjQ6D4rDGiy7YWLchn6oog8Ai +064C6ktteKZGM7H5fP0NCwzrnY8fn0oS/vabBWagwkMblYjz7n+P/t0/allJ1tdK0GH NFthhsuMiaHsJZ2GbsGnvtBJVkrSVtEWSH8dcyn5DWvrxm1qofD94iHsSYQhBZMAOHeG LfFg== X-Gm-Message-State: AHQUAuanQcgnhUf4hYBPeFdbnbz4pwGf4e7QtG564ZYQZCpZ3q8HCAaw Phyyf7CcaC7mrp8/5SQeaJVZxTrP2Ok= X-Google-Smtp-Source: AHgI3IYtiTLTnf+zj4rKJMXXVIDYPI9YK5bYIkGS+meZTL0TxS0EELNwCTVyKmQ+G1gqB5bovQ4UiA== X-Received: by 2002:a63:31c8:: with SMTP id x191mr421627pgx.99.1551209796570; Tue, 26 Feb 2019 11:36:36 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:35 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/9] drm/bridge: tc358767: Introduce tc_set_syspllparam() Date: Tue, 26 Feb 2019 11:36:07 -0800 Message-Id: <20190226193609.9862-8-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=m4Hu2QCxn5OJqL1KMoylJ0W+atiXbfqxwE6Hc3/RGaw=; b=dlagRZnF4HIVuvNrb144ZDWe+YXbLIhJYz96nvGlaG9IoBQscKI6pgbqce5LBceYs9 xulSNH84l4EDPSxuj+pXOxM1KzT9J/Q4pYFLTXFKHLAka5dXfUCb1p8VimWjYznNcfz2 5joW6bCLNY/t62V2xsAvipbS1bgcmgouytshHOMBNmERqKpHEDywkcpgR1GLNE8ew3EB R++u6GAZp68AVE6jBpQXELoUZCQokaN05uO10bzWKI6td2/gzoaoR3OWxvYeMngtXVsB KoDSkodnKYIKmHKRzQAnjj7F1XmyaNmOwEgq0OytOeDdGxzCOkna0zaME1FplyCHwcWg 37fQ== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/bridge/tc358767.c | 50 +++++++++++++------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 54ff95f66e30..227f14cd2d3d 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -522,35 +522,42 @@ 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 value; - int ret; - u32 dp_phy_ctrl; + 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; + /* Setup DP-PHY / PLL */ - value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2; - tc_write(SYS_PLLPARAM, value); + ret = tc_set_syspllparam(tc); + if (ret) + return ret; dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN; if (tc->link.base.num_lanes == 2) @@ -811,7 +818,6 @@ static int tc_main_link_setup(struct tc_data *tc) { struct drm_dp_aux *aux = &tc->aux; struct device *dev = tc->dev; - unsigned int rate; u32 dp_phy_ctrl; int timeout; u32 value; @@ -828,25 +834,9 @@ static int tc_main_link_setup(struct tc_data *tc) (tc->link.spread ? DP0_SRCCTRL_SSCG : 0) | ((tc->link.base.rate != 162000) ? DP0_SRCCTRL_BW27 : 0)); - 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; - tc_write(SYS_PLLPARAM, value); + ret = tc_set_syspllparam(tc); + if (ret) + return ret; /* Setup Main Link */ dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN | PHY_M0_EN; From patchwork Tue Feb 26 19:36:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831439 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 245861390 for ; Wed, 27 Feb 2019 08:57:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FE092B002 for ; Wed, 27 Feb 2019 08:57:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 044152C162; Wed, 27 Feb 2019 08:57:03 +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 00F3E2B002 for ; Wed, 27 Feb 2019 08:57:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2B8C6E06A; Wed, 27 Feb 2019 08:56:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEC096E024 for ; Tue, 26 Feb 2019 19:36:38 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id i19so6737012pfd.0 for ; Tue, 26 Feb 2019 11:36:38 -0800 (PST) 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=RGzhHRXCSSTUV8y9+sZJ9O8fW6lSd15+7S2lT8PZLKA=; b=bmL6sOKdL182JO5QYImV3eEGBGPOjtpn94ffvlH+TF5Rl90GhDwGuJm6rThK3O8e9v GMEaX92UUaCm+OFw9iSqIDmjeOvnOjDhW8c+a51plemFyyv/nQ3DS+Hf8DzxYknCuX52 ADalWaIJ6nnxfkMSRmMDF+tTnS5YDZy7gsvmTtbWNyitOH1U8/x6tMnsxgUIB2oVAr/o RBWZ6RCu0h/10wp/Y2ctXL7XJFw79OR2A66nY5eoHD1moUjXEWvmNID4iQFQdoTHqRGl 3sCCks/KF4k8fd3kac4VmseDz4rY8JzBRJyvSTFen3OFrEM45Buga0T9M3BLXMjBeMcZ eJLQ== X-Gm-Message-State: AHQUAuYlah83FgU3Vp7AkuUMUwrrhrmfIVvYa+41Pa9fGn1wruHparRK E2IqcchyZw5Y/AXyTlnvU/KzWXI6q8E= X-Google-Smtp-Source: AHgI3IYBKXd+WcIOttjJ2/AqPrDDfdXeAWYSdT7lTdKZeN63pE1l21nX8QLdWskyqKN7gIry08xFUA== X-Received: by 2002:a63:8942:: with SMTP id v63mr25177689pgd.406.1551209798004; Tue, 26 Feb 2019 11:36:38 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:37 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 8/9] drm/bridge: tc358767: Introduce tc_pllupdate_pllen() Date: Tue, 26 Feb 2019 11:36:08 -0800 Message-Id: <20190226193609.9862-9-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=RGzhHRXCSSTUV8y9+sZJ9O8fW6lSd15+7S2lT8PZLKA=; b=oVsb9oQLiw7fuySZNvlTxYC1ZehjkTc/1qbDebFX0OVzzj1lDRVZYVj/hVcKlX2UgJ 6RiYPPmIM4CxFqs23wm6SwGZXpVFGvgffu6sCZCP3yTHs3pUefaHP1YSTD4BMop17Y37 S185yh8XgT4Ucv6nhw6jK7Q5uygOunVf16nDnp60gGvwVFK9Z1y8Ct9HvB8DNzHruGwJ zjx+8ecwX0piZrihN/7y4y/C9IWiy7qoo0VNO/7jr5mMz/Ewiyg4hcXjUFG2vkuy1qPf SfF9aFi8PphRz4iz+6IbaR7Qh/TZQkLf6B1LJY1bgfurGFXhC4nd/9nc5lE0T+eFy/vC lx5g== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, 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 Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/bridge/tc358767.c | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 227f14cd2d3d..239b3aaa255d 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -390,10 +390,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) @@ -487,11 +495,7 @@ static int tc_pxl_pll_en(struct tc_data *tc, u32 refclk, u32 pixelclock) (best_mul << 0)); /* Multiplier for PLL */ /* Force PLL parameter update and disable bypass */ - tc_write(PXL_PLLCTRL, PLLUPDATE | PLLEN); - - tc_wait_pll_lock(tc); - - return 0; + return tc_pllupdate_pllen(tc, PXL_PLLCTRL); err: return ret; } @@ -568,11 +572,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 */ - tc_write(DP0_PLLCTRL, PLLUPDATE | PLLEN); - tc_wait_pll_lock(tc); + ret = tc_pllupdate_pllen(tc, DP0_PLLCTRL); + if (ret) + return ret; - tc_write(DP1_PLLCTRL, PLLUPDATE | PLLEN); - tc_wait_pll_lock(tc); + ret = tc_pllupdate_pllen(tc, DP1_PLLCTRL); + if (ret) + return ret; ret = tc_poll_timeout(tc->regmap, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, 1000); @@ -846,11 +852,13 @@ static int tc_main_link_setup(struct tc_data *tc) msleep(100); /* PLL setup */ - tc_write(DP0_PLLCTRL, PLLUPDATE | PLLEN); - tc_wait_pll_lock(tc); + ret = tc_pllupdate_pllen(tc, DP0_PLLCTRL); + if (ret) + return ret; - tc_write(DP1_PLLCTRL, PLLUPDATE | PLLEN); - tc_wait_pll_lock(tc); + ret = tc_pllupdate_pllen(tc, DP1_PLLCTRL); + if (ret) + return ret; /* PXL PLL setup */ if (tc_test_pattern) { From patchwork Tue Feb 26 19:36:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831423 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 B56351390 for ; Wed, 27 Feb 2019 08:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BBA82B002 for ; Wed, 27 Feb 2019 08:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FE202C162; Wed, 27 Feb 2019 08:56:36 +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 1B3A82B002 for ; Wed, 27 Feb 2019 08:56:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE3C46E03C; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0951D6E01C for ; Tue, 26 Feb 2019 19:36:40 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id l11so6669986pgq.10 for ; Tue, 26 Feb 2019 11:36:40 -0800 (PST) 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=pI4yPgzZ84XKblQbDTBB4uLpp98dYXickwI7aXAPp7g=; b=Zslej9DN+Vr89s1OXsCB6g6OmzZSMZEQ2rUfUOmKw6R1+WZhqAFYCzLAZUjwelDusT 89Ig2Svh8EQRy1C26dolmAkrDauw/HdbxeE+5aNBZvbLitdL1BGGBN3mWRe0T7HJrIwJ tFP+FsNw66XAPzn03Ypwug35Ctx7QiRAwzDrOOk6qXliPiTkSWEu87dq+IzJtCukbVqF 0oPy2cJmDGkhHY3xt+KjaoIMZC96D9Vd45dbCZKPiWR2mGO+VqTY0RpE9O05m/s5EyLd 8eUlc1/Zcy8r6e6WWPwNI+ZG40J1dkDaMAo6avoc31lANlDZ1IDHQhS+0QIdbxY5mooc LIHQ== X-Gm-Message-State: AHQUAuZlYlIwb0TXb00wl9c9bCKh3tPAmLcd9GNs8Sl/77E2gabikzKV eQs8tjbrXO1/N0XwtilP7jPFz9YzNY8= X-Google-Smtp-Source: AHgI3IYUHn9WI8cwRr5hkkvaU/rjwDIGjhsgBcNqz2rVnGfopvyQ6evHFqQtqAd9sXyppS4NO15leA== X-Received: by 2002:a62:1c94:: with SMTP id c142mr13121004pfc.54.1551209799170; Tue, 26 Feb 2019 11:36:39 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:38 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 9/9] drm/bridge: tc358767: Drop tc_read() macro Date: Tue, 26 Feb 2019 11:36:09 -0800 Message-Id: <20190226193609.9862-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=pI4yPgzZ84XKblQbDTBB4uLpp98dYXickwI7aXAPp7g=; b=HRAQFBbF4QmVvGC47md5YX6at4CuD5bSUC49t0NPvv9xLIOzAesexN13K5zTNXn3QH LC5tGeX0EhpEGkKRR3oezVqbsUhEv5DwHHMkqfU1nYwo3LV6K+pJitFv+/JKgzmGI5q1 dQS5bpk1K3a7Gf4B7n8eqkxY0w1fnZeeJtCnSOBEGD4xj9hosg10dKOsn/dCZz/40MMF qM5V+HfZ+LamJai8bDXkJ5E9AsLEHBRuLq7vhfKXrTamfgmTVWG0ZeWm9XAe6JztbeaM CDIQz34sqdow75da4CtVFuTDZUkuHaozuubUeT6VbifdJKNdX3u0Gw9YjKho0//YzpWW SJLw== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's only one place where tc_read() is used, so it doesn't save us much. Drop it. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 239b3aaa255d..3c574f1569aa 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -240,12 +240,6 @@ static inline struct tc_data *connector_to_tc(struct drm_connector *c) if (ret) \ goto err; \ } while (0) -#define tc_read(reg, var) \ - do { \ - ret = regmap_read(tc->regmap, reg, var); \ - if (ret) \ - goto err; \ - } while (0) static inline int tc_poll_timeout(struct regmap *map, unsigned int addr, unsigned int cond_mask, @@ -337,8 +331,13 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, if (request == DP_AUX_I2C_READ || request == DP_AUX_NATIVE_READ) { /* Read data */ while (i < size) { - if ((i % 4) == 0) - tc_read(DP0_AUXRDATA(i >> 2), &tmp); + if ((i % 4) == 0) { + ret = regmap_read(tc->regmap, + DP0_AUXRDATA(i >> 2), + &tmp); + if (ret) + goto err; + } buf[i] = tmp & 0xff; tmp = tmp >> 8; i++;