Skip to contentSkip to conversation

Add Starfive Camera Subsystem driver

PATCH Superseded Jack Zhu 5 participants 32 messages Mar 31, 2023 – Apr 7, 2023

Subsystems (3)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
author
#8 lore raw

PATCH v3 2/9 media: admin-guide: Add starfive_camss.rst for Starfive Camera Subsystem

In reply to Jack Zhu

Add starfive_camss.rst file that documents the Starfive Camera Subsystem driver which is used for handing image sensor data.

---
 .../admin-guide/media/starfive_camss.rst      | 57 +++++++++++++++++++
 .../media/starfive_camss_graph.dot            | 16 ++++++
 .../admin-guide/media/v4l-drivers.rst         |  1 +
 MAINTAINERS                                   |  1 +
 4 files changed, 75 insertions(+)
 create mode 100644 Documentation/admin-guide/media/starfive_camss.rst
 create mode 100644 Documentation/admin-guide/media/starfive_camss_graph.dot
Documentation/admin-guide/media/starfive_camss.rst new file +57 -0
new file mode 100644
index 000000000000..a6378849384f
@@ -0,0 +1,57 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>
+
+================================
+Starfive Camera Subsystem driver
+================================
+
+Introduction
+------------
+
+This file documents the driver for the Starfive Camera Subsystem found on
+Starfive JH7110 SoC. The driver is located under drivers/media/platform/
+starfive.
+
+The driver implements V4L2, Media controller and v4l2_subdev interfaces.
+Camera sensor using V4L2 subdev interface in the kernel is supported.
+
+The driver has been successfully used on the Gstreamer 1.18.5 with
+v4l2src plugin.
+
+
+Starfive Camera Subsystem hardware
+----------------------------------
+
+The Starfive Camera Subsystem hardware consists of:
+
+- MIPI DPHY Receiver: receives mipi data from a MIPI camera sensor.
+- MIPI CSIRx Controller: is responsible for handling and decoding CSI2 protocol
+  based camera sensor data stream.
+- ISP: handles the image data streams from the MIPI CSIRx Controller.
+- VIN(Video In): a top-level module, is responsible for controlling power
+  and clocks to other modules, dumps the input data to memory or transfers the
+  input data to ISP.
+
+
+Topology
+--------
+
+The media controller pipeline graph is as follows:
+
+.. _starfive_camss_graph:
+
+.. kernel-figure:: starfive_camss_graph.dot
+    :alt:   starfive_camss_graph.dot
+    :align: center
+
+The driver has 2 video devices:
+
+- stf_vin0_wr_video0: capture device for images directly from the VIN module.
+- stf_vin0_isp0_video1: capture device for images without scaling.
+
+The driver has 3 subdevices:
+
+- stf_isp0: is responsible for all the isp operations.
+- stf_vin0_wr: used to dump RAW images to memory.
+- stf_vin0_isp0: used to capture images for the stf_vin0_isp0_video1 device.
Documentation/admin-guide/media/starfive_camss_graph.dot new file +16 -0
new file mode 100644
index 000000000000..850be912cdeb
@@ -0,0 +1,16 @@
+digraph board {
+	rankdir=TB
+	n00000001 [label="{{<port0> 0} | stf_isp0\n/dev/v4l-subdev0 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n0000000d:port0
+	n00000004 [label="{{<port0> 0} | stf_vin0_wr\n/dev/v4l-subdev1 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000004:port1 -> n00000007 [style=bold]
+	n00000007 [label="stf_vin0_wr_video0\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n0000000d [label="{{<port0> 0} | stf_vin0_isp0\n/dev/v4l-subdev2 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n0000000d:port1 -> n00000010 [style=bold]
+	n00000010 [label="stf_vin0_isp0_video1\n/dev/video1", shape=box, style=filled, fillcolor=yellow]
+	n00000018 [label="{{<port0> 0} | cdns_csi2rx.19800000.csi-bridge\n | {<port1> 1 | <port2> 2 | <port3> 3 | <port4> 4}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000018:port1 -> n00000004:port0 [style=dashed]
+	n00000018:port1 -> n00000001:port0
+	n00000028 [label="{{} | imx219 6-0010\n | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000028:port0 -> n00000018:port0 [style=bold]
+}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
index 1c41f87c3917..3005d637199a 100644
@@ -27,6 +27,7 @@ Video4Linux (V4L) driver-specific documentation
 	si470x
 	si4713
 	si476x
+	starfive
 	vimc
 	visl
 	vivid
MAINTAINERS +1 -0
index f7165371c56d..8c0a4d80d2bf 100644
@@ -19913,6 +19913,7 @@ M:	Jack Zhu <[email protected]>
 M:	Changhuang Liang <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/admin-guide/media/starfive_camss.rst
 F:	Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
 
 STARFIVE DEVICETREES
Signature · 1 line
2.34.1
author
#15 lore raw

PATCH v3 4/9 media: dt-bindings: cadence-csi2rx: Add resets property

In reply to Jack Zhu

Add resets property for Cadence MIPI-CSI2 RX controller

---
 .../bindings/media/cdns,csi2rx.yaml           | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/media/cdns,csi2rx.yaml +24 -0
index 89f414eeef47..f8da4a35e98e 100644
@@ -38,6 +38,24 @@ properties:
       - const: pixel_if2_clk
       - const: pixel_if3_clk
 
+  resets:
+    items:
+      - description: CSI2Rx system reset
+      - description: Gated Register bank reset for APB interface
+      - description: pixel reset for Stream interface 0
+      - description: pixel reset for Stream interface 1
+      - description: pixel reset for Stream interface 2
+      - description: pixel reset for Stream interface 3
+
+  reset-names:
+    items:
+      - const: sys
+      - const: reg_bank
+      - const: pixel_if0
+      - const: pixel_if1
+      - const: pixel_if2
+      - const: pixel_if3
+
   phys:
     maxItems: 1
     description: MIPI D-PHY
@@ -120,6 +138,12 @@ examples:
         clock-names = "sys_clk", "p_clk",
                       "pixel_if0_clk", "pixel_if1_clk",
                       "pixel_if2_clk", "pixel_if3_clk";
+        resets = <&bytereset 9>, <&bytereset 4>,
+                 <&corereset 5>, <&corereset 6>,
+                 <&corereset 7>, <&corereset 8>;
+        reset-names = "sys", "reg_bank",
+                      "pixel_if0", "pixel_if1",
+                      "pixel_if2", "pixel_if3";
         phys = <&csi_phy>;
         phy-names = "dphy";
 
Signature · 1 line
2.34.1
author
#21 lore raw

PATCH v3 6/9 media: cadence: Add operation on reset

In reply to Jack Zhu

Add operation on reset for Cadence MIPI-CSI2 RX Controller.

---
 drivers/media/platform/cadence/cdns-csi2rx.c | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/cadence/cdns-csi2rx.c +30 -0
index cc3ebb0d96f6..a1555cedb349 100644
@@ -13,6 +13,7 @@
 #include <linux/of_graph.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #include <media/v4l2-ctrls.h>
@@ -68,6 +69,9 @@ struct csi2rx_priv {
 	struct clk			*sys_clk;
 	struct clk			*p_clk;
 	struct clk			*pixel_clk[CSI2RX_STREAMS_MAX];
+	struct reset_control		*sys_rst;
+	struct reset_control		*p_rst;
+	struct reset_control		*pixel_rst[CSI2RX_STREAMS_MAX];
 	struct phy			*dphy;
 
 	u8				lanes[CSI2RX_LANES_MAX];
@@ -112,6 +116,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		return ret;
 
+	reset_control_deassert(csi2rx->p_rst);
 	csi2rx_reset(csi2rx);
 
 	reg = csi2rx->num_lanes << 8;
@@ -154,6 +159,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 		if (ret)
 			goto err_disable_pixclk;
 
+		reset_control_deassert(csi2rx->pixel_rst[i]);
+
 		writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF,
 		       csi2rx->base + CSI2RX_STREAM_CFG_REG(i));
 
@@ -169,6 +176,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		goto err_disable_pixclk;
 
+	reset_control_deassert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	return 0;
@@ -188,14 +196,17 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 	unsigned int i;
 
 	clk_prepare_enable(csi2rx->p_clk);
+	reset_control_assert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->sys_clk);
 
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
 
+		reset_control_assert(csi2rx->pixel_rst[i]);
 		clk_disable_unprepare(csi2rx->pixel_clk[i]);
 	}
 
+	reset_control_assert(csi2rx->p_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
@@ -299,6 +310,17 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 		return PTR_ERR(csi2rx->p_clk);
 	}
 
+	csi2rx->sys_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev,
+							  "sys_rst");
+	if (IS_ERR(csi2rx->sys_rst))
+		return PTR_ERR(csi2rx->sys_rst);
+
+	csi2rx->p_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev, "p_rst");
+	if (IS_ERR(csi2rx->p_rst))
+		return PTR_ERR(csi2rx->p_rst);
+
 	csi2rx->dphy = devm_phy_optional_get(&pdev->dev, "dphy");
 	if (IS_ERR(csi2rx->dphy)) {
 		dev_err(&pdev->dev, "Couldn't get external D-PHY\n");
@@ -350,6 +372,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		char clk_name[16];
+		char rst_name[16];
 
 		snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
 		csi2rx->pixel_clk[i] = devm_clk_get(&pdev->dev, clk_name);
@@ -357,6 +380,13 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 			dev_err(&pdev->dev, "Couldn't get clock %s\n", clk_name);
 			return PTR_ERR(csi2rx->pixel_clk[i]);
 		}
+
+		snprintf(rst_name, sizeof(rst_name), "pixel_if%u_rst", i);
+		csi2rx->pixel_rst[i] =
+			devm_reset_control_get_optional_exclusive(&pdev->dev,
+								  rst_name);
+		if (IS_ERR(csi2rx->pixel_rst[i]))
+			return PTR_ERR(csi2rx->pixel_rst[i]);
 	}
 
 	return 0;
Signature · 1 line
2.34.1
author
#26 lore raw

PATCH v3 8/9 media: cadence: Add support for JH7110 SoC

In reply to Jack Zhu

Add support for Starfive JH7110 SoC which
has the cadence csi2 receiver.

---
 drivers/media/platform/cadence/cdns-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/cadence/cdns-csi2rx.c +1 -0
index add982edce64..5e36b994b8d5 100644
@@ -560,6 +560,7 @@ static int csi2rx_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id csi2rx_of_table[] = {
+	{ .compatible = "starfive,jh7110-csi2rx" },
 	{ .compatible = "cdns,csi2rx" },
 	{ },
 };
Signature · 1 line
2.34.1

Jack Zhu

author
#0 lore raw

v3 cover Add Starfive Camera Subsystem driver

Hi,

This patch series adds support for the Starfive Camera Subsystem found on Starfive JH7110 SoC.

The driver implements V4L2, Media controller and V4L2 subdev interfaces. Camera sensor using V4L2 subdev interface in the kernel is supported.

The driver is tested on VisionFive V2 board with IMX219 camera sensor. GStreamer 1.18.5 with v4l2src plugin is supported.

Changes since v2:
- Rebased on v6.3-rc1.
Patch 1:
- Modified spelling errors.
- Added port@0.
- Modified '$ref' of port.
- Added 'ports' to 'required'.
- Dropped 'stfcamss' label in example.
- Added port@0 in example.
- Added MAINTAINERS file.
Patch 2:
- Split this patch into three new patches.
- Modified compatible property.
- Replaced clock names with the existing names.
- Modified 'bus-type' and 'clock-lanes'
- Added port@2 - port@4
- Dropped 'csi2rx' label in example.
Patch 3:
- Updated rst and dot file as three pipelines were deleted. Patch 4:
- Split this patch into three new patches.
- Dropped .s_power() and .get_fmt().
- Dropped CSI-2 DT support.
- Dropped v4l2_device_register_subdev_nodes().
- Used assigned-clock-rates in DT to set clk value.
- Modified 'compatible' field.
Patch 5:
- Deleted three pipelines.
- Modified 'stfcamss_clocks'/'stfcamss_resets' struct.
- Dropped stfcamss_find_sensor() function.
- Removed redundant code from stfcamss_of_parse_endpoint_node().
- Modified spelling errors.
- Rewrote stfcamss_reg_media_subdev_node() function.
- Modified stfcamss_subdev_notifier_bound().
- Modified stfcamss_probe() function.
- Dropped stfcamss_suspend() and stfcamss_resume().
- Dropped dev_info() in stfcamss_remove() function.
- Added 'stf_' prefix for enum subdev_type.
- Moved all includes to the top in stf_camss.h file.
- Dropped unused fields in stfcamss struct.
- Replaced Custom logging macros with regular macros.
- Rewrote register read and write functions.
- Used lowercase for all hex constants.
- Used macro to name registers.
- Dropped unused ioctl and stf_isp_ioctl.h file.

v2: https://lore.kernel.org/all/[email protected]/

Changes since v1:
- Deleted starfive,jh7110-mipi-csi2.yaml.
- Converted cdns,csi2rx.txt to cdns,csi2rx.yaml and added ‘resets’ properties.
- Added ‘cdns,csi2rx.yaml’ in ‘CADENCE MIPI-CSI2 BRIDGES’ entry.
- The following contents were modified in starfive,jh7110-camss.yaml:
dropped quotes from ’id’ and ‘schema’; dropped ‘|’ for ‘description’; corrected the wrong or redundant words: ‘a ISP’, ‘PD ISP’; dropped ‘minItems’ for ‘reg’, ‘clocks’, ‘resets’ and ‘interrupts’; dropped the '_clk' and 'rst_' prefix about the 'clock-names' and 'reset-names';
changed ‘endpoint@1’ to ‘endpoint’; updated examples;
- Updated Subject for some patches.
- Merged patch 6, 7, 8, 9, 10, 11 into one patch.

Jack Zhu (9):
media: dt-bindings: Add bindings for JH7110 Camera Subsystem
media: admin-guide: Add starfive_camss.rst for Starfive Camera
Subsystem
media: dt-bindings: cadence-csi2rx: Convert to DT schema
media: dt-bindings: cadence-csi2rx: Add resets property
media: dt-bindings: cadence-csi2rx: Add starfive compatible
media: cadence: Add operation on reset
media: cadence: Add support for external dphy
media: cadence: Add support for JH7110 SoC
media: starfive: Add Starfive Camera Subsystem driver

 .../admin-guide/media/starfive_camss.rst      |   57 +
 .../media/starfive_camss_graph.dot            |   16 +
 .../admin-guide/media/v4l-drivers.rst         |    1 +
 .../devicetree/bindings/media/cdns,csi2rx.txt |  100 --
 .../bindings/media/cdns,csi2rx.yaml           |  201 +++
 .../bindings/media/starfive,jh7110-camss.yaml |  159 +++
 MAINTAINERS                                   |   10 +
 drivers/media/platform/Kconfig                |    1 +
 drivers/media/platform/Makefile               |    1 +
 drivers/media/platform/cadence/cdns-csi2rx.c  |   97 +-
 drivers/media/platform/starfive/Kconfig       |   18 +
 drivers/media/platform/starfive/Makefile      |   14 +
 drivers/media/platform/starfive/stf_camss.c   |  477 +++++++
 drivers/media/platform/starfive/stf_camss.h   |  150 +++
 drivers/media/platform/starfive/stf_common.h  |   18 +
 drivers/media/platform/starfive/stf_isp.c     |  737 +++++++++++
 drivers/media/platform/starfive/stf_isp.h     |  999 ++++++++++++++
 .../media/platform/starfive/stf_isp_hw_ops.c  |  715 ++++++++++
 drivers/media/platform/starfive/stf_video.c   |  989 ++++++++++++++
 drivers/media/platform/starfive/stf_video.h   |   89 ++
 drivers/media/platform/starfive/stf_vin.c     | 1151 +++++++++++++++++
 drivers/media/platform/starfive/stf_vin.h     |  174 +++
 .../media/platform/starfive/stf_vin_hw_ops.c  |  211 +++
 23 files changed, 6275 insertions(+), 110 deletions(-)
 create mode 100644 Documentation/admin-guide/media/starfive_camss.rst
 create mode 100644 Documentation/admin-guide/media/starfive_camss_graph.dot
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
 create mode 100644 drivers/media/platform/starfive/Kconfig
 create mode 100644 drivers/media/platform/starfive/Makefile
 create mode 100644 drivers/media/platform/starfive/stf_camss.c
 create mode 100644 drivers/media/platform/starfive/stf_camss.h
 create mode 100644 drivers/media/platform/starfive/stf_common.h
 create mode 100644 drivers/media/platform/starfive/stf_isp.c
 create mode 100644 drivers/media/platform/starfive/stf_isp.h
 create mode 100644 drivers/media/platform/starfive/stf_isp_hw_ops.c
 create mode 100644 drivers/media/platform/starfive/stf_video.c
 create mode 100644 drivers/media/platform/starfive/stf_video.h
 create mode 100644 drivers/media/platform/starfive/stf_vin.c
 create mode 100644 drivers/media/platform/starfive/stf_vin.h
 create mode 100644 drivers/media/platform/starfive/stf_vin_hw_ops.c
Signature · 1 line
2.34.1
author
#24 lore raw

PATCH v3 7/9 media: cadence: Add support for external dphy

Add support for external MIPI D-PHY.

---
 drivers/media/platform/cadence/cdns-csi2rx.c | 66 +++++++++++++++++---
 1 file changed, 56 insertions(+), 10 deletions(-)
drivers/media/platform/cadence/cdns-csi2rx.c +56 -10
index a1555cedb349..add982edce64 100644
@@ -31,6 +31,12 @@
 #define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane)	((plane) << (16 + (llane) * 4))
 #define CSI2RX_STATIC_CFG_LANES_MASK			GENMASK(11, 8)
 
+#define CSI2RX_DPHY_LANE_CTRL_REG		0x40
+#define CSI2RX_DPHY_CL_RST			BIT(16)
+#define CSI2RX_DPHY_DL_RST(i)			BIT((i) + 12)
+#define CSI2RX_DPHY_CL_EN			BIT(4)
+#define CSI2RX_DPHY_DL_EN(i)			BIT(i)
+
 #define CSI2RX_STREAM_BASE(n)		(((n) + 1) * 0x100)
 
 #define CSI2RX_STREAM_CTRL_REG(n)		(CSI2RX_STREAM_BASE(n) + 0x000)
@@ -105,6 +111,24 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
 	writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
 }
 
+static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
+{
+	union phy_configure_opts opts = { };
+	int ret;
+
+	ret = phy_power_on(csi2rx->dphy);
+	if (ret)
+		return ret;
+
+	ret = phy_configure(csi2rx->dphy, &opts);
+	if (ret) {
+		phy_power_off(csi2rx->dphy);
+		return ret;
+	}
+
+	return 0;
+}
+
 static int csi2rx_start(struct csi2rx_priv *csi2rx)
 {
 	unsigned int i;
@@ -144,6 +168,17 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		goto err_disable_pclk;
 
+	/* Enable DPHY clk and data lanes. */
+	if (csi2rx->dphy) {
+		reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST;
+		for (i = 0; i < csi2rx->num_lanes; i++) {
+			reg |= CSI2RX_DPHY_DL_EN(csi2rx->lanes[i] - 1);
+			reg |= CSI2RX_DPHY_DL_RST(csi2rx->lanes[i] - 1);
+		}
+
+		writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+	}
+
 	/*
 	 * Create a static mapping between the CSI virtual channels
 	 * and the output stream.
@@ -177,10 +212,22 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 		goto err_disable_pixclk;
 
 	reset_control_deassert(csi2rx->sys_rst);
+
+	if (csi2rx->dphy) {
+		ret = csi2rx_configure_ext_dphy(csi2rx);
+		if (ret) {
+			dev_err(csi2rx->dev,
+				"Failed to configure external DPHY: %d\n", ret);
+			goto err_disable_sysclk;
+		}
+	}
+
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	return 0;
 
+err_disable_sysclk:
+	clk_disable_unprepare(csi2rx->sys_clk);
 err_disable_pixclk:
 	for (; i > 0; i--)
 		clk_disable_unprepare(csi2rx->pixel_clk[i - 1]);
@@ -211,6 +258,13 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
 		dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
+
+	if (csi2rx->dphy) {
+		writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+
+		if (phy_power_off(csi2rx->dphy))
+			dev_warn(csi2rx->dev, "Couldn't power off DPHY\n");
+	}
 }
 
 static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
@@ -327,15 +381,6 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 		return PTR_ERR(csi2rx->dphy);
 	}
 
-	/*
-	 * FIXME: Once we'll have external D-PHY support, the check
-	 * will need to be removed.
-	 */
-	if (csi2rx->dphy) {
-		dev_err(&pdev->dev, "External D-PHY not supported yet\n");
-		return -EINVAL;
-	}
-
 	ret = clk_prepare_enable(csi2rx->p_clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Couldn't prepare and enable P clock\n");
@@ -365,7 +410,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 	 * FIXME: Once we'll have internal D-PHY support, the check
 	 * will need to be removed.
 	 */
-	if (csi2rx->has_internal_dphy) {
+	if (!csi2rx->dphy && csi2rx->has_internal_dphy) {
 		dev_err(&pdev->dev, "Internal D-PHY not supported yet\n");
 		return -EINVAL;
 	}
@@ -492,6 +537,7 @@ static int csi2rx_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev,
 		 "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
 		 csi2rx->num_lanes, csi2rx->max_lanes, csi2rx->max_streams,
+		 csi2rx->dphy ? "external" :
 		 csi2rx->has_internal_dphy ? "internal" : "no");
 
 	return 0;
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/9 media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +159 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false
+
+    required:
+      - port@1
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+  - interrupts
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+    isp@19840000 {
+        compatible = "starfive,jh7110-camss";
+        reg = <0x19840000 0x10000>,
+              <0x19870000 0x30000>;
+        reg-names = "syscon", "isp";
+        clocks = <&ispcrg 0>,
+                 <&ispcrg 13>,
+                 <&ispcrg 2>,
+                 <&ispcrg 12>,
+                 <&ispcrg 1>,
+                 <&syscrg 51>,
+                 <&syscrg 52>;
+        clock-names = "apb_func",
+                      "wrapper_clk_c",
+                      "dvp_inv",
+                      "axiwr",
+                      "mipi_rx0_pxl",
+                      "ispcore_2x",
+                      "isp_axi";
+        resets = <&ispcrg 0>,
+                 <&ispcrg 1>,
+                 <&ispcrg 10>,
+                 <&ispcrg 11>,
+                 <&syscrg 41>,
+                 <&syscrg 42>;
+        reset-names = "wrapper_p",
+                      "wrapper_c",
+                      "axird",
+                      "axiwr",
+                      "isp_top_n",
+                      "isp_top_axi";
+        power-domains = <&pwrc 5>;
+        interrupts = <92>, <87>, <88>, <90>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            port@0 {
+                reg = <0>;
+                vin_from_sc2235: endpoint {
+                    remote-endpoint = <&sc2235_to_vin>;
+                };
+            };
+
+            port@1 {
+                reg = <1>;
+                vin_from_csi2rx: endpoint {
+                    remote-endpoint = <&csi2rx_to_vin>;
+                };
+            };
+        };
+    };
MAINTAINERS +7 -0
index b6c811326355..f7165371c56d 100644
@@ -19908,6 +19908,13 @@ M:	Ion Badulescu <[email protected]>
 S:	Odd Fixes
 F:	drivers/net/ethernet/adaptec/starfire*
 
+STARFIVE CAMERA SUBSYSTEM DRIVER
+M:	Jack Zhu <[email protected]>
+M:	Changhuang Liang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
+
 STARFIVE DEVICETREES
 M:	Emil Renner Berthing <[email protected]>
 S:	Maintained
Signature · 1 line
2.34.1
author
#18 lore raw

PATCH v3 5/9 media: dt-bindings: cadence-csi2rx: Add starfive compatible

In reply to Jack Zhu

Add starfive compatible for Starfive JH7110 SoC which has a Cadence MIPI-CSI2 RX controller.

---
 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/media/cdns,csi2rx.yaml +5 -2
index f8da4a35e98e..30a335b10762 100644
@@ -15,7 +15,10 @@ description:
 
 properties:
   compatible:
-    const: cdns,csi2rx
+    items:
+      - enum:
+          - starfive,jh7110-csi2rx
+      - const: cdns,csi2rx
 
   reg:
     maxItems: 1
@@ -130,7 +133,7 @@ additionalProperties: false
 examples:
   - |
     csi@d060000 {
-        compatible = "cdns,csi2rx";
+        compatible = "starfive,jh7110-csi2rx", "cdns,csi2rx";
         reg = <0x0d060000 0x1000>;
         clocks = <&byteclock 7>, <&byteclock 6>,
                  <&coreclock 8>, <&coreclock 9>,
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH v3 3/9 media: dt-bindings: cadence-csi2rx: Convert to DT schema

In reply to Jack Zhu

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to DT schema format.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt | 100 ----------
 .../bindings/media/cdns,csi2rx.yaml           | 174 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 3 files changed, 175 insertions(+), 100 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +0 -100
deleted file mode 100644
index 6b02a0657ad9..000000000000
@@ -1,100 +0,0 @@
-Cadence MIPI-CSI2 RX controller
-===============================
-
-The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
-lanes in input, and 4 different pixel streams in output.
-
-Required properties:
-  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible
-  - reg: base address and size of the memory mapped region
-  - clocks: phandles to the clocks driving the controller
-  - clock-names: must contain:
-    * sys_clk: main clock
-    * p_clk: register bank clock
-    * pixel_if[0-3]_clk: pixel stream output clock, one for each stream
-                         implemented in hardware, between 0 and 3
-
-Optional properties:
-  - phys: phandle to the external D-PHY, phy-names must be provided
-  - phy-names: must contain "dphy", if the implementation uses an
-               external D-PHY
-
-Required subnodes:
-  - ports: A ports node with one port child node per device input and output
-           port, in accordance with the video interface bindings defined in
-           Documentation/devicetree/bindings/media/video-interfaces.txt. The
-           port nodes are numbered as follows:
-
-           Port Description
-           -----------------------------
-           0    CSI-2 input
-           1    Stream 0 output
-           2    Stream 1 output
-           3    Stream 2 output
-           4    Stream 3 output
-
-           The stream output port nodes are optional if they are not
-           connected to anything at the hardware level or implemented
-           in the design.Since there is only one endpoint per port,
-           the endpoints are not numbered.
-
-
-Example:
-
-csi2rx: csi-bridge@0d060000 {
-	compatible = "cdns,csi2rx";
-	reg = <0x0d060000 0x1000>;
-	clocks = <&byteclock>, <&byteclock>
-		 <&coreclock>, <&coreclock>,
-		 <&coreclock>, <&coreclock>;
-	clock-names = "sys_clk", "p_clk",
-		      "pixel_if0_clk", "pixel_if1_clk",
-		      "pixel_if2_clk", "pixel_if3_clk";
-
-	ports {
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		port@0 {
-			reg = <0>;
-
-			csi2rx_in_sensor: endpoint {
-				remote-endpoint = <&sensor_out_csi2rx>;
-				clock-lanes = <0>;
-				data-lanes = <1 2>;
-			};
-		};
-
-		port@1 {
-			reg = <1>;
-
-			csi2rx_out_grabber0: endpoint {
-				remote-endpoint = <&grabber0_in_csi2rx>;
-			};
-		};
-
-		port@2 {
-			reg = <2>;
-
-			csi2rx_out_grabber1: endpoint {
-				remote-endpoint = <&grabber1_in_csi2rx>;
-			};
-		};
-
-		port@3 {
-			reg = <3>;
-
-			csi2rx_out_grabber2: endpoint {
-				remote-endpoint = <&grabber2_in_csi2rx>;
-			};
-		};
-
-		port@4 {
-			reg = <4>;
-
-			csi2rx_out_grabber3: endpoint {
-				remote-endpoint = <&grabber3_in_csi2rx>;
-			};
-		};
-	};
-};
Documentation/devicetree/bindings/media/cdns,csi2rx.yaml new file +174 -0

174 lines not on this page · raw message

MAINTAINERS +1 -0
index 8c0a4d80d2bf..3f3ed2a51158 100644
@@ -4495,6 +4495,7 @@ M:	Maxime Ripard <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/cdns,*.txt
+F:	Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
 F:	drivers/media/platform/cadence/cdns-csi2*
 
 CADENCE NAND DRIVER
Signature · 1 line
2.34.1
author
#29 lore raw

PATCH v3 9/9 media: starfive: Add Starfive Camera Subsystem driver

In reply to Jack Zhu

Add the driver for Starfive Camera Subsystem found on Starfive JH7110 SoC. It is used for handing image sensor data.

---
 MAINTAINERS                                   |    1 +
 drivers/media/platform/Kconfig                |    1 +
 drivers/media/platform/Makefile               |    1 +
 drivers/media/platform/starfive/Kconfig       |   18 +
 drivers/media/platform/starfive/Makefile      |   14 +
 drivers/media/platform/starfive/stf_camss.c   |  477 +++++++
 drivers/media/platform/starfive/stf_camss.h   |  150 +++
 drivers/media/platform/starfive/stf_common.h  |   18 +
 drivers/media/platform/starfive/stf_isp.c     |  737 +++++++++++
 drivers/media/platform/starfive/stf_isp.h     |  999 ++++++++++++++
 .../media/platform/starfive/stf_isp_hw_ops.c  |  715 ++++++++++
 drivers/media/platform/starfive/stf_video.c   |  989 ++++++++++++++
 drivers/media/platform/starfive/stf_video.h   |   89 ++
 drivers/media/platform/starfive/stf_vin.c     | 1151 +++++++++++++++++
 drivers/media/platform/starfive/stf_vin.h     |  174 +++
 .../media/platform/starfive/stf_vin_hw_ops.c  |  211 +++
 16 files changed, 5745 insertions(+)
 create mode 100644 drivers/media/platform/starfive/Kconfig
 create mode 100644 drivers/media/platform/starfive/Makefile
 create mode 100644 drivers/media/platform/starfive/stf_camss.c
 create mode 100644 drivers/media/platform/starfive/stf_camss.h
 create mode 100644 drivers/media/platform/starfive/stf_common.h
 create mode 100644 drivers/media/platform/starfive/stf_isp.c
 create mode 100644 drivers/media/platform/starfive/stf_isp.h
 create mode 100644 drivers/media/platform/starfive/stf_isp_hw_ops.c
 create mode 100644 drivers/media/platform/starfive/stf_video.c
 create mode 100644 drivers/media/platform/starfive/stf_video.h
 create mode 100644 drivers/media/platform/starfive/stf_vin.c
 create mode 100644 drivers/media/platform/starfive/stf_vin.h
 create mode 100644 drivers/media/platform/starfive/stf_vin_hw_ops.c
MAINTAINERS +1 -0
index 3f3ed2a51158..bb0800c1d9eb 100644
@@ -19916,6 +19916,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/admin-guide/media/starfive_camss.rst
 F:	Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
+F:	drivers/media/platform/starfive/
 
 STARFIVE DEVICETREES
 M:	Emil Renner Berthing <[email protected]>
drivers/media/platform/Kconfig +1 -0
index ee579916f874..627eaa0ab3ee 100644
@@ -80,6 +80,7 @@ source "drivers/media/platform/renesas/Kconfig"
 source "drivers/media/platform/rockchip/Kconfig"
 source "drivers/media/platform/samsung/Kconfig"
 source "drivers/media/platform/st/Kconfig"
+source "drivers/media/platform/starfive/Kconfig"
 source "drivers/media/platform/sunxi/Kconfig"
 source "drivers/media/platform/ti/Kconfig"
 source "drivers/media/platform/verisilicon/Kconfig"
drivers/media/platform/Makefile +1 -0
index 5453bb868e67..5a038498a370 100644
@@ -23,6 +23,7 @@ obj-y += renesas/
 obj-y += rockchip/
 obj-y += samsung/
 obj-y += st/
+obj-y += starfive/
 obj-y += sunxi/
 obj-y += ti/
 obj-y += verisilicon/
drivers/media/platform/starfive/Kconfig new file +18 -0
new file mode 100644
index 000000000000..4bb1e25b66ca
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+comment "Starfive media platform drivers"
+
+config VIDEO_STARFIVE_CAMSS
+	tristate "Starfive Camera Subsystem driver"
+	depends on V4L_PLATFORM_DRIVERS
+	depends on VIDEO_DEV && OF
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_FWNODE
+	help
+	   Enable this to support for the Starfive Camera subsystem
+	   found on Starfive JH7110 SoC.
+
+	   To compile this driver as a module, choose M here: the
+	   module will be called stf-camss.
drivers/media/platform/starfive/Makefile new file +14 -0
new file mode 100644
index 000000000000..bf497dd24bbb
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for StarFive camera subsystem driver.
+#
+
+starfive-camss-objs += \
+		stf_camss.o \
+		stf_isp.o \
+		stf_isp_hw_ops.o \
+		stf_video.o \
+		stf_vin.o \
+		stf_vin_hw_ops.o
+
+obj-$(CONFIG_VIDEO_STARFIVE_CAMSS) += starfive-camss.o \
drivers/media/platform/starfive/stf_camss.c new file +477 -0

477 lines not on this page · raw message

drivers/media/platform/starfive/stf_camss.h new file +150 -0

150 lines not on this page · raw message

drivers/media/platform/starfive/stf_common.h new file +18 -0
new file mode 100644
index 000000000000..e04fca2d9cd4
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * stf_common.h
+ *
+ * StarFive Camera Subsystem - Common definitions
+ *
+ * Copyright (C) 2021-2023 StarFive Technology Co., Ltd.
+ */
+
+#ifndef STF_COMMON_H
+#define STF_COMMON_H
+
+enum stf_subdev_type {
+	STF_SUBDEV_TYPE_VIN,
+	STF_SUBDEV_TYPE_ISP,
+};
+
+#endif /* STF_COMMON_H */
drivers/media/platform/starfive/stf_isp.c new file +737 -0

737 lines not on this page · raw message

drivers/media/platform/starfive/stf_isp.h new file +999 -0

999 lines not on this page · raw message

drivers/media/platform/starfive/stf_isp_hw_ops.c new file +715 -0

566 lines not on this page · raw message

drivers/media/platform/starfive/stf_video.c new file +989 -0

989 lines not on this page · raw message

drivers/media/platform/starfive/stf_video.h new file +89 -0

89 lines not on this page · raw message

drivers/media/platform/starfive/stf_vin.c new file +1151 -0

1,151 lines not on this page · raw message

drivers/media/platform/starfive/stf_vin.h new file +174 -0

174 lines not on this page · raw message

drivers/media/platform/starfive/stf_vin_hw_ops.c new file +211 -0

211 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#30 lore raw

Re: [PATCH v3 9/9] media: starfive: Add Starfive Camera Subsystem driver

I love your patch! Perhaps something to improve:

Hi Jack,

I love your patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on robh/for-next linus/master v6.3-rc4 next-20230331] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230331121826.96973-10-jack.zhu%40starfivetech.com
patch subject: [PATCH v3 9/9] media: starfive: Add Starfive Camera Subsystem driver
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230331/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/421adbf9815b633e8bac5da7146c33aac01e283c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001 git checkout 421adbf9815b633e8bac5da7146c33aac01e283c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash drivers/media/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/media/platform/starfive/stf_camss.c:41:5: warning: no previous prototype for 'stfcamss_get_mem_res' [-Wmissing-prototypes]
      41 | int stfcamss_get_mem_res(struct platform_device *pdev,
         |     ^~~~~~~~~~~~~~~~~~~~
--
>> drivers/media/platform/starfive/stf_isp.c:627:5: warning: no previous prototype for 'isp_close' [-Wmissing-prototypes]

627 | int isp_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
| ^~~~~~~~~
--
drivers/media/platform/starfive/stf_vin.c: In function 'stf_vin_map_isp_pad':

>> drivers/media/platform/starfive/stf_vin.c:99:24: warning: implicit conversion from 'enum isp_line_id' to 'enum isp_pad_id' [-Wenum-conversion]
      99 |                 pad_id = vin_map_isp_line(line);
         |                        ^
   drivers/media/platform/starfive/stf_vin.c: In function 'vin_output_init_addrs':
>> drivers/media/platform/starfive/stf_vin.c:683:20: warning: variable 'pong_addr' set but not used [-Wunused-but-set-variable]
     683 |         dma_addr_t pong_addr;
         |                    ^~~~~~~~~
   drivers/media/platform/starfive/stf_vin.c: At top level:
   drivers/media/platform/starfive/stf_vin.c:33:32: warning: 'vin_formats_raw' defined but not used [-Wunused-const-variable=]
      33 | static const struct vin_format vin_formats_raw[] = {
         |                                ^~~~~~~~~~~~~~~

vim +/stfcamss_get_mem_res +41 drivers/media/platform/starfive/stf_camss.c

    40	
  > 41	int stfcamss_get_mem_res(struct platform_device *pdev,
    42				 struct stfcamss *stfcamss)
    43	{
    44		stfcamss->syscon_base =
    45			devm_platform_ioremap_resource_byname(pdev, "syscon");
    46		if (IS_ERR(stfcamss->syscon_base))
    47			return PTR_ERR(stfcamss->syscon_base);
    48	
    49		stfcamss->isp_base =
    50			devm_platform_ioremap_resource_byname(pdev, "isp");
    51		if (IS_ERR(stfcamss->isp_base))
    52			return PTR_ERR(stfcamss->isp_base);
    53	
    54		return 0;
    55	}
    56	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#2 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Jack Zhu
Quoted 81 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +65 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 75

Quoted 10 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +10 -0
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#

I don't think we use video-interfaces with port. Are you sure this works fine? Please extend the example with appropriate properties to check...

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 87

Quoted 12 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +12 -0
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false

Same concerns here.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v3 3/9] media: dt-bindings: cadence-csi2rx: Convert to DT schema

In reply to Jack Zhu
Quoted 26 lines · Jack Zhu

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to DT schema format.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt | 100 ----------
 .../bindings/media/cdns,csi2rx.yaml           | 174 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 3 files changed, 175 insertions(+), 100 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +0 -8
deleted file mode 100644
index 6b02a0657ad9..000000000000
@@ -1,100 +0,0 @@
-Cadence MIPI-CSI2 RX controller
-===============================
-
-The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
-lanes in input, and 4 different pixel streams in output.
-
-Required properties:
-  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible

...

Quoted 5 lines

+$id: http://devicetree.org/schemas/media/cdns,csi2rx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +3 -0
+
+title: Cadence MIPI-CSI2 RX controller
+

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 10 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +10 -0
+maintainers:
+  - Maxime Ripard <[email protected]>
+
+description:
+  The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
+  lanes in input, and 4 different pixel streams in output.
+
+properties:
+  compatible:
+    const: cdns,csi2rx

That's not equivalent conversion and your commit msg does no mention any drops in compatibles.

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 13 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +13 -0
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: CSI2Rx system clock
+      - description: Gated Register bank clock for APB interface
+      - description: pixel Clock for Stream interface 0
+      - description: pixel Clock for Stream interface 1
+      - description: pixel Clock for Stream interface 2
+      - description: pixel Clock for Stream interface 3
+

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v3 2/9] media: admin-guide: Add starfive_camss.rst for Starfive Camera Subsystem

In reply to Jack Zhu
I love your patch! Perhaps something to improve:

Hi Jack,

I love your patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on robh/for-next linus/master v6.3-rc4 next-20230331] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230331121826.96973-3-jack.zhu%40starfivetech.com
patch subject: [PATCH v3 2/9] media: admin-guide: Add starfive_camss.rst for Starfive Camera Subsystem
reproduce:
        # https://github.com/intel-lab-lkp/linux/commit/2e986871a1e6e63c6915803102a6025f19781772
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001
        git checkout 2e986871a1e6e63c6915803102a6025f19781772
        make menuconfig
        # enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS, CONFIG_WARN_ABI_ERRORS
        make htmldocs

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> Documentation/admin-guide/media/v4l-drivers.rst:9: WARNING: toctree contains reference to nonexisting document 'admin-guide/media/starfive'
>> Documentation/admin-guide/media/starfive_camss.rst: WARNING: document isn't included in any toctree

vim +9 Documentation/admin-guide/media/v4l-drivers.rst

33fc918ab89bec Mauro Carvalho Chehab 2020-04-18 8 33fc918ab89bec Mauro Carvalho Chehab 2020-04-18 @9 .. toctree::

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#31 lore raw

Re: [PATCH v3 9/9] media: starfive: Add Starfive Camera Subsystem driver

In reply to Jack Zhu
I love your patch! Perhaps something to improve:

Hi Jack,

I love your patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on robh/for-next linus/master v6.3-rc4 next-20230331] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230331121826.96973-10-jack.zhu%40starfivetech.com
patch subject: [PATCH v3 9/9] media: starfive: Add Starfive Camera Subsystem driver
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230401/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/421adbf9815b633e8bac5da7146c33aac01e283c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jack-Zhu/media-dt-bindings-Add-bindings-for-JH7110-Camera-Subsystem/20230331-202001 git checkout 421adbf9815b633e8bac5da7146c33aac01e283c
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/media/platform/starfive/stf_vin.c: In function 'stf_vin_map_isp_pad':
drivers/media/platform/starfive/stf_vin.c:99:24: warning: implicit conversion from 'enum isp_line_id' to 'enum isp_pad_id' [-Wenum-conversion]

      99 |                 pad_id = vin_map_isp_line(line);
         |                        ^
   drivers/media/platform/starfive/stf_vin.c: In function 'vin_output_init_addrs':
   drivers/media/platform/starfive/stf_vin.c:683:20: warning: variable 'pong_addr' set but not used [-Wunused-but-set-variable]
     683 |         dma_addr_t pong_addr;
         |                    ^~~~~~~~~
   At top level:
>> drivers/media/platform/starfive/stf_vin.c:33:32: warning: 'vin_formats_raw' defined but not used [-Wunused-const-variable=]
      33 | static const struct vin_format vin_formats_raw[] = {
         |                                ^~~~~~~~~~~~~~~

vim +/vin_formats_raw +33 drivers/media/platform/starfive/stf_vin.c

    32	
  > 33	static const struct vin_format vin_formats_raw[] = {
    34		{ MEDIA_BUS_FMT_SBGGR12_1X12, 12},
    35		{ MEDIA_BUS_FMT_SRGGB12_1X12, 12},
    36		{ MEDIA_BUS_FMT_SGRBG12_1X12, 12},
    37		{ MEDIA_BUS_FMT_SGBRG12_1X12, 12},
    38	};
    39	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
author
#3 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Krzysztof Kozlowski
Quoted 87 lines · Krzysztof Kozlowski
Quoted 86 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +70 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 75

Quoted 5 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +5 -0
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#

I don't think we use video-interfaces with port. Are you sure this works fine? Please extend the example with appropriate properties to check...

Thank you for your review.
the following change, is it OK?

endpoint:
$ref: video-interfaces.yaml#
unevaluatedProperties: false

properties:
bus-width:
const: 8

data-shift:
const: 2

in example:

	port@0 {
                reg = <0>;
                vin_from_sc2235: endpoint {
                    remote-endpoint = <&sc2235_to_vin>;
                    bus-width = <8>;
                    data-shift = <2>;
                    hsync-active = <1>;
                    vsync-active = <0>;
                    pclk-sample = <1>;
                };
	};
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 87

Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false

Same concerns here.

for port@1, We don't use any properties as the allwinner,sun6i-a31-isp.yaml file. Use the following modification, I don't know if it is ok?

port@1:
$ref: /schemas/graph.yaml#/properties/port
description: Input port for receiving CSI data.

Quoted 4 lines

Best regards,
Krzysztof

author
#12 lore raw

Re: [PATCH v3 3/9] media: dt-bindings: cadence-csi2rx: Convert to DT schema

In reply to Krzysztof Kozlowski
Quoted 41 lines · Krzysztof Kozlowski
Quoted 26 lines · Jack Zhu

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to DT schema format.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt | 100 ----------
 .../bindings/media/cdns,csi2rx.yaml           | 174 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 3 files changed, 175 insertions(+), 100 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +0 -8
deleted file mode 100644
index 6b02a0657ad9..000000000000
@@ -1,100 +0,0 @@
-Cadence MIPI-CSI2 RX controller
-===============================
-
-The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
-lanes in input, and 4 different pixel streams in output.
-
-Required properties:
-  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible

...

Quoted 10 lines

+$id: http://devicetree.org/schemas/media/cdns,csi2rx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +8 -0
+
+title: Cadence MIPI-CSI2 RX controller
+
+maintainers:
+  - Maxime Ripard <[email protected]>
+
+description:
+  The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
Quoted 9 lines

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 5 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +5 -0
+  lanes in input, and 4 different pixel streams in output.
+
+properties:
+  compatible:
+    const: cdns,csi2rx

That's not equivalent conversion and your commit msg does no mention any drops in compatibles.

The equivalent conversion refers to 'an SoC-specific compatible'?
I'm not sure that, is it enough to add a description (drop an 'SoC-specific compatible') to my next version commit message?

Quoted 17 lines

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 13 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +13 -0
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: CSI2Rx system clock
+      - description: Gated Register bank clock for APB interface
+      - description: pixel Clock for Stream interface 0
+      - description: pixel Clock for Stream interface 1
+      - description: pixel Clock for Stream interface 2
+      - description: pixel Clock for Stream interface 3
+

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v3 3/9] media: dt-bindings: cadence-csi2rx: Convert to DT schema

Quoted 53 lines · Jack Zhu
Quoted 41 lines · Krzysztof Kozlowski
Quoted 26 lines · Jack Zhu

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to DT schema format.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt | 100 ----------
 .../bindings/media/cdns,csi2rx.yaml           | 174 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 3 files changed, 175 insertions(+), 100 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +0 -8
deleted file mode 100644
index 6b02a0657ad9..000000000000
@@ -1,100 +0,0 @@
-Cadence MIPI-CSI2 RX controller
-===============================
-
-The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
-lanes in input, and 4 different pixel streams in output.
-
-Required properties:
-  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible

...

Quoted 10 lines

+$id: http://devicetree.org/schemas/media/cdns,csi2rx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +8 -0
+
+title: Cadence MIPI-CSI2 RX controller
+
+maintainers:
+  - Maxime Ripard <[email protected]>
+
+description:
+  The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
Quoted 9 lines

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 5 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +5 -0
+  lanes in input, and 4 different pixel streams in output.
+
+properties:
+  compatible:
+    const: cdns,csi2rx

That's not equivalent conversion and your commit msg does no mention any drops in compatibles.

Quoted 1 line

The equivalent conversion refers to 'an SoC-specific compatible'?

Yes.

Quoted 2 lines

I'm not sure that, is it enough to add a description (drop an 'SoC-specific compatible') to my next version commit message?

Original binding did not allow csi2rx compatible alone. Your binding here allows it, thus it is not simple conversion.

I think patch 5 should be squashed here - with proper explanation. Usually new compatibles should not be messed with conversion, but this conversion on its own does not make much sense.

Best regards,
Krzysztof

maintainer
#4 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Jack Zhu
Quoted 99 lines · Jack Zhu
Quoted 87 lines · Krzysztof Kozlowski
Quoted 86 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +70 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 75

Quoted 5 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +5 -0
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#

I don't think we use video-interfaces with port. Are you sure this works fine? Please extend the example with appropriate properties to check...

Quoted 2 lines

Thank you for your review.
the following change, is it OK?

What Krzysztof meant is port@0 needs to $ref '$defs/port-base' rather then 'properties/port' to work with video-interfaces.yaml. If you made that change, then this is fine.

Quoted 41 lines

endpoint:
$ref: video-interfaces.yaml#
unevaluatedProperties: false

properties:
bus-width:
const: 8

data-shift:
const: 2

in example:

	port@0 {
                reg = <0>;
                vin_from_sc2235: endpoint {
                    remote-endpoint = <&sc2235_to_vin>;
                    bus-width = <8>;
                    data-shift = <2>;
                    hsync-active = <1>;
                    vsync-active = <0>;
                    pclk-sample = <1>;
                };
	};
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 87

Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false

Same concerns here.

Quoted 2 lines

for port@1, We don't use any properties as the allwinner,sun6i-a31-isp.yaml file. Use the following modification, I don't know if it is ok?

Yes.

Quoted 3 lines

port@1:
$ref: /schemas/graph.yaml#/properties/port
description: Input port for receiving CSI data.

Rob

author
#14 lore raw

Re: [PATCH v3 3/9] media: dt-bindings: cadence-csi2rx: Convert to DT schema

In reply to Krzysztof Kozlowski
Quoted 61 lines · Krzysztof Kozlowski
Quoted 53 lines · Jack Zhu
Quoted 41 lines · Krzysztof Kozlowski
Quoted 26 lines · Jack Zhu

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to DT schema format.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt | 100 ----------
 .../bindings/media/cdns,csi2rx.yaml           | 174 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 3 files changed, 175 insertions(+), 100 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +0 -8
deleted file mode 100644
index 6b02a0657ad9..000000000000
@@ -1,100 +0,0 @@
-Cadence MIPI-CSI2 RX controller
-===============================
-
-The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
-lanes in input, and 4 different pixel streams in output.
-
-Required properties:
-  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible

...

Quoted 10 lines

+$id: http://devicetree.org/schemas/media/cdns,csi2rx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +8 -0
+
+title: Cadence MIPI-CSI2 RX controller
+
+maintainers:
+  - Maxime Ripard <[email protected]>
+
+description:
+  The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
Quoted 9 lines

Documentation/devicetree/bindings/media/cdns,csi2rx.txt

Quoted 5 lines
Documentation/devicetree/bindings/media/cdns,csi2rx.txt deleted +5 -0
+  lanes in input, and 4 different pixel streams in output.
+
+properties:
+  compatible:
+    const: cdns,csi2rx

That's not equivalent conversion and your commit msg does no mention any drops in compatibles.

Quoted 1 line

The equivalent conversion refers to 'an SoC-specific compatible'?

Yes.

Quoted 2 lines

I'm not sure that, is it enough to add a description (drop an 'SoC-specific compatible') to my next version commit message?

Quoted 7 lines

Original binding did not allow csi2rx compatible alone. Your binding here allows it, thus it is not simple conversion.

I think patch 5 should be squashed here - with proper explanation. Usually new compatibles should not be messed with conversion, but this conversion on its own does not make much sense.

Ok, I will merge patch 5 into the patch, and add explanation in my commit msg.

Quoted 5 lines

Best regards,
Krzysztof

author
#5 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Rob Herring
Quoted 100 lines · Rob Herring
Quoted 99 lines · Jack Zhu
Quoted 96 lines · Krzysztof Kozlowski
Quoted 81 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +65 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 75

Quoted 10 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +10 -0
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#

I don't think we use video-interfaces with port. Are you sure this works fine? Please extend the example with appropriate properties to check...

Quoted 7 lines
Quoted 2 lines

Thank you for your review.
the following change, is it OK?

What Krzysztof meant is port@0 needs to $ref '$defs/port-base' rather then 'properties/port' to work with video-interfaces.yaml. If you made that change, then this is fine.

Thank you for your comment.
OK, I have made that change. Thank you.

port@0:
$ref: /schemas/graph.yaml#/$defs/port-base
unevaluatedProperties: false
description: Input port for receiving DVP data.

properties:
endpoint:
$ref: video-interfaces.yaml#
unevaluatedProperties: false

properties:
bus-width:
const: 8

data-shift:
const: 2

Quoted 51 lines
Quoted 41 lines

endpoint:
$ref: video-interfaces.yaml#
unevaluatedProperties: false

properties:
bus-width:
const: 8

data-shift:
const: 2

in example:

	port@0 {
                reg = <0>;
                vin_from_sc2235: endpoint {
                    remote-endpoint = <&sc2235_to_vin>;
                    bus-width = <8>;
                    data-shift = <2>;
                    hsync-active = <1>;
                    vsync-active = <0>;
                    pclk-sample = <1>;
                };
	};
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 87

Quoted 6 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +6 -0
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false

Same concerns here.

Quoted 2 lines

for port@1, We don't use any properties as the allwinner,sun6i-a31-isp.yaml file. Use the following modification, I don't know if it is ok?

Yes.

Quoted 3 lines

port@1:
$ref: /schemas/graph.yaml#/properties/port
description: Input port for receiving CSI data.

Rob

#6 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 96 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +80 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 90

Quoted 10 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +10 -0
+        description:
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false
+
+    required:
+      - port@1

Both ports should be required. It's fine to have unconnected ports (that is, without any endpoint child node), but the ports should always be present if they exist in the hardware.

Quoted 87 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +69 -0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+  - interrupts
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+    isp@19840000 {
+        compatible = "starfive,jh7110-camss";
+        reg = <0x19840000 0x10000>,
+              <0x19870000 0x30000>;
+        reg-names = "syscon", "isp";
+        clocks = <&ispcrg 0>,
+                 <&ispcrg 13>,
+                 <&ispcrg 2>,
+                 <&ispcrg 12>,
+                 <&ispcrg 1>,
+                 <&syscrg 51>,
+                 <&syscrg 52>;
+        clock-names = "apb_func",
+                      "wrapper_clk_c",
+                      "dvp_inv",
+                      "axiwr",
+                      "mipi_rx0_pxl",
+                      "ispcore_2x",
+                      "isp_axi";
+        resets = <&ispcrg 0>,
+                 <&ispcrg 1>,
+                 <&ispcrg 10>,
+                 <&ispcrg 11>,
+                 <&syscrg 41>,
+                 <&syscrg 42>;
+        reset-names = "wrapper_p",
+                      "wrapper_c",
+                      "axird",
+                      "axiwr",
+                      "isp_top_n",
+                      "isp_top_axi";
+        power-domains = <&pwrc 5>;
+        interrupts = <92>, <87>, <88>, <90>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            port@0 {
+                reg = <0>;
+                vin_from_sc2235: endpoint {
+                    remote-endpoint = <&sc2235_to_vin>;
+                };
+            };
+
+            port@1 {
+                reg = <1>;
+                vin_from_csi2rx: endpoint {
+                    remote-endpoint = <&csi2rx_to_vin>;
+                };
+            };
+        };
+    };
MAINTAINERS +7 -0
index b6c811326355..f7165371c56d 100644
@@ -19908,6 +19908,13 @@ M:	Ion Badulescu <[email protected]>
 S:	Odd Fixes
 F:	drivers/net/ethernet/adaptec/starfire*
 
+STARFIVE CAMERA SUBSYSTEM DRIVER
+M:	Jack Zhu <[email protected]>
+M:	Changhuang Liang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
+
 STARFIVE DEVICETREES
 M:	Emil Renner Berthing <[email protected]>
 S:	Maintained
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v3 5/9
#20 lore raw

Re: [PATCH v3 5/9] media: dt-bindings: cadence-csi2rx: Add starfive compatible

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 4 lines · Jack Zhu

Add starfive compatible for Starfive JH7110 SoC which has a Cadence MIPI-CSI2 RX controller.

Quoted 29 lines
---
 Documentation/devicetree/bindings/media/cdns,csi2rx.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/media/cdns,csi2rx.yaml +5 -2
index f8da4a35e98e..30a335b10762 100644
@@ -15,7 +15,10 @@ description:
 
 properties:
   compatible:
-    const: cdns,csi2rx
+    items:
+      - enum:
+          - starfive,jh7110-csi2rx
+      - const: cdns,csi2rx
 
   reg:
     maxItems: 1
@@ -130,7 +133,7 @@ additionalProperties: false
 examples:
   - |
     csi@d060000 {
-        compatible = "cdns,csi2rx";
+        compatible = "starfive,jh7110-csi2rx", "cdns,csi2rx";
         reg = <0x0d060000 0x1000>;
         clocks = <&byteclock 7>, <&byteclock 6>,
                  <&coreclock 8>, <&coreclock 9>,
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v3 7/9
#25 lore raw

Re: [PATCH v3 7/9] media: cadence: Add support for external dphy

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 3 lines · Jack Zhu

Add support for external MIPI D-PHY.

Quoted 134 lines
---
 drivers/media/platform/cadence/cdns-csi2rx.c | 66 +++++++++++++++++---
 1 file changed, 56 insertions(+), 10 deletions(-)
drivers/media/platform/cadence/cdns-csi2rx.c +56 -10
index a1555cedb349..add982edce64 100644
@@ -31,6 +31,12 @@
 #define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane)	((plane) << (16 + (llane) * 4))
 #define CSI2RX_STATIC_CFG_LANES_MASK			GENMASK(11, 8)
 
+#define CSI2RX_DPHY_LANE_CTRL_REG		0x40
+#define CSI2RX_DPHY_CL_RST			BIT(16)
+#define CSI2RX_DPHY_DL_RST(i)			BIT((i) + 12)
+#define CSI2RX_DPHY_CL_EN			BIT(4)
+#define CSI2RX_DPHY_DL_EN(i)			BIT(i)
+
 #define CSI2RX_STREAM_BASE(n)		(((n) + 1) * 0x100)
 
 #define CSI2RX_STREAM_CTRL_REG(n)		(CSI2RX_STREAM_BASE(n) + 0x000)
@@ -105,6 +111,24 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
 	writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
 }
 
+static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
+{
+	union phy_configure_opts opts = { };
+	int ret;
+
+	ret = phy_power_on(csi2rx->dphy);
+	if (ret)
+		return ret;
+
+	ret = phy_configure(csi2rx->dphy, &opts);
+	if (ret) {
+		phy_power_off(csi2rx->dphy);
+		return ret;
+	}
+
+	return 0;
+}
+
 static int csi2rx_start(struct csi2rx_priv *csi2rx)
 {
 	unsigned int i;
@@ -144,6 +168,17 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		goto err_disable_pclk;
 
+	/* Enable DPHY clk and data lanes. */
+	if (csi2rx->dphy) {
+		reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST;
+		for (i = 0; i < csi2rx->num_lanes; i++) {
+			reg |= CSI2RX_DPHY_DL_EN(csi2rx->lanes[i] - 1);
+			reg |= CSI2RX_DPHY_DL_RST(csi2rx->lanes[i] - 1);
+		}
+
+		writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+	}
+
 	/*
 	 * Create a static mapping between the CSI virtual channels
 	 * and the output stream.
@@ -177,10 +212,22 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 		goto err_disable_pixclk;
 
 	reset_control_deassert(csi2rx->sys_rst);
+
+	if (csi2rx->dphy) {
+		ret = csi2rx_configure_ext_dphy(csi2rx);
+		if (ret) {
+			dev_err(csi2rx->dev,
+				"Failed to configure external DPHY: %d\n", ret);
+			goto err_disable_sysclk;
+		}
+	}
+
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	return 0;
 
+err_disable_sysclk:
+	clk_disable_unprepare(csi2rx->sys_clk);
 err_disable_pixclk:
 	for (; i > 0; i--)
 		clk_disable_unprepare(csi2rx->pixel_clk[i - 1]);
@@ -211,6 +258,13 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
 		dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
+
+	if (csi2rx->dphy) {
+		writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+
+		if (phy_power_off(csi2rx->dphy))
+			dev_warn(csi2rx->dev, "Couldn't power off DPHY\n");
+	}
 }
 
 static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
@@ -327,15 +381,6 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 		return PTR_ERR(csi2rx->dphy);
 	}
 
-	/*
-	 * FIXME: Once we'll have external D-PHY support, the check
-	 * will need to be removed.
-	 */
-	if (csi2rx->dphy) {
-		dev_err(&pdev->dev, "External D-PHY not supported yet\n");
-		return -EINVAL;
-	}
-
 	ret = clk_prepare_enable(csi2rx->p_clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Couldn't prepare and enable P clock\n");
@@ -365,7 +410,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 	 * FIXME: Once we'll have internal D-PHY support, the check
 	 * will need to be removed.
 	 */
-	if (csi2rx->has_internal_dphy) {
+	if (!csi2rx->dphy && csi2rx->has_internal_dphy) {
 		dev_err(&pdev->dev, "Internal D-PHY not supported yet\n");
 		return -EINVAL;
 	}
@@ -492,6 +537,7 @@ static int csi2rx_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev,
 		 "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
 		 csi2rx->num_lanes, csi2rx->max_lanes, csi2rx->max_streams,
+		 csi2rx->dphy ? "external" :
 		 csi2rx->has_internal_dphy ? "internal" : "no");
 
 	return 0;
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v3 4/9
#17 lore raw

Re: [PATCH v3 4/9] media: dt-bindings: cadence-csi2rx: Add resets property

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 3 lines · Jack Zhu

Add resets property for Cadence MIPI-CSI2 RX controller

Quoted 46 lines
---
 .../bindings/media/cdns,csi2rx.yaml           | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/media/cdns,csi2rx.yaml +24 -0
index 89f414eeef47..f8da4a35e98e 100644
@@ -38,6 +38,24 @@ properties:
       - const: pixel_if2_clk
       - const: pixel_if3_clk
 
+  resets:
+    items:
+      - description: CSI2Rx system reset
+      - description: Gated Register bank reset for APB interface
+      - description: pixel reset for Stream interface 0
+      - description: pixel reset for Stream interface 1
+      - description: pixel reset for Stream interface 2
+      - description: pixel reset for Stream interface 3
+
+  reset-names:
+    items:
+      - const: sys
+      - const: reg_bank
+      - const: pixel_if0
+      - const: pixel_if1
+      - const: pixel_if2
+      - const: pixel_if3
+
   phys:
     maxItems: 1
     description: MIPI D-PHY
@@ -120,6 +138,12 @@ examples:
         clock-names = "sys_clk", "p_clk",
                       "pixel_if0_clk", "pixel_if1_clk",
                       "pixel_if2_clk", "pixel_if3_clk";
+        resets = <&bytereset 9>, <&bytereset 4>,
+                 <&corereset 5>, <&corereset 6>,
+                 <&corereset 7>, <&corereset 8>;
+        reset-names = "sys", "reg_bank",
+                      "pixel_if0", "pixel_if1",
+                      "pixel_if2", "pixel_if3";
         phys = <&csi_phy>;
         phy-names = "dphy";
 
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v3 6/9
#22 lore raw

Re: [PATCH v3 6/9] media: cadence: Add operation on reset

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 38 lines · Jack Zhu

Add operation on reset for Cadence MIPI-CSI2 RX Controller.

---
 drivers/media/platform/cadence/cdns-csi2rx.c | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/cadence/cdns-csi2rx.c +5 -0
index cc3ebb0d96f6..a1555cedb349 100644
@@ -13,6 +13,7 @@
 #include <linux/of_graph.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #include <media/v4l2-ctrls.h>
@@ -68,6 +69,9 @@ struct csi2rx_priv {
 	struct clk			*sys_clk;
 	struct clk			*p_clk;
 	struct clk			*pixel_clk[CSI2RX_STREAMS_MAX];
+	struct reset_control		*sys_rst;
+	struct reset_control		*p_rst;
+	struct reset_control		*pixel_rst[CSI2RX_STREAMS_MAX];
 	struct phy			*dphy;
 
 	u8				lanes[CSI2RX_LANES_MAX];
@@ -112,6 +116,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		return ret;
 
+	reset_control_deassert(csi2rx->p_rst);
 	csi2rx_reset(csi2rx);
 
 	reg = csi2rx->num_lanes << 8;

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_start(struct csi2rx_priv *csi2rx) · line 160

Quoted 2 lines
drivers/media/platform/cadence/cdns-csi2rx.c +0 -0
@@ -154,6 +159,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 		if (ret)
 			goto err_disable_pixclk;

The loop after the err_disable_pixclk label should assert the pixel_rst[i] reset.

Quoted 33 lines
drivers/media/platform/cadence/cdns-csi2rx.c +6 -0
+		reset_control_deassert(csi2rx->pixel_rst[i]);
+
 		writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF,
 		       csi2rx->base + CSI2RX_STREAM_CFG_REG(i));
 
@@ -169,6 +176,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		goto err_disable_pixclk;
 
+	reset_control_deassert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	return 0;
@@ -188,14 +196,17 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 	unsigned int i;
 
 	clk_prepare_enable(csi2rx->p_clk);
+	reset_control_assert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->sys_clk);
 
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
 
+		reset_control_assert(csi2rx->pixel_rst[i]);
 		clk_disable_unprepare(csi2rx->pixel_clk[i]);
 	}
 
+	reset_control_assert(csi2rx->p_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 315

Quoted 6 lines
drivers/media/platform/cadence/cdns-csi2rx.c +3 -0
@@ -299,6 +310,17 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 		return PTR_ERR(csi2rx->p_clk);
 	}
 
+	csi2rx->sys_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev,
+							  "sys_rst");

You can write this on two lines:

	csi2rx->sys_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
								    "sys_rst");

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 320

Quoted 5 lines
drivers/media/platform/cadence/cdns-csi2rx.c +5 -0
+	if (IS_ERR(csi2rx->sys_rst))
+		return PTR_ERR(csi2rx->sys_rst);
+
+	csi2rx->p_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev, "p_rst");

And here,

	csi2rx->p_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
								  "p_rst");

would be the same number of lines but more readable in my opinion.

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 375

Quoted 11 lines
drivers/media/platform/cadence/cdns-csi2rx.c +4 -0
+	if (IS_ERR(csi2rx->p_rst))
+		return PTR_ERR(csi2rx->p_rst);
+
 	csi2rx->dphy = devm_phy_optional_get(&pdev->dev, "dphy");
 	if (IS_ERR(csi2rx->dphy)) {
 		dev_err(&pdev->dev, "Couldn't get external D-PHY\n");
@@ -350,6 +372,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		char clk_name[16];
+		char rst_name[16];

You don't need two variables, you can rename clk_name to name, and use it for both clk and rst.

With these small issues addressed you can add my

in the next version.

Quoted 17 lines
drivers/media/platform/cadence/cdns-csi2rx.c +7 -0
 		snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
 		csi2rx->pixel_clk[i] = devm_clk_get(&pdev->dev, clk_name);
@@ -357,6 +380,13 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 			dev_err(&pdev->dev, "Couldn't get clock %s\n", clk_name);
 			return PTR_ERR(csi2rx->pixel_clk[i]);
 		}
+
+		snprintf(rst_name, sizeof(rst_name), "pixel_if%u_rst", i);
+		csi2rx->pixel_rst[i] =
+			devm_reset_control_get_optional_exclusive(&pdev->dev,
+								  rst_name);
+		if (IS_ERR(csi2rx->pixel_rst[i]))
+			return PTR_ERR(csi2rx->pixel_rst[i]);
 	}
 
 	return 0;
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v3 8/9
#27 lore raw

Re: [PATCH v3 8/9] media: cadence: Add support for JH7110 SoC

In reply to Jack Zhu

Hi Jack,

Thank you for the patch.

Quoted 2 lines · Jack Zhu

Add support for Starfive JH7110 SoC which
has the cadence csi2 receiver.

This fits on one line:

Add support for Starfive JH7110 SoC which has the cadence csi2 receiver.

Quoted 1 line
Quoted 16 lines
---
 drivers/media/platform/cadence/cdns-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/cadence/cdns-csi2rx.c +1 -0
index add982edce64..5e36b994b8d5 100644
@@ -560,6 +560,7 @@ static int csi2rx_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id csi2rx_of_table[] = {
+	{ .compatible = "starfive,jh7110-csi2rx" },
 	{ .compatible = "cdns,csi2rx" },
 	{ },
 };
Signature · 3 lines
Regards,

Laurent Pinchart
author
#7 lore raw

Re: [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem

In reply to Laurent Pinchart
Quoted 107 lines · Laurent Pinchart

Hi Jack,

Thank you for the patch.

Quoted 102 lines · Jack Zhu

Add the bindings documentation for Starfive JH7110 Camera Subsystem which is used for handing image sensor data.

---
 .../bindings/media/starfive,jh7110-camss.yaml | 159 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +86 -0
new file mode 100644
index 000000000000..0235c70e7793
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/starfive,jh7110-camss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Starfive SoC CAMSS ISP
+
+maintainers:
+  - Jack Zhu <[email protected]>
+  - Changhuang Liang <[email protected]>
+
+description:
+  The Starfive CAMSS ISP is a Camera interface for Starfive JH7110 SoC. It
+  consists of a VIN controller (Video In Controller, a top-level control until)
+  and an ISP.
+
+properties:
+  compatible:
+    const: starfive,jh7110-camss
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: syscon
+      - const: isp
+
+  clocks:
+    maxItems: 7
+
+  clock-names:
+    items:
+      - const: apb_func
+      - const: wrapper_clk_c
+      - const: dvp_inv
+      - const: axiwr
+      - const: mipi_rx0_pxl
+      - const: ispcore_2x
+      - const: isp_axi
+
+  resets:
+    maxItems: 6
+
+  reset-names:
+    items:
+      - const: wrapper_p
+      - const: wrapper_c
+      - const: axird
+      - const: axiwr
+      - const: isp_top_n
+      - const: isp_top_axi
+
+  power-domains:
+    items:
+      - description: JH7110 ISP Power Domain Switch Controller.
+
+  interrupts:
+    maxItems: 4
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving DVP data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
+            unevaluatedProperties: false
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description:
+          Input port for receiving CSI data.
+
+        properties:
+          endpoint:
+            $ref: video-interfaces.yaml#
Quoted 9 lines

Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml line 90

Quoted 4 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +4 -0
+            unevaluatedProperties: false
+
+    required:
+      - port@1

Both ports should be required. It's fine to have unconnected ports (that is, without any endpoint child node), but the ports should always be present if they exist in the hardware.

Thank you for your comments.
OK, I will add port@0.

Quoted 88 lines
Quoted 87 lines
Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml new file +69 -0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+  - interrupts
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+    isp@19840000 {
+        compatible = "starfive,jh7110-camss";
+        reg = <0x19840000 0x10000>,
+              <0x19870000 0x30000>;
+        reg-names = "syscon", "isp";
+        clocks = <&ispcrg 0>,
+                 <&ispcrg 13>,
+                 <&ispcrg 2>,
+                 <&ispcrg 12>,
+                 <&ispcrg 1>,
+                 <&syscrg 51>,
+                 <&syscrg 52>;
+        clock-names = "apb_func",
+                      "wrapper_clk_c",
+                      "dvp_inv",
+                      "axiwr",
+                      "mipi_rx0_pxl",
+                      "ispcore_2x",
+                      "isp_axi";
+        resets = <&ispcrg 0>,
+                 <&ispcrg 1>,
+                 <&ispcrg 10>,
+                 <&ispcrg 11>,
+                 <&syscrg 41>,
+                 <&syscrg 42>;
+        reset-names = "wrapper_p",
+                      "wrapper_c",
+                      "axird",
+                      "axiwr",
+                      "isp_top_n",
+                      "isp_top_axi";
+        power-domains = <&pwrc 5>;
+        interrupts = <92>, <87>, <88>, <90>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            port@0 {
+                reg = <0>;
+                vin_from_sc2235: endpoint {
+                    remote-endpoint = <&sc2235_to_vin>;
+                };
+            };
+
+            port@1 {
+                reg = <1>;
+                vin_from_csi2rx: endpoint {
+                    remote-endpoint = <&csi2rx_to_vin>;
+                };
+            };
+        };
+    };
MAINTAINERS +7 -0
index b6c811326355..f7165371c56d 100644
@@ -19908,6 +19908,13 @@ M:	Ion Badulescu <[email protected]>
 S:	Odd Fixes
 F:	drivers/net/ethernet/adaptec/starfire*
 
+STARFIVE CAMERA SUBSYSTEM DRIVER
+M:	Jack Zhu <[email protected]>
+M:	Changhuang Liang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml
+
 STARFIVE DEVICETREES
 M:	Emil Renner Berthing <[email protected]>
 S:	Maintained
author
#23 lore raw

Re: [PATCH v3 6/9] media: cadence: Add operation on reset

In reply to Laurent Pinchart
Quoted 41 lines · Laurent Pinchart

Hi Jack,

Thank you for the patch.

Quoted 36 lines · Jack Zhu

Add operation on reset for Cadence MIPI-CSI2 RX Controller.

---
 drivers/media/platform/cadence/cdns-csi2rx.c | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/cadence/cdns-csi2rx.c +5 -0
index cc3ebb0d96f6..a1555cedb349 100644
@@ -13,6 +13,7 @@
 #include <linux/of_graph.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #include <media/v4l2-ctrls.h>
@@ -68,6 +69,9 @@ struct csi2rx_priv {
 	struct clk			*sys_clk;
 	struct clk			*p_clk;
 	struct clk			*pixel_clk[CSI2RX_STREAMS_MAX];
+	struct reset_control		*sys_rst;
+	struct reset_control		*p_rst;
+	struct reset_control		*pixel_rst[CSI2RX_STREAMS_MAX];
 	struct phy			*dphy;
 
 	u8				lanes[CSI2RX_LANES_MAX];
@@ -112,6 +116,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		return ret;
 
+	reset_control_deassert(csi2rx->p_rst);
 	csi2rx_reset(csi2rx);
 
Quoted 8 lines

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_start(struct csi2rx_priv *csi2rx) · line 160

Quoted 4 lines
drivers/media/platform/cadence/cdns-csi2rx.c +0 -0
 	reg = csi2rx->num_lanes << 8;
@@ -154,6 +159,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 		if (ret)
 			goto err_disable_pixclk;

The loop after the err_disable_pixclk label should assert the pixel_rst[i] reset.

OK, I will fix it.

Quoted 36 lines
Quoted 36 lines
drivers/media/platform/cadence/cdns-csi2rx.c +6 -0
+		reset_control_deassert(csi2rx->pixel_rst[i]);
+
 		writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF,
 		       csi2rx->base + CSI2RX_STREAM_CFG_REG(i));
 
@@ -169,6 +176,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	if (ret)
 		goto err_disable_pixclk;
 
+	reset_control_deassert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	return 0;
@@ -188,14 +196,17 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 	unsigned int i;
 
 	clk_prepare_enable(csi2rx->p_clk);
+	reset_control_assert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->sys_clk);
 
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
 
+		reset_control_assert(csi2rx->pixel_rst[i]);
 		clk_disable_unprepare(csi2rx->pixel_clk[i]);
 	}
 
+	reset_control_assert(csi2rx->p_rst);
 	clk_disable_unprepare(csi2rx->p_clk);
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
@@ -299,6 +310,17 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 		return PTR_ERR(csi2rx->p_clk);
 	}
 
Quoted 8 lines

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 315

Quoted 3 lines
drivers/media/platform/cadence/cdns-csi2rx.c +3 -0
+	csi2rx->sys_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev,
+							  "sys_rst");

You can write this on two lines:

	csi2rx->sys_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
								    "sys_rst");

OK, I will modify it.

Quoted 8 lines

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 320

Quoted 5 lines
drivers/media/platform/cadence/cdns-csi2rx.c +5 -0
+	if (IS_ERR(csi2rx->sys_rst))
+		return PTR_ERR(csi2rx->sys_rst);
+
+	csi2rx->p_rst =
+		devm_reset_control_get_optional_exclusive(&pdev->dev, "p_rst");

And here,

Quoted 5 lines
	csi2rx->p_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
								  "p_rst");

would be the same number of lines but more readable in my opinion.

OK, I will modify it.

Quoted 8 lines
Quoted 8 lines
drivers/media/platform/cadence/cdns-csi2rx.c +3 -0
+	if (IS_ERR(csi2rx->p_rst))
+		return PTR_ERR(csi2rx->p_rst);
+
 	csi2rx->dphy = devm_phy_optional_get(&pdev->dev, "dphy");
 	if (IS_ERR(csi2rx->dphy)) {
 		dev_err(&pdev->dev, "Couldn't get external D-PHY\n");
@@ -350,6 +372,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 
Quoted 7 lines

drivers/media/platform/cadence/cdns-csi2rx.c static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, · line 375

Quoted 3 lines
drivers/media/platform/cadence/cdns-csi2rx.c +1 -0
 	for (i = 0; i < csi2rx->max_streams; i++) {
 		char clk_name[16];
+		char rst_name[16];

You don't need two variables, you can rename clk_name to name, and use it for both clk and rst.

OK, I will fix it.

Quoted 6 lines

With these small issues addressed you can add my

in the next version.

OK. Thank you for your review.

Quoted 18 lines
Quoted 17 lines
drivers/media/platform/cadence/cdns-csi2rx.c +7 -0
 		snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
 		csi2rx->pixel_clk[i] = devm_clk_get(&pdev->dev, clk_name);
@@ -357,6 +380,13 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
 			dev_err(&pdev->dev, "Couldn't get clock %s\n", clk_name);
 			return PTR_ERR(csi2rx->pixel_clk[i]);
 		}
+
+		snprintf(rst_name, sizeof(rst_name), "pixel_if%u_rst", i);
+		csi2rx->pixel_rst[i] =
+			devm_reset_control_get_optional_exclusive(&pdev->dev,
+								  rst_name);
+		if (IS_ERR(csi2rx->pixel_rst[i]))
+			return PTR_ERR(csi2rx->pixel_rst[i]);
 	}
 
 	return 0;
author
#28 lore raw

Re: [PATCH v3 8/9] media: cadence: Add support for JH7110 SoC

In reply to Laurent Pinchart
Quoted 4 lines · Laurent Pinchart

Hi Jack,

Thank you for the patch.

Quoted 8 lines
Quoted 2 lines · Jack Zhu

Add support for Starfive JH7110 SoC which
has the cadence csi2 receiver.

This fits on one line:

Add support for Starfive JH7110 SoC which has the cadence csi2 receiver.

OK, I will modify it in my next commit msg.

Quoted 21 lines
Quoted 1 line
Quoted 16 lines
---
 drivers/media/platform/cadence/cdns-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/cadence/cdns-csi2rx.c +1 -0
index add982edce64..5e36b994b8d5 100644
@@ -560,6 +560,7 @@ static int csi2rx_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id csi2rx_of_table[] = {
+	{ .compatible = "starfive,jh7110-csi2rx" },
 	{ .compatible = "cdns,csi2rx" },
 	{ },
 };