From patchwork Wed Jul 31 16:33:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=A9bastien_Szymanski?= X-Patchwork-Id: 11069113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CEAA746 for ; Wed, 31 Jul 2019 19:03:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2828726E3A for ; Wed, 31 Jul 2019 19:03:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 197CD26E40; Wed, 31 Jul 2019 19:03:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B06A26E3A for ; Wed, 31 Jul 2019 19:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728595AbfGaTDd (ORCPT ); Wed, 31 Jul 2019 15:03:33 -0400 Received: from 5.mo4.mail-out.ovh.net ([188.165.44.50]:38198 "EHLO 5.mo4.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfGaTDc (ORCPT ); Wed, 31 Jul 2019 15:03:32 -0400 X-Greylist: delayed 4199 seconds by postgrey-1.27 at vger.kernel.org; Wed, 31 Jul 2019 15:03:31 EDT Received: from player776.ha.ovh.net (unknown [10.108.57.226]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 3B4C31FC3F2 for ; Wed, 31 Jul 2019 18:33:47 +0200 (CEST) Received: from armadeus.com (lfbn-1-7591-179.w90-126.abo.wanadoo.fr [90.126.248.179]) (Authenticated sender: sebastien.szymanski@armadeus.com) by player776.ha.ovh.net (Postfix) with ESMTPSA id A3C58878DD52; Wed, 31 Jul 2019 16:33:28 +0000 (UTC) From: =?utf-8?q?S=C3=A9bastien_Szymanski?= To: Rui Miguel Silva , Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Steve Longerbeam , Philipp Zabel Cc: Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Greg Kroah-Hartman , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, =?utf-8?q?S=C3=A9bastien_Szymanski?= Subject: [PATCH v3 2/3] media: imx7-media-csi: add i.MX6UL support Date: Wed, 31 Jul 2019 18:33:30 +0200 Message-Id: <20190731163330.32532-1-sebastien.szymanski@armadeus.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 14045319867170182183 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrleehgddutdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support to imx7-media-csi driver. Signed-off-by: Sébastien Szymanski Reviewed-by: Rui Miguel Silva Reviewed-by: Fabio Estevam --- Changes for v3: - rebase on Linux v5.3-rc2 - remove csi_soc_id var as it's not needed anymore thanks to commit e0c76a7d3428 ("media: imx7-media-csi: get csi upstream endpoint") Changes for v2: - rebase on top of linuxtv/master - mention i.MX6UL/L in header and Kconfig help text - rename csi_type to csi_soc_id drivers/staging/media/imx/Kconfig | 4 +-- drivers/staging/media/imx/imx7-media-csi.c | 30 +++++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig index 4c726345dc25..f51476243016 100644 --- a/drivers/staging/media/imx/Kconfig +++ b/drivers/staging/media/imx/Kconfig @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI A video4linux camera sensor interface driver for i.MX5/6. config VIDEO_IMX7_CSI - tristate "i.MX7 Camera Sensor Interface driver" + tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver" depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C default y help Enable support for video4linux camera sensor interface driver for - i.MX7. + i.MX6UL/L or i.MX7. endmenu endif diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 500b4c08d967..4ca79ff4c9b3 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC + * V4L2 Capture CSI Subdev for Freescale i.MX6UL/L / i.MX7 SOC * * Copyright (c) 2019 Linaro Ltd * @@ -765,6 +765,7 @@ static int imx7_csi_configure(struct imx7_csi *csi) struct v4l2_pix_format *out_pix = &vdev->fmt.fmt.pix; __u32 in_code = csi->format_mbus[IMX7_CSI_PAD_SINK].code; u32 cr1, cr18; + int width = out_pix->width; if (out_pix->field == V4L2_FIELD_INTERLACED) { imx7_csi_deinterlace_enable(csi, true); @@ -774,15 +775,27 @@ static int imx7_csi_configure(struct imx7_csi *csi) imx7_csi_buf_stride_set(csi, 0); } - imx7_csi_set_imagpara(csi, out_pix->width, out_pix->height); + cr18 = imx7_csi_reg_read(csi, CSI_CSICR18); + + if (!csi->is_csi2) { + if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY || + out_pix->pixelformat == V4L2_PIX_FMT_YUYV) + width *= 2; + + imx7_csi_set_imagpara(csi, width, out_pix->height); + + cr18 |= (BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL | + BIT_BASEADDR_CHG_ERR_EN); + imx7_csi_reg_write(csi, cr18, CSI_CSICR18); - if (!csi->is_csi2) return 0; + } + + imx7_csi_set_imagpara(csi, width, out_pix->height); cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); cr1 &= ~BIT_GCLK_MODE; - cr18 = imx7_csi_reg_read(csi, CSI_CSICR18); cr18 &= BIT_MIPI_DATA_FORMAT_MASK; cr18 |= BIT_DATA_FROM_MIPI; @@ -817,11 +830,9 @@ static void imx7_csi_enable(struct imx7_csi *csi) { imx7_csi_sw_reset(csi); - if (csi->is_csi2) { - imx7_csi_dmareq_rff_enable(csi); - imx7_csi_hw_enable_irq(csi); - imx7_csi_hw_enable(csi); - } + imx7_csi_dmareq_rff_enable(csi); + imx7_csi_hw_enable_irq(csi); + imx7_csi_hw_enable(csi); } static void imx7_csi_disable(struct imx7_csi *csi) @@ -1302,6 +1313,7 @@ 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" }, { }, }; MODULE_DEVICE_TABLE(of, imx7_csi_of_match);