Re: [PATCH v3 02/13] [media] mtk-mipicsi: add mediatek mipicsi driver for mt2712

2019-05-17 Thread CK Hu
Hi, Stu:

On Tue, 2019-05-14 at 14:13 +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  | 587 ++
>  2 files changed, 591 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 ..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 ..4ae5b88abc5f
> --- /dev/null
> +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c
> @@ -0,0 +1,587 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2017 MediaTek Inc.
> + * Author: Ricky Zhang 
> + * Baoyin Zhang 
> + * Alan Yue 
> + * Stu Hsieh 
> + *
> + * 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 
> +
> +#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 MIPI_RX_ANA00_CSI0x00
> +#define MIPI_RX_ANA04_CSI0x04
> +#define MIPI_RX_ANA08_CSI0x08
> +#define MIPI_RX_ANA0C_CSI0x0c
> +#define MIPI_RX_ANA10_CSI0x10
> +#define MIPI_RX_ANA20_CSI0x20
> +#define MIPI_RX_ANA24_CSI0x24
> +#define MIPI_RX_ANA4C_CSI0x4c
> +#define MIPI_RX_ANA50_CSI0x50
> +
> +#define SENINF_CTRL  0x00
> +
> +#define SENINF_NCSI2_CAL_24  0x24
> +#define SENINF_NCSI2_CAL_38  0x38
> +#define SENINF_NCSI2_CAL_3C  0x3C
> +#define SENINF_NCSI2_CTL 0xA0
> +#define SENINF_NCSI2_LNRD_TIMING 0xA8
> +#define SENINF_NCSI2_INT_EN  0xB0
> +#define SENINF_NCSI2_INT_STATUS  0xB4
> +#define SENINF_NCSI2_DBG_SEL 0xB8
> +#define SENINF_NCSI2_HSRX_DBG0xD8
> +#define SENINF_NCSI2_DI  0xDC
> +#define SENINF_NCSI2_DI_CTRL 0xE4
> +
> +#define SENINF_TOP_CTRL  0x00
> +#define SENINF_TOP_CMODEL_PAR0x04
> +#define SENINF_TOP_MUX   0x08
> +
> +#define SENINF_MUX_CTRL  0x00
> +
> +#define CAMSV_MODULE_EN  0x10
> +#define CAMSV_FMT_SEL0x14
> +#define CAMSV_INT_EN 0x18
> +#define CAMSV_CLK_EN 0x30
> +
> +#define CAMSV_TG_SEN_MODE0x500
> +#define CAMSV_TG_SEN_GRAB_PXL0x508
> +#define CAMSV_TG_SEN_GRAB_LIN0x50C
> +#define CAMSV_TG_PATH_CFG0x510
> +
> +#define IMGO_XSIZE   0x230
> +#define IMGO_YSIZE   0x234
> +#define IMGO_STRIDE  0x238
> +#define DMA_FRAME_HEADER_EN  0xE00
> +
> +struct mtk_mipicsi_dev {
> + struct platform_device *pdev;
> + unsigned int camsv_num;
> + struct device 

[PATCH v3 02/13] [media] mtk-mipicsi: add mediatek mipicsi driver for mt2712

2019-05-14 Thread Stu Hsieh
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  | 587 ++
 2 files changed, 591 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 ..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 ..4ae5b88abc5f
--- /dev/null
+++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c
@@ -0,0 +1,587 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017 MediaTek Inc.
+ * Author: Ricky Zhang 
+ * Baoyin Zhang 
+ * Alan Yue 
+ * Stu Hsieh 
+ *
+ * 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 
+
+#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 MIPI_RX_ANA00_CSI  0x00
+#define MIPI_RX_ANA04_CSI  0x04
+#define MIPI_RX_ANA08_CSI  0x08
+#define MIPI_RX_ANA0C_CSI  0x0c
+#define MIPI_RX_ANA10_CSI  0x10
+#define MIPI_RX_ANA20_CSI  0x20
+#define MIPI_RX_ANA24_CSI  0x24
+#define MIPI_RX_ANA4C_CSI  0x4c
+#define MIPI_RX_ANA50_CSI  0x50
+
+#define SENINF_CTRL0x00
+
+#define SENINF_NCSI2_CAL_240x24
+#define SENINF_NCSI2_CAL_380x38
+#define SENINF_NCSI2_CAL_3C0x3C
+#define SENINF_NCSI2_CTL   0xA0
+#define SENINF_NCSI2_LNRD_TIMING   0xA8
+#define SENINF_NCSI2_INT_EN0xB0
+#define SENINF_NCSI2_INT_STATUS0xB4
+#define SENINF_NCSI2_DBG_SEL   0xB8
+#define SENINF_NCSI2_HSRX_DBG  0xD8
+#define SENINF_NCSI2_DI0xDC
+#define SENINF_NCSI2_DI_CTRL   0xE4
+
+#define SENINF_TOP_CTRL0x00
+#define SENINF_TOP_CMODEL_PAR  0x04
+#define SENINF_TOP_MUX 0x08
+
+#define SENINF_MUX_CTRL0x00
+
+#define CAMSV_MODULE_EN0x10
+#define CAMSV_FMT_SEL  0x14
+#define CAMSV_INT_EN   0x18
+#define CAMSV_CLK_EN   0x30
+
+#define CAMSV_TG_SEN_MODE  0x500
+#define CAMSV_TG_SEN_GRAB_PXL  0x508
+#define CAMSV_TG_SEN_GRAB_LIN  0x50C
+#define CAMSV_TG_PATH_CFG  0x510
+
+#define IMGO_XSIZE 0x230
+#define IMGO_YSIZE 0x234
+#define IMGO_STRIDE0x238
+#define DMA_FRAME_HEADER_EN0xE00
+
+struct mtk_mipicsi_dev {
+   struct platform_device *pdev;
+   unsigned int camsv_num;
+   struct device *larb_pdev;
+   void __iomem*ana;
+   void __iomem*seninf_ctrl;
+   void __iomem*seninf;
+   struct regmap   *seninf_top;
+   void __iomem*seninf_mux[MTK_CAMDMA_MAX_NUM];
+   void __iomem