From patchwork Fri Mar 10 04:32:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9614773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC9CC60415 for ; Fri, 10 Mar 2017 04:50:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF7C1286E3 for ; Fri, 10 Mar 2017 04:50:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3BB8286F3; Fri, 10 Mar 2017 04:50: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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 8E9E5286E3 for ; Fri, 10 Mar 2017 04:50:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB2E96ED8C; Fri, 10 Mar 2017 04:50:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x22e.google.com (mail-qk0-x22e.google.com [IPv6:2607:f8b0:400d:c09::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78324893B9 for ; Fri, 10 Mar 2017 04:48:50 +0000 (UTC) Received: by mail-qk0-x22e.google.com with SMTP id p64so152496711qke.1 for ; Thu, 09 Mar 2017 20:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gaYYxDfhQJqq1dR+Hchvhp2ovZuqxvt2Y5bPhLjpW00=; b=EtKZQKzxGXff56il7k0DEGJeGY1Mb1QrCZShynKU8E6DiLmvWHvm40rKsKqJg8KVFt ogTxPFnGxD57JfByuToVX6u+FHzhgOQ5GJfcLnu36MBLgPZj6SIgZIwMrurI0lU4Ej2a zGKr2AkJnVO6e0UXWHbWo9XCpq11uCsEH27iI= 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=gaYYxDfhQJqq1dR+Hchvhp2ovZuqxvt2Y5bPhLjpW00=; b=VNa+9s98nn3wIZtGZhaC23UYYe8Be0/aAI39dDeUyYFedfT/owrUCQRCxDPRnEjjyB cKfUrgZo8PRdCh9uxlvm6nXRbkIGnAri4Mj5SJpYdnj+mWZRIUFLxo37q2Oqez9ApIfT nCDcv3tH2Pcm2+Vtlx7vSPUJx1n4njmBhouikYvxjjxwhyp940e3e7cf+m7zCD1nawjo I2S7+ljB1TkwqMuCzEoFka+DI78R2B7MQcycudH3ZOQvZDI+ksLw9KV1CiU6D+frYTF3 7jTWLUy/6gf8p7szIt2maPxiiIv5oJbeg313jbw6MFiD9erhVBQO+8WzkH2JDhFhFP03 ql4Q== X-Gm-Message-State: AMke39nQLgPNXAJ90llaInnk/XdOOwEIzD7r+3o+NXFPXef9Jf4dQtEyRf0LGCgF6iBtwr7V X-Received: by 10.200.48.174 with SMTP id v43mr18341765qta.263.1489120642947; Thu, 09 Mar 2017 20:37:22 -0800 (PST) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id n19sm5697731qtn.35.2017.03.09.20.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:37:21 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 16/41] drm/bridge: analogix_dp: Check AUX_EN status when doing AUX transfer Date: Thu, 9 Mar 2017 23:32:31 -0500 Message-Id: <20170310043305.17216-17-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310043305.17216-1-seanpaul@chromium.org> References: <20170310043305.17216-1-seanpaul@chromium.org> MIME-Version: 1.0 Cc: zain wang , Lin Huang , Tomeu Vizoso , Douglas Anderson , Yakir Yang , =?UTF-8?q?St=C3=A9phane=20Marchesin?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 */