From patchwork Thu Nov 18 06:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 12693014 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62AB2C433F5 for ; Thu, 18 Nov 2021 06:36:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2842061221 for ; Thu, 18 Nov 2021 06:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2842061221 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=puri.sm Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=1YFBA1VpcYx4ogXwhRxbvcS1+ZOtPtF5n8v5+Y4/xt4=; b=HqURkiuWY9WvoX O/s1PHdQAMe9ZYXu5as61Y5sjpZX+3c4v8h8IHvZ2it91OYamLm2VHMQ+XdCsbzASJDC4xMLD1BZa 8ngK67TlEZXOYvStlyaG9RUEZbKlpEDPdE/RXvTaXgl4gSy0hc8axoGrLIuHpKVNAWUBt8X4b4nLv fKIHS71BCyoj4sUnrgV/FI5/2BktRm3DUvea0g+U5dK5TBM57fqTkEGB+7wS+bj+n1nxQS2vOVTCk 3WNeVwS7MTe2EJiSoLCgG4+va3AhoFJrarXgyImjJmgGfHzI4g4vufBARrxjivxfkc8unkQ9z7eWW cDtBGOYcb1hkRqO9zbNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnb0d-006zha-4P; Thu, 18 Nov 2021 06:34:59 +0000 Received: from comms.puri.sm ([159.203.221.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnb0Z-006zgu-1P for linux-arm-kernel@lists.infradead.org; Thu, 18 Nov 2021 06:34:56 +0000 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 8FE9ADF90B; Wed, 17 Nov 2021 22:34:23 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IPlzYpn1Qo5L; Wed, 17 Nov 2021 22:34:22 -0800 (PST) From: Martin Kepplinger To: martin.kepplinger@puri.sm, laurent.pinchart@ideasonboard.com, mchehab@kernel.org Cc: devicetree@vger.kernel.org, kernel@pengutronix.de, kernel@puri.sm, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, rmfrfs@gmail.com, robh@kernel.org, shawnguo@kernel.org Subject: [PATCH v2 1/2] media: imx: imx7-media-csi: add support for imx8mq Date: Thu, 18 Nov 2021 07:33:46 +0100 Message-Id: <20211118063347.3370678-1-martin.kepplinger@puri.sm> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_223455_100342_831D40B9 X-CRM114-Status: GOOD ( 16.24 ) 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 Modeled after the NXP driver mx6s_capture.c that this driver is based on, imx8mq needs different settings for the baseaddr_switch mechanism. Define the needed bits and set that for imx8mq. Without these settings, the system will "sometimes" hang completely when starting to stream (the interrupt will never be called). Signed-off-by: Martin Kepplinger Acked-by: Rui Miguel Silva Reported-by: kernel test robot --- revision history ---------------- v2: (thank you Rui and Laurent) * rename function and enum * remove unrealted newline * add Laurents reviewed tag to the bindings patch v1: https://lore.kernel.org/linux-media/20211117092710.3084034-1-martin.kepplinger@puri.sm/T/#t drivers/staging/media/imx/imx7-media-csi.c | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 2288dadb2683..1f3d9e27270d 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +123,10 @@ #define BIT_DATA_FROM_MIPI BIT(22) #define BIT_MIPI_YU_SWAP BIT(21) #define BIT_MIPI_DOUBLE_CMPNT BIT(20) +#define BIT_MASK_OPTION_FIRST_FRAME (0 << 18) +#define BIT_MASK_OPTION_CSI_EN (1 << 18) +#define BIT_MASK_OPTION_SECOND_FRAME (2 << 18) +#define BIT_MASK_OPTION_ON_DATA (3 << 18) #define BIT_BASEADDR_CHG_ERR_EN BIT(9) #define BIT_BASEADDR_SWITCH_SEL BIT(5) #define BIT_BASEADDR_SWITCH_EN BIT(4) @@ -154,6 +159,11 @@ #define CSI_CSICR18 0x48 #define CSI_CSICR19 0x4c +enum imx_csi_model { + IMX7_CSI_IMX7 = 0, + IMX7_CSI_IMX8MQ, +}; + struct imx7_csi { struct device *dev; struct v4l2_subdev sd; @@ -189,6 +199,8 @@ struct imx7_csi { bool is_csi2; struct completion last_eof_completion; + + enum imx_csi_model model; }; static struct imx7_csi * @@ -537,6 +549,16 @@ static void imx7_csi_deinit(struct imx7_csi *csi, clk_disable_unprepare(csi->mclk); } +static void imx7_csi_baseaddr_switch_on_second_frame(struct imx7_csi *csi) +{ + u32 cr18 = imx7_csi_reg_read(csi, CSI_CSICR18); + + cr18 |= BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL | + BIT_BASEADDR_CHG_ERR_EN; + cr18 |= BIT_MASK_OPTION_SECOND_FRAME; + imx7_csi_reg_write(csi, cr18, CSI_CSICR18); +} + static void imx7_csi_enable(struct imx7_csi *csi) { /* Clear the Rx FIFO and reflash the DMA controller. */ @@ -552,6 +574,9 @@ static void imx7_csi_enable(struct imx7_csi *csi) /* Enable the RxFIFO DMA and the CSI. */ imx7_csi_dmareq_rff_enable(csi); imx7_csi_hw_enable(csi); + + if (csi->model == IMX7_CSI_IMX8MQ) + imx7_csi_baseaddr_switch_on_second_frame(csi); } static void imx7_csi_disable(struct imx7_csi *csi) @@ -1155,6 +1180,8 @@ static int imx7_csi_probe(struct platform_device *pdev) if (IS_ERR(csi->regbase)) return PTR_ERR(csi->regbase); + csi->model = (enum imx_csi_model)of_device_get_match_data(&pdev->dev); + spin_lock_init(&csi->irqlock); mutex_init(&csi->lock); @@ -1249,8 +1276,9 @@ static int imx7_csi_remove(struct platform_device *pdev) } static const struct of_device_id imx7_csi_of_match[] = { - { .compatible = "fsl,imx7-csi" }, - { .compatible = "fsl,imx6ul-csi" }, + { .compatible = "fsl,imx8mq-csi", .data = (void *)IMX7_CSI_IMX8MQ }, + { .compatible = "fsl,imx7-csi", .data = (void *)IMX7_CSI_IMX7 }, + { .compatible = "fsl,imx6ul-csi", .data = (void *)IMX7_CSI_IMX7 }, { }, }; MODULE_DEVICE_TABLE(of, imx7_csi_of_match); From patchwork Thu Nov 18 06:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 12693015 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55015C433EF for ; Thu, 18 Nov 2021 06:36:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1A51661B31 for ; Thu, 18 Nov 2021 06:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1A51661B31 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=puri.sm Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:References:In-Reply-To: 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: List-Owner; bh=nI60xjhDhgzWoB/a9k5H3ZHd0+aGKfVxWZe8CIAJj0o=; b=3urQRskq5DxAjh 8v6w4AukX7A9I6dBu/d4F0VG1pZWYNoal6fon5fqQHtjYkyryIMxMC7LmYW5alf3tjARNgfMkLR9O lzXw978j6RriVGAQ4m9JztZNvo29nOpJ1bz0UWuSdbFdIc1yqUk6o2Qk8Qy4eZJMkspEzjaEhT44b TjKIFAnsNPDi/ppSEU3tGrbcNh4q/j8BJD2DXtS9xzvT5ikzY5OYGEWOyWfqktzb7/Vd+jOfOaSW9 irz2MYv62upylUID9bvka9BnwK1rHBRfPaBQ67DZCRae+gAi5icbs/sGqySppbONHZm604Y9P/kdO icFNjLVKwHIyi8D27qcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnb0o-006zjJ-Ea; Thu, 18 Nov 2021 06:35:10 +0000 Received: from comms.puri.sm ([159.203.221.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnb0a-006zhL-SJ for linux-arm-kernel@lists.infradead.org; Thu, 18 Nov 2021 06:34:58 +0000 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id AE80ADF722; Wed, 17 Nov 2021 22:34:26 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lI4L4XnOkeEm; Wed, 17 Nov 2021 22:34:26 -0800 (PST) From: Martin Kepplinger To: martin.kepplinger@puri.sm, laurent.pinchart@ideasonboard.com, mchehab@kernel.org Cc: devicetree@vger.kernel.org, kernel@pengutronix.de, kernel@puri.sm, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, rmfrfs@gmail.com, robh@kernel.org, shawnguo@kernel.org Subject: [PATCH v2 2/2] dt-bindings: media: document imx8mq support for imx7-csi Date: Thu, 18 Nov 2021 07:33:47 +0100 Message-Id: <20211118063347.3370678-2-martin.kepplinger@puri.sm> In-Reply-To: <20211118063347.3370678-1-martin.kepplinger@puri.sm> References: <20211118063347.3370678-1-martin.kepplinger@puri.sm> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_223456_926841_2FCE13E1 X-CRM114-Status: UNSURE ( 7.71 ) X-CRM114-Notice: Please train this message. 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 Add the fsl,imx8mq-csi compatible string to the bindings for nxp,imx7-csi. The i.MX8MQ SoC contains the same CSI bridge controller as the i.MX7. Signed-off-by: Martin Kepplinger Reviewed-by: Laurent Pinchart --- Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml b/Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml index 5922a2795167..4f7b78265336 100644 --- a/Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml +++ b/Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml @@ -17,6 +17,7 @@ properties: compatible: oneOf: - enum: + - fsl,imx8mq-csi - fsl,imx7-csi - fsl,imx6ul-csi - items: