Received: by 10.223.176.46 with SMTP id f43csp689031wra; Fri, 26 Jan 2018 05:26:02 -0800 (PST) X-Google-Smtp-Source: AH8x226OFAqhCjTidsyog9c5Aj9Wjk0Cy6X/i7oa5NBumK5zZSs7rSqdygQc3PSK1mDRIZ5K0XNd X-Received: by 10.99.113.15 with SMTP id m15mr16437839pgc.236.1516973162084; Fri, 26 Jan 2018 05:26:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516973162; cv=none; d=google.com; s=arc-20160816; b=QYsoDXgkZs3Twy5felTIxgq5PIU7xX+drap1lSd/nU5kdi0ClxHAUzel4xk8szLBxX dPuKO43An1XuQbBLI6a1f6eGu8/IPKgepPbka8q/iOJvigA9wa2p8yuQeAlYO3yA1kkp O5lI5sB23cdTGt9IzjdvXLIeWaSp4V5mQLV+E4RDn4AcI7NsS629VoDjGyHs/4PiCXtn PaDpKmqvtaLPJ6kPoEaerfLB+qnNVocI0uSU9MxAUzYCL2/c/WigyfCx7Fj1VXqGTtA/ hgDfWUa5j88xMasdpmnSIEJ0ZLd6rx8elCEY+ZIN41CB4Wgj71+xC33yExWFFn10rlY2 etmw== 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 :content-transfert-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=hxH0XBDIZg/V16rrOkfejynVKqOtwSR/IngHTIJqS2M=; b=LmR5rK2sh0NLMAAf1kS/5e3GRYPPucnvMTUHkzQQQZ9SMS6me7xClddcKiY6yPBH6E vGbjyPznyz6dqyI3V83GfYWrjDz4gihr+FUX2UNoMV/0TL3T+H6UyfNj69PoHynM87zi nwvOmV8kwwiSHuUF/Op8fHgjzC/EcCQXTahieOcg3bJ7k6fyNfGNGZMO7iFqud9uXdkK FwKhVzGNUWoDu3MUEBk0Kw7Xjfuu7iMl6gaTm5e0zGtTw/x59KxEH0JFG7jk67gX5eU6 SMWrm74m+GoQE90HzqKlUCKs5IDstHkCXPKyuvb1dqhyNcdPwo5LFe5j6kCv88C3yWvz 7e8Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si3707223pli.294.2018.01.26.05.25.48; Fri, 26 Jan 2018 05:26:02 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbeAZNRu (ORCPT + 99 others); Fri, 26 Jan 2018 08:17:50 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34388 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbeAZNRs (ORCPT ); Fri, 26 Jan 2018 08:17:48 -0500 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:8a7e:4790:a8d7:ca4:7b4f:7f87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tescande) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 41F5D2747F9; Fri, 26 Jan 2018 13:17:47 +0000 (GMT) From: Thierry Escande To: Archit Taneja , Inki Dae , Thierry Reding , Sandy Huang , Sean Paul , David Airlie , Tomasz Figa Cc: Haixia Shi , =?UTF-8?q?=C3=98rjan=20Eide?= , Zain Wang , Yakir Yang , Lin Huang , Douglas Anderson , Mark Yao , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 14/43] drm/bridge: analogix_dp: Check AUX_EN status when doing AUX transfer Date: Fri, 26 Jan 2018 14:16:41 +0100 Message-Id: <20180126131710.7622-15-thierry.escande@collabora.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180126131710.7622-1-thierry.escande@collabora.com> References: <20180126131710.7622-1-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lin Huang We should check AUX_EN bit to confirm the AUX CH operation is completed. Cc: Stéphane Marchesin Signed-off-by: Lin Huang Signed-off-by: zain wang Signed-off-by: Sean Paul Signed-off-by: Thierry Escande --- drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c index 9df2f3ef000c..e78c861b9e06 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c @@ -1073,9 +1073,9 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, { u32 reg; u8 *buffer = msg->buffer; - int timeout_loop = 0; unsigned int i; int num_transferred = 0; + int ret; /* Buffer size of AUX CH is 16 bytes */ if (WARN_ON(msg->size > 16)) @@ -1139,17 +1139,20 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, writel(reg, dp->reg_base + ANALOGIX_DP_AUX_CH_CTL_2); - /* Is AUX CH command reply received? */ + ret = readx_poll_timeout(readl, dp->reg_base + ANALOGIX_DP_AUX_CH_CTL_2, + reg, !(reg & AUX_EN), 25, 500 * 1000); + if (ret) { + dev_err(dp->dev, "AUX CH enable timeout!\n"); + return -ETIMEDOUT; + } + /* TODO: Wait for an interrupt instead of looping? */ - reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA); - while (!(reg & RPLY_RECEIV)) { - timeout_loop++; - if (timeout_loop > DP_TIMEOUT_LOOP_COUNT) { - dev_err(dp->dev, "AUX CH command reply failed!\n"); - return -ETIMEDOUT; - } - reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA); - usleep_range(10, 11); + /* Is AUX CH command reply received? */ + ret = readx_poll_timeout(readl, dp->reg_base + ANALOGIX_DP_INT_STA, + reg, reg & RPLY_RECEIV, 10, 20 * 1000); + if (ret) { + dev_err(dp->dev, "AUX CH cmd reply timeout!\n"); + return -ETIMEDOUT; } /* Clear interrupt source for AUX CH command reply */ -- 2.14.1