From patchwork Mon Jan 24 15:22:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 12722307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37D91C433EF for ; Mon, 24 Jan 2022 15:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=laEddvlq/122Q15DcKmxiePfxUMqlA7CiWQsJDRkRsM=; b=NeITbQ3zhEmNxI wgneDlca3T4SVoSh9X+LolRwJDPg+/T56SHAR2pOxDtKLDgiu99Rpi8Jl9mRmjl+29iaenvxTfaAl OEs+q3C1WBZadH5gjzADLg2Q8axQbCxRAtZujAJmDxwdZXZYE2CtqX3vTUeWyFxEvau4HySUMl//F +SehoN2v7e/Gaik5856Mp/939QswxZlbkA/fFCrOiLRgJQCGk3w4TVqB5Nt4NG24868qKF6aLymZe 9xOumLxHf5NvxVGnfllhBcz3aLo3drC5kPBbVZF9u66Qpx6f9lg4s5c5zCMo/MGk8ir6PHPWu6kLl NMst5lSa64rLa587EAyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC1CH-003pCP-CU; Mon, 24 Jan 2022 15:23:57 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC1CC-003pBH-6Z for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 15:23:54 +0000 Received: by mail-wr1-x429.google.com with SMTP id i2so14249324wrb.12 for ; Mon, 24 Jan 2022 07:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HoCKTXe73b6LRfZ2yfJRg1I4/082DZV6wf8n+3iyv3U=; b=DXFMPQqZJ0tKT0e1GyjQjptwLQE+7cHPUKFQBr+FQZeLkkE77ifDs5YB3GOF2h2Seh bgVGO7FGtiVNy3Mg062PsxfHEv95vu/7FuDahESCUCJFO1xZnM5iGo1upx+/pmKrvaB6 CSUStL3QD1cOCq8v/QVMbsKXpJs2to+BaJ6sFHSy/sLvqdOxY9TIlA8KUI4Jrj4Zarux H3yY4uEjrAm5+t5Un+56XZMFQGrGxPIHVNdV9OMQtXbVEBu7Yd1EyCdR9Putf8JzYEQ7 7zdN+Tdh+rSzq6KW5FsWt+yw5LYnZnrdPn/KOiBaoshGM3xl5+rV4Szbq/KKk17PP89m 4qiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HoCKTXe73b6LRfZ2yfJRg1I4/082DZV6wf8n+3iyv3U=; b=25rUnfuxNIIvKJZoaFQc5qaxbd7gTv5Y5d6/4vSTlYG/6YzsESFvpD62OYqUgNYvqg ixYmGfEL6mgNzQpPvtstPKZSa5npgO8jRujkgW/ndehsfcNuX4FI4baVTs2oMa9hiZFr 8sn62TtiCc1o4tRBMH31eaisDCYXLthL4k4DTrYamNRyRhZQFgDYa3xBE8YHvRQdOGfq /0npJyZnJxYcTwutUS5sMEoFSy0irRJYQhcNFeziN3zae1EOVPJ+hvuTknB9cVnQGnoE GAF+Sj6nhRR3LoRR8yiRmFY9NNYoEQzs1uBvVLSFJylDMNVggyq1ZSr9fZ1xTFWCIXp2 7Ilw== X-Gm-Message-State: AOAM532SMcY44g/beSf8saQmPRZSLKI19mKctwkds/n6r4BI/VyByaW4 idShSVwss6seJYD9gKT2JiTGNg== X-Google-Smtp-Source: ABdhPJwuOAaYhLMRPNPmkmjib9G4ImRHpSjbxVDsSwkT8tECvG6c7seMPvA24tjBSCj5SaEJ5QMa9Q== X-Received: by 2002:a5d:544c:: with SMTP id w12mr1825656wrv.47.1643037828828; Mon, 24 Jan 2022 07:23:48 -0800 (PST) Received: from localhost.localdomain (179.160.117.78.rev.sfr.net. [78.117.160.179]) by smtp.gmail.com with ESMTPSA id p14sm3806868wmq.40.2022.01.24.07.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 07:23:48 -0800 (PST) From: Julien STEPHAN To: Cc: Julien STEPHAN , Mattijs Korpershoek , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR MEDIATEK), linux-mediatek@lists.infradead.org (moderated list:DRM DRIVERS FOR MEDIATEK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/mediatek: allow commands to be sent during video mode Date: Mon, 24 Jan 2022 16:22:50 +0100 Message-Id: <20220124152250.441809-1-jstephan@baylibre.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_072352_292261_F06C004E X-CRM114-Status: GOOD ( 15.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the DSI is in video mode, all commands are rejected. Detect current DSI mode in mtk_dsi_host_transfer() and switch modes temporarily to allow commands to be sent. Signed-off-by: Julien STEPHAN Signed-off-by: Mattijs Korpershoek --- drivers/gpu/drm/mediatek/mtk_dsi.c | 34 ++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 5d90d2eb0019..7d66fdc7f81d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -891,24 +891,34 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, u8 read_data[16]; void *src_addr; u8 irq_flag = CMD_DONE_INT_FLAG; - - if (readl(dsi->regs + DSI_MODE_CTRL) & MODE) { - DRM_ERROR("dsi engine is not command mode\n"); - return -EINVAL; + u32 dsi_mode; + + dsi_mode = readl(dsi->regs + DSI_MODE_CTRL); + if (dsi_mode & MODE) { + mtk_dsi_stop(dsi); + if (mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500)) { + recv_cnt = -EINVAL; + goto restore_dsi_mode; + } } if (MTK_DSI_HOST_IS_READ(msg->type)) irq_flag |= LPRX_RD_RDY_INT_FLAG; - if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0) - return -ETIME; + if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0) { + recv_cnt = -ETIME; + goto restore_dsi_mode; + } - if (!MTK_DSI_HOST_IS_READ(msg->type)) - return 0; + if (!MTK_DSI_HOST_IS_READ(msg->type)) { + recv_cnt = 0; + goto restore_dsi_mode; + } if (!msg->rx_buf) { DRM_ERROR("dsi receive buffer size may be NULL\n"); - return -EINVAL; + recv_cnt = -EINVAL; + goto restore_dsi_mode; } for (i = 0; i < 16; i++) @@ -933,6 +943,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n", recv_cnt, *((u8 *)(msg->tx_buf))); +restore_dsi_mode: + if (dsi_mode & MODE) { + mtk_dsi_set_mode(dsi); + mtk_dsi_start(dsi); + } + return recv_cnt; }