Received: by 10.223.185.111 with SMTP id b44csp822685wrg; Fri, 9 Mar 2018 14:33:15 -0800 (PST) X-Google-Smtp-Source: AG47ELsl8/s2dwAoyzJn9rqCeq7lhizO3EWoLPoGPRxUwTj+qX6//bOeULvKtRPUz3FZYfQEH09O X-Received: by 10.98.217.76 with SMTP id s73mr50115pfg.209.1520634795127; Fri, 09 Mar 2018 14:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520634795; cv=none; d=google.com; s=arc-20160816; b=YA9jl4mPBhohxPLnzkfO+4tpgJ+cPoYGLvt6rZdG9L5OT62ZYsdyynSkryk6OG1MdY 0UODUuDjMKg91D3yBYXnXuhDVfldru+CltwUhTbW8Y7VceVJcHCDxlpCbHQHHmbeSnkv 3GVcBzYbxguia75hr4Ys6CRRg2hBA31NtFZbuL8pNJdT/uhGt9t1XBWvUCdWzQK5F2bM hIzClqPRggVtc7e0hpz3p+r9pUS0UyDm7wSak7HD93usQOva2eQPivfirGnszLbThnD3 US/8Cj8kRwM4PudqxT8Njk1lsbkYYL7njbAC/KPWL+NjAUNCcpBkkRV7lfWamBTU0jJS BVrg== 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 :arc-authentication-results; bh=b4jsQ2L6DIBGgx18kjug8Ha8gDoiowzbU5gTQeHEuu0=; b=jTKhTH0FVqymtWbrpfUNNPd23CWNcrENbSYDu3KnnD1n54yaOmCQC7UN2OiXGOUQsc 8uSD3STG5ZN3WICFd2XU/M0EE0v7skUWqNcUuWSO0gzKvAdffFTfc6M9gycyIJ0tlZf2 ikIytzvd3AkKKvooj9nuepIJ3bfW6Fre9dgjgO2y15G8eV5ysAMQKaLccIwb9mvU3BMU dtbyr6uw6wFanEOdqRMNNEDGI/rSnAiWteHNMT75eY6eidw6is3SwzOLrtfYs+w6dbDB hJdyWXzMjZFyM73Ttjtg26vhoMkf95Vns5U7Zd4vTTgjzIASI9MYZ1fs31ucLrfWhC4d 1IAQ== 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 g1si1374520pgr.588.2018.03.09.14.33.00; Fri, 09 Mar 2018 14:33:15 -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 S932921AbeCIWYJ (ORCPT + 99 others); Fri, 9 Mar 2018 17:24:09 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42396 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932795AbeCIWYG (ORCPT ); Fri, 9 Mar 2018 17:24:06 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id F1A502761CB From: Enric Balletbo i Serra To: architt@codeaurora.org, inki.dae@samsung.com, thierry.reding@gmail.com, hjc@rock-chips.com, seanpaul@chromium.org, airlied@linux.ie, tfiga@chromium.org, heiko@sntech.de Cc: dri-devel@lists.freedesktop.org, dianders@chromium.org, a.hajda@samsung.com, ykk@rock-chips.com, kernel@collabora.com, m.szyprowski@samsung.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, rydberg@bitmath.org, krzk@kernel.org, linux-rockchip@lists.infradead.org, kgene@kernel.org, linux-input@vger.kernel.org, orjan.eide@arm.com, wxt@rock-chips.com, jeffy.chen@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, wzz@rock-chips.com, hl@rock-chips.com, jingoohan1@gmail.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, Laurent.pinchart@ideasonboard.com, kuankuan.y@gmail.com, hshi@chromium.org, =?UTF-8?q?St=C3=A9phane=20Marchesin?= , Enric Balletbo i Serra Subject: [PATCH v5 08/36] drm/bridge: analogix_dp: Check AUX_EN status when doing AUX transfer Date: Fri, 9 Mar 2018 23:22:59 +0100 Message-Id: <20180309222327.18689-9-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180309222327.18689-1-enric.balletbo@collabora.com> References: <20180309222327.18689-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Signed-off-by: Enric Balletbo i Serra Tested-by: Marek Szyprowski --- 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.16.1