From patchwork Thu Nov 26 07:47:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11932885 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAD81C63777 for ; Thu, 26 Nov 2020 07:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B3C92075A for ; Thu, 26 Nov 2020 07:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730850AbgKZHsP (ORCPT ); Thu, 26 Nov 2020 02:48:15 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35805 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730206AbgKZHsP (ORCPT ); Thu, 26 Nov 2020 02:48:15 -0500 X-Originating-IP: 80.104.176.17 Received: from uno.homenet.telecomitalia.it (host-80-104-176-17.retail.telecomitalia.it [80.104.176.17]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 2A3E61C0005; Thu, 26 Nov 2020 07:48:11 +0000 (UTC) From: Jacopo Mondi To: koji.matsuoka.xm@renesas.com, niklas.soderlund+renesas@ragnatech.se, laurent.pinchart@ideasonboard.com Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 1/2] media: rcar-vin: Remove unused macro Date: Thu, 26 Nov 2020 08:47:56 +0100 Message-Id: <20201126074757.2768-2-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201126074757.2768-1-jacopo+renesas@jmondi.org> References: <20201126074757.2768-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The VNCSI_IFMD_CSI_CHSEL_MASK is not used: remove it. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index f6e84fa29bce..378514a75bc2 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -137,7 +137,6 @@ #define VNCSI_IFMD_DES1 (1 << 26) #define VNCSI_IFMD_DES0 (1 << 25) #define VNCSI_IFMD_CSI_CHSEL(n) (((n) & 0xf) << 0) -#define VNCSI_IFMD_CSI_CHSEL_MASK 0xf /* Video n scaling control register (Gen3) */ #define VNUDS_CTRL_AMD (1 << 30) From patchwork Thu Nov 26 07:47:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11932887 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35886C64E75 for ; Thu, 26 Nov 2020 07:48:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E42E1206C0 for ; Thu, 26 Nov 2020 07:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731052AbgKZHsS (ORCPT ); Thu, 26 Nov 2020 02:48:18 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:36985 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730206AbgKZHsR (ORCPT ); Thu, 26 Nov 2020 02:48:17 -0500 X-Originating-IP: 80.104.176.17 Received: from uno.homenet.telecomitalia.it (host-80-104-176-17.retail.telecomitalia.it [80.104.176.17]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id D68981C0002; Thu, 26 Nov 2020 07:48:13 +0000 (UTC) From: Jacopo Mondi To: koji.matsuoka.xm@renesas.com, niklas.soderlund+renesas@ragnatech.se, laurent.pinchart@ideasonboard.com Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 2/2] media: rcar-vin: Mask VNCSI_IFMD register Date: Thu, 26 Nov 2020 08:47:57 +0100 Message-Id: <20201126074757.2768-3-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201126074757.2768-1-jacopo+renesas@jmondi.org> References: <20201126074757.2768-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The VNCSI_IFMD register controls the data expansion mode and the channel routing between the CSI-2 receivers and VIN instances. According to the chip manual revision 2.20 not all fields are available for all the SoCs: - V3M, V3H and E3 do not support the DES1 field has they do not feature a CSI20 receiver. - D3 only supports parallel input, and the whole register shall always be written as 0. Inspect the per-SoC channel routing table where the available CSI-2 instances are reported and configure VNCSI_IFMD accordingly. This patch upports the BSP change commit f54697394457 ("media: rcar-vin: Fix VnCSI_IFMD register access for r8a77990") Reviewed-by: Niklas Söderlund Suggested-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- drivers/media/platform/rcar-vin/rcar-dma.c | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 378514a75bc2..6397eea665d1 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -1570,7 +1570,9 @@ int rvin_dma_register(struct rvin_dev *vin, int irq) */ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel) { - u32 ifmd, vnmc; + const struct rvin_group_route *route; + u32 ifmd = 0; + u32 vnmc; int ret; ret = pm_runtime_get_sync(vin->dev); @@ -1583,9 +1585,26 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel) vnmc = rvin_read(vin, VNMC_REG); rvin_write(vin, vnmc & ~VNMC_VUP, VNMC_REG); - ifmd = VNCSI_IFMD_DES1 | VNCSI_IFMD_DES0 | VNCSI_IFMD_CSI_CHSEL(chsel); + /* + * Set data expansion mode to "pad with 0s" by inspecting the routes + * table to find out which bit fields are available in the IFMD + * register. IFMD_DES1 controls data expansion mode for CSI20/21, + * IFMD_DES0 controls data expansion mode for CSI40/41. + */ + for (route = vin->info->routes; route->mask; route++) { + if (route->csi == RVIN_CSI20 || route->csi == RVIN_CSI21) + ifmd |= VNCSI_IFMD_DES1; + else + ifmd |= VNCSI_IFMD_DES0; + + if (ifmd == (VNCSI_IFMD_DES0 | VNCSI_IFMD_DES1)) + break; + } - rvin_write(vin, ifmd, VNCSI_IFMD_REG); + if (ifmd) { + ifmd |= VNCSI_IFMD_CSI_CHSEL(chsel); + rvin_write(vin, ifmd, VNCSI_IFMD_REG); + } vin_dbg(vin, "Set IFMD 0x%x\n", ifmd);