Skip to contentSkip to conversation

platform: dwc: Add of DesignWare MIPI CSI-2 Host

PATCH In review Luis Oliveira 5 participants 26 messages Oct 19, 2018 – Jan 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover platform: dwc: Add of DesignWare MIPI CSI-2 Host

This adds support for Synopsys MIPI CSI-2 Host and MIPI D-PHY. The patch series include support for initialization/configuration of the DW MIPI CSI-2 controller and DW MIPI D-PHY and both include a reference platform driver. This way the future PCI integration will be clean.

This will enable future SoCs to use this standard approach and possibly create a more clean environment.

This series also documents the dt-bindings needed for the platform drivers.

This was applied in: https://git.linuxtv.org/media_tree.git

Luis Oliveira (4):
Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx
bindings
media: platform: dwc: Add DW MIPI DPHY Rx platform
Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2
Host
media: platform: dwc: Add MIPI CSI-2 controller driver

 .../devicetree/bindings/media/snps,dw-csi-plat.txt |  52 ++
 .../devicetree/bindings/phy/snps,dphy-rx.txt       |  28 +
 MAINTAINERS                                        |  11 +
 drivers/media/platform/Kconfig                     |   1 +
 drivers/media/platform/Makefile                    |   3 +
 drivers/media/platform/dwc/Kconfig                 |  52 ++
 drivers/media/platform/dwc/Makefile                |   4 +
 drivers/media/platform/dwc/dw-csi-plat.c           | 699 +++++++++++++++++++++
 drivers/media/platform/dwc/dw-csi-plat.h           |  77 +++
 drivers/media/platform/dwc/dw-dphy-plat.c          | 347 ++++++++++
 drivers/media/platform/dwc/dw-dphy-rx.c            | 596 ++++++++++++++++++
 drivers/media/platform/dwc/dw-dphy-rx.h            | 181 ++++++
 drivers/media/platform/dwc/dw-mipi-csi.c           | 494 +++++++++++++++
 drivers/media/platform/dwc/dw-mipi-csi.h           | 202 ++++++
 include/media/dwc/dw-mipi-csi-pltfrm.h             | 102 +++
 15 files changed, 2849 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
 create mode 100644 drivers/media/platform/dwc/Kconfig
 create mode 100644 drivers/media/platform/dwc/Makefile
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h
 create mode 100644 drivers/media/platform/dwc/dw-dphy-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-dphy-rx.c
 create mode 100644 drivers/media/platform/dwc/dw-dphy-rx.h
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h
 create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

--
2.7.4

#1 lore raw

PATCH v3 1/4 Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings

Add device-tree bindings documentation for SNPS DesignWare MIPI D-PHY in RX mode.

---
Changelog
v2-V3
- removed gpios reference - it was for a separated driver
- changed address to show complete address

 .../devicetree/bindings/phy/snps,dphy-rx.txt       | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +28 -0
new file mode 100644
index 0000000..03d17ab
@@ -0,0 +1,28 @@
+Synopsys DesignWare MIPI Rx D-PHY block details
+
+Description
+-----------
+
+The Synopsys MIPI D-PHY controller supports MIPI-DPHY in receiver mode.
+Please refer to phy-bindings.txt for more information.
+
+Required properties:
+- compatible		: Shall be "snps,dphy-rx".
+- #phy-cells		: Must be 1.
+- snps,dphy-frequency	: Output frequency of the D-PHY.
+- snps,dphy-te-len	: Size of the communication interface (8 bits->8 or 12bits->12).
+- reg			: Physical base address and size of the device memory mapped
+		 	  registers;
+
+Example:
+
+	mipi_dphy_rx1: dphy@d00003040 {
+		compatible = "snps,dphy-rx";
+		#phy-cells = <1>;
+		snps,dphy-frequency = <300000>;
+		snps,dphy-te-len = <12>;
+		reg = < 0xd0003040 0x20
+			0xd0008000 0x100
+			0xd0009000 0x100>;
+	};
+

--
2.7.4

maintainer
#2 lore raw

Re: [V3, 1/4] Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings

Quoted 22 lines · Luis Oliveira

Add device-tree bindings documentation for SNPS DesignWare MIPI D-PHY in RX mode.

---
Changelog
v2-V3
- removed gpios reference - it was for a separated driver
- changed address to show complete address

 .../devicetree/bindings/phy/snps,dphy-rx.txt       | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +2 -0
new file mode 100644
index 0000000..03d17ab
@@ -0,0 +1,28 @@
+Synopsys DesignWare MIPI Rx D-PHY block details
+

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +10 -0
+Description
+-----------
+
+The Synopsys MIPI D-PHY controller supports MIPI-DPHY in receiver mode.
+Please refer to phy-bindings.txt for more information.
+
+Required properties:
+- compatible		: Shall be "snps,dphy-rx".
+- #phy-cells		: Must be 1.
+- snps,dphy-frequency	: Output frequency of the D-PHY.

Needs a unit suffix (-hz).

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +3 -0
+- snps,dphy-te-len	: Size of the communication interface (8 bits->8 or 12bits->12).
+- reg			: Physical base address and size of the device memory mapped
+		 	  registers;

How many, what are they, and what order? Looks like 3 below.

Also, a tab after spaces error.

Quoted 16 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +13 -1
+
+Example:
+
+	mipi_dphy_rx1: dphy@d00003040 {
+		compatible = "snps,dphy-rx";
+		#phy-cells = <1>;
+		snps,dphy-frequency = <300000>;
+		snps,dphy-te-len = <12>;
+		reg = < 0xd0003040 0x20
+			0xd0008000 0x100
+			0xd0009000 0x100>;
+	};
+
--

2.7.4

#3 lore raw

Re: [V3, 1/4] Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings

Hi Rob, my responses inline.

Quoted 27 lines · Rob Herring
Quoted 26 lines · Luis Oliveira

Add device-tree bindings documentation for SNPS DesignWare MIPI D-PHY in RX mode.

---
Changelog
v2-V3
- removed gpios reference - it was for a separated driver
- changed address to show complete address

 .../devicetree/bindings/phy/snps,dphy-rx.txt       | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +6 -0
new file mode 100644
index 0000000..03d17ab
@@ -0,0 +1,28 @@
+Synopsys DesignWare MIPI Rx D-PHY block details
+
+Description
+-----------
+
+The Synopsys MIPI D-PHY controller supports MIPI-DPHY in receiver mode.
Quoted 9 lines

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 12

Quoted 6 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +6 -0
+Please refer to phy-bindings.txt for more information.
+
+Required properties:
+- compatible		: Shall be "snps,dphy-rx".
+- #phy-cells		: Must be 1.
+- snps,dphy-frequency	: Output frequency of the D-PHY.

Needs a unit suffix (-hz).

Yes,

Quoted 8 lines

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +3 -0
+- snps,dphy-te-len	: Size of the communication interface (8 bits->8 or 12bits->12).
+- reg			: Physical base address and size of the device memory mapped
+		 	  registers;

How many, what are they, and what order? Looks like 3 below.

Also, a tab after spaces error.

Yep, I will fix it. Thanks

Quoted 16 lines
Quoted 16 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +13 -1
+
+Example:
+
+	mipi_dphy_rx1: dphy@d00003040 {
+		compatible = "snps,dphy-rx";
+		#phy-cells = <1>;
+		snps,dphy-frequency = <300000>;
+		snps,dphy-te-len = <12>;
+		reg = < 0xd0003040 0x20
+			0xd0008000 0x100
+			0xd0009000 0x100>;
+	};
+
--

2.7.4

#4 lore raw

Re: [V3, 1/4] Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings

In reply to Rob Herring

Hi Rob, my responses inline.

Quoted 27 lines · Rob Herring
Quoted 26 lines · Luis Oliveira

Add device-tree bindings documentation for SNPS DesignWare MIPI D-PHY in RX mode.

---
Changelog
v2-V3
- removed gpios reference - it was for a separated driver
- changed address to show complete address

 .../devicetree/bindings/phy/snps,dphy-rx.txt       | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +6 -0
new file mode 100644
index 0000000..03d17ab
@@ -0,0 +1,28 @@
+Synopsys DesignWare MIPI Rx D-PHY block details
+
+Description
+-----------
+
+The Synopsys MIPI D-PHY controller supports MIPI-DPHY in receiver mode.
Quoted 9 lines

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 12

Quoted 6 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +6 -0
+Please refer to phy-bindings.txt for more information.
+
+Required properties:
+- compatible		: Shall be "snps,dphy-rx".
+- #phy-cells		: Must be 1.
+- snps,dphy-frequency	: Output frequency of the D-PHY.

Needs a unit suffix (-hz).

Yes,

Quoted 8 lines

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +3 -0
+- snps,dphy-te-len	: Size of the communication interface (8 bits->8 or 12bits->12).
+- reg			: Physical base address and size of the device memory mapped
+		 	  registers;

How many, what are they, and what order? Looks like 3 below.

Also, a tab after spaces error.

Yep, I will fix it. Thanks

Quoted 16 lines
Quoted 16 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +13 -1
+
+Example:
+
+	mipi_dphy_rx1: dphy@d00003040 {
+		compatible = "snps,dphy-rx";
+		#phy-cells = <1>;
+		snps,dphy-frequency = <300000>;
+		snps,dphy-te-len = <12>;
+		reg = < 0xd0003040 0x20
+			0xd0008000 0x100
+			0xd0009000 0x100>;
+	};
+
--

2.7.4

#5 lore raw

Re: [V3, 1/4] Documentation: dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings

In reply to Luis Oliveira

Hi Luis,

Thank you for the patch.

Quoted 23 lines · On Friday, 19 October 2018 15:52:23 EET Luis Oliveira wrote:

Add device-tree bindings documentation for SNPS DesignWare MIPI D-PHY in RX mode.

---
Changelog
v2-V3
- removed gpios reference - it was for a separated driver
- changed address to show complete address

 .../devicetree/bindings/phy/snps,dphy-rx.txt       | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file mode 100644
index 0000000..03d17ab

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +2 -0
@@ -0,0 +1,28 @@
+Synopsys DesignWare MIPI Rx D-PHY block details
+

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +10 -0
+Description
+-----------
+
+The Synopsys MIPI D-PHY controller supports MIPI-DPHY in receiver mode.
+Please refer to phy-bindings.txt for more information.
+
+Required properties:
+- compatible		: Shall be "snps,dphy-rx".
+- #phy-cells		: Must be 1.
+- snps,dphy-frequency	: Output frequency of the D-PHY.

You replied to my review of v2 that you would remove this property. Is this an oversight ?

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt line 15

Quoted 4 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +1 -0
+- snps,dphy-te-len	: Size of the communication interface (8 bits->8 or

12bits->12).
+- reg : Physical base address and size of the device memory mapped

Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +1 -0
+		 	  registers;

Please document the ranges.

Quoted 12 lines
Documentation/devicetree/bindings/phy/snps,dphy-rx.txt new file +12 -0
+Example:
+
+	mipi_dphy_rx1: dphy@d00003040 {
+		compatible = "snps,dphy-rx";
+		#phy-cells = <1>;
+		snps,dphy-frequency = <300000>;
+		snps,dphy-te-len = <12>;
+		reg = < 0xd0003040 0x20
+			0xd0008000 0x100
+			0xd0009000 0x100>;
+	};
+
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

PATCH v3 2/4 media: platform: dwc: Add DW MIPI DPHY Rx platform

In reply to Luis Oliveira

Add of Synopsys MIPI D-PHY in RX mode support.
Separated in the implementation are platform dependent probing functions.

---
Changelog
v2-V3
- merged V2 Patch 1 with Patch 3.
- fixed headers problems.
- add IS_ENABLED to separate implementations of "ASIC" DPHY and "TESTCHIP" DPHY flow.

 drivers/media/platform/Kconfig            |   1 +
 drivers/media/platform/Makefile           |   3 +
 drivers/media/platform/dwc/Kconfig        |  24 ++
 drivers/media/platform/dwc/Makefile       |   2 +
 drivers/media/platform/dwc/dw-dphy-plat.c | 347 +++++++++++++++++
 drivers/media/platform/dwc/dw-dphy-rx.c   | 596 ++++++++++++++++++++++++++++++
 drivers/media/platform/dwc/dw-dphy-rx.h   | 181 +++++++++
 7 files changed, 1154 insertions(+)
 create mode 100644 drivers/media/platform/dwc/Kconfig
 create mode 100644 drivers/media/platform/dwc/Makefile
 create mode 100644 drivers/media/platform/dwc/dw-dphy-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-dphy-rx.c
 create mode 100644 drivers/media/platform/dwc/dw-dphy-rx.h
drivers/media/platform/Kconfig +1 -0
index f627587..f627a27 100644
@@ -137,6 +137,7 @@ source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
 source "drivers/media/platform/rcar-vin/Kconfig"
 source "drivers/media/platform/atmel/Kconfig"
+source "drivers/media/platform/dwc/Kconfig"
 
 config VIDEO_TI_CAL
 	tristate "TI CAL (Camera Adaptation Layer) driver"
drivers/media/platform/Makefile +3 -0
index 6ab6200..def2f33 100644
@@ -98,3 +98,6 @@ obj-$(CONFIG_VIDEO_QCOM_VENUS)		+= qcom/venus/
 obj-y					+= meson/
 
 obj-y					+= cros-ec-cec/
+
+obj-y					+= dwc/
+
drivers/media/platform/dwc/Kconfig new file +24 -0
new file mode 100644
index 0000000..353034c
@@ -0,0 +1,24 @@
+#
+#  Synopsys DWC Platform drivers
+#	Drivers here are currently for MIPI DPHY support
+
+config DWC_MIPI_DPHY_GEN3
+	tristate "DesignWare platform support using a Gen3 D-PHY"
+	depends on DWC_MIPI_CSI2_HOST
+	select GENERIC_PHY
+	help
+	 Synopsys MIPI D-PHY Generation 3 reference driver.
+
+	  If unsure, say N.
+
+if DWC_MIPI_DPHY_GEN3
+
+config DWC_MIPI_TC_DPHY_GEN3
+	bool "Platform support using a Synopsys Test Chip"
+	help
+	 Synopsys Test Chip is for prototyping purposes.
+
+	  If unsure, say N.
+
+endif # DWC_MIPI_DPHY_GEN3
+
drivers/media/platform/dwc/Makefile new file +2 -0
new file mode 100644
index 0000000..2573e96
@@ -0,0 +1,2 @@
+obj-$(CONFIG_DWC_MIPI_DPHY_GEN3) += dw-dphy-platfrm.o
+dw-dphy-platfrm-objs := dw-dphy-plat.o dw-dphy-rx.o
drivers/media/platform/dwc/dw-dphy-plat.c new file +347 -0

347 lines not on this page · raw message

drivers/media/platform/dwc/dw-dphy-rx.c new file +596 -0

596 lines not on this page · raw message

drivers/media/platform/dwc/dw-dphy-rx.h new file +181 -0

181 lines not on this page · raw message

--
2.7.4

#7 lore raw

Re: [V3, 2/4] media: platform: dwc: Add DW MIPI DPHY Rx platform

Hi Luis,

Quoted 4 lines · Luis Oliveira

Add of Synopsys MIPI D-PHY in RX mode support.
Separated in the implementation are platform dependent probing functions.

Maxime has a patchset adding D-PHY parameters to the PHY API. I think they could be relevant for this one as well:

<URL:https://www.spinics.net/lists/linux-media/msg144214.html>

Signature · 3 lines
Kind regards,

Sakari Ailus
#8 lore raw

Re: [V3, 2/4] media: platform: dwc: Add DW MIPI DPHY Rx platform

Hi Sakari,

Quoted 11 lines · Sakari Ailus

Hi Luis,

Quoted 4 lines · Luis Oliveira

Add of Synopsys MIPI D-PHY in RX mode support.
Separated in the implementation are platform dependent probing functions.

Maxime has a patchset adding D-PHY parameters to the PHY API. I think they could be relevant for this one as well:

Maxime was kind to send me the patchset for me to use.
I was on a different project for the last weeks but I will get back to this and prepare a V4 with the new PHY API parameters asap.

Thank you,
Luis

#9 lore raw

PATCH v3 3/4 Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

In reply to Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +52 -0
new file mode 100644
index 0000000..be3da05
@@ -0,0 +1,52 @@
+Synopsys DesignWare CSI-2 Host controller
+
+Description
+-----------
+
+This HW block is used to receive image coming from an MIPI CSI-2 compatible
+camera.
+
+Required properties:
+- compatible: shall be "snps,dw-csi-plat"
+- reg			: physical base address and size of the device memory mapped
+  registers;
+- interrupts		: CSI-2 Host interrupt
+- snps,output-type	: Core output to be used (IPI-> 0 or IDI->1 or BOTH->2)
+			  These  values choose which of the Core outputs will be used,
+			  it can be Image Data Interface or Image Pixel Interface.
+- phys			: List of one PHY specifier (as defined in
+			  Documentation/devicetree/bindings/phy/phy-bindings.txt).
+			  This PHY is a MIPI DPHY working in RX mode.
+- resets		: Reference to a reset controller (optional)
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the camera as
+   described in video-interfaces.txt[1].
+
+Example:
+
+	csi2_1: csi2@3000 {
+		compatible = "snps,dw-csi-plat";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = < 0x03000 0x7FF>;
+		interrupts = <2>;
+		output-type = <2>;
+		resets = <&dw_rst 1>;
+		phys = <&mipi_dphy_rx1 0>;
+		phy-names = "csi2-dphy";
+
+		/* CSI-2 per-board settings */
+		port@1 {
+			reg = <1>;
+			csi1_ep1: endpoint {
+				remote-endpoint = <&camera_1>;
+				data-lanes = <1 2>;
+			};
+		};
+		port@2 {
+			csi1_ep2: endpoint {
+				remote-endpoint = <&vif1_ep>;
+			};
+		};
+	};

--
2.7.4

maintainer
#10 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

Quoted 18 lines · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +0 -0
new file mode 100644
index 0000000..be3da05

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +10 -0
@@ -0,0 +1,52 @@
+Synopsys DesignWare CSI-2 Host controller
+
+Description
+-----------
+
+This HW block is used to receive image coming from an MIPI CSI-2 compatible
+camera.
+
+Required properties:
+- compatible: shall be "snps,dw-csi-plat"

'plat' is really part of the name of the h/w block?

Quoted 4 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +4 -0
+- reg			: physical base address and size of the device memory mapped
+  registers;
+- interrupts		: CSI-2 Host interrupt
+- snps,output-type	: Core output to be used (IPI-> 0 or IDI->1 or BOTH->2)

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 24

Quoted 10 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +10 -0
+			  These  values choose which of the Core outputs will be used,
+			  it can be Image Data Interface or Image Pixel Interface.
+- phys			: List of one PHY specifier (as defined in
+			  Documentation/devicetree/bindings/phy/phy-bindings.txt).
+			  This PHY is a MIPI DPHY working in RX mode.
+- resets		: Reference to a reset controller (optional)
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the camera as
+   described in video-interfaces.txt[1].

Need to say 2 ports and what is each port? Why no port #0?

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 37

Quoted 13 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +13 -0
+
+Example:
+
+	csi2_1: csi2@3000 {
+		compatible = "snps,dw-csi-plat";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = < 0x03000 0x7FF>;
+		interrupts = <2>;
+		output-type = <2>;
+		resets = <&dw_rst 1>;
+		phys = <&mipi_dphy_rx1 0>;
+		phy-names = "csi2-dphy";

Not documented. Not really needed for a single entry, so I'd just drop it.

Quoted 18 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +15 -1
+
+		/* CSI-2 per-board settings */
+		port@1 {
+			reg = <1>;
+			csi1_ep1: endpoint {
+				remote-endpoint = <&camera_1>;
+				data-lanes = <1 2>;
+			};
+		};
+		port@2 {
+			csi1_ep2: endpoint {
+				remote-endpoint = <&vif1_ep>;
+			};
+		};
+	};
--

2.7.4

#11 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

Quoted 23 lines · Rob Herring
Quoted 22 lines · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +4 -0
new file mode 100644
index 0000000..be3da05
@@ -0,0 +1,52 @@
+Synopsys DesignWare CSI-2 Host controller
+
+Description
+-----------
Quoted 9 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 10

Quoted 6 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +6 -0
+
+This HW block is used to receive image coming from an MIPI CSI-2 compatible
+camera.
+
+Required properties:
+- compatible: shall be "snps,dw-csi-plat"

'plat' is really part of the name of the h/w block?

It is the name of the platform driver for CSI compatible with this block. Is that wrong?

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +8 -0
+- reg			: physical base address and size of the device memory mapped
+  registers;
+- interrupts		: CSI-2 Host interrupt
+- snps,output-type	: Core output to be used (IPI-> 0 or IDI->1 or BOTH->2)
+			  These  values choose which of the Core outputs will be used,
+			  it can be Image Data Interface or Image Pixel Interface.
+- phys			: List of one PHY specifier (as defined in
+			  Documentation/devicetree/bindings/phy/phy-bindings.txt).
Quoted 9 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 24

Quoted 6 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +6 -0
+			  This PHY is a MIPI DPHY working in RX mode.
+- resets		: Reference to a reset controller (optional)
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the camera as
+   described in video-interfaces.txt[1].

Need to say 2 ports and what is each port? Why no port #0?

I will elaborate on that.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +8 -0
+
+Example:
+
+	csi2_1: csi2@3000 {
+		compatible = "snps,dw-csi-plat";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = < 0x03000 0x7FF>;
Quoted 9 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 37

Quoted 5 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +5 -0
+		interrupts = <2>;
+		output-type = <2>;
+		resets = <&dw_rst 1>;
+		phys = <&mipi_dphy_rx1 0>;
+		phy-names = "csi2-dphy";

Not documented. Not really needed for a single entry, so I'd just drop it.

I will, thanks.

Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +15 -1
+
+		/* CSI-2 per-board settings */
+		port@1 {
+			reg = <1>;
+			csi1_ep1: endpoint {
+				remote-endpoint = <&camera_1>;
+				data-lanes = <1 2>;
+			};
+		};
+		port@2 {
+			csi1_ep2: endpoint {
+				remote-endpoint = <&vif1_ep>;
+			};
+		};
+	};
--

2.7.4

#12 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

Hi Luis,

Thank you for the patch.

Quoted 34 lines · On Tuesday, 13 November 2018 12:00:22 EET Luis de Oliveira wrote:
Quoted 24 lines · Rob Herring
Quoted 23 lines · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt>>

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file mode 100644
index 0000000..be3da05

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +4 -0
@@ -0,0 +1,52 @@
+Synopsys DesignWare CSI-2 Host controller
+
+Description
+-----------
Quoted 8 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 10

Quoted 6 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +2 -0
+
+This HW block is used to receive image coming from an MIPI CSI-2

compatible +camera.

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +3 -0
+
+Required properties:
+- compatible: shall be "snps,dw-csi-plat"

'plat' is really part of the name of the h/w block?

Quoted 2 lines

It is the name of the platform driver for CSI compatible with this block. Is that wrong?

DT bindings describe hardware, not drivers. This should be the name of the IP core, regardless of how the drivers are architectured and named.

Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 16

Quoted 8 lines

+- reg : physical base address and size of the device memory
mapped
+ registers;

+- interrupts		: CSI-2 Host interrupt
+- snps,output-type	: Core output to be used (IPI-> 0 or IDI->1 or

BOTH->2)

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +2 -0
+			  These  values choose which of the Core outputs will be used,
+			  it can be Image Data Interface or Image Pixel Interface.

Does this describe what outputs the IP core has been instantiated (synthesized) with, or what output(s) are used at runtime ? How does that relate to the port nodes ?

Quoted 47 lines
Quoted 10 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 24

Quoted 8 lines

+- phys : List of one PHY specifier (as defined in

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +7 -0
+			  Documentation/devicetree/bindings/phy/phy-bindings.txt).
+			  This PHY is a MIPI DPHY working in RX mode.
+- resets		: Reference to a reset controller (optional)
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the camera as
+   described in video-interfaces.txt[1].

Need to say 2 ports and what is each port? Why no port #0?

I will elaborate on that.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +8 -0
+
+Example:
+
+	csi2_1: csi2@3000 {
+		compatible = "snps,dw-csi-plat";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = < 0x03000 0x7FF>;
Quoted 8 lines

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 37

Quoted 5 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +5 -0
+		interrupts = <2>;
+		output-type = <2>;
+		resets = <&dw_rst 1>;
+		phys = <&mipi_dphy_rx1 0>;
+		phy-names = "csi2-dphy";

Not documented. Not really needed for a single entry, so I'd just drop it.

I will, thanks.

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +15 -0
+
+		/* CSI-2 per-board settings */
+		port@1 {
+			reg = <1>;
+			csi1_ep1: endpoint {
+				remote-endpoint = <&camera_1>;
+				data-lanes = <1 2>;
+			};
+		};
+		port@2 {
+			csi1_ep2: endpoint {
+				remote-endpoint = <&vif1_ep>;
+			};
+		};
+	};
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer
#13 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

In reply to Luis Oliveira
Quoted 1 line · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

Also, drop "Documentation: " from the subject. All bindings are documentation and the preferred prefix is 'dt-bindings: <binding dir>: '.

Quoted 10 lines

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
#14 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

Quoted 7 lines · Rob Herring
Quoted 1 line · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

Also, drop "Documentation: " from the subject. All bindings are documentation and the preferred prefix is 'dt-bindings: <binding dir>: '.

Quoted 1 line

Ok, thank you again.

Quoted 9 lines
Quoted 9 lines

---
Changelog
v2-V3
- removed IPI settings

 .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
#15 lore raw

Re: [V3, 3/4] Documentation: dt-bindings: media: Document bindings for DW MIPI CSI-2 Host

In reply to Luis Oliveira
Quoted 57 lines · Luis Oliveira

Add bindings for Synopsys DesignWare MIPI CSI-2 host.

---
Changelog
v2-V3
- removed IPI settings

  .../devicetree/bindings/media/snps,dw-csi-plat.txt | 52 ++++++++++++++++++++++
  1 file changed, 52 insertions(+)

create mode 100644 Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +39 -0
new file mode 100644
index 0000000..be3da05
@@ -0,0 +1,52 @@
+Synopsys DesignWare CSI-2 Host controller
+
+Description
+-----------
+
+This HW block is used to receive image coming from an MIPI CSI-2 compatible
+camera.
+
+Required properties:
+- compatible: shall be "snps,dw-csi-plat"
+- reg			: physical base address and size of the device memory mapped
+  registers;
+- interrupts		: CSI-2 Host interrupt
+- snps,output-type	: Core output to be used (IPI-> 0 or IDI->1 or BOTH->2)
+			  These  values choose which of the Core outputs will be used,
+			  it can be Image Data Interface or Image Pixel Interface.
+- phys			: List of one PHY specifier (as defined in
+			  Documentation/devicetree/bindings/phy/phy-bindings.txt).
+			  This PHY is a MIPI DPHY working in RX mode.
+- resets		: Reference to a reset controller (optional)
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the camera as
+   described in video-interfaces.txt[1].
+
+Example:
+
+	csi2_1: csi2@3000 {
+		compatible = "snps,dw-csi-plat";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = < 0x03000 0x7FF>;
+		interrupts = <2>;
+		output-type = <2>;
+		resets = <&dw_rst 1>;
+		phys = <&mipi_dphy_rx1 0>;
+		phy-names = "csi2-dphy";
+
+		/* CSI-2 per-board settings */

Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt line 49

Quoted 10 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +10 -0
+		port@1 {
+			reg = <1>;
+			csi1_ep1: endpoint {
+				remote-endpoint = <&camera_1>;
+				data-lanes = <1 2>;
+			};
+		};
+		port@2 {
+			csi1_ep2: endpoint {
+				remote-endpoint = <&vif1_ep>;

Hi again Luis,

Regarding the output endpoint, in your example port@2, if we use the property snps,output-type=2 for example, so IDI output, which bus-type you have in mind for this link? IDI is not documented in the video-interfaces.txt binding.

Since the MIPI CSI-2 DPHY is actually between camera sensor and csi2host, after this we can use either IDI or IPI if my understanding is correct, and connect to a different pad/hw block which can further handle these packets/pixels.

I am interested on how to specify the connection type between this output pad and the next one (until a /dev/video can be registered by the last driver for the last hw block).

Thanks,

Eugen

Quoted 7 lines
Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt new file +3 -1
+			};
+		};
+	};
--

2.7.4

#16 lore raw

PATCH v3 4/4 media: platform: dwc: Add MIPI CSI-2 controller driver

In reply to Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

 MAINTAINERS                              |  11 +
 drivers/media/platform/dwc/Kconfig       |  30 +-
 drivers/media/platform/dwc/Makefile      |   2 +
 drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
 drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
 drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
 drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
 include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
 8 files changed, 1616 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h
 create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h
MAINTAINERS +11 -0
index da2e509..fd5f1fc 100644
@@ -14032,6 +14032,16 @@ S:	Maintained
 F:	drivers/dma/dwi-axi-dmac/
 F:	Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.txt
 
+SYNOPSYS DESIGNWARE MIPI CSI-2 HOST VIDEO PLATFORM
+M:	Luis Oliveira <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/dwc
+F:	include/media/dwc/dw-mipi-csi-pltfrm.h
+F:	Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
+F:	Documentation/devicetree/bindings/phy/snps,dphy-rx.txt
+
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M:	Viresh Kumar <[email protected]>
 R:	Andy Shevchenko <[email protected]>
@@ -16217,3 +16227,4 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 S:	Buried alive in reporters
 F:	*
 F:	*/
+
drivers/media/platform/dwc/Kconfig +29 -1
index 353034c..7c3332c 100644
@@ -1,6 +1,34 @@
 #
 #  Synopsys DWC Platform drivers
-#	Drivers here are currently for MIPI DPHY support
+#	Most drivers here are currently for MIPI CSI-2 and MIPI DPHY support
+
+config DWC_MIPI_CSI2_HOST
+	bool "Synopsys Designware CSI-2 Host Controller and DPHY-RX support"
+	select VIDEO_DEV
+	select VIDEO_V4L2
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	 This selects the CSI-2 host controller support.
+
+	 If you have a controller with this interface, say Y.
+
+	  If unsure, say N.
+
+if DWC_MIPI_CSI2_HOST
+
+config DWC_MIPI_CSI2_HOST_PLATFORM
+	tristate "Platform bus based CSI-2 Host Controller support"
+	depends on HAS_DMA
+	help
+	 This selects the CSI-2 host controller support. Select this if
+	 you have an CSI-2 Host controller on Platform bus.
+
+	 If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
+endif # DWC_MIPI_CSI2_HOST
 
 config DWC_MIPI_DPHY_GEN3
 	tristate "DesignWare platform support using a Gen3 D-PHY"
drivers/media/platform/dwc/Makefile +2 -0
index 2573e96..ab0de7d 100644
@@ -1,2 +1,4 @@
 obj-$(CONFIG_DWC_MIPI_DPHY_GEN3) += dw-dphy-platfrm.o
 dw-dphy-platfrm-objs := dw-dphy-plat.o dw-dphy-rx.o
+obj-$(CONFIG_DWC_MIPI_CSI2_HOST_PLATFORM) += dw-csi-platfrm.o
+dw-csi-platfrm-objs := dw-csi-plat.o dw-mipi-csi.o
drivers/media/platform/dwc/dw-csi-plat.c new file +699 -0

699 lines not on this page · raw message

drivers/media/platform/dwc/dw-csi-plat.h new file +77 -0

77 lines not on this page · raw message

drivers/media/platform/dwc/dw-mipi-csi.c new file +494 -0

494 lines not on this page · raw message

drivers/media/platform/dwc/dw-mipi-csi.h new file +202 -0

202 lines not on this page · raw message

include/media/dwc/dw-mipi-csi-pltfrm.h new file +102 -0

102 lines not on this page · raw message

--
2.7.4

#17 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Hi Luis,

Thank you for the patch.

Quoted 10 lines · On Friday, 19 October 2018 15:52:26 EET Luis Oliveira wrote:

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace

Could you please explain why you need this and can't use standard APIs ? Custom sysfs attributes are needed, they need to be documented in Documentation/ABI/.

Quoted 24 lines

- fixed headers

 MAINTAINERS                              |  11 +
 drivers/media/platform/dwc/Kconfig       |  30 +-
 drivers/media/platform/dwc/Makefile      |   2 +
 drivers/media/platform/dwc/dw-csi-plat.c | 699 ++++++++++++++++++++++++++++
 drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
 drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
 drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
 include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
 8 files changed, 1616 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h
 create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h
MAINTAINERS +0 -0
index da2e509..fd5f1fc 100644
@@ -14032,6 +14032,16 @@ S:	Maintained
 F:	drivers/dma/dwi-axi-dmac/
 F:	Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.txt

MAINTAINERS S: Maintained · line 14043

Quoted 10 lines
MAINTAINERS +9 -0
 
+SYNOPSYS DESIGNWARE MIPI CSI-2 HOST VIDEO PLATFORM
+M:	Luis Oliveira <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/dwc
+F:	include/media/dwc/dw-mipi-csi-pltfrm.h
+F:	Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
+F:	Documentation/devicetree/bindings/phy/snps,dphy-rx.txt

These two lines belong to patches 1/4 and 3/4. Doesn't checkpatch.pl warn about this ? Now that I mentioned checkpatch.pl, I tried running it on this series, and it generates a fair number of warnings and errors. Could you please fix them ?

Quoted 10 lines
MAINTAINERS +1 -0
+
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M:	Viresh Kumar <[email protected]>
 R:	Andy Shevchenko <[email protected]>
@@ -16217,3 +16227,4 @@ T:	git

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git S: Buried
alive in reporters
F: *
F: */
+

Stray new line.

[snip]

Signature · 3 lines
Regards,

Laurent Pinchart
#18 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Hi Laurent,

Sorry for taking so long to answer. I was stuck in other projects and lost track of this.

My answers inline,

Quoted 16 lines · Laurent Pinchart

Hi Luis,

Thank you for the patch.

Quoted 10 lines · On Friday, 19 October 2018 15:52:26 EET Luis Oliveira wrote:

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace

Quoted 4 lines

Could you please explain why you need this and can't use standard APIs ? Custom sysfs attributes are needed, they need to be documented in Documentation/ABI/.

IPI - Image Pixel Interface enables to access direct video stream in our CSI-2 Host IP and needs to be configured to match the video source. I can't hard code it. But maybe I can think of a way to configure it using the video configuration. I will try do that in the next patchset.

Quoted 25 lines
Quoted 25 lines

- fixed headers

 MAINTAINERS                              |  11 +
 drivers/media/platform/dwc/Kconfig       |  30 +-
 drivers/media/platform/dwc/Makefile      |   2 +
 drivers/media/platform/dwc/dw-csi-plat.c | 699 ++++++++++++++++++++++++++++
 drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
 drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
 drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
 include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
 8 files changed, 1616 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c
 create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c
 create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h
 create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h
MAINTAINERS +0 -0
index da2e509..fd5f1fc 100644
@@ -14032,6 +14032,16 @@ S:	Maintained
 F:	drivers/dma/dwi-axi-dmac/
 F:	Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.txt
 
Quoted 15 lines

MAINTAINERS S: Maintained · line 14043

Quoted 9 lines
MAINTAINERS +9 -0
+SYNOPSYS DESIGNWARE MIPI CSI-2 HOST VIDEO PLATFORM
+M:	Luis Oliveira <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/dwc
+F:	include/media/dwc/dw-mipi-csi-pltfrm.h
+F:	Documentation/devicetree/bindings/media/snps,dw-csi-plat.txt
+F:	Documentation/devicetree/bindings/phy/snps,dphy-rx.txt

These two lines belong to patches 1/4 and 3/4. Doesn't checkpatch.pl warn about this ? Now that I mentioned checkpatch.pl, I tried running it on this series, and it generates a fair number of warnings and errors. Could you please fix them ?

I did, but maybe - or probably - i did not fix them all. Sorry.
I am preparing a new patchset and I will make sure everything goes right this time.

Quoted 4 lines
Quoted 4 lines
MAINTAINERS +1 -0
+
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M:	Viresh Kumar <[email protected]>
 R:	Andy Shevchenko <[email protected]>
Quoted 9 lines
Quoted 6 lines
MAINTAINERS +0 -0
@@ -16217,3 +16227,4 @@ T:	git

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git S: Buried
alive in reporters
F: *
F: */
+

Stray new line.

Noted.

Quoted 2 lines

[snip]

Thank you,
Luis

#19 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

In reply to Luis Oliveira
Quoted 11 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

[...]

snip

drivers/media/platform/dwc/dw-csi-plat.c line 172

Quoted 6 lines
drivers/media/platform/dwc/dw-csi-plat.c new file +6 -0
+
+static int
+dw_mipi_csi_parse_dt(struct platform_device *pdev, struct mipi_csi_dev *dev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct v4l2_fwnode_endpoint endpoint;

Hello Luis,

I believe you have to initialize "endpoint" here correctly, otherwise the parsing mechanism (fwnode_endpoint_parse) will consider you have a specific mbus type and fail to probe the endpoint: bail out with debug message "expecting bus type not found "

(namely, initialize to zero which is the UNKNOWN mbus type, or , to a specific mbus (from DT or whatever source))

Eugen

Quoted 25 lines
drivers/media/platform/dwc/dw-csi-plat.c new file +25 -0
+	int ret;
+
+	node = of_graph_get_next_endpoint(node, NULL);
+	if (!node) {
+		dev_err(&pdev->dev, "No port node at %s\n",
+				pdev->dev.of_node->full_name);
+		return -EINVAL;
+	}
+
+	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &endpoint);
+	if (ret)
+		goto err;
+
+	dev->index = endpoint.base.port - 1;
+	if (dev->index >= CSI_MAX_ENTITIES) {
+		ret = -ENXIO;
+		goto err;
+	}
+	dev->hw.num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
+
+err:
+	of_node_put(node);
+	return ret;
+}
+

snip

#20 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Quoted 33 lines · On 10-Dec-18 12:39, [email protected] wrote:
Quoted 11 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

[...]

snip

drivers/media/platform/dwc/dw-csi-plat.c line 172

Quoted 6 lines
drivers/media/platform/dwc/dw-csi-plat.c new file +6 -0
+
+static int
+dw_mipi_csi_parse_dt(struct platform_device *pdev, struct mipi_csi_dev *dev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct v4l2_fwnode_endpoint endpoint;

Hello Luis,

I believe you have to initialize "endpoint" here correctly, otherwise the parsing mechanism (fwnode_endpoint_parse) will consider you have a specific mbus type and fail to probe the endpoint: bail out with debug message "expecting bus type not found "

Quoted 5 lines

(namely, initialize to zero which is the UNKNOWN mbus type, or , to a specific mbus (from DT or whatever source))

Eugen

Hi Eugen,

Sorry for my late reply, I was on Christmas break. You are right, I will add that fix.

Quoted 20 lines
Quoted 20 lines
drivers/media/platform/dwc/dw-csi-plat.c new file +19 -0
+	int ret;
+
+	node = of_graph_get_next_endpoint(node, NULL);
+	if (!node) {
+		dev_err(&pdev->dev, "No port node at %s\n",
+				pdev->dev.of_node->full_name);
+		return -EINVAL;
+	}
+
+	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &endpoint);
+	if (ret)
+		goto err;
+
+	dev->index = endpoint.base.port - 1;
+	if (dev->index >= CSI_MAX_ENTITIES) {
+		ret = -ENXIO;
+		goto err;
+	}
+	dev->hw.num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
Quoted 9 lines
Quoted 6 lines
drivers/media/platform/dwc/dw-csi-plat.c new file +6 -0
+
+err:
+	of_node_put(node);
+	return ret;
+}
+

snip

Thank you.

#21 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

In reply to Luis Oliveira
Quoted 27 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

  MAINTAINERS                              |  11 +
  drivers/media/platform/dwc/Kconfig       |  30 +-
  drivers/media/platform/dwc/Makefile      |   2 +
  drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
  drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
  drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
  drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
  include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
  8 files changed, 1616 insertions(+), 1 deletion(-)

create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

[snip]

drivers/media/platform/dwc/dw-csi-plat.h line 49

Quoted 12 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +12 -0
+/* Video formats supported by the MIPI CSI-2 */
+const struct mipi_fmt dw_mipi_csi_formats[] = {
+	{
+		/* RAW 8 */
+		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
+		.depth = 8,
+	},
+	{
+		/* RAW 10 */
+		.code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE,
+		.depth = 10,
+	},

Hi Luis,

Any reason why RAW12 format is not handled here ?

Here, namely MEDIA_BUS_FMT_SBGGR12_1X12 etc.

Quoted 21 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +21 -0
+	{
+		/* RGB 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+		.depth = 16,
+	},
+	{
+		/* BGR 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+		.depth = 16,
+	},
+	{
+		/* RGB 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_LE,
+		.depth = 24,
+	},
+	{
+		/* BGR 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_BE,
+		.depth = 24,
+	},
+};

[snip]

Quoted 22 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +22 -0
+
+void dw_mipi_csi_set_ipi_fmt(struct mipi_csi_dev *csi_dev)
+{
+	struct device *dev = csi_dev->dev;
+
+	if (csi_dev->ipi_dt)
+		dw_mipi_csi_write(csi_dev, reg.IPI_DATA_TYPE, csi_dev->ipi_dt);
+	else {
+		switch (csi_dev->fmt->code) {
+		case MEDIA_BUS_FMT_RGB565_2X8_BE:
+		case MEDIA_BUS_FMT_RGB565_2X8_LE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "DT: RGB 565");
+			break;
+
+		case MEDIA_BUS_FMT_RGB888_2X12_LE:
+		case MEDIA_BUS_FMT_RGB888_2X12_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB888);
+			dev_dbg(dev, "DT: RGB 888");
+			break;

drivers/media/platform/dwc/dw-mipi-csi.c line 188

Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +10 -0
+		case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW10);
+			dev_dbg(dev, "DT: RAW 10");
+			break;
+		case MEDIA_BUS_FMT_SBGGR8_1X8:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW8);
+			dev_dbg(dev, "DT: RAW 8");
+			break;

Same here, in CSI_2_RAW12 case it will default to a RGB565 case.

Thanks,

Eugen

Quoted 9 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +9 -0
+		default:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "Error");
+			break;
+		}
+	}
+}
+

[snip]

#22 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Quoted 48 lines · On 09-Jan-19 13:07, [email protected] wrote:
Quoted 27 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

  MAINTAINERS                              |  11 +
  drivers/media/platform/dwc/Kconfig       |  30 +-
  drivers/media/platform/dwc/Makefile      |   2 +
  drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
  drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
  drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
  drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
  include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
  8 files changed, 1616 insertions(+), 1 deletion(-)

create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

[snip]

drivers/media/platform/dwc/dw-csi-plat.h line 49

Quoted 12 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +12 -0
+/* Video formats supported by the MIPI CSI-2 */
+const struct mipi_fmt dw_mipi_csi_formats[] = {
+	{
+		/* RAW 8 */
+		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
+		.depth = 8,
+	},
+	{
+		/* RAW 10 */
+		.code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE,
+		.depth = 10,
+	},

Hi Luis,

Quoted 4 lines

Any reason why RAW12 format is not handled here ?

Here, namely MEDIA_BUS_FMT_SBGGR12_1X12 etc.

Hi Eugen,

My Hw testing setup currently does not support it, so I didn't add it.

Quoted 59 lines
Quoted 21 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +21 -0
+	{
+		/* RGB 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+		.depth = 16,
+	},
+	{
+		/* BGR 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+		.depth = 16,
+	},
+	{
+		/* RGB 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_LE,
+		.depth = 24,
+	},
+	{
+		/* BGR 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_BE,
+		.depth = 24,
+	},
+};

[snip]

Quoted 22 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +22 -0
+
+void dw_mipi_csi_set_ipi_fmt(struct mipi_csi_dev *csi_dev)
+{
+	struct device *dev = csi_dev->dev;
+
+	if (csi_dev->ipi_dt)
+		dw_mipi_csi_write(csi_dev, reg.IPI_DATA_TYPE, csi_dev->ipi_dt);
+	else {
+		switch (csi_dev->fmt->code) {
+		case MEDIA_BUS_FMT_RGB565_2X8_BE:
+		case MEDIA_BUS_FMT_RGB565_2X8_LE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "DT: RGB 565");
+			break;
+
+		case MEDIA_BUS_FMT_RGB888_2X12_LE:
+		case MEDIA_BUS_FMT_RGB888_2X12_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB888);
+			dev_dbg(dev, "DT: RGB 888");
+			break;

drivers/media/platform/dwc/dw-mipi-csi.c line 188

Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +10 -0
+		case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW10);
+			dev_dbg(dev, "DT: RAW 10");
+			break;
+		case MEDIA_BUS_FMT_SBGGR8_1X8:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW8);
+			dev_dbg(dev, "DT: RAW 8");
+			break;

Same here, in CSI_2_RAW12 case it will default to a RGB565 case.

Quoted 5 lines

Thanks,

Eugen

I will try to add the support for this data type in my next patchset if not I will flag it as unsupported for now in the commit message and code.

Thanks for your review,
Luis

Quoted 13 lines
Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +9 -0
+		default:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "Error");
+			break;
+		}
+	}
+}
+

[snip]

#23 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Quoted 118 lines · Luis de Oliveira
Quoted 48 lines · On 09-Jan-19 13:07, [email protected] wrote:
Quoted 27 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

   MAINTAINERS                              |  11 +
   drivers/media/platform/dwc/Kconfig       |  30 +-
   drivers/media/platform/dwc/Makefile      |   2 +
   drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
   drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
   drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
   drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
   include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
   8 files changed, 1616 insertions(+), 1 deletion(-)

create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

[snip]

drivers/media/platform/dwc/dw-csi-plat.h line 49

Quoted 12 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +12 -0
+/* Video formats supported by the MIPI CSI-2 */
+const struct mipi_fmt dw_mipi_csi_formats[] = {
+	{
+		/* RAW 8 */
+		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
+		.depth = 8,
+	},
+	{
+		/* RAW 10 */
+		.code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE,
+		.depth = 10,
+	},

Hi Luis,

Quoted 4 lines

Any reason why RAW12 format is not handled here ?

Here, namely MEDIA_BUS_FMT_SBGGR12_1X12 etc.

Hi Eugen,

My Hw testing setup currently does not support it, so I didn't add it.

Quoted 59 lines
Quoted 21 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +21 -0
+	{
+		/* RGB 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+		.depth = 16,
+	},
+	{
+		/* BGR 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+		.depth = 16,
+	},
+	{
+		/* RGB 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_LE,
+		.depth = 24,
+	},
+	{
+		/* BGR 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_BE,
+		.depth = 24,
+	},
+};

[snip]

Quoted 22 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +22 -0
+
+void dw_mipi_csi_set_ipi_fmt(struct mipi_csi_dev *csi_dev)
+{
+	struct device *dev = csi_dev->dev;
+
+	if (csi_dev->ipi_dt)
+		dw_mipi_csi_write(csi_dev, reg.IPI_DATA_TYPE, csi_dev->ipi_dt);
+	else {
+		switch (csi_dev->fmt->code) {
+		case MEDIA_BUS_FMT_RGB565_2X8_BE:
+		case MEDIA_BUS_FMT_RGB565_2X8_LE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "DT: RGB 565");
+			break;
+
+		case MEDIA_BUS_FMT_RGB888_2X12_LE:
+		case MEDIA_BUS_FMT_RGB888_2X12_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB888);
+			dev_dbg(dev, "DT: RGB 888");
+			break;

drivers/media/platform/dwc/dw-mipi-csi.c line 188

Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +10 -0
+		case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW10);
+			dev_dbg(dev, "DT: RAW 10");
+			break;
+		case MEDIA_BUS_FMT_SBGGR8_1X8:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW8);
+			dev_dbg(dev, "DT: RAW 8");
+			break;

Same here, in CSI_2_RAW12 case it will default to a RGB565 case.

Quoted 7 lines
Quoted 5 lines

Thanks,

Eugen

I will try to add the support for this data type in my next patchset if not I will flag it as unsupported for now in the commit message and code.

Hi Luis,

I am currently trying to see if your driver works , and I need the RAW12 type, that's why I am asking about it.

One question related to the subdevice you create here, how do you register this subdev into the media subsystem ? sync or async, or not at all ?
After the driver probes, there is no call to the set format functions, I added a node inside the Device tree, I see you are registering media pads, but the other endpoint needs to be an async waiting for completion node or your subdev registers in some other way ? (maybe some link validation required ?)

Thanks for your help,

Eugen

Quoted 18 lines

Thanks for your review,
Luis

Quoted 13 lines
Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +9 -0
+		default:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "Error");
+			break;
+		}
+	}
+}
+

[snip]

#24 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Quoted 143 lines · On 11-Jan-19 7:25, [email protected] wrote:
Quoted 118 lines · Luis de Oliveira
Quoted 48 lines · On 09-Jan-19 13:07, [email protected] wrote:
Quoted 27 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

   MAINTAINERS                              |  11 +
   drivers/media/platform/dwc/Kconfig       |  30 +-
   drivers/media/platform/dwc/Makefile      |   2 +
   drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
   drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
   drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
   drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
   include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
   8 files changed, 1616 insertions(+), 1 deletion(-)

create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

[snip]

drivers/media/platform/dwc/dw-csi-plat.h line 49

Quoted 12 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +12 -0
+/* Video formats supported by the MIPI CSI-2 */
+const struct mipi_fmt dw_mipi_csi_formats[] = {
+	{
+		/* RAW 8 */
+		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
+		.depth = 8,
+	},
+	{
+		/* RAW 10 */
+		.code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE,
+		.depth = 10,
+	},

Hi Luis,

Quoted 4 lines

Any reason why RAW12 format is not handled here ?

Here, namely MEDIA_BUS_FMT_SBGGR12_1X12 etc.

Hi Eugen,

My Hw testing setup currently does not support it, so I didn't add it.

Quoted 59 lines
Quoted 21 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +21 -0
+	{
+		/* RGB 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+		.depth = 16,
+	},
+	{
+		/* BGR 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+		.depth = 16,
+	},
+	{
+		/* RGB 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_LE,
+		.depth = 24,
+	},
+	{
+		/* BGR 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_BE,
+		.depth = 24,
+	},
+};

[snip]

Quoted 22 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +22 -0
+
+void dw_mipi_csi_set_ipi_fmt(struct mipi_csi_dev *csi_dev)
+{
+	struct device *dev = csi_dev->dev;
+
+	if (csi_dev->ipi_dt)
+		dw_mipi_csi_write(csi_dev, reg.IPI_DATA_TYPE, csi_dev->ipi_dt);
+	else {
+		switch (csi_dev->fmt->code) {
+		case MEDIA_BUS_FMT_RGB565_2X8_BE:
+		case MEDIA_BUS_FMT_RGB565_2X8_LE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "DT: RGB 565");
+			break;
+
+		case MEDIA_BUS_FMT_RGB888_2X12_LE:
+		case MEDIA_BUS_FMT_RGB888_2X12_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB888);
+			dev_dbg(dev, "DT: RGB 888");
+			break;

drivers/media/platform/dwc/dw-mipi-csi.c line 188

Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +10 -0
+		case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW10);
+			dev_dbg(dev, "DT: RAW 10");
+			break;
+		case MEDIA_BUS_FMT_SBGGR8_1X8:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW8);
+			dev_dbg(dev, "DT: RAW 8");
+			break;

Same here, in CSI_2_RAW12 case it will default to a RGB565 case.

Quoted 7 lines
Quoted 5 lines

Thanks,

Eugen

I will try to add the support for this data type in my next patchset if not I will flag it as unsupported for now in the commit message and code.

Hi Luis,

I am currently trying to see if your driver works , and I need the RAW12 type, that's why I am asking about it.

One question related to the subdevice you create here, how do you register this subdev into the media subsystem ? sync or async, or not at all ?
After the driver probes, there is no call to the set format functions, I added a node inside the Device tree, I see you are registering media pads, but the other endpoint needs to be an async waiting for completion node or your subdev registers in some other way ? (maybe some link validation required ?)

Quoted 4 lines

Thanks for your help,

Eugen

Hi Eugen,

On top of this dphy+controller solution I use a wrapper driver that binds this two together and create the links.
I use V4L2_ASYNC_MATCH_FWNODE and v4l2_async_notifier_operations to match and bound all my sensors until completion.

My dt looks like this:

camera wrapper {

	video_dev {
		dma
	}
	vif_1 @reg {
		...
	}
	..
	vif_n @reg {
		...
	}
	csi_1 @reg {
		...
		phy
		port 1..2 {}
	}
	csi_n @reg {
		...
		phy
		port 1..2 {}
	}

Fundamentally It is the same principle as this drivers/media/platform/exynos4-is/media-dev.c but my solution has more entities for testing purposes.
Check the exynos4-is because is very similar to my top solution.

When I started doing this patchset I was thinking of sending the wrapper also but I then decided to not do it because it is very narrow and focused in my tests. But I can include it in v4 if everyone think its best.

Thank you,
Luis

Quoted 18 lines
Quoted 18 lines

Thanks for your review,
Luis

Quoted 13 lines
Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +9 -0
+		default:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "Error");
+			break;
+		}
+	}
+}
+

[snip]

#25 lore raw

Re: [V3, 4/4] media: platform: dwc: Add MIPI CSI-2 controller driver

Quoted 182 lines · Luis de Oliveira
Quoted 143 lines · On 11-Jan-19 7:25, [email protected] wrote:
Quoted 118 lines · Luis de Oliveira
Quoted 48 lines · On 09-Jan-19 13:07, [email protected] wrote:
Quoted 27 lines · Luis Oliveira

Add the Synopsys MIPI CSI-2 controller driver. This controller driver is divided in platform dependent functions and core functions. It also includes a platform for future DesignWare drivers.

---
Changelog
v2-V3
- exposed IPI settings to userspace
- fixed headers

    MAINTAINERS                              |  11 +
    drivers/media/platform/dwc/Kconfig       |  30 +-
    drivers/media/platform/dwc/Makefile      |   2 +
    drivers/media/platform/dwc/dw-csi-plat.c | 699 +++++++++++++++++++++++++++++++
    drivers/media/platform/dwc/dw-csi-plat.h |  77 ++++
    drivers/media/platform/dwc/dw-mipi-csi.c | 494 ++++++++++++++++++++++
    drivers/media/platform/dwc/dw-mipi-csi.h | 202 +++++++++
    include/media/dwc/dw-mipi-csi-pltfrm.h   | 102 +++++
    8 files changed, 1616 insertions(+), 1 deletion(-)

create mode 100644 drivers/media/platform/dwc/dw-csi-plat.c create mode 100644 drivers/media/platform/dwc/dw-csi-plat.h create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.c create mode 100644 drivers/media/platform/dwc/dw-mipi-csi.h create mode 100644 include/media/dwc/dw-mipi-csi-pltfrm.h

[snip]

drivers/media/platform/dwc/dw-csi-plat.h line 49

Quoted 12 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +12 -0
+/* Video formats supported by the MIPI CSI-2 */
+const struct mipi_fmt dw_mipi_csi_formats[] = {
+	{
+		/* RAW 8 */
+		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
+		.depth = 8,
+	},
+	{
+		/* RAW 10 */
+		.code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE,
+		.depth = 10,
+	},

Hi Luis,

Quoted 4 lines

Any reason why RAW12 format is not handled here ?

Here, namely MEDIA_BUS_FMT_SBGGR12_1X12 etc.

Hi Eugen,

My Hw testing setup currently does not support it, so I didn't add it.

Quoted 59 lines
Quoted 21 lines
drivers/media/platform/dwc/dw-csi-plat.h new file +21 -0
+	{
+		/* RGB 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+		.depth = 16,
+	},
+	{
+		/* BGR 565 */
+		.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+		.depth = 16,
+	},
+	{
+		/* RGB 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_LE,
+		.depth = 24,
+	},
+	{
+		/* BGR 888 */
+		.code = MEDIA_BUS_FMT_RGB888_2X12_BE,
+		.depth = 24,
+	},
+};

[snip]

Quoted 22 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +22 -0
+
+void dw_mipi_csi_set_ipi_fmt(struct mipi_csi_dev *csi_dev)
+{
+	struct device *dev = csi_dev->dev;
+
+	if (csi_dev->ipi_dt)
+		dw_mipi_csi_write(csi_dev, reg.IPI_DATA_TYPE, csi_dev->ipi_dt);
+	else {
+		switch (csi_dev->fmt->code) {
+		case MEDIA_BUS_FMT_RGB565_2X8_BE:
+		case MEDIA_BUS_FMT_RGB565_2X8_LE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "DT: RGB 565");
+			break;
+
+		case MEDIA_BUS_FMT_RGB888_2X12_LE:
+		case MEDIA_BUS_FMT_RGB888_2X12_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB888);
+			dev_dbg(dev, "DT: RGB 888");
+			break;

drivers/media/platform/dwc/dw-mipi-csi.c line 188

Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +10 -0
+		case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW10);
+			dev_dbg(dev, "DT: RAW 10");
+			break;
+		case MEDIA_BUS_FMT_SBGGR8_1X8:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RAW8);
+			dev_dbg(dev, "DT: RAW 8");
+			break;

Same here, in CSI_2_RAW12 case it will default to a RGB565 case.

Quoted 7 lines
Quoted 5 lines

Thanks,

Eugen

I will try to add the support for this data type in my next patchset if not I will flag it as unsupported for now in the commit message and code.

Hi Luis,

I am currently trying to see if your driver works , and I need the RAW12 type, that's why I am asking about it.

One question related to the subdevice you create here, how do you register this subdev into the media subsystem ? sync or async, or not at all ?
After the driver probes, there is no call to the set format functions, I added a node inside the Device tree, I see you are registering media pads, but the other endpoint needs to be an async waiting for completion node or your subdev registers in some other way ? (maybe some link validation required ?)

Quoted 4 lines

Thanks for your help,

Eugen

Hi Eugen,

On top of this dphy+controller solution I use a wrapper driver that binds this two together and create the links.
I use V4L2_ASYNC_MATCH_FWNODE and v4l2_async_notifier_operations to match and bound all my sensors until completion.

My dt looks like this:

camera wrapper {

	video_dev {
		dma
	}
	vif_1 @reg {
		...
	}
	..
	vif_n @reg {
		...
	}
	csi_1 @reg {
		...
		phy
		port 1..2 {}
	}
	csi_n @reg {
		...
		phy
		port 1..2 {}
	}
Quoted 8 lines

Fundamentally It is the same principle as this drivers/media/platform/exynos4-is/media-dev.c but my solution has more entities for testing purposes.
Check the exynos4-is because is very similar to my top solution.

When I started doing this patchset I was thinking of sending the wrapper also but I then decided to not do it because it is very narrow and focused in my tests. But I can include it in v4 if everyone think its best.

Ok, I understand how you did, but do you have a public tree with this code which I can access to have a look on exactly how you connected everything ?

Thanks

Quoted 22 lines

Thank you,
Luis

Quoted 18 lines
Quoted 18 lines

Thanks for your review,
Luis

Quoted 13 lines
Quoted 10 lines
drivers/media/platform/dwc/dw-mipi-csi.c new file +9 -0
+		default:
+			dw_mipi_csi_write(csi_dev,
+					reg.IPI_DATA_TYPE, CSI_2_RGB565);
+			dev_dbg(dev, "Error");
+			break;
+		}
+	}
+}
+

[snip]