From patchwork Thu Apr 19 10:17:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133724 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp613916edd; Thu, 19 Apr 2018 03:18:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+WbmBmojAjVc+poj+Gx1UeTTzXFrudiEyGz5ePV+YnsPVrOcKQoix0dLHuxALJaykid2rR X-Received: by 10.98.11.144 with SMTP id 16mr5294374pfl.228.1524133119825; Thu, 19 Apr 2018 03:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133119; cv=none; d=google.com; s=arc-20160816; b=wvqGvtRyhhhoHmjpoBFIO9ujhUAgkX1rXLMHtkuXZ8/Ia9Uv8KQ1MjFX4ZLwQAN02p 0IQ6SicbpZN2L3OfZDsdi6eG714x1NDslP4+Lq9rBHQrPAMLhf3H5LuRJ7+MBx28XD1N CTP95Md8c473fyyHe2t//PVGavYwaJjqvgb1dr81U8R6tn5EDE47/Ej5LREA1VmojM/T Id9hDmET7l9G4qdpjyJzv1QhOAIa1/qETEeRw4QKEBPaDdmy/2TgS0ADiTqF9/7OgUdt pJY72A6PVDdMXNWlWhKbv8gRN4MJWzRSxECXuH7IZ9b/MSJ82SmEoQ7Q6WV1RDhFINnn MBwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=08bBKUtNESQSDt5OM1Q2a3JZBU21dc6Vn6s1Corsylc=; b=jspi/P7lW8mmeSghXTdjTCovWcv/oTbuC56Dg/UBmCx5m93cZcWSd520rVMdYLTSh3 cj9rdARjqQSQY4+Czd/YRZRmpQGPVnVqTFBYBpLcrvigIgGYjjCzTMchktRs+ZJgyH+7 tarqyEWOIy8HAOttfMLdn4WW11Wl3D+OBDUhHDUYFkEzhGMq8T2ed8p/NgjoUFfNAmvk 2FCX1x26GBneBFak70kVH+ExBjxnKAhNGA0oGWggqbOE3KZoDpZMjpgo/CTXhhewZAW8 HbuOFWiBJZb2NaRDh/v5zGeSvhb8U+VtfoRM9Y4UxrNCEnksFKhdPOx+CQNx9LDfD2Ky rI4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i0dPO+3M; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.18.39; Thu, 19 Apr 2018 03:18:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i0dPO+3M; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751565AbeDSKSi (ORCPT + 5 others); Thu, 19 Apr 2018 06:18:38 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:45519 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbeDSKSg (ORCPT ); Thu, 19 Apr 2018 06:18:36 -0400 Received: by mail-wr0-f170.google.com with SMTP id u11-v6so12503109wri.12 for ; Thu, 19 Apr 2018 03:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=08bBKUtNESQSDt5OM1Q2a3JZBU21dc6Vn6s1Corsylc=; b=i0dPO+3MrzizJ0ZN9i5QauSNtgf7CS4CSr92fw7Sg6As3sqNw5tiGImbLC+SmDDm3s BVXeEguFQRt4X3RYGXV/bJ5TXERMqC98gpF0lkveUqSsiumwIZYm1nS0Xedop3wEo9ti UW/3ghHEZnk1bMM1ffAj5xsfSwtc8mnecfR+Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=08bBKUtNESQSDt5OM1Q2a3JZBU21dc6Vn6s1Corsylc=; b=dKWsG/pM5lvZ6SnR62ra1swbSXwz9PaAQ+o2L18pK3/D//azdvXxdT0mdCxRu1WzwC ee23sLC/8oPPHTLG854YVVvmbquyzyCsbq5E9WTorLvdCTjE3jEslOvz6IMPR07H3vRv paRVkTwFCvNXiQ7NbzRZJogZmYsQr3pgyCgfsBMNstc//+3hXAdHTy6pEuAJCwwitiXg ifSMc+ai+m9/+nVMvej9RaHKH21A/ywYcehE8dyrdFX7fh+bdearoThYddn+mn4lC81r lovE865FHctXsXj2FdA7vBIV4oHz9KBE+ge9M2tX1EJB+1ume/u2zLaKicgeHczu+ME3 6/2Q== X-Gm-Message-State: ALQs6tBsuavAvScVb5fKvEg+/mzBYVbir5pI7DSDvzyzrqcbIspFz8US JK4mi811i7QcdP+1D6O/rRlE/Q== X-Received: by 2002:adf:9cc5:: with SMTP id h5-v6mr4141617wre.11.1524133114148; Thu, 19 Apr 2018 03:18:34 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:18:33 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 02/15] media: staging/imx7: add imx7 CSI subdev driver Date: Thu, 19 Apr 2018 11:17:59 +0100 Message-Id: <20180419101812.30688-3-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This add the media entity subdevice and control driver for the i.MX7 CMOS Sensor Interface. Signed-off-by: Rui Miguel Silva --- drivers/staging/media/imx/Kconfig | 9 +- drivers/staging/media/imx/Makefile | 2 + drivers/staging/media/imx/imx7-media-csi.c | 1327 ++++++++++++++++++++ 3 files changed, 1337 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/media/imx/imx7-media-csi.c -- 2.17.0 diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig index bfc17de56b17..40a11f988fc6 100644 --- a/drivers/staging/media/imx/Kconfig +++ b/drivers/staging/media/imx/Kconfig @@ -11,7 +11,7 @@ config VIDEO_IMX_MEDIA driver for the i.MX5/6 SOC. if VIDEO_IMX_MEDIA -menu "i.MX5/6 Media Sub devices" +menu "i.MX5/6/7 Media Sub devices" config VIDEO_IMX_CSI tristate "i.MX5/6 Camera Sensor Interface driver" @@ -20,5 +20,12 @@ config VIDEO_IMX_CSI ---help--- A video4linux camera sensor interface driver for i.MX5/6. +config VIDEO_IMX7_CSI + tristate "i.MX7 Camera Sensor Interface driver" + depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C + default y + ---help--- + A video4linux camera sensor interface driver for i.MX7. + endmenu endif diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 698a4210316e..771846717146 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o + +obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c new file mode 100644 index 000000000000..167043869419 --- /dev/null +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -0,0 +1,1327 @@ +// SPDX-License-Identifier: GPL +/* + * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC + * + * Copyright (c) 2018 Linaro Ltd + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include "imx-media.h" + +#define IMX7_CSI_PAD_SINK 0 +#define IMX7_CSI_PAD_SRC 1 +#define IMX7_CSI_PADS_NUM 2 + +/* reset values */ +#define CSICR1_RESET_VAL 0x40000800 +#define CSICR2_RESET_VAL 0x0 +#define CSICR3_RESET_VAL 0x0 + +/* csi control reg 1 */ +#define BIT_SWAP16_EN BIT(31) +#define BIT_EXT_VSYNC BIT(30) +#define BIT_EOF_INT_EN BIT(29) +#define BIT_PRP_IF_EN BIT(28) +#define BIT_CCIR_MODE BIT(27) +#define BIT_COF_INT_EN BIT(26) +#define BIT_SF_OR_INTEN BIT(25) +#define BIT_RF_OR_INTEN BIT(24) +#define BIT_SFF_DMA_DONE_INTEN BIT(22) +#define BIT_STATFF_INTEN BIT(21) +#define BIT_FB2_DMA_DONE_INTEN BIT(20) +#define BIT_FB1_DMA_DONE_INTEN BIT(19) +#define BIT_RXFF_INTEN BIT(18) +#define BIT_SOF_POL BIT(17) +#define BIT_SOF_INTEN BIT(16) +#define BIT_MCLKDIV (0xF << 12) +#define BIT_HSYNC_POL BIT(11) +#define BIT_CCIR_EN BIT(10) +#define BIT_MCLKEN BIT(9) +#define BIT_FCC BIT(8) +#define BIT_PACK_DIR BIT(7) +#define BIT_CLR_STATFIFO BIT(6) +#define BIT_CLR_RXFIFO BIT(5) +#define BIT_GCLK_MODE BIT(4) +#define BIT_INV_DATA BIT(3) +#define BIT_INV_PCLK BIT(2) +#define BIT_REDGE BIT(1) +#define BIT_PIXEL_BIT BIT(0) + +#define SHIFT_MCLKDIV 12 + +/* control reg 3 */ +#define BIT_FRMCNT (0xFFFF << 16) +#define BIT_FRMCNT_RST BIT(15) +#define BIT_DMA_REFLASH_RFF BIT(14) +#define BIT_DMA_REFLASH_SFF BIT(13) +#define BIT_DMA_REQ_EN_RFF BIT(12) +#define BIT_DMA_REQ_EN_SFF BIT(11) +#define BIT_STATFF_LEVEL (0x7 << 8) +#define BIT_HRESP_ERR_EN BIT(7) +#define BIT_RXFF_LEVEL (0x7 << 4) +#define BIT_TWO_8BIT_SENSOR BIT(3) +#define BIT_ZERO_PACK_EN BIT(2) +#define BIT_ECC_INT_EN BIT(1) +#define BIT_ECC_AUTO_EN BIT(0) + +#define SHIFT_FRMCNT 16 +#define SHIFT_RXFIFO_LEVEL 4 + +/* csi status reg */ +#define BIT_ADDR_CH_ERR_INT BIT(28) +#define BIT_FIELD0_INT BIT(27) +#define BIT_FIELD1_INT BIT(26) +#define BIT_SFF_OR_INT BIT(25) +#define BIT_RFF_OR_INT BIT(24) +#define BIT_DMA_TSF_DONE_SFF BIT(22) +#define BIT_STATFF_INT BIT(21) +#define BIT_DMA_TSF_DONE_FB2 BIT(20) +#define BIT_DMA_TSF_DONE_FB1 BIT(19) +#define BIT_RXFF_INT BIT(18) +#define BIT_EOF_INT BIT(17) +#define BIT_SOF_INT BIT(16) +#define BIT_F2_INT BIT(15) +#define BIT_F1_INT BIT(14) +#define BIT_COF_INT BIT(13) +#define BIT_HRESP_ERR_INT BIT(7) +#define BIT_ECC_INT BIT(1) +#define BIT_DRDY BIT(0) + +/* csi control reg 18 */ +#define BIT_CSI_HW_ENABLE BIT(31) +#define BIT_MIPI_DATA_FORMAT_RAW8 (0x2a << 25) +#define BIT_MIPI_DATA_FORMAT_RAW10 (0x2b << 25) +#define BIT_MIPI_DATA_FORMAT_YUV422_8B (0x1e << 25) +#define BIT_MIPI_DATA_FORMAT_MASK (0x3F << 25) +#define BIT_MIPI_DATA_FORMAT_OFFSET 25 +#define BIT_DATA_FROM_MIPI BIT(22) +#define BIT_MIPI_YU_SWAP BIT(21) +#define BIT_MIPI_DOUBLE_CMPNT BIT(20) +#define BIT_BASEADDR_CHG_ERR_EN BIT(9) +#define BIT_BASEADDR_SWITCH_SEL BIT(5) +#define BIT_BASEADDR_SWITCH_EN BIT(4) +#define BIT_PARALLEL24_EN BIT(3) +#define BIT_DEINTERLACE_EN BIT(2) +#define BIT_TVDECODER_IN_EN BIT(1) +#define BIT_NTSC_EN BIT(0) + +#define CSI_MCLK_VF 1 +#define CSI_MCLK_ENC 2 +#define CSI_MCLK_RAW 4 +#define CSI_MCLK_I2C 8 + +#define CSI_CSICR1 0x0 +#define CSI_CSICR2 0x4 +#define CSI_CSICR3 0x8 +#define CSI_STATFIFO 0xC +#define CSI_CSIRXFIFO 0x10 +#define CSI_CSIRXCNT 0x14 +#define CSI_CSISR 0x18 + +#define CSI_CSIDBG 0x1C +#define CSI_CSIDMASA_STATFIFO 0x20 +#define CSI_CSIDMATS_STATFIFO 0x24 +#define CSI_CSIDMASA_FB1 0x28 +#define CSI_CSIDMASA_FB2 0x2C +#define CSI_CSIFBUF_PARA 0x30 +#define CSI_CSIIMAG_PARA 0x34 + +#define CSI_CSICR18 0x48 +#define CSI_CSICR19 0x4c + +struct imx7_csi { + struct device *dev; + struct imx_media_dev *md; + struct v4l2_subdev sd; + struct imx_media_video_dev *vdev; + struct media_pad pad[IMX7_CSI_PADS_NUM]; + + struct mutex lock; + spinlock_t irqlock; + + struct v4l2_subdev *src_sd; + + struct media_entity *sink; + + struct v4l2_fwnode_endpoint upstream_ep; + + struct v4l2_mbus_framefmt format_mbus[IMX7_CSI_PADS_NUM]; + const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; + struct v4l2_fract frame_interval[IMX7_CSI_PADS_NUM]; + + struct v4l2_ctrl_handler ctrl_hdlr; + + void __iomem *regbase; + int irq; + + struct clk *clk_disp_axi; + struct clk *clk_disp_dcic; + struct clk *clk_csi_mclk; + + /* active vb2 buffers to send to video dev sink */ + struct imx_media_buffer *active_vb2_buf[2]; + struct imx_media_dma_buf underrun_buf; + + int buf_num; + u32 frame_sequence; + + bool last_eof; + bool is_init; + bool is_streaming; + bool is_csi2; + + struct completion last_eof_completion; +}; + +#define imx7_csi_reg_read(_csi, _offset) __raw_readl(_csi->regbase + _offset) +#define imx7_csi_reg_write(_csi, _val, _offset) \ + __raw_writel(_val, _csi->regbase + _offset) + +static void imx7_csi_clk_enable(struct imx7_csi *csi) +{ + clk_prepare_enable(csi->clk_disp_axi); + clk_prepare_enable(csi->clk_disp_dcic); + clk_prepare_enable(csi->clk_csi_mclk); +} + +static void imx7_csi_clk_disable(struct imx7_csi *csi) +{ + clk_disable_unprepare(csi->clk_csi_mclk); + clk_disable_unprepare(csi->clk_disp_dcic); + clk_disable_unprepare(csi->clk_disp_axi); +} + +static void imx7_csi_hw_reset(struct imx7_csi *csi) +{ + imx7_csi_reg_write(csi, + imx7_csi_reg_read(csi, CSI_CSICR3) | BIT_FRMCNT_RST, + CSI_CSICR3); + + imx7_csi_reg_write(csi, CSICR1_RESET_VAL, CSI_CSICR1); + imx7_csi_reg_write(csi, CSICR2_RESET_VAL, CSI_CSICR2); + imx7_csi_reg_write(csi, CSICR3_RESET_VAL, CSI_CSICR3); +} + +static unsigned long imx7_csi_irq_clear(struct imx7_csi *csi) +{ + unsigned long isr; + + isr = imx7_csi_reg_read(csi, CSI_CSISR); + imx7_csi_reg_write(csi, isr, CSI_CSISR); + + return isr; +} + +static void imx7_csi_init_interface(struct imx7_csi *csi) +{ + unsigned int val = 0; + unsigned int imag_para; + + val = BIT_SOF_POL | BIT_REDGE | BIT_GCLK_MODE | BIT_HSYNC_POL | + BIT_FCC | 1 << SHIFT_MCLKDIV | BIT_MCLKEN; + imx7_csi_reg_write(csi, val, CSI_CSICR1); + + imag_para = (800 << 16) | 600; + imx7_csi_reg_write(csi, imag_para, CSI_CSIIMAG_PARA); + + val = BIT_DMA_REFLASH_RFF; + imx7_csi_reg_write(csi, val, CSI_CSICR3); +} + +static void imx7_csi_hw_enable_irq(struct imx7_csi *csi) +{ + unsigned long cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); + + cr1 |= BIT_SOF_INTEN; + cr1 |= BIT_RFF_OR_INT; + + /* still capture needs DMA interrupt */ + cr1 |= BIT_FB1_DMA_DONE_INTEN; + cr1 |= BIT_FB2_DMA_DONE_INTEN; + + cr1 |= BIT_EOF_INT_EN; + + imx7_csi_reg_write(csi, cr1, CSI_CSICR1); +} + +static void imx7_csi_hw_disable_irq(struct imx7_csi *csi) +{ + unsigned long cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); + + cr1 &= ~BIT_SOF_INTEN; + cr1 &= ~BIT_RFF_OR_INT; + cr1 &= ~BIT_FB1_DMA_DONE_INTEN; + cr1 &= ~BIT_FB2_DMA_DONE_INTEN; + cr1 &= ~BIT_EOF_INT_EN; + + imx7_csi_reg_write(csi, cr1, CSI_CSICR1); +} + +static void imx7_csi_hw_enable(struct imx7_csi *csi) +{ + unsigned long cr = imx7_csi_reg_read(csi, CSI_CSICR18); + + cr |= BIT_CSI_HW_ENABLE; + + imx7_csi_reg_write(csi, cr, CSI_CSICR18); +} + +static void imx7_csi_hw_disable(struct imx7_csi *csi) +{ + unsigned long cr = imx7_csi_reg_read(csi, CSI_CSICR18); + + cr &= ~BIT_CSI_HW_ENABLE; + + imx7_csi_reg_write(csi, cr, CSI_CSICR18); +} + +static void imx7_csi_dma_reflash(struct imx7_csi *csi) +{ + unsigned long cr3 = imx7_csi_reg_read(csi, CSI_CSICR18); + + cr3 = imx7_csi_reg_read(csi, CSI_CSICR3); + cr3 |= BIT_DMA_REFLASH_RFF; + imx7_csi_reg_write(csi, cr3, CSI_CSICR3); +} + +static void imx7_csi_rx_fifo_clear(struct imx7_csi *csi) +{ + unsigned long cr1; + + cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); + imx7_csi_reg_write(csi, cr1 & ~BIT_FCC, CSI_CSICR1); + cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); + imx7_csi_reg_write(csi, cr1 | BIT_CLR_RXFIFO, CSI_CSICR1); + + cr1 = imx7_csi_reg_read(csi, CSI_CSICR1); + imx7_csi_reg_write(csi, cr1 | BIT_FCC, CSI_CSICR1); +} + +static void imx7_csi_buf_stride_set(struct imx7_csi *csi, u32 stride) +{ + imx7_csi_reg_write(csi, stride, CSI_CSIFBUF_PARA); +} + +static void imx7_csi_deinterlace_enable(struct imx7_csi *csi, bool enable) +{ + unsigned long cr18 = imx7_csi_reg_read(csi, CSI_CSICR18); + + if (enable) + cr18 |= BIT_DEINTERLACE_EN; + else + cr18 &= ~BIT_DEINTERLACE_EN; + + imx7_csi_reg_write(csi, cr18, CSI_CSICR18); +} + +static void imx7_csi_dmareq_rff_enable(struct imx7_csi *csi) +{ + unsigned long cr3 = imx7_csi_reg_read(csi, CSI_CSICR3); + unsigned long cr2 = imx7_csi_reg_read(csi, CSI_CSICR2); + + /* Burst Type of DMA Transfer from RxFIFO. INCR16 */ + cr2 |= 0xC0000000; + + cr3 |= BIT_DMA_REQ_EN_RFF; + cr3 |= BIT_HRESP_ERR_EN; + cr3 &= ~BIT_RXFF_LEVEL; + cr3 |= 0x2 << 4; + + imx7_csi_reg_write(csi, cr3, CSI_CSICR3); + imx7_csi_reg_write(csi, cr2, CSI_CSICR2); +} + +static void imx7_csi_dmareq_rff_disable(struct imx7_csi *csi) +{ + unsigned long cr3 = imx7_csi_reg_read(csi, CSI_CSICR3); + + cr3 &= ~BIT_DMA_REQ_EN_RFF; + cr3 &= ~BIT_HRESP_ERR_EN; + imx7_csi_reg_write(csi, cr3, CSI_CSICR3); +} + +static void imx7_csi_set_imagpara(struct imx7_csi *csi, int width, int height) +{ + int imag_para = 0; + + imag_para = (width << 16) | height; + imx7_csi_reg_write(csi, imag_para, CSI_CSIIMAG_PARA); + + /* reflash the embedded DMA controller */ + imx7_csi_dma_reflash(csi); +} + +static void imx7_csi_sw_reset(struct imx7_csi *csi) +{ + imx7_csi_hw_disable(csi); + + imx7_csi_rx_fifo_clear(csi); + + imx7_csi_dma_reflash(csi); + + usleep_range(2000, 3000); + + imx7_csi_irq_clear(csi); + + imx7_csi_hw_enable(csi); +} + +static void imx7_csi_error_recovery(struct imx7_csi *csi) +{ + imx7_csi_hw_disable(csi); + + imx7_csi_rx_fifo_clear(csi); + + imx7_csi_dma_reflash(csi); + + imx7_csi_hw_enable(csi); +} + +static void imx7_csi_init(struct imx7_csi *csi) +{ + if (csi->is_init) + return; + + imx7_csi_clk_enable(csi); + imx7_csi_hw_reset(csi); + imx7_csi_init_interface(csi); + imx7_csi_dmareq_rff_enable(csi); + + csi->is_init = true; +} + +static void imx7_csi_deinit(struct imx7_csi *csi) +{ + if (!csi->is_init) + return; + + imx7_csi_hw_reset(csi); + imx7_csi_init_interface(csi); + imx7_csi_dmareq_rff_disable(csi); + imx7_csi_clk_disable(csi); + + csi->is_init = false; +} + +static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, + struct v4l2_fwnode_endpoint *ep, + bool skip_mux) +{ + struct device_node *endpoint, *port; + struct media_entity *src; + struct v4l2_subdev *sd; + struct media_pad *pad; + + if (!csi->src_sd) + return -EPIPE; + + src = &csi->src_sd->entity; + +skip_video_mux: + /* get source pad of entity directly upstream from src */ + pad = imx_media_find_upstream_pad(csi->md, src, 0); + if (IS_ERR(pad)) + return PTR_ERR(pad); + + sd = media_entity_to_v4l2_subdev(pad->entity); + + /* To get bus type we may need to skip video mux */ + if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { + src = &sd->entity; + goto skip_video_mux; + } + + /* + * NOTE: this assumes an OF-graph port id is the same as a + * media pad index. + */ + port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); + if (!port) + return -ENODEV; + + endpoint = of_get_next_child(port, NULL); + of_node_put(port); + if (!endpoint) + return -ENODEV; + + v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); + of_node_put(endpoint); + + return 0; +} + +static int imx7_csi_link_setup(struct media_entity *entity, + const struct media_pad *local, + const struct media_pad *remote, u32 flags) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct v4l2_subdev *remote_sd; + int ret = 0; + + dev_dbg(csi->dev, "link setup %s -> %s\n", remote->entity->name, + local->entity->name); + + mutex_lock(&csi->lock); + + if (local->flags & MEDIA_PAD_FL_SINK) { + if (!is_media_entity_v4l2_subdev(remote->entity)) { + ret = -EINVAL; + goto unlock; + } + + remote_sd = media_entity_to_v4l2_subdev(remote->entity); + + if (flags & MEDIA_LNK_FL_ENABLED) { + if (csi->src_sd) { + ret = -EBUSY; + goto unlock; + } + csi->src_sd = remote_sd; + } else { + csi->src_sd = NULL; + } + + goto init; + } + + /* source pad */ + if (flags & MEDIA_LNK_FL_ENABLED) { + if (csi->sink) { + ret = -EBUSY; + goto unlock; + } + csi->sink = remote->entity; + } else { + v4l2_ctrl_handler_free(&csi->ctrl_hdlr); + v4l2_ctrl_handler_init(&csi->ctrl_hdlr, 0); + csi->sink = NULL; + } + +init: + if (csi->sink || csi->src_sd) + imx7_csi_init(csi); + else + imx7_csi_deinit(csi); + +unlock: + mutex_unlock(&csi->lock); + + return 0; +} + +static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, + struct media_link *link, + struct v4l2_subdev_format *source_fmt, + struct v4l2_subdev_format *sink_fmt) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct v4l2_fwnode_endpoint upstream_ep; + int ret; + + ret = v4l2_subdev_link_validate_default(sd, link, source_fmt, sink_fmt); + if (ret) + return ret; + + ret = imx7_csi_get_upstream_endpoint(csi, &upstream_ep, true); + if (ret) { + v4l2_err(&csi->sd, "failed to find upstream endpoint\n"); + return ret; + } + + mutex_lock(&csi->lock); + + csi->upstream_ep = upstream_ep; + csi->is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2); + + mutex_unlock(&csi->lock); + + return ret; +} + +static void imx7_csi_update_buf(struct imx7_csi *csi, dma_addr_t phys, + int buf_num) +{ + if (buf_num == 1) + imx7_csi_reg_write(csi, phys, CSI_CSIDMASA_FB2); + else + imx7_csi_reg_write(csi, phys, CSI_CSIDMASA_FB1); +} + +static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) +{ + struct imx_media_video_dev *vdev = csi->vdev; + struct imx_media_buffer *buf; + struct vb2_buffer *vb2_buf; + dma_addr_t phys[2]; + int i; + + for (i = 0; i < 2; i++) { + buf = imx_media_capture_device_next_buf(vdev); + if (buf) { + csi->active_vb2_buf[i] = buf; + vb2_buf = &buf->vbuf.vb2_buf; + phys[i] = vb2_dma_contig_plane_dma_addr(vb2_buf, 0); + } else { + csi->active_vb2_buf[i] = NULL; + phys[i] = csi->underrun_buf.phys; + } + + imx7_csi_update_buf(csi, phys[i], i); + } +} + +static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi, + enum vb2_buffer_state return_status) +{ + struct imx_media_buffer *buf; + int i; + + /* return any remaining active frames with return_status */ + for (i = 0; i < 2; i++) { + buf = csi->active_vb2_buf[i]; + if (buf) { + struct vb2_buffer *vb = &buf->vbuf.vb2_buf; + + vb->timestamp = ktime_get_ns(); + vb2_buffer_done(vb, return_status); + } + } +} + +static void imx7_csi_vb2_buf_done(struct imx7_csi *csi) +{ + struct imx_media_video_dev *vdev = csi->vdev; + struct imx_media_buffer *done, *next; + struct vb2_buffer *vb; + dma_addr_t phys; + + done = csi->active_vb2_buf[csi->buf_num]; + if (done) { + done->vbuf.field = vdev->fmt.fmt.pix.field; + done->vbuf.sequence = csi->frame_sequence; + vb = &done->vbuf.vb2_buf; + vb->timestamp = ktime_get_ns(); + vb2_buffer_done(vb, VB2_BUF_STATE_DONE); + } + csi->frame_sequence++; + + /* get next queued buffer */ + next = imx_media_capture_device_next_buf(vdev); + if (next) { + phys = vb2_dma_contig_plane_dma_addr(&next->vbuf.vb2_buf, 0); + csi->active_vb2_buf[csi->buf_num] = next; + } else { + phys = csi->underrun_buf.phys; + csi->active_vb2_buf[csi->buf_num] = NULL; + } + + imx7_csi_update_buf(csi, phys, csi->buf_num); +} + +static irqreturn_t imx7_csi_irq_handler(int irq, void *data) +{ + struct imx7_csi *csi = data; + unsigned long status; + + spin_lock(&csi->irqlock); + + status = imx7_csi_irq_clear(csi); + + if (status & BIT_EOF_INT && csi->last_eof) { + complete(&csi->last_eof_completion); + csi->last_eof = false; + goto unlock; + } + + if (status & BIT_RFF_OR_INT) { + dev_warn(csi->dev, "Rx fifo overflow\n"); + imx7_csi_error_recovery(csi); + } + + if (status & BIT_HRESP_ERR_INT) { + dev_warn(csi->dev, "Hresponse error detected\n"); + imx7_csi_error_recovery(csi); + } + + if (status & BIT_ADDR_CH_ERR_INT) { + imx7_csi_hw_disable(csi); + + imx7_csi_dma_reflash(csi); + + imx7_csi_hw_enable(csi); + } + + if ((status & BIT_DMA_TSF_DONE_FB1) && + (status & BIT_DMA_TSF_DONE_FB2)) { + /* + * For both FB1 and FB2 interrupter bits set case, + * CSI DMA is work in one of FB1 and FB2 buffer, + * but software can not know the state. + * Skip it to avoid base address updated + * when csi work in field0 and field1 will write to + * new base address. + */ + } else if (status & BIT_DMA_TSF_DONE_FB1) { + csi->buf_num = 0; + } else if (status & BIT_DMA_TSF_DONE_FB2) { + csi->buf_num = 1; + } + + imx7_csi_vb2_buf_done(csi); + +unlock: + spin_unlock(&csi->irqlock); + + return IRQ_HANDLED; +} + +static int imx7_csi_dma_start(struct imx7_csi *csi) +{ + struct imx_media_video_dev *vdev = csi->vdev; + struct v4l2_pix_format *out_pix = &vdev->fmt.fmt.pix; + int ret; + + ret = imx_media_alloc_dma_buf(csi->md, &csi->underrun_buf, + out_pix->sizeimage); + if (ret < 0) + return ret; + + csi->frame_sequence = 0; + csi->last_eof = false; + init_completion(&csi->last_eof_completion); + + imx7_csi_setup_vb2_buf(csi); + + return 0; +} + +static void imx7_csi_dma_stop(struct imx7_csi *csi) +{ + unsigned long flags; + int ret; + + /* mark next EOF interrupt as the last before stream off */ + spin_lock_irqsave(&csi->irqlock, flags); + csi->last_eof = true; + spin_unlock_irqrestore(&csi->irqlock, flags); + + /* + * and then wait for interrupt handler to mark completion. + */ + ret = wait_for_completion_timeout(&csi->last_eof_completion, + msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT)); + if (ret == 0) + v4l2_warn(&csi->sd, "wait last EOF timeout\n"); + + imx7_csi_hw_disable_irq(csi); + + imx7_csi_dma_unsetup_vb2_buf(csi, VB2_BUF_STATE_ERROR); + + imx_media_free_dma_buf(csi->md, &csi->underrun_buf); +} + +static int imx7_csi_configure(struct imx7_csi *csi) +{ + struct imx_media_video_dev *vdev = csi->vdev; + struct v4l2_pix_format *out_pix = &vdev->fmt.fmt.pix; + u32 cr1, cr18; + u32 width; + + if (out_pix->field == V4L2_FIELD_INTERLACED) { + imx7_csi_deinterlace_enable(csi, true); + imx7_csi_buf_stride_set(csi, out_pix->width); + } else { + imx7_csi_deinterlace_enable(csi, false); + imx7_csi_buf_stride_set(csi, 0); + } + + switch (out_pix->pixelformat) { + case V4L2_PIX_FMT_YUV32: + case V4L2_PIX_FMT_SBGGR8: + width = out_pix->width; + break; + case V4L2_PIX_FMT_SBGGR10: + width = out_pix->width * 2; + break; + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YUYV: + if (csi->is_csi2) + width = out_pix->width; + else + width = out_pix->width * 2; + break; + default: + return -EINVAL; + } + + imx7_csi_set_imagpara(csi, width, out_pix->height); + + if (!csi->is_csi2) + return 0; + + 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; + + switch (out_pix->pixelformat) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YUYV: + cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B; + break; + case V4L2_PIX_FMT_SBGGR8: + cr18 |= BIT_MIPI_DATA_FORMAT_RAW8; + break; + case V4L2_PIX_FMT_SBGGR10: + cr18 |= BIT_MIPI_DATA_FORMAT_RAW10; + cr1 |= BIT_PIXEL_BIT; + break; + default: + return -EINVAL; + } + + imx7_csi_reg_write(csi, cr1, CSI_CSICR1); + imx7_csi_reg_write(csi, cr18, CSI_CSICR18); + + return 0; +} + +static int 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); + return 0; + } + + return 0; +} + +static void imx7_csi_disable(struct imx7_csi *csi) +{ + imx7_csi_dmareq_rff_disable(csi); + + imx7_csi_hw_disable_irq(csi); + + imx7_csi_buf_stride_set(csi, 0); + + imx7_csi_hw_disable(csi); +} + +static int imx7_csi_streaming_start(struct imx7_csi *csi) +{ + int ret; + + ret = imx7_csi_dma_start(csi); + if (ret < 0) + return ret; + + ret = imx7_csi_configure(csi); + if (ret < 0) + goto dma_stop; + + imx7_csi_enable(csi); + + return 0; + +dma_stop: + imx7_csi_dma_stop(csi); + + return ret; +} + +static int imx7_csi_streaming_stop(struct imx7_csi *csi) +{ + imx7_csi_dma_stop(csi); + + imx7_csi_disable(csi); + + return 0; +} + +static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + int ret = 0; + + mutex_lock(&csi->lock); + + if (!csi->src_sd || !csi->sink) { + ret = -EPIPE; + goto out_unlock; + } + + if (csi->is_streaming == !!enable) + goto out_unlock; + + if (enable) { + ret = v4l2_subdev_call(csi->src_sd, video, s_stream, 1); + if (ret < 0) + goto out_unlock; + + ret = imx7_csi_streaming_start(csi); + if (ret < 0) { + v4l2_subdev_call(csi->src_sd, video, s_stream, 0); + goto out_unlock; + } + } else { + imx7_csi_streaming_stop(csi); + + v4l2_subdev_call(csi->src_sd, video, s_stream, 0); + } + + csi->is_streaming = !!enable; + +out_unlock: + mutex_unlock(&csi->lock); + + return ret; +} + +static struct v4l2_mbus_framefmt *imx7_csi_get_format(struct imx7_csi *csi, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + enum v4l2_subdev_format_whence which) +{ + if (which == V4L2_SUBDEV_FORMAT_TRY) + return v4l2_subdev_get_try_format(&csi->sd, cfg, pad); + + return &csi->format_mbus[pad]; +} + +static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + const struct imx_media_pixfmt *in_cc; + struct v4l2_mbus_framefmt *in_fmt; + int ret = 0; + + mutex_lock(&csi->lock); + + in_fmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SINK, code->which); + + in_cc = imx_media_find_mbus_format(in_fmt->code, CS_SEL_ANY, true); + + switch (code->pad) { + case IMX7_CSI_PAD_SINK: + ret = imx_media_enum_mbus_format(&code->code, code->index, + CS_SEL_ANY, true); + break; + case IMX7_CSI_PAD_SRC: + if (code->index != 0) { + ret = -EINVAL; + goto out_unlock; + } + + code->code = in_fmt->code; + break; + default: + ret = -EINVAL; + } + +out_unlock: + mutex_unlock(&csi->lock); + + return ret; +} + +static int imx7_csi_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct v4l2_mbus_framefmt *fmt; + int ret = 0; + + if (sdformat->pad >= IMX7_CSI_PADS_NUM) + return -EINVAL; + + mutex_lock(&csi->lock); + + fmt = imx7_csi_get_format(csi, cfg, sdformat->pad, sdformat->which); + if (!fmt) { + ret = -EINVAL; + goto out_unlock; + } + + sdformat->format = *fmt; + +out_unlock: + mutex_unlock(&csi->lock); + + return ret; +} + +static void imx7_csi_try_fmt(struct imx7_csi *csi, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat, + const struct imx_media_pixfmt **cc) +{ + const struct imx_media_pixfmt *in_cc; + struct v4l2_mbus_framefmt *in_fmt; + u32 code; + + in_fmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SINK, + sdformat->which); + if (!in_fmt) + return; + + switch (sdformat->pad) { + case IMX7_CSI_PAD_SRC: + in_cc = imx_media_find_mbus_format(in_fmt->code, CS_SEL_ANY, + true); + + sdformat->format.width = in_fmt->width; + sdformat->format.height = in_fmt->height; + sdformat->format.code = in_fmt->code; + *cc = in_cc; + + sdformat->format.colorspace = in_fmt->colorspace; + sdformat->format.xfer_func = in_fmt->xfer_func; + sdformat->format.quantization = in_fmt->quantization; + sdformat->format.ycbcr_enc = in_fmt->ycbcr_enc; + break; + case IMX7_CSI_PAD_SINK: + *cc = imx_media_find_mbus_format(sdformat->format.code, + CS_SEL_ANY, true); + if (!*cc) { + imx_media_enum_mbus_format(&code, 0, CS_SEL_ANY, false); + *cc = imx_media_find_mbus_format(code, CS_SEL_ANY, + false); + sdformat->format.code = (*cc)->codes[0]; + } + + imx_media_fill_default_mbus_fields(&sdformat->format, in_fmt, + false); + break; + default: + break; + } +} + +static int imx7_csi_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct imx_media_video_dev *vdev = csi->vdev; + const struct imx_media_pixfmt *outcc; + struct v4l2_mbus_framefmt *outfmt; + struct v4l2_pix_format vdev_fmt; + const struct imx_media_pixfmt *cc; + struct v4l2_mbus_framefmt *fmt; + struct v4l2_subdev_format format; + int ret = 0; + + if (sdformat->pad >= IMX7_CSI_PADS_NUM) + return -EINVAL; + + mutex_lock(&csi->lock); + + if (csi->is_streaming) { + ret = -EBUSY; + goto out_unlock; + } + + imx7_csi_try_fmt(csi, cfg, sdformat, &cc); + + fmt = imx7_csi_get_format(csi, cfg, sdformat->pad, sdformat->which); + if (!fmt) { + ret = -EINVAL; + goto out_unlock; + } + + *fmt = sdformat->format; + + if (sdformat->pad == IMX7_CSI_PAD_SINK) { + /* propagate format to source pads */ + format.pad = IMX7_CSI_PAD_SRC; + format.which = sdformat->which; + format.format = sdformat->format; + imx7_csi_try_fmt(csi, cfg, &format, &outcc); + + outfmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SRC, + sdformat->which); + *outfmt = format.format; + + if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE) + csi->cc[IMX7_CSI_PAD_SRC] = outcc; + } + + if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) + goto out_unlock; + + csi->cc[sdformat->pad] = cc; + + /* propagate output pad format to capture device */ + imx_media_mbus_fmt_to_pix_fmt(&vdev_fmt, + &csi->format_mbus[IMX7_CSI_PAD_SRC], + csi->cc[IMX7_CSI_PAD_SRC]); + mutex_unlock(&csi->lock); + imx_media_capture_device_set_format(vdev, &vdev_fmt); + + return 0; + +out_unlock: + mutex_unlock(&csi->lock); + + return ret; +} + +static int imx7_csi_registered(struct v4l2_subdev *sd) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + int ret; + int i; + + csi->md = dev_get_drvdata(sd->v4l2_dev->dev); + + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { + csi->pad[i].flags = (i == IMX7_CSI_PAD_SINK) ? + MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; + + /* set a default mbus format */ + ret = imx_media_init_mbus_fmt(&csi->format_mbus[i], + 800, 600, 0, V4L2_FIELD_NONE, + &csi->cc[i]); + if (ret < 0) + return ret; + + /* init default frame interval */ + csi->frame_interval[i].numerator = 1; + csi->frame_interval[i].denominator = 30; + } + + ret = media_entity_pads_init(&sd->entity, IMX7_CSI_PADS_NUM, csi->pad); + if (ret < 0) + return ret; + + ret = imx_media_capture_device_register(csi->vdev); + if (ret < 0) + return ret; + + ret = imx_media_add_video_device(csi->md, csi->vdev); + if (ret < 0) { + imx_media_capture_device_unregister(csi->vdev); + return ret; + } + + return 0; +} + +static void imx7_csi_unregistered(struct v4l2_subdev *sd) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + + imx_media_capture_device_unregister(csi->vdev); +} + +static int imx7_csi_init_cfg(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg) +{ + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct v4l2_mbus_framefmt *mf; + int ret; + int i; + + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { + mf = v4l2_subdev_get_try_format(sd, cfg, i); + + ret = imx_media_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, + &csi->cc[i]); + if (ret < 0) + return ret; + } + + return 0; +} + +static const struct media_entity_operations imx7_csi_entity_ops = { + .link_setup = imx7_csi_link_setup, + .link_validate = v4l2_subdev_link_validate, +}; + +static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { + .s_stream = imx7_csi_s_stream, +}; + +static const struct v4l2_subdev_pad_ops imx7_csi_pad_ops = { + .init_cfg = imx7_csi_init_cfg, + .enum_mbus_code = imx7_csi_enum_mbus_code, + .get_fmt = imx7_csi_get_fmt, + .set_fmt = imx7_csi_set_fmt, + .link_validate = imx7_csi_pad_link_validate, +}; + +static const struct v4l2_subdev_ops imx7_csi_subdev_ops = { + .video = &imx7_csi_video_ops, + .pad = &imx7_csi_pad_ops, +}; + +static const struct v4l2_subdev_internal_ops imx7_csi_internal_ops = { + .registered = imx7_csi_registered, + .unregistered = imx7_csi_unregistered, +}; + +static int imx7_csi_parse_endpoint(struct device *dev, + struct v4l2_fwnode_endpoint *vep, + struct v4l2_async_subdev *asd) +{ + return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; +} + +static int imx7_csi_parse_dt(struct imx7_csi *csi) +{ + struct device *dev = csi->dev; + + csi->clk_disp_axi = devm_clk_get(dev, "axi"); + if (IS_ERR(csi->clk_disp_axi)) { + dev_err(dev, "Could not get csi axi clock\n"); + return -ENODEV; + } + + csi->clk_disp_dcic = devm_clk_get(dev, "dcic"); + if (IS_ERR(csi->clk_disp_dcic)) { + dev_err(dev, "Could not get disp dcic clock\n"); + return -ENODEV; + } + + csi->clk_csi_mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(csi->clk_csi_mclk)) { + dev_err(dev, "Could not get csi mclk clock\n"); + return -ENODEV; + } + + return 0; +} + +static int imx7_csi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct imx7_csi *csi; + struct resource *res; + int ret; + + csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); + if (!csi) + return -ENOMEM; + + platform_set_drvdata(pdev, &csi->sd); + csi->dev = dev; + + ret = imx7_csi_parse_dt(csi); + if (ret < 0) + return -ENODEV; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + csi->irq = platform_get_irq(pdev, 0); + if (!res || csi->irq < 0) { + dev_err(dev, "Missing platform resources data\n"); + return -ENODEV; + } + + csi->regbase = devm_ioremap_resource(dev, res); + if (IS_ERR(csi->regbase)) { + dev_err(dev, "Failed platform resources map\n"); + return -ENODEV; + } + + spin_lock_init(&csi->irqlock); + mutex_init(&csi->lock); + + /* install interrupt handler */ + ret = devm_request_irq(dev, csi->irq, imx7_csi_irq_handler, 0, "csi", + (void *)csi); + if (ret < 0) { + dev_err(dev, "Request CSI IRQ failed.\n"); + return -ENODEV; + } + + v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); + v4l2_set_subdevdata(&csi->sd, csi); + csi->sd.internal_ops = &imx7_csi_internal_ops; + csi->sd.entity.ops = &imx7_csi_entity_ops; + csi->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + csi->sd.dev = &pdev->dev; + csi->sd.owner = THIS_MODULE; + csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + csi->sd.grp_id = IMX_MEDIA_GRP_ID_CSI0; + snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); + + csi->vdev = imx_media_capture_device_init(&csi->sd, IMX7_CSI_PAD_SRC); + if (IS_ERR(csi->vdev)) + return PTR_ERR(csi->vdev); + + v4l2_ctrl_handler_init(&csi->ctrl_hdlr, 0); + csi->sd.ctrl_handler = &csi->ctrl_hdlr; + + ret = v4l2_async_register_fwnode_subdev(&csi->sd, + sizeof(struct v4l2_async_subdev), + NULL, 0, imx7_csi_parse_endpoint); + if (ret) + goto free; + + return 0; + +free: + v4l2_ctrl_handler_free(&csi->ctrl_hdlr); + mutex_destroy(&csi->lock); + imx_media_capture_device_remove(csi->vdev); + + return ret; +} + +static int imx7_csi_remove(struct platform_device *pdev) +{ + return 0; +} + +static const struct of_device_id imx7_csi_of_match[] = { + { .compatible = "fsl,imx7-csi" }, + { }, +}; +MODULE_DEVICE_TABLE(of, imx7_csi_of_match); + +static struct platform_driver imx7_csi_driver = { + .probe = imx7_csi_probe, + .remove = imx7_csi_remove, + .driver = { + .of_match_table = imx7_csi_of_match, + .name = "imx7-csi", + }, +}; +module_platform_driver(imx7_csi_driver); + +MODULE_DESCRIPTION("i.MX7 CSI subdev driver"); +MODULE_AUTHOR("Rui Miguel Silva "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:imx7-csi"); From patchwork Thu Apr 19 10:18:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133729 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614134edd; Thu, 19 Apr 2018 03:18:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RqFDX1T8z6028OtCjNvGgcIV6c+PYcvS9E+DgUJsKa5zypnn6ase3vvPiNGY9y8/RHKJO X-Received: by 10.98.55.69 with SMTP id e66mr5270750pfa.253.1524133135395; Thu, 19 Apr 2018 03:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133135; cv=none; d=google.com; s=arc-20160816; b=nVQrexTkB02H0ylZTZ1fq+9LM78YQaYhS+Bb38SRR80bckIJpejx8aJmK7Ntb3MIlK hxFAwFfMFJVm8wS3ESfpXwF1Z1mCW8neDXK2CqVDHuh25q7N3BIewEA3IZEywP5LCXIQ PYPSj6HdmkV50lZiC6y/RrHQmv/QSYrYXSyWU7P3M2/88pM8YEEDTlL0Arj9dvO9xXmD R41ocmcMfRR8Z0JFRw+5BfV/KNDWTpUzWhah6MV0yBbJyGQcVOlAjIaEJw92nodXZU1h idb69qClZoqWNtIzOPx3xMPOxyGyTToDsSxXRaLEQZDpPJDO8aYBjJOMHWjUkO6rEW/l iZkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8pAz7BwzBIQmxPnVeJD2tvstpcSv8T02ZpF0zxewmRE=; b=XXpZvWQedIUaRAj80HhdOWmUGejbTNYQBB0SFIuuwTywCLIeZdeuVz99tH3Pz3CPRA KvvcdA1R+iZ3uhDKmZW6z4XL5jEyp6BcsD+NPMtPYm1h8CUSsdOsxiEDmJJlm2CFxIuC UyJ0V2d4YGddMkFfFzWve3mYJBUJBBkEZfLgnMsBfLZpdijbOOrYiPcHweAKvOfakFNJ 7o4W7vJS9kfhNjT5TL5FYrDjNI7J0RJDc8wTPueYH07MbCohe6v0ww8yBUVDTKYuBtby 2P7qbJISvslLCEAV8upAHcR73+rltJsmjAdXV67ro7qEW2U/kBBmuUZfwwbLpV0yknKu 48/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FNX7N828; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.18.55; Thu, 19 Apr 2018 03:18:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FNX7N828; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbeDSKSw (ORCPT + 5 others); Thu, 19 Apr 2018 06:18:52 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35265 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbeDSKSu (ORCPT ); Thu, 19 Apr 2018 06:18:50 -0400 Received: by mail-wr0-f194.google.com with SMTP id w3-v6so12520401wrg.2 for ; Thu, 19 Apr 2018 03:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8pAz7BwzBIQmxPnVeJD2tvstpcSv8T02ZpF0zxewmRE=; b=FNX7N828dhMTAVFGmyAkH7RUND2d1G5RckD8iTw45aGOFmFDTSMszCUP9TJqxJVu5s ZywVI5dcNc0mLbbH6wM9EDG4RHEPC0bWZcuyowrNFFY1EYFN3SuJ3sEUj+eeJuql5BrJ DHxtoBlg8BUlnnEoNLfAEnZFBzGhfyOostk/A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8pAz7BwzBIQmxPnVeJD2tvstpcSv8T02ZpF0zxewmRE=; b=KkPVlPGEPUkCMlwMOJb/uw+nnEqV1nxVAx2c2StGjOEAsXWAES7VAQwhPuSMQegc17 JeSm9akACoWAW9DvWskfN4RwRc59tgRAbWKXqjD8piMX3BMhbqnffNmkqCb7RstjY1ap eBNnSTfRIQQC40yFJSBBjspl02QD81UlD8fW427PsDlrllUjTXZHvkFT8VZ7t0FjtgX3 Zs6DQRjen969vVMq8Nxc9yk+Q+lc1sSoVUIEdXlM0PCySLQiKIoFSYXrUYRc+Oit4sx+ EOfzypG9i6Zc2We4JZg0hW/5eL34Ek9tMtLAdcOX//l6Fe5IM/4PpSBBmk7ionX5Cn15 2K0w== X-Gm-Message-State: ALQs6tAXWLk2H/DmM7deLkjpRliKIGA0k5f5MvTUDB9E/4sGKU4bEo7t 307Jk4IorZOJZ7v0AYmDSdsNCw== X-Received: by 10.28.129.148 with SMTP id c142mr4003618wmd.103.1524133128917; Thu, 19 Apr 2018 03:18:48 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:18:48 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 07/15] media: staging/imx: add 10 bit bayer support Date: Thu, 19 Apr 2018 11:18:04 +0100 Message-Id: <20180419101812.30688-8-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some sensors can only output 10 bit bayer formats, like the OV2680. Add support for that in imx-media. Signed-off-by: Rui Miguel Silva --- drivers/staging/media/imx/imx-media-utils.c | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.17.0 diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index fab98fc0d6a0..99527daba29a 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -118,6 +118,30 @@ static const struct imx_media_pixfmt rgb_formats[] = { .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR10, + .codes = {MEDIA_BUS_FMT_SBGGR10_1X10}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG10, + .codes = {MEDIA_BUS_FMT_SGBRG10_1X10}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG10, + .codes = {MEDIA_BUS_FMT_SGRBG10_1X10}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB10, + .codes = {MEDIA_BUS_FMT_SRGGB10_1X10}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR16, .codes = { From patchwork Thu Apr 19 10:18:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133730 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614156edd; Thu, 19 Apr 2018 03:18:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MdWtJ9xooks6gBFmC4/NHxNA4tm7in/a6vMeQGW+AldVXI0C5lrfBjiY1Vw0IRzrtlKZO X-Received: by 10.99.95.130 with SMTP id t124mr4721048pgb.150.1524133136370; Thu, 19 Apr 2018 03:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133136; cv=none; d=google.com; s=arc-20160816; b=gVCNecVN41Vd1vOY7DE9qdfDOy4KnOMg3KRmTLgJzk2+WYg8gBer0IRyeejEptM2FS tVNoYtPlcy7vMKOG+cXASI5HeqAcAc/NywiVI2PnjW53VrcPBHKrxZn1Cg+I8RGQEbL1 e02dMqaz+co29t6maMBlV2svi4KlqkyWJwMF1XKmrzpdWFZxkwW5rLQrcSFSBgHRxZes ONceGQHRma/pMprZQV2F/oy25Cwxm5oKJmtvaf4FMzpkpMZs4LHtEKjmXzvhzAKHXmoU cqyKgCIoueRddkcFPV6XyIPLyfJXOH86m5KO1Gw1zjjf6z1VWnVg/S44isc4Z71e77qC 68WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iYeH3velqK4JMtXvVYuTWojZ5yd9g77mW6Ku0eB1P38=; b=gEcLq9CpTSSLBKIsLXzJ3bcWgKYXlaR2TWEvicILjBKwhTfi20zpHTEJXAoP8eH1z3 E5IWajhwD6Oiw+hEIoDe2fFS8L4eonFUoZnTma4rbBpgAs4+NommqXPbfnyOHxxUdch5 OofigwhDnqKbSi2hvvRkFL6QReuyACIDjv+8M5BibWriUgFeUejUhWCvhASE1uiXIx7E sS+qnQI4MGHTpF/NKYfNtqlvcHKw8+8c3FABSyALtQA5zPejxIPKQ91s7zKym0w1hyJ4 ArW00KrHFt1mP2uJbC1DWNXFx7f81r2JozMYuw9ROwSI6/zNZG3s+qvOcXo3l7Yjziz6 jDRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QWhLmIx2; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.18.56; Thu, 19 Apr 2018 03:18:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QWhLmIx2; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752245AbeDSKSy (ORCPT + 5 others); Thu, 19 Apr 2018 06:18:54 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40783 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbeDSKSw (ORCPT ); Thu, 19 Apr 2018 06:18:52 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so12507293wrc.7 for ; Thu, 19 Apr 2018 03:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iYeH3velqK4JMtXvVYuTWojZ5yd9g77mW6Ku0eB1P38=; b=QWhLmIx2AeKL9xE2bgyNQEx0mf/n1bPwRXRqfZGf7U6i7Vmj/zsL0lZFQkHq2aoCwf 8SiSUPxGh4UBWOJpDkUWSRrwT5/EK/iWT7Y9QrIRH0EilkIaFtcOpZuJYmuT30NRfcRz DfN206Ge0HvRmIPTmmK+E870hOrtNFm9nJtYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iYeH3velqK4JMtXvVYuTWojZ5yd9g77mW6Ku0eB1P38=; b=fv8af6xUFGNx+kb2/Ve+OWQW8pLAXCENi05V4eoeTxC0e2Tui28im+0Dg1xINsF3N9 RRW16A0u44SlbbetpF7XV2kRGnMYY+aOjb1dZNkQmKVMYMYmyPqAvP8qSnFUjPnkYXYL QsXqsjrv9vCJjqqwgTEE3uRh5Qzgf/ddwu4+psQItzseR87CVYLmHWMW85rEgGx4mP3V 0GgeKRL/gyHtV1ITlL/UIYw6ac8UErrQFq2OBajOnCSEdvHZfH9+jPAgK724GT2VMQUi aMp4yT5WHe2PgjNvpvehtP1dxXV3flcvLigUc5IKWXXGDlSkdSunwCzd3jZSi9VBdSHD 0MFg== X-Gm-Message-State: ALQs6tB9b8ATMwVY5bQHGTXnY4Kuxh+YiUnEzqjkSGzV6FGQ8aXdi8wc rK69e+tBRiuEf9jhNgMEY+qIpg== X-Received: by 10.28.135.9 with SMTP id j9mr4371385wmd.68.1524133131455; Thu, 19 Apr 2018 03:18:51 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:18:50 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 08/15] ARM: dts: increase default cma size to 40MB Date: Thu, 19 Apr 2018 11:18:05 +0100 Message-Id: <20180419101812.30688-9-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To support camera in i.MX7 the cma heap is used to allocate frame buffers. The default size of CMA is 16MB which is not enough for higher resolutions (ex: 1600x1200). So, increase the default CMA size to 40MB. Signed-off-by: Rui Miguel Silva --- arch/arm/boot/dts/imx7s.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.17.0 diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi index 4d42335c0dee..142ea709d296 100644 --- a/arch/arm/boot/dts/imx7s.dtsi +++ b/arch/arm/boot/dts/imx7s.dtsi @@ -182,6 +182,20 @@ ; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* global autoconfigured region for contiguous allocations */ + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x2800000>; + linux,cma-default; + }; + }; + soc { #address-cells = <1>; #size-cells = <1>; From patchwork Thu Apr 19 10:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133732 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614241edd; Thu, 19 Apr 2018 03:19:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/86Vpi7ROtlTJJmF0HMuFus9k/sfDJPZSh+zxhdBGSCXw6IhXvm5+Szqc9CTtIdXB1ApYY X-Received: by 2002:a17:902:265:: with SMTP id 92-v6mr5427823plc.368.1524133141187; Thu, 19 Apr 2018 03:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133141; cv=none; d=google.com; s=arc-20160816; b=LcP26rf97i2Bl0yqZJJKAPDTOn/g3Rc3//JUQy7XmyI0/HYz+KoRSbkIkSv4XK4L5b hB+npByJIyusVBHlCTFqF8IY8fF5wZzWYZrmj9AiyUvO96hWQUbCpIE1bg4ZLV/d7A0s aWcVNl8S0SjLUKjLz1M4Ko+RIb+GBPIE/niAQVtrHckjEXWmteXWbu+8LOTn76TVDUHh Y8penJhX+WL9dELMHRXSnc8UePU7fm695SG6ZO3MpF6mmXclK8mhxNbEBnci1fhH9H2W Wz7X31BmYAYmS4r4kd9zgsW6M8ncsptxS6NWoW2PxtX5dwEDQfCCHv+Cnhx/2RrVImMq LyyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OEt0xlEacP/3Wq23BkPMp22Uuxu67D8c9piS3omUFA0=; b=Xry7zuYWGZbT1Qq//9VZkDyjxFQK5/sfCtvaNc4ZaI/ecDFbhkwhvyDhmype7Ue9Fy i/zoRVivxm67VXLWLG0FE3iIW9VTR1iQmTU4rgdczmTrIHvKthDHQMEWFgNv8XSgJ97j bWIYYQcPZ2m0gKSb4KEuG7lu0YB7hO31qGGzwJGfHLX8M5WnRk+/ofx38NjSgspcI3eY 2v3FJhe6oXtkLuHzgOpgy3ZK7WpVUxkBeP1gr1RNSirlVi+q9iLt7OCE4+gmfRP9sC3H 5lgU3IztwIRwl4Z0O+qjxa9BXrBQXmshvpnNZK94ZLkbtygtBacI7bvZhpL0csa4JyZh xxwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xwphmr9t; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.00; Thu, 19 Apr 2018 03:19:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xwphmr9t; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbeDSKS7 (ORCPT + 5 others); Thu, 19 Apr 2018 06:18:59 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36411 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbeDSKS5 (ORCPT ); Thu, 19 Apr 2018 06:18:57 -0400 Received: by mail-wr0-f193.google.com with SMTP id q13-v6so12538224wre.3 for ; Thu, 19 Apr 2018 03:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OEt0xlEacP/3Wq23BkPMp22Uuxu67D8c9piS3omUFA0=; b=Xwphmr9tcoaSyjLYHl8znq+PzmCAt5pXhhR96mDPwwSoxkMovIWP46AGKtDCxbu1+j DPdpOPz0aLUvHz+wnppzQp/PXM8vyNiUaUpmeCAyJYFQhqH4DnB5jXwhshWimOUY/m5g +F40cwguTnfFDo/aHJIcPDkT0EP+uNUebAg4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OEt0xlEacP/3Wq23BkPMp22Uuxu67D8c9piS3omUFA0=; b=BXglPiFbqlG8eqlhAEfsxW/+pqNjuIr563wnbo46m9ob9Vmwi1pdaY56ga5hXcE7H0 ztJYQkbzK6GOXqlYqN/30eQsamXEFeKUeRhdImB4rHk8zDTN1zUCF1J1COAkvHtFJLcO hYbG4agD14etbRGULGfFbXvZ5OreCr5X6AfkBN10ZVbhgJQ6enML0gTHnbHK1HdwsfvU sjV2WmT/MN1HYgWwv1aFgZ7jWpesOEZYVMqxhQZQ51xUBSoYXOMgMjTNzBCODax4EzO+ HYWLI1i87ofhCiEogVRil+lZJdtKFL1HTYpNev7yNefGtzGpBlYS4P/mnNTlfYXfST4t dtyw== X-Gm-Message-State: ALQs6tBxts2dkkQTLDpMzEloThp5eTIANn7JGx4N1Xrw8tehSmL9hTR7 CTLXR73DxpHPcxOnpihtJpHXZA== X-Received: by 10.28.41.133 with SMTP id p127mr4433434wmp.0.1524133136246; Thu, 19 Apr 2018 03:18:56 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:18:55 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 10/15] ARM: dts: imx7s: add mipi phy power domain Date: Thu, 19 Apr 2018 11:18:07 +0100 Message-Id: <20180419101812.30688-11-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add power domain index 0 related with mipi-phy to imx7s. Signed-off-by: Rui Miguel Silva --- arch/arm/boot/dts/imx7s.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.0 diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi index 142ea709d296..d913c3f9c284 100644 --- a/arch/arm/boot/dts/imx7s.dtsi +++ b/arch/arm/boot/dts/imx7s.dtsi @@ -650,6 +650,12 @@ #address-cells = <1>; #size-cells = <0>; + pgc_mipi_phy: pgc-power-domain@0 { + #power-domain-cells = <0>; + reg = <0>; + power-supply = <®_1p0d>; + }; + pgc_pcie_phy: pgc-power-domain@1 { #power-domain-cells = <0>; reg = <1>; From patchwork Thu Apr 19 10:18:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133733 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614306edd; Thu, 19 Apr 2018 03:19:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ro5U2z+syQ8x0IcyefMvqyiATPRiYKjjZbkq/9ZGUsXRbzBZkyPsGR7V8LwVKy9QxOgLa X-Received: by 10.98.55.69 with SMTP id e66mr5271451pfa.253.1524133145273; Thu, 19 Apr 2018 03:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133145; cv=none; d=google.com; s=arc-20160816; b=vJmSHe6MO4efb0MpZ9FwIrchTOiHJH2xdtWp9/r8HyBh/duCxXAigp9kUhoEtWBAur IlAmUfHdmerV8GSdXZSUXJp8RGmvTWoydlmMGudvFWxI1Rcz2UP7gVsJA/dA7no+AHJB 1dyN4Ow/gKZf59ObKRuwxQleFDXS05+WADUY8eSc5J1h52lF1/U+O9I4KCZorWxkZifZ WEymKh5TWMkwvreg3CO9jnViruyK+e6fmK+nvXrH+HDreDD7CsSMO8tuzelnF3oTqNcn i+6RA0Qsz0ioA5tSNoY5KuCuiPYycNhSq80GotZa4HIq7g5FeVF3soPxZF9RPSEg5qKb 67Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Xa4v1qUIiXCo5Ho2lIiBxLnUGEl1BaTMlbR/f3J2gKI=; b=h7SIJVGGmIPmOJt4P7pfpPmQMP9c6vPDvLXM4zTbGZ5dOmaf2hMqeWFXBXUGXAcYEF eqaYFyX34gXkSehfsF49FiCkpV7lLNcldcb7b4C2wgVfRT3lUENSpo4SKWyKc/NMe+Zs Ku78LTfgz+KZRAksbsqBhA7Ini3HTvyrbOiwczw67qMGRtVsfvpYfFygKbNBq4QmJaJJ 95tM8MPwSQ2ukU4AkolPLMd6aCp4kcOcZwN6nQxGXcv2cFahA664AoojwJM5Yoj27T46 wRuwx36Rxgq4lWo33Ki+Cdl9nK9W0A4hMYuI0t4+DGqPwJTnn/QzbdUqpySmDh8St4h5 liJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TCcYlX9Y; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.05; Thu, 19 Apr 2018 03:19:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TCcYlX9Y; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbeDSKTC (ORCPT + 5 others); Thu, 19 Apr 2018 06:19:02 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41823 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752308AbeDSKS7 (ORCPT ); Thu, 19 Apr 2018 06:18:59 -0400 Received: by mail-wr0-f194.google.com with SMTP id v24-v6so12504664wra.8 for ; Thu, 19 Apr 2018 03:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xa4v1qUIiXCo5Ho2lIiBxLnUGEl1BaTMlbR/f3J2gKI=; b=TCcYlX9YFlc+8G4sO43n7Fiw8hn071vKehWHuFp+Qn99gcQ6pN8G91ncHUpNJt73hD 12DgDaT7fjKjopa2EyCqou8xEzIyczLaSzGd5+OGBwc3iDZhaLyQ9Tox2E2UhfBl0dSW GZhO4Ge4ItIEUDsY08sPgAPFwgWG/lKApUzTc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Xa4v1qUIiXCo5Ho2lIiBxLnUGEl1BaTMlbR/f3J2gKI=; b=WefxbT8B3nvecuC351v6Fkikq3y0awLxfb1uduI1tfrhAKuFZD5ftd77XQCcJDc0I6 66CmcfqHaRYP/1Lb1Ue8sw59dZ1YNyOqiHwpAXRMTZeN8hLhLzfFdZzn9tnmzzpo6Pp1 yrkDZucbjbDMia+9wrOZnmh6W8jqpfuCG0PV2MymYUIvDm18CsoymU+CJNGRZCBVTF4k 1pg8PgLG/HW91NLuQOJL0rmxSDWxLWpzEFXC260za9DJ5vs4aiAnZt9cn7hP1XKQNOfn cptwP5j45CJNhWRxdPp+BT+V4d+Hlv0bH2oTLC4D0pi7BAHu4uQ/iI+vRuIv94pqbhUo mBpA== X-Gm-Message-State: ALQs6tBNmkVnhJLCsA6PRcX8QruGjLEPKxTTG+lZ75/fhIIFzhgSuOqk yZJIdJ2pDHBsXMyS9epDftIE4w== X-Received: by 10.28.5.10 with SMTP id 10mr4221224wmf.47.1524133138682; Thu, 19 Apr 2018 03:18:58 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:18:57 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 11/15] ARM: dts: imx7s: add multiplexer controls Date: Thu, 19 Apr 2018 11:18:08 +0100 Message-Id: <20180419101812.30688-12-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The IOMUXC General Purpose Register has bitfield to control video bus multiplexer to control the CSI input between the MIPI-CSI2 and parallel interface. Add that register and mask. Signed-off-by: Rui Miguel Silva --- arch/arm/boot/dts/imx7s.dtsi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi index d913c3f9c284..3027d6a62021 100644 --- a/arch/arm/boot/dts/imx7s.dtsi +++ b/arch/arm/boot/dts/imx7s.dtsi @@ -534,8 +534,15 @@ gpr: iomuxc-gpr@30340000 { compatible = "fsl,imx7d-iomuxc-gpr", - "fsl,imx6q-iomuxc-gpr", "syscon"; + "fsl,imx6q-iomuxc-gpr", "syscon", "simple-mfd"; reg = <0x30340000 0x10000>; + + mux: mux-controller { + compatible = "mmio-mux"; + #mux-control-cells = <1>; + + mux-reg-masks = <0x14 0x00000010>; + }; }; ocotp: ocotp-ctrl@30350000 { From patchwork Thu Apr 19 10:18:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133734 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614335edd; Thu, 19 Apr 2018 03:19:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/N5CfFD0Em0aq9c0uiO+R1YOGWCVUzvEx4OGCzMycCVWIZDHoKaRYXag7UQZzOwszHpqMK X-Received: by 2002:a17:902:8a8a:: with SMTP id p10-v6mr5551215plo.251.1524133146691; Thu, 19 Apr 2018 03:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133146; cv=none; d=google.com; s=arc-20160816; b=P/coxaNSTBq0gtQOOYDIY6pfr2w30P1ZM9dKPXTOAWgD5Rq9zcaU1aISU9g3pByA0L 1jcgRyPsYvUnjx/1B419WvtxRArQOQfPDZE8FpdHAx7V/TSacsyKR/YVDOdpqWbYPcKD gtNfg2METz+Pol2+se7v+mUADB9i6VlIZklrGgYFGYDulfJKiWjBbmgy5f2FHsRwgeke XYAUpW+YtKTdt3zeFUgc0lvivdz9CwF+3nJ7sBTI/Mefg3IXFu2zelDG94b4D9kgEiHb 0m0S+AmX1FRQfO9HMTOYT/LeQeF5UBVgRnXocuag6Ks0G5KfazSXi8LOPgHrOWHmDcAq 024A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PnAcr5DXt5Bt0k0aev9IWMmSisS8fGlQPYQOfb8W/oE=; b=SQ3JMhEpSDdtObg3CsJLPlkDvqr35A/I+b/W442At7BmaQ8Gm8EGK5k+8YPAGRT24E NYOEQl244Js6/Zo79h1ChN0QjZY2sLLllSH7R2ruiR9Qmp0cqlkd4GGDx/1BYEREXE/t 6eC7nEh8O3R0HTGDYjebELMPE1y5qhRBksSvXx0DUTKPh1OR8salRRaKbHDXA1NJbpan jD2Gb7KnEh9eq5fA9elTzLnjrJhobF5253U/GhOgFiAHuKRK5l8wt3DEI9YhLTKqvsXo W51M7pvt7sQq9722IFcj8lNYwHMvnOeRCvyX0Ujq62pX4sWqUx4g4TZEWubRkrc2TkXk pc5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QvoCG+Gm; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.06; Thu, 19 Apr 2018 03:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QvoCG+Gm; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752308AbeDSKTF (ORCPT + 5 others); Thu, 19 Apr 2018 06:19:05 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38691 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414AbeDSKTC (ORCPT ); Thu, 19 Apr 2018 06:19:02 -0400 Received: by mail-wr0-f195.google.com with SMTP id h3-v6so12531592wrh.5 for ; Thu, 19 Apr 2018 03:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PnAcr5DXt5Bt0k0aev9IWMmSisS8fGlQPYQOfb8W/oE=; b=QvoCG+Gmw+e8AecJRdsl9YzattKzWk6UokbIJZM3y+bJ1NIoP+txBUrDmqAaRBg/7o hkKjTobFt2CW5+/1LTk+jBgmudPbjW/RBOTJ2tn4QbmX3bZTBwBPyqssRqElAmU3E1+R 9dxa3y6clVPL1Zv9EgrNMehsYLGxn5oqSjctU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PnAcr5DXt5Bt0k0aev9IWMmSisS8fGlQPYQOfb8W/oE=; b=uFr1Yc5a8sG0GyZQzFISGrgtM6H+OyXsm4FKTDGAdcz06WyH/odZfdkcS/gtXJig+W YVuwC6MmhnkuX85O2EsQuVcZN/FppaxJGoDbeWL62LTAtBqbbP9lRNsZq45tWpND2cmd nPk0/sJ8H1SZ3woJ52vWwRBrJBfSUsYby3+1MZlku1GWOfgxSBQUlOnRqNnrA65VPxIe sLG0IRzpJlZ6VjOJWuvQt6aYskAIvtUXLbcyi4rdGLokfFC72HGuMnBNcu6aguKVgTCm pIrSuUBShwTzOHlwEqOSLgHmHa++XJueAbKHBYqn7j0269tm1tBVy35Tceup023YXMGv 7UQg== X-Gm-Message-State: ALQs6tBqLhQkbO+tYKhI9BvgrXQRB/g7hII+c6K7en8Mh2cAHDmvTXjY Gl/0vdZZL2NXtAGVyHZfRm1qtA== X-Received: by 10.28.176.201 with SMTP id z192mr3871281wme.62.1524133141066; Thu, 19 Apr 2018 03:19:01 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.18.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:19:00 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 12/15] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections Date: Thu, 19 Apr 2018 11:18:09 +0100 Message-Id: <20180419101812.30688-13-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch adds the device tree nodes for csi, video multiplexer and mipi-csi besides the graph connecting the necessary endpoints to make the media capture entities to work in imx7 Warp board. Also add the pin control related with the mipi_csi in that board. Signed-off-by: Rui Miguel Silva --- arch/arm/boot/dts/imx7s-warp.dts | 80 ++++++++++++++++++++++++++++++++ arch/arm/boot/dts/imx7s.dtsi | 27 +++++++++++ 2 files changed, 107 insertions(+) -- 2.17.0 diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts index 8a30b148534d..91d06adf7c24 100644 --- a/arch/arm/boot/dts/imx7s-warp.dts +++ b/arch/arm/boot/dts/imx7s-warp.dts @@ -310,6 +310,79 @@ status = "okay"; }; +&gpr { + csi_mux { + compatible = "video-mux"; + mux-controls = <&mux 0>; + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + csi_mux_from_parallel_sensor: endpoint { + }; + }; + + port@1 { + reg = <1>; + + csi_mux_from_mipi_vc0: endpoint { + remote-endpoint = <&mipi_vc0_to_csi_mux>; + }; + }; + + port@2 { + reg = <2>; + + csi_mux_to_csi: endpoint { + remote-endpoint = <&csi_from_csi_mux>; + }; + }; + }; +}; + +&csi { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + csi_from_csi_mux: endpoint { + remote-endpoint = <&csi_mux_to_csi>; + }; + }; +}; + +&mipi_csi { + clock-frequency = <166000000>; + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + mipi_from_sensor: endpoint { + remote-endpoint = <&ov2680_to_mipi>; + data-lanes = <1>; + csis-hs-settle = <3>; + csis-clk-settle = <0>; + csis-wclk; + }; + }; + + port@1 { + reg = <1>; + + mipi_vc0_to_csi_mux: endpoint { + remote-endpoint = <&csi_mux_from_mipi_vc0>; + }; + }; +}; + &wdog1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_wdog>; @@ -357,6 +430,13 @@ >; }; + pinctrl_mipi_csi: mipi_csi { + fsl,pins = < + MX7D_PAD_LPSR_GPIO1_IO03__GPIO1_IO3 0x14 + MX7D_PAD_ENET1_RGMII_TD0__GPIO7_IO6 0x14 + >; + }; + pinctrl_sai1: sai1grp { fsl,pins = < MX7D_PAD_SAI1_RX_DATA__SAI1_RX_DATA0 0x1f diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi index 3027d6a62021..6b49b73053f9 100644 --- a/arch/arm/boot/dts/imx7s.dtsi +++ b/arch/arm/boot/dts/imx7s.dtsi @@ -46,6 +46,7 @@ #include #include #include +#include #include "imx7d-pinfunc.h" / { @@ -753,6 +754,17 @@ status = "disabled"; }; + csi: csi@30710000 { + compatible = "fsl,imx7-csi"; + reg = <0x30710000 0x10000>; + interrupts = ; + clocks = <&clks IMX7D_CLK_DUMMY>, + <&clks IMX7D_CSI_MCLK_ROOT_CLK>, + <&clks IMX7D_CLK_DUMMY>; + clock-names = "axi", "mclk", "dcic"; + status = "disabled"; + }; + lcdif: lcdif@30730000 { compatible = "fsl,imx7d-lcdif", "fsl,imx28-lcdif"; reg = <0x30730000 0x10000>; @@ -762,6 +774,21 @@ clock-names = "pix", "axi"; status = "disabled"; }; + + mipi_csi: mipi-csi@30750000 { + compatible = "fsl,imx7-mipi-csi2"; + reg = <0x30750000 0x10000>; + interrupts = ; + clocks = <&clks IMX7D_MIPI_CSI_ROOT_CLK>, + <&clks IMX7D_MIPI_DPHY_ROOT_CLK>; + clock-names = "mipi", "phy"; + power-domains = <&pgc_mipi_phy>; + phy-supply = <®_1p0d>; + resets = <&src IMX7_RESET_MIPI_PHY_MRST>; + reset-names = "mrst"; + bus-width = <4>; + status = "disabled"; + }; }; aips3: aips-bus@30800000 { From patchwork Thu Apr 19 10:18:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133735 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614381edd; Thu, 19 Apr 2018 03:19:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+n/5x3v+FGKwMLGCIVm09CCrL+E3M55Tlts+e4RDiMkTqXjy1arSdSCoQaV5OT9lM9TCTk X-Received: by 2002:a17:902:5801:: with SMTP id m1-v6mr5641466pli.325.1524133149209; Thu, 19 Apr 2018 03:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133149; cv=none; d=google.com; s=arc-20160816; b=OZvRb2oGK75pA3ibYhMUG6Qlkkq5fQFDicOSyn2JC1pnxHO2wLAAOMf0YJrI6b+NIR ytcLtBDeWsMmskoOefK/79/iuCefE8bh6Tjp3qKfTJLFt+Z2si3aultZ4qhh4pWi8bYw 0NdgQNhcmp5rVc0hUhIzKIxXu2Pxx6NLOo0obrKRkOVtFy5UV1exLTvPlnEpkoViHZSq Z7LuKG5+zXl8DfBQ0R0iMBlFG9XO0DXWHUdowAdO40CsaweB+gLHKUZj23m3O6p9/sFO Sq3c0zv5kXHOXcYN3UoQPad2DE8hV1tLrt1cB0Jm6Z5R36Ay1A3g75u8XBfuOu4KP1EH pAtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=KBTrgqD+3e+qE5mEOObEOY1QSgt/YloL5yxmAaFB1lM=; b=qlsXkt7/AbMWRH7xxjhhWG7W2dJmXjOZCXaIwPNMVmORk6vUWoF3c7Z64rNyG1hmOg iPw1QrInBg35y094oOuOrK+cE5aSVTtHHvx7g70R7dNbYxmgFTqp9tXry4LbGCraeVb9 e+VmmSQ5Sx7oQ17Wjoc907WsfegTtZLCWWss0uVkkGXI9NjYJjq4voK3+IHlwJ+cG/9A Scd9EE2oCITLewQBulY4pPK+TRMxSkn/ygVmwumxQwqoG7UC/bsFd+Bnb7508kac99TJ +rwQ59Qjq44/vluwNSiSnDl2hZj1o94kZiPXhtH7dbL3kiRMevo1x3Wsa1WU5lKzsqbt h9KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5VK+y21; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.08; Thu, 19 Apr 2018 03:19:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5VK+y21; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752417AbeDSKTH (ORCPT + 5 others); Thu, 19 Apr 2018 06:19:07 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44650 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481AbeDSKTE (ORCPT ); Thu, 19 Apr 2018 06:19:04 -0400 Received: by mail-wr0-f196.google.com with SMTP id o15-v6so12505054wro.11 for ; Thu, 19 Apr 2018 03:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KBTrgqD+3e+qE5mEOObEOY1QSgt/YloL5yxmAaFB1lM=; b=d5VK+y21hX1lO0Ewz7yl5FKs6A+VjEvF05OFVUQJAyyTlAXr9OnD+W/RSX5ahZqL0q k92x+TsiD7a66si6CvX0SyVet5oyYEGtFO7OMiqdVdgvr3Gy31IzeUYkO0xeniJ+r4i+ TmBialjcRN1r0ryQUFh5dJLCh21H8kuMnPECY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KBTrgqD+3e+qE5mEOObEOY1QSgt/YloL5yxmAaFB1lM=; b=fF/AG8I9338kzt1UqkY3/4JOcp+uR6Yg2kdtl9TwnYDosNUxkvjHut8exDXhsqxHxo pX8ZXreqPyduoZ8l7PPZobzyA/j/alVJdQlJ0fJolPuTJqTTXMqrJLtxxvjyDzsDKdE9 hTzPMEWIUopp1qO5Xe4r82wqx/4h4tLsiPFwITmrT0nSQjID25rh4SrvIHDVRh7xQuRL xsVh8fpYZpPmGS1WZQzMwU9Cr16KrsO5EQrvIMCLuoS6P2i6T3UK+SfkSsRiZ3H1t7f1 wvUk2G9mltQGc064iYxMp+AY2eQR+4hBoE2jIT3nWO4NTUr+thyUq6+lJZWDFtORiGiY jTMg== X-Gm-Message-State: ALQs6tB27QHLSg/ui9py7va4OpOuLGb7i/LHzCrjECzJDm8se23yb+ek uUVfLU4PBAqPBUhhPmdMJpIAHQ== X-Received: by 2002:adf:b595:: with SMTP id c21-v6mr4396091wre.233.1524133143537; Thu, 19 Apr 2018 03:19:03 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.19.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:19:02 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 13/15] ARM: dts: imx7s: add capture subsystem Date: Thu, 19 Apr 2018 11:18:10 +0100 Message-Id: <20180419101812.30688-14-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add media capture subsystem device to i.MX7 definitions. Signed-off-by: Rui Miguel Silva --- arch/arm/boot/dts/imx7s.dtsi | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.0 diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi index 6b49b73053f9..333d9fe6b989 100644 --- a/arch/arm/boot/dts/imx7s.dtsi +++ b/arch/arm/boot/dts/imx7s.dtsi @@ -1189,4 +1189,9 @@ assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_500M_CLK>; }; }; + + capture-subsystem { + compatible = "fsl,imx7-capture-subsystem"; + ports = <&csi>; + }; }; From patchwork Thu Apr 19 10:18:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133736 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614467edd; Thu, 19 Apr 2018 03:19:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx48dXin6nVS6QvvgiNL4hknNafqi4AAjT5BimNwoZSWznHe4g6S/UEc7AkdPez+24UsQbWEL X-Received: by 2002:a17:902:5801:: with SMTP id m1-v6mr5641730pli.325.1524133153506; Thu, 19 Apr 2018 03:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133153; cv=none; d=google.com; s=arc-20160816; b=ZnQ/Nqkgtmyena2HjzmsIQ8VZ61xuQ5RQWGSRV/wMuwiz76jTpsItGRc0HufPBDyrb Yk/xEOaEzqzBpX9LmTCoYBBTQCoGCvGqQWW21xvuDm3lbwcFXsd9GrJDNE04PIBP/2Gb KaMt8qFRqyZt3S9+Rw/MWrmuslaDrA8PhtXFD51hd1ofUTMsR1VRm88r58SwDBegrFth LoHYfTSm/9pIYo9ZHVpBVpwXj9n+NkWF1OkTJrcXoJXzufIPZiPMdAGKSYZe2bqm/gAv MCETfkB20SPBlzCGQeYoziXsNAuT1a7yxRhV1KsWq53JGULSgs7WgOc9/TPMGFRQGcqS D+Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=xqDB+wJgdnken53wSy9TUWUI1dKxrBpe4AGVjuPv7bo=; b=DGvPPFaa9LvfGm4V0JWJcVEkpnsYGeg2Dg+Ktpb0DX0kDIlWyvp0Ci6ifMHwCxnhQQ bMUFveV5OGuVRYACVR3Z+OXEeDAV27Kfgj67+61yXROjBfhotkBY08yBqJ7GqyL4dY6Q I8Vtb8pwBuKSyS5KOUP6uA3nVX4lvufM99odVdOLrQq1VKjXDHecZn9torbbc4ocPB2/ zJh4+1cN0UTDOBmr0CNlrl+Hzi8Ypv0R19+0/+s07+zhM8iLCtejHDpHd+GIBRDfekuw fnX5Rs+vLI7Qz9OCfwACEILxzjnGwgGAFS4M0pA2ZRu0QAPfp0K5IRX2IAJwP7Ao/u0b vFTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XhBaMzxy; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.13; Thu, 19 Apr 2018 03:19:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XhBaMzxy; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbeDSKTK (ORCPT + 5 others); Thu, 19 Apr 2018 06:19:10 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34206 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751046AbeDSKTH (ORCPT ); Thu, 19 Apr 2018 06:19:07 -0400 Received: by mail-wr0-f194.google.com with SMTP id d19-v6so12540997wre.1 for ; Thu, 19 Apr 2018 03:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xqDB+wJgdnken53wSy9TUWUI1dKxrBpe4AGVjuPv7bo=; b=XhBaMzxyr/Jq3fLz/q085/4XmqSmQ3RZ2oLyhmS78PbtwIndVS6iTl7wbWVoTmrVJj HQIWyLK+1sh29/HhRVX1RTJaaZQDXOBkHxKk/ojzS+ZfwHgiqN2KALI7xQW5jeVO9uDR 4GzSxV/X/e8EPT5cLT3k6zQYE7j3mZFZwgtAo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xqDB+wJgdnken53wSy9TUWUI1dKxrBpe4AGVjuPv7bo=; b=t6tn9X1mC25FB2xL5nS5AlTEZGQfS/MqDzSziXEO7i9q/dqXwpYSF+6EK4PAnAUdwo YAkbj5Tu1ohfiJQxmpv4KwJm09Mkv5LhllYj6hKUYmmKbtuLusxFhM9+BLaoXXlfRIdE gzoFrHYfN+Sbbx/TdQvlyHrny7F9rt69rl0VXndOIIMPDT4+3LViVJwMMWT3sf7i/n9f leK+VmM9AmuR5GHisGhzPpP5cB1W0/p8w6GMvaT7w26ACz6IES+UDpafKGAWFx7cRTcg 5QM2I4I5oNhbuJFl65qyozKJuAkV/Nw1fimMPtzuL08Amike41VfeST7DqN4Jznl9Pg1 qLuA== X-Gm-Message-State: ALQs6tAOh9oI6uImgSVLNH06InCBXC8XXcWurtV1L39ztTLEMj2XCU4H Sslp60NOTCWW4FFrxCXUafQAvQ== X-Received: by 2002:adf:9925:: with SMTP id x34-v6mr4454900wrb.29.1524133145944; Thu, 19 Apr 2018 03:19:05 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.19.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:19:05 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 14/15] media: imx7.rst: add documentation for i.MX7 media driver Date: Thu, 19 Apr 2018 11:18:11 +0100 Message-Id: <20180419101812.30688-15-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add rst document to describe the i.MX7 media driver and also a working example from the Warp7 board usage with a OV2680 sensor. Signed-off-by: Rui Miguel Silva --- Documentation/media/v4l-drivers/imx7.rst | 157 ++++++++++++++++++++++ Documentation/media/v4l-drivers/index.rst | 1 + 2 files changed, 158 insertions(+) create mode 100644 Documentation/media/v4l-drivers/imx7.rst -- 2.17.0 diff --git a/Documentation/media/v4l-drivers/imx7.rst b/Documentation/media/v4l-drivers/imx7.rst new file mode 100644 index 000000000000..64b97b442277 --- /dev/null +++ b/Documentation/media/v4l-drivers/imx7.rst @@ -0,0 +1,157 @@ +i.MX7 Video Capture Driver +========================== + +Introduction +------------ + +The i.MX7 contrary to the i.MX5/6 family does not contain an Image Processing +Unit (IPU), because of that the capabilities to perform operations or +manipulation of the capture frames is less feature rich. + +For image capture the i.MX7 have three units: +- CMOS Sensor Interface (CSI) +- Video Multiplexer +- MIPI CSI-2 Receiver + +:: + |\ + MIPI Camera Input ---> MIPI CSI-2 --- > | \ + | \ + | M | + | U | ------> CSI ---> Capture + | X | + | / + Parallel Camera Input ----------------> | / + |/ + +For additional information, please refer to the latest versions of the i.MX7 +reference manual [#f1]_. + +Entities +-------- + +imx7-mipi-csi2 +-------------- + +This is the MIPI CSI-2 recevier entity. It has one sink pad to receive the pixel +data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the +virtual channel 0. This module is compliant to previous version of Samsung +D-phy, and support two D-PHY Rx Data lanes. + +csi_mux +------- + +This is the video multiplexer. It has two sink pads to select from either camera +sensors with a parallel interface or from MIPI CSI-2 virtual channel 0. It has +a single source pad that routes to the CSI. + +csi +--- + +The CSI enables the chip to connect directly to external CMOS image sensor. CSI +can interfaces directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 FIFO +to store received image pixel data and embedded DMA controllers to transfer data +from the FIFO through AHB bus. + +This entity has one sink pad that receive from the csi_mux entity and a single +source pad that route video frames directly to memory buffers, this pad is +routed to a capture device node. + +Usage Notes +----------- + +To aid in configuration and for backward compatibility with V4L2 applications +that access controls only from video device nodes, the capture device interfaces +inherit controls from the active entities in the current pipeline, so controls +can be accessed either directly from the subdev or from the active capture +device interface. For example, the sensor controls are available either from the +sensor subdevs or from the active capture device. + +Warp7 with OV2680 +----------------- + +On this platform an OV2680 MIPI CSI-2 module is connected to the internal MIPI +CSI-2 receiver. The following example configures a video capture pipeline with +an output of 800x600, and BGGR 10 bit bayer format: + +.. code-block:: none + # Setup links + media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]" + media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]" + media-ctl -l "'csi_mux':2 -> 'csi':0[1]" + media-ctl -l "'csi':1 -> 'csi capture':0[1]" + + # Configure pads for pipeline + media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]" + media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]" + media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]" + media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]" + media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]" + +After this streaming can start, the v4l2-ctl tool can be used to select any of +the resolutions supported by the sensor. + +.. code-block:: none + root@imx7s-warp:~# media-ctl -p + Media controller API version 4.17.0 + + Media device information + ------------------------ + driver imx-media + model imx-media + serial + bus info + hw revision 0x0 + driver version 4.17.0 + + Device topology + - entity 1: csi (2 pads, 2 links) + type V4L2 subdev subtype Unknown flags 0 + device node name /dev/v4l-subdev0 + pad0: Sink + [fmt:SBGGR10_1X10/800x600 field:none] + <- "csi_mux":2 [ENABLED] + pad1: Source + [fmt:SBGGR10_1X10/800x600 field:none] + -> "csi capture":0 [ENABLED] + + - entity 4: csi capture (1 pad, 1 link) + type Node subtype V4L flags 0 + device node name /dev/video0 + pad0: Sink + <- "csi":1 [ENABLED] + + - entity 10: csi_mux (3 pads, 2 links) + type V4L2 subdev subtype Unknown flags 0 + device node name /dev/v4l-subdev1 + pad0: Sink + [fmt:unknown/0x0] + pad1: Sink + [fmt:unknown/800x600 field:none] + <- "imx7-mipi-csis.0":1 [ENABLED] + pad2: Source + [fmt:unknown/800x600 field:none] + -> "csi":0 [ENABLED] + + - entity 14: imx7-mipi-csis.0 (2 pads, 2 links) + type V4L2 subdev subtype Unknown flags 0 + device node name /dev/v4l-subdev2 + pad0: Sink + [fmt:SBGGR10_1X10/800x600 field:none] + <- "ov2680 1-0036":0 [ENABLED] + pad1: Source + [fmt:SBGGR10_1X10/800x600 field:none] + -> "csi_mux":1 [ENABLED] + + - entity 17: ov2680 1-0036 (1 pad, 1 link) + type V4L2 subdev subtype Sensor flags 0 + device node name /dev/v4l-subdev3 + pad0: Source + [fmt:SBGGR10_1X10/800x600 field:none] + -> "imx7-mipi-csis.0":0 [ENABLED] + + +References +---------- + +.. [#f1] https://www.nxp.com/docs/en/reference-manual/IMX7SRM.pdf diff --git a/Documentation/media/v4l-drivers/index.rst b/Documentation/media/v4l-drivers/index.rst index 679238e786a7..693295bbc53f 100644 --- a/Documentation/media/v4l-drivers/index.rst +++ b/Documentation/media/v4l-drivers/index.rst @@ -44,6 +44,7 @@ For more details see the file COPYING in the source distribution of Linux. davinci-vpbe fimc imx + imx7 ivtv max2175 meye From patchwork Thu Apr 19 10:18:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 133737 Delivered-To: patch@linaro.org Received: by 10.80.173.174 with SMTP id a43csp614489edd; Thu, 19 Apr 2018 03:19:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx48AxBwvzIcGnjKUX63BHknqHd6NBHbQUrCvPr8i8inIkRMr7f+xhBr+pF0KHTJt+nEH+nZY X-Received: by 10.167.130.22 with SMTP id k22mr5300340pfi.73.1524133154543; Thu, 19 Apr 2018 03:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133154; cv=none; d=google.com; s=arc-20160816; b=zCCIsrMpyJ5qpjQlkH7j4x8F2mP56hCngRIwpcL/rK6pCA4FCI1iYy9ur/DDUTF02F SIllt1z1G08rLbqCckY3vQoRrIpwYXRKin8FFGPs9lMdIxoIIABWTC0mG3rsvdmXkL9v uHh6hvKjtwTk63od93romvA6DhIna3QCbpkhhhP3u1pir5bsYIoUc6wynP6XuWxBJCDJ SY1pmqMgNJTPFvgNksxsAaA2rK6vz5xn1fN9cGPcwn3VTfy14MhN5hHDUKmDqkf+dGpD s9g5XZgeBhvbVKdUqehUHGmIshUCRo/CWCRNDxjzGmsJ/fa7wLUvnNIsqAXUicjFTJu7 FAqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TiMKxNcuWyiIR1/1GRykjtSZyeJ3/oWUfsTfPU4yLf0=; b=nRQPqvhDqa01T4jGBh2/L16ILGaEjBh4DVpBht+BnkKKSOOthqI8RUY+L6h08zM9JJ HYuEFmtcHIVT9WJ9EuqHFHPa730Vmmw+h75BINAvfoIlsincCi1cquCURd2iYeUcl/HP aMi+B8fgpN2IzLiLRLXQSo8HEvEewTqbZ9A3p3kPl6C3epeqbWtv7ZS0AwhJ5c0PlckN JAzMc7l7wjPW81Sn5J1YWMBX8jeYDCFZuVmX6jeZWG9TOFYn9sJyNGxz54ZPGhUQh8TV XR5LOvTVRwx1zuJA5JToH36uX2+xoBo84hmshcCbyBc0JhRahMaSiLj0X4kxg2Ib5AZH qMhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ACcHw00S; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si3018088pfe.168.2018.04.19.03.19.14; Thu, 19 Apr 2018 03:19:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ACcHw00S; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbeDSKTM (ORCPT + 5 others); Thu, 19 Apr 2018 06:19:12 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:43965 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeDSKTJ (ORCPT ); Thu, 19 Apr 2018 06:19:09 -0400 Received: by mail-wr0-f193.google.com with SMTP id u4-v6so12503160wrg.10 for ; Thu, 19 Apr 2018 03:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TiMKxNcuWyiIR1/1GRykjtSZyeJ3/oWUfsTfPU4yLf0=; b=ACcHw00SB60UcmCw5WlQhBc7Wsr2nQJHVsBLROtNR6Fm1sFpUygv4S6lvHARdUYaGS 0OzuMBRVUgL1SmGYbamqDB7KDvI/OCOtFH5t4ZYuxGmffec/t4M8xD3jIq2uYF28BnjR B8dI9BYGmWUyM15AM5/rt8XFwBhoB5/bBS1Go= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TiMKxNcuWyiIR1/1GRykjtSZyeJ3/oWUfsTfPU4yLf0=; b=c/1Bqovn9dJTz+/K4szezXoUCgVTW+oi7XBKfrEJzCXxI+w7XQzQYRLt4V0DUyLy2A UxZ/dqpNnDKKR5LL6zn7OPlpT2hj09IKDcQOnmZqzK459TQCKYpa20SfEQUFsKusw+XX W1yM+svZ6krxnp78yDOql+KWRP9ZZDNfBSFvzrl/rBE4fxPqkDB4an1hHMH8jOthFddp e1uQUkuaHLzWvj4cu/a27mb2DO43L8HfThHNl+pZNZM8BpWtlfseExWs2icaut45gNni 1YPod/vyddB0be7HDRotG009hZ01szjp60T8zwOW3lIV3lAP37wwQAAcC5PK3/wxc+tl vlrw== X-Gm-Message-State: ALQs6tBxKIJgWv/PXpdPnyqQ6x1ijDAAaqTCMcmlcZwIXgVAtly30KOD wZzt4OsF+a08xwwqs5AbR6kQpg== X-Received: by 10.28.97.139 with SMTP id v133mr4393901wmb.75.1524133148504; Thu, 19 Apr 2018 03:19:08 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id v66sm5220937wmd.41.2018.04.19.03.19.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:19:07 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH 15/15] media: staging/imx: add i.MX7 entries to TODO file Date: Thu, 19 Apr 2018 11:18:12 +0100 Message-Id: <20180419101812.30688-16-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419101812.30688-1-rui.silva@linaro.org> References: <20180419101812.30688-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add some i.MX7 related entries to TODO file. Signed-off-by: Rui Miguel Silva --- drivers/staging/media/imx/TODO | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.0 diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO index aeeb15494a49..6f29b5ca5324 100644 --- a/drivers/staging/media/imx/TODO +++ b/drivers/staging/media/imx/TODO @@ -45,3 +45,12 @@ Which means a port must not contain mixed-use endpoints, they must all refer to media links between V4L2 subdevices. + +- i.MX7: all of the above, since it uses the imx media core + +- i.MX7: use Frame Interval Monitor + +- i.MX7: runtime testing with parallel sensor, links setup and streaming + +- i.MX7: runtime testing with different formats, for the time only 10-bit bayer + is tested