Received: by 10.223.176.5 with SMTP id f5csp1843610wra; Sun, 4 Feb 2018 13:35:17 -0800 (PST) X-Google-Smtp-Source: AH8x227i+iNTWp88G/CYookUYyXp0aURTGPQJvY8Ox9Cb9yg+18gWKNmdnKdylHGgFWkx5pJmibZ X-Received: by 10.99.163.92 with SMTP id v28mr9306526pgn.432.1517780117558; Sun, 04 Feb 2018 13:35:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517780117; cv=none; d=google.com; s=arc-20160816; b=LfjT2bm+isUE+40nvXtNVpN2mMZVpNMc62n1WQL3cYQK5qtE0ejcIdJF2FnOrdK6b0 u6OXwX7aPcLLj9hoBYIJTkm8imGSaHnb8pFHnVB4AC2gqFGKtgtJKAgAAVbicekoUuB9 /sySoj+aFhqv0zB3FSdCdr2BRcbcUiKrPOSEh9Hei8LU59g0kW8hEOnuGLKLOqAiKBVK lHpXKVJpL0Y2SrH6JBtjQfS9LJ0JplBRSy6ijpAov01a+FGn8wZWlZTyIv90aNZXRjJ8 SmufVvaphWn2gC2r29CS0GzPyqWPCXw9Q3iOX8Xu6QN7xZRFwCueUan8sGQQN5q6q23Y /tyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=exnO8dlfR858Tek4Eh4H5lkVSEPXFVOs/bxafbRtwoo=; b=x3EEe4F4kKFxA5++g6Ju0hUCFwEB3VTC6aFKwXSK3iUsFQbaxuK4AAlTh3iqzZqfay d7Xfy8o2naz28j2A+j2HMuQ7dPY68oTajWw9nFnlk5Z3iUCK/tOC19ecNtTMAcXuJay+ JalHch9iYWG0TuVNczLsBN5SB/2YQ5vofHHAIivJhucgBnNzKY65uRiEydVWlixG6+wb M96bAXD2bgtEhkbXxp1wf4wF/pjqgMewnHBVTo7VMy1C9t6CoeIFXs7JMukrY75Ha7CQ ykYASwAUNMGZLYjmv8h1d6OMY430bTg23gj9Ym/YBEmzhXiOJIRaKzpZ0YCM7z/HLgAc ojng== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22si5764699pfh.162.2018.02.04.13.35.02; Sun, 04 Feb 2018 13:35:17 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbeBDVc2 (ORCPT + 99 others); Sun, 4 Feb 2018 16:32:28 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:55983 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751724AbeBDVcV (ORCPT ); Sun, 4 Feb 2018 16:32:21 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w14LTBVd017327; Sun, 4 Feb 2018 22:31:43 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2fw3e279jq-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 04 Feb 2018 22:31:43 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AE57A31; Sun, 4 Feb 2018 21:31:42 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 797B3AAC5; Sun, 4 Feb 2018 21:31:42 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.44) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sun, 4 Feb 2018 22:31:42 +0100 Received: from localhost (10.129.5.167) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Sun, 4 Feb 2018 22:31:41 +0100 From: Philippe Cornu To: Archit Taneja , Andrzej Hajda , Laurent Pinchart , David Airlie , Philippe Cornu , Brian Norris , Benjamin Gaignard , Bhumika Goyal , , , "Sandy Huang" , Heiko Stubner , , CC: Yannick Fertre , Vincent Abriou , Alexandre Torgue Subject: [PATCH] drm/bridge/synopsys: dsi: Add read feature Date: Sun, 4 Feb 2018 22:31:04 +0100 Message-ID: <20180204213104.17834-1-philippe.cornu@st.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.129.5.167] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-04_05:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the DCS/GENERIC DSI read feature. Signed-off-by: Philippe Cornu --- Extra notes: DSI read tests have been performed with DCS & GENERIC, short & long commands, on two different panels. The maximum fifo size (32*32-bit = 128 bytes on stm32) has been verified too. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 58 +++++++++++++++++++++------ 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index e9422d05e897..65aeb3f78b48 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -397,18 +397,46 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, return dw_mipi_dsi_gen_pkt_hdr_write(dsi, le32_to_cpu(word)); } +static int dw_mipi_dsi_read(struct dw_mipi_dsi *dsi, + const struct mipi_dsi_msg *msg) +{ + int i, j, ret, len = msg->rx_len; + u8 *buf = msg->rx_buf; + u32 val; + + /* Wait end of the read operation */ + ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS, + val, !(val & GEN_RD_CMD_BUSY), + 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(dsi->dev, "Timeout during read operation\n"); + return ret; + } + + for (i = 0; i < len; i += 4) { + /* Read fifo must not be empty before all bytes are read */ + ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS, + val, !(val & GEN_PLD_R_EMPTY), + 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(dsi->dev, "Read payload FIFO is empty\n"); + return ret; + } + + val = dsi_read(dsi, DSI_GEN_PLD_DATA); + for (j = 0; j < 4 && j + i < len; j++) + buf[i + j] = val >> (8 * j); + } + + return ret; +} + static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, const struct mipi_dsi_msg *msg) { struct dw_mipi_dsi *dsi = host_to_dsi(host); struct mipi_dsi_packet packet; - int ret; - - if (msg->rx_buf || msg->rx_len) { - /* TODO dw drv improvements: implement read feature */ - dev_warn(dsi->dev, "read operations not yet implemented\n"); - return -EINVAL; - } + int ret, nb_bytes; ret = mipi_dsi_create_packet(&packet, msg); if (ret) { @@ -422,12 +450,16 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, if (ret) return ret; - /* - * TODO Only transmitted size is returned as actual driver does - * not support dcs/generic reads. Please update return value when - * delivering the read feature. - */ - return packet.size; + if (msg->rx_buf && msg->rx_len) { + ret = dw_mipi_dsi_read(dsi, msg); + if (ret) + return ret; + nb_bytes = msg->rx_len; + } else { + nb_bytes = packet.size; + } + + return nb_bytes; } static const struct mipi_dsi_host_ops dw_mipi_dsi_host_ops = { -- 2.15.1