From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stu Hsieh Subject: Re: [PATCH v2 02/15] [media] mtk-mipicsi: add mediatek mipicsi driver for mt2712 Date: Fri, 19 Apr 2019 13:28:15 +0800 Message-ID: <1555651695.9968.11.camel@mtksdccf07> References: <1555407015-18130-1-git-send-email-stu.hsieh@mediatek.com> <1555407015-18130-3-git-send-email-stu.hsieh@mediatek.com> <1555551269.2407.9.camel@mtksdaap41> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1555551269.2407.9.camel@mtksdaap41> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: CK Hu Cc: Mark Rutland , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org List-Id: devicetree@vger.kernel.org Hi, CK: On Thu, 2019-04-18 at 09:34 +0800, CK Hu wrote: > Hi, Stu: > > On Tue, 2019-04-16 at 17:30 +0800, Stu Hsieh wrote: > > This patch add mediatek mipicsi driver for mt2712, > > including probe function to get the value from device tree, > > and register to v4l2 the host device. > > > > Signed-off-by: Stu Hsieh > > --- > > drivers/media/platform/mtk-mipicsi/Makefile | 4 + > > .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 767 ++++++++++++++++++ > > 2 files changed, 771 insertions(+) > > create mode 100644 drivers/media/platform/mtk-mipicsi/Makefile > > create mode 100644 drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > > > diff --git a/drivers/media/platform/mtk-mipicsi/Makefile b/drivers/media/platform/mtk-mipicsi/Makefile > > new file mode 100644 > > index 000000000000..326a5e3808fa > > --- /dev/null > > +++ b/drivers/media/platform/mtk-mipicsi/Makefile > > @@ -0,0 +1,4 @@ > > +mtk-mipicsi-y += mtk_mipicsi.o > > + > > +obj-$(CONFIG_VIDEO_MEDIATEK_MIPICSI) += mtk-mipicsi.o > > + > > diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > new file mode 100644 > > index 000000000000..e26bebe17fe5 > > --- /dev/null > > +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > @@ -0,0 +1,767 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2017 MediaTek Inc. > > + * Author: Ricky Zhang > > + * Baoyin Zhang > > + * Alan Yue > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * http://www.gnu.org/licenses/gpl-2.0.html for more details. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#ifdef CONFIG_VB2_MEDIATEK_DMA_SG > > +#include "mtkbuf-dma-cache-sg.h" > > +#endif > > + > > +#define MTK_MIPICSI_DRV_NAME "mtk-mipicsi" > > +#define MTK_PLATFORM_STR "platform:mt2712" > > +#define MIPICSI_COMMON_CLK 2 > > +#define MTK_CAMDMA_MAX_NUM 4U > > +#define MIPICSI_CLK (MIPICSI_COMMON_CLK + MTK_CAMDMA_MAX_NUM) > > +#define MTK_DATAWIDTH_8 (0x01U << 7U) > > +#define MAX_SUPPORT_WIDTH 4096U > > +#define MAX_SUPPORT_HEIGHT 4096U > > +#define MAX_BUFFER_NUM 32U > > +#define VID_LIMIT_BYTES (100U * 1024U * 1024U) > > + > > +/* buffer for one video frame */ > > +struct mtk_mipicsi_buf { > > + struct list_head queue; > > + struct vb2_buffer *vb; > > + dma_addr_t vb_dma_addr_phy; > > + int prepare_flag; > > +}; > > + > > +struct mtk_mipicsi_dev { > > + struct soc_camera_host soc_host; > > + struct platform_device *pdev; > > + unsigned int camsv_num; > > + struct v4l2_device v4l2_dev; > > + struct device *larb_pdev; > > + void __iomem *ana; > > + void __iomem *seninf_ctrl; > > Separating register control to another patch looks strange to me. > Register control is the bottom part and this patch is the top part. You > send a top part first then the bottom part. 'seninf_ctrl' is useless in > this patch, you may move this to the patch that use this variable or > merge that patch into this patch. > > Regards, > CK > In patch "[PATCH v2 07/15] [media] mtk-mipicsi: add mipicsi reg setting for mt2712", there are register control. This driver use mtk_mipicsi_reg_init(mipicsi) to set the register and the struct mipicsi is get from "struct soc_camera_host *ici". So I send top part first then the bottom part, because the soc_camera need to register first. Regards, Stu > > + void __iomem *seninf; > > + struct regmap *seninf_top; > > + void __iomem *seninf_mux[MTK_CAMDMA_MAX_NUM]; > > + void __iomem *camsv[MTK_CAMDMA_MAX_NUM]; > > + const struct soc_camera_format_xlate *current_fmt; > > + u16 width_flags; /* max 12 bits */ > > + struct list_head capture_list[MTK_CAMDMA_MAX_NUM]; > > + struct list_head fb_list; > > + spinlock_t lock; > > + spinlock_t queue_lock; > > + struct mtk_mipicsi_buf cam_buf[MAX_BUFFER_NUM]; > > + bool streamon; > > + unsigned long frame_cnt[MTK_CAMDMA_MAX_NUM]; > > + unsigned int link; > > + unsigned long enqueue_cnt; > > + unsigned long dequeue_cnt; > > + struct v4l2_ctrl_handler ctrl_hdl; > > + char drv_name[16]; > > + u32 id; > > + int clk_num; > > + struct clk *clk[MIPICSI_CLK]; > > +}; > > + > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C616C282DA for ; Fri, 19 Apr 2019 05:28:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E38222087F for ; Fri, 19 Apr 2019 05:28:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fzuDWrF0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E38222087F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NERyXJyKjDsZLQ8/zDknhTk2n2Jy4M7JR3tSbk2nwVs=; b=fzuDWrF0jAxkT5 yu4daCvgDDHB/3DtoK7NfGHEVGYvgqrgnX+JkWBKU6npPm3GHxulPoYSMI9r8MncbOhIXGy82tHji 0aZ7bh+VgsIE5D9j5RsJ2dafhzhIuAVP6Ht8Y4mDjoPLiBsoXDuQQePz0+QJpoEkztCJTlIv7LrvX EsEh4PybX9/dQ0RSP5WFK1wwxKn+vONHbKI+wAlf1VOS/JWLCEfefKUnNqDAn9l2cJ5hUD/7GmE9K 7Kdgd4/y4jja1um0AXdSCkia/6fxIXx7n5ZjhiUjRZEhe0vGl1RNjNMQ4Iq/O3yT3FX5Rns/FMM3x KTfrzX5cNwpatPuPhJog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHM4e-0004Y2-JQ; Fri, 19 Apr 2019 05:28:32 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHM4Y-0004X2-Hz; Fri, 19 Apr 2019 05:28:30 +0000 X-UUID: deb8e16108594beab0a64535bc92f559-20190418 X-UUID: deb8e16108594beab0a64535bc92f559-20190418 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 529429348; Thu, 18 Apr 2019 21:28:19 -0800 Received: from mtkmbs03n1.mediatek.inc (172.21.101.181) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 18 Apr 2019 22:28:17 -0700 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 19 Apr 2019 13:28:15 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 19 Apr 2019 13:28:15 +0800 Message-ID: <1555651695.9968.11.camel@mtksdccf07> Subject: Re: [PATCH v2 02/15] [media] mtk-mipicsi: add mediatek mipicsi driver for mt2712 From: Stu Hsieh To: CK Hu Date: Fri, 19 Apr 2019 13:28:15 +0800 In-Reply-To: <1555551269.2407.9.camel@mtksdaap41> References: <1555407015-18130-1-git-send-email-stu.hsieh@mediatek.com> <1555407015-18130-3-git-send-email-stu.hsieh@mediatek.com> <1555551269.2407.9.camel@mtksdaap41> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_222826_594872_AC81F1C2 X-CRM114-Status: GOOD ( 25.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, CK: On Thu, 2019-04-18 at 09:34 +0800, CK Hu wrote: > Hi, Stu: > > On Tue, 2019-04-16 at 17:30 +0800, Stu Hsieh wrote: > > This patch add mediatek mipicsi driver for mt2712, > > including probe function to get the value from device tree, > > and register to v4l2 the host device. > > > > Signed-off-by: Stu Hsieh > > --- > > drivers/media/platform/mtk-mipicsi/Makefile | 4 + > > .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 767 ++++++++++++++++++ > > 2 files changed, 771 insertions(+) > > create mode 100644 drivers/media/platform/mtk-mipicsi/Makefile > > create mode 100644 drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > > > diff --git a/drivers/media/platform/mtk-mipicsi/Makefile b/drivers/media/platform/mtk-mipicsi/Makefile > > new file mode 100644 > > index 000000000000..326a5e3808fa > > --- /dev/null > > +++ b/drivers/media/platform/mtk-mipicsi/Makefile > > @@ -0,0 +1,4 @@ > > +mtk-mipicsi-y += mtk_mipicsi.o > > + > > +obj-$(CONFIG_VIDEO_MEDIATEK_MIPICSI) += mtk-mipicsi.o > > + > > diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > new file mode 100644 > > index 000000000000..e26bebe17fe5 > > --- /dev/null > > +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c > > @@ -0,0 +1,767 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2017 MediaTek Inc. > > + * Author: Ricky Zhang > > + * Baoyin Zhang > > + * Alan Yue > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * http://www.gnu.org/licenses/gpl-2.0.html for more details. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#ifdef CONFIG_VB2_MEDIATEK_DMA_SG > > +#include "mtkbuf-dma-cache-sg.h" > > +#endif > > + > > +#define MTK_MIPICSI_DRV_NAME "mtk-mipicsi" > > +#define MTK_PLATFORM_STR "platform:mt2712" > > +#define MIPICSI_COMMON_CLK 2 > > +#define MTK_CAMDMA_MAX_NUM 4U > > +#define MIPICSI_CLK (MIPICSI_COMMON_CLK + MTK_CAMDMA_MAX_NUM) > > +#define MTK_DATAWIDTH_8 (0x01U << 7U) > > +#define MAX_SUPPORT_WIDTH 4096U > > +#define MAX_SUPPORT_HEIGHT 4096U > > +#define MAX_BUFFER_NUM 32U > > +#define VID_LIMIT_BYTES (100U * 1024U * 1024U) > > + > > +/* buffer for one video frame */ > > +struct mtk_mipicsi_buf { > > + struct list_head queue; > > + struct vb2_buffer *vb; > > + dma_addr_t vb_dma_addr_phy; > > + int prepare_flag; > > +}; > > + > > +struct mtk_mipicsi_dev { > > + struct soc_camera_host soc_host; > > + struct platform_device *pdev; > > + unsigned int camsv_num; > > + struct v4l2_device v4l2_dev; > > + struct device *larb_pdev; > > + void __iomem *ana; > > + void __iomem *seninf_ctrl; > > Separating register control to another patch looks strange to me. > Register control is the bottom part and this patch is the top part. You > send a top part first then the bottom part. 'seninf_ctrl' is useless in > this patch, you may move this to the patch that use this variable or > merge that patch into this patch. > > Regards, > CK > In patch "[PATCH v2 07/15] [media] mtk-mipicsi: add mipicsi reg setting for mt2712", there are register control. This driver use mtk_mipicsi_reg_init(mipicsi) to set the register and the struct mipicsi is get from "struct soc_camera_host *ici". So I send top part first then the bottom part, because the soc_camera need to register first. Regards, Stu > > + void __iomem *seninf; > > + struct regmap *seninf_top; > > + void __iomem *seninf_mux[MTK_CAMDMA_MAX_NUM]; > > + void __iomem *camsv[MTK_CAMDMA_MAX_NUM]; > > + const struct soc_camera_format_xlate *current_fmt; > > + u16 width_flags; /* max 12 bits */ > > + struct list_head capture_list[MTK_CAMDMA_MAX_NUM]; > > + struct list_head fb_list; > > + spinlock_t lock; > > + spinlock_t queue_lock; > > + struct mtk_mipicsi_buf cam_buf[MAX_BUFFER_NUM]; > > + bool streamon; > > + unsigned long frame_cnt[MTK_CAMDMA_MAX_NUM]; > > + unsigned int link; > > + unsigned long enqueue_cnt; > > + unsigned long dequeue_cnt; > > + struct v4l2_ctrl_handler ctrl_hdl; > > + char drv_name[16]; > > + u32 id; > > + int clk_num; > > + struct clk *clk[MIPICSI_CLK]; > > +}; > > + > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel