From patchwork Mon Jan 16 10:08:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9518417 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 6DDF66020B for ; Mon, 16 Jan 2017 10:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39DB728364 for ; Mon, 16 Jan 2017 10:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2836928435; Mon, 16 Jan 2017 10:11:01 +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=-2.5 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, URIBL_BLACK autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B120628364 for ; Mon, 16 Jan 2017 10:10:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cT4Ff-0004Ux-3M; Mon, 16 Jan 2017 10:10:59 +0000 Received: from mail-pg0-f65.google.com ([74.125.83.65]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cT4EN-0000Ps-7T; Mon, 16 Jan 2017 10:09:41 +0000 Received: by mail-pg0-f65.google.com with SMTP id 75so5058413pgf.3; Mon, 16 Jan 2017 02:09:19 -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; bh=8PHJMPinGMDm9fisalupnqCEbZ3dPHWtqPlbsT6YTck=; b=uBQAGzalh4vVmB8FvQrJeIYe69MnoOXx8PRmf3rX7ruNd8najyKOZz/NjNyacGdfYi ikWH1T7dm36xumXCIH75o9oNfLein4LZaPkisRE0+wIuP32sdhaLy5r+9/aWbqsJ/MxT wHoyaTfwDBUqKHrDoBmrCoH6DHyp5kg6iAnyjniBmx1V427BNhfqv0fzB1lQ6wAFVHKI WaiARvGZcDNuEDdWgSwBmguCneY6I8r5bIY0LyqODrZJekksgiuJKxPkqotAydHktEIs nin3d+KYbFwDMy1MV9Dp/5aAi6ccDTHQB/NOBMr0Qdw6/jKgwpNUaxiulsDIoniAmN0z Lhfw== X-Gm-Message-State: AIkVDXKlkypL3NWtcUWoNpc182RnXk20tRAUIbM2wYWgRERMy9d3ebPpFmkTYHW11jh7yA== X-Received: by 10.84.177.129 with SMTP id x1mr48399648plb.75.1484561358805; Mon, 16 Jan 2017 02:09:18 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id k78sm46351848pfb.93.2017.01.16.02.09.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jan 2017 02:09:18 -0800 (PST) From: Chris Zhong To: dianders@chromium.org, tfiga@chromium.org, heiko@sntech.de, yzq@rock-chips.com, mark.rutland@arm.com, devicetree@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, pawel.moll@arm.com, seanpaul@chromium.org Subject: [PATCH v2 08/11] drm/rockchip/dsi: fix the issue can not send commands Date: Mon, 16 Jan 2017 18:08:28 +0800 Message-Id: <1484561311-494-9-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1484561311-494-1-git-send-email-zyw@rock-chips.com> References: <1484561311-494-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170116_020939_328345_3FB21D7D X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Chris Zhong , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xubilv , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: xubilv There is a bug in hdr_write function, the value from the caller will be overwritten, it cause the mipi can not send the correct command. And the MIPI_DSI_GENERIC_SHORT_WRITE_n_PARAM message type should be supported. Signed-off-by: xubilv Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 4ec82f6..4a2691c 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -572,10 +572,12 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) { int ret; + u32 sts; ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, !(val & GEN_CMD_FULL), 1000, + sts, !(sts & GEN_CMD_FULL), 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret < 0) { dev_err(dsi->dev, "failed to get available command FIFO\n"); return ret; @@ -584,8 +586,9 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) dsi_write(dsi, DSI_GEN_HDR, val); ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, val & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY), + sts, sts & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY), 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret < 0) { dev_err(dsi->dev, "failed to write command FIFO\n"); return ret; @@ -594,8 +597,8 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) return 0; } -static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, - const struct mipi_dsi_msg *msg) +static int dw_mipi_dsi_short_write(struct dw_mipi_dsi *dsi, + const struct mipi_dsi_msg *msg) { const u16 *tx_buf = msg->tx_buf; u32 val = GEN_HDATA(*tx_buf) | GEN_HTYPE(msg->type); @@ -609,13 +612,14 @@ static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, return dw_mipi_dsi_gen_pkt_hdr_write(dsi, val); } -static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, - const struct mipi_dsi_msg *msg) +static int dw_mipi_dsi_long_write(struct dw_mipi_dsi *dsi, + const struct mipi_dsi_msg *msg) { const u32 *tx_buf = msg->tx_buf; int len = msg->tx_len, pld_data_bytes = sizeof(*tx_buf), ret; u32 val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type); u32 remainder = 0; + u32 sts = 0; if (msg->tx_len < 3) { dev_err(dsi->dev, "wrong tx buf length %zu for long write\n", @@ -635,7 +639,7 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, } ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, !(val & GEN_PLD_W_FULL), 1000, + sts, !(sts & GEN_PLD_W_FULL), 1000, CMD_PKT_STATUS_TIMEOUT_US); if (ret < 0) { dev_err(dsi->dev, @@ -656,11 +660,15 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, switch (msg->type) { case MIPI_DSI_DCS_SHORT_WRITE: case MIPI_DSI_DCS_SHORT_WRITE_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: - ret = dw_mipi_dsi_dcs_short_write(dsi, msg); + ret = dw_mipi_dsi_short_write(dsi, msg); break; case MIPI_DSI_DCS_LONG_WRITE: - ret = dw_mipi_dsi_dcs_long_write(dsi, msg); + case MIPI_DSI_GENERIC_LONG_WRITE: + ret = dw_mipi_dsi_long_write(dsi, msg); break; default: dev_err(dsi->dev, "unsupported message type\n");