Skip to contentSkip to conversation

media: v4l: Add support for the Cadence MIPI-CSI2 RX

PATCH Superseded Maxime Ripard 1 participant 3 messages Apr 4, 2018

Subsystems (3)

v9 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v9 cover media: v4l: Add support for the Cadence MIPI-CSI2 RX

Hi,

Here is another attempt at supporting the MIPI-CSI2 RX block from Cadence.

This IP block is able to receive CSI data over up to 4 lanes, and split it to over 4 streams. Those streams are basically the interfaces to the video grabbers that will perform the capture.

It is able to map streams to both CSI datatypes and virtual channels, dynamically. This is unclear at this point what the right way to support it would be, so the driver only uses a static mapping between the virtual channels and streams, and ignores the data types.

Let me know what you think!
Maxime

Changes from v8:
- Added maintainer entry
- Added MODULE_AUTHOR, MODULE_DESCRIPTION and MODULE_LICENSE
- Added Kconfig help
- Removed unused headers
- Added Niklas' Reviewed-by

Changes from v7:
- Changed calls to usleep_range to udelay
- Rebased on top of 4.16
- Renamed the reg variable in _get_resources to dev_cfg
- Checked for the clk_prepare_enable return codes
- Fixed a race condition in concurrent calls to s_stream by moving from the atomic counter to a mutex.

Changes from v6:
- Added Sakari's Acked-by
- Added Kconfig help
- Removed the comment in the probe next to the kmalloc

Changes from v5:
- Use SPDX license header
- Fix the lane mapping logic and map unused logical lanes only to unused physical lanes. Added a comment to explain why.

Changes from v4:
- Rebased on top of 4.15
- Fixed a lane mapping issue that prevented the CSI2-RX device to operate properly.
- Reworded the output endpoints documentation in the binding

Changes from v3:
- Removed stale printk
- Propagate start/stop functions error code to s_stream
- Renamed the DT bindings files
- Clarified the output ports wording in the DT binding doc
- Added a define for the maximum number of lanes
- Rebased on top of Sakari's serie
- Gathered tags based on the reviews

Changes from v2:
- Added reference counting for the controller initialisation
- Fixed checkpatch warnings
- Moved the sensor initialisation after the DPHY configuration
- Renamed the sensor fields to source for consistency
- Defined some variables
- Renamed a few structures variables
- Added internal and external phy errors messages
- Reworked the binding slighty by making the external D-PHY optional
- Moved the notifier registration in the probe function
- Removed some clocks that are not system clocks
- Added clocks enabling where needed
- Added the code to remap the data lanes
- Changed the memory allocator for the non-devm function, and a comment explaining why
- Reworked the binding wording

Changes from v1:
- Amended the DT bindings as suggested by Rob
- Rebase on top of 4.13-rc1 and latest Niklas' serie iteration

Maxime Ripard (2):
dt-bindings: media: Add Cadence MIPI-CSI2 RX Device Tree bindings
v4l: cadence: Add Cadence MIPI-CSI2 RX driver

 .../devicetree/bindings/media/cdns,csi2rx.txt      | 100 +++++
 MAINTAINERS                                        |   7 +
 drivers/media/platform/Kconfig                     |   1 +
 drivers/media/platform/Makefile                    |   2 +
 drivers/media/platform/cadence/Kconfig             |  23 +
 drivers/media/platform/cadence/Makefile            |   1 +
 drivers/media/platform/cadence/cdns-csi2rx.c       | 500 +++++++++++++++++++++
 7 files changed, 634 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 drivers/media/platform/cadence/Kconfig
 create mode 100644 drivers/media/platform/cadence/Makefile
 create mode 100644 drivers/media/platform/cadence/cdns-csi2rx.c
Signature · 1 line
2.14.3
#1 lore raw

PATCH v9 1/2 dt-bindings: media: Add Cadence MIPI-CSI2 RX Device Tree bindings

The Cadence MIPI-CSI2 RX controller is a CSI2RX bridge that supports up to 4 CSI-2 lanes, and can route the frames to up to 4 streams, depending on the hardware implementation.

It can operate with an external D-PHY, an internal one or no D-PHY at all in some configurations.

---
 .../devicetree/bindings/media/cdns,csi2rx.txt      | 100 +++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
Documentation/devicetree/bindings/media/cdns,csi2rx.txt new file +100 -0
new file mode 100644
index 000000000000..6b02a0657ad9
@@ -0,0 +1,100 @@
+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>;
+			};
+		};
+	};
+};
Signature · 1 line
2.14.3
#2 lore raw

PATCH v9 2/2 v4l: cadence: Add Cadence MIPI-CSI2 RX driver

In reply to Maxime Ripard

The Cadence CSI-2 RX Controller is an hardware block meant to be used as a bridge between a CSI-2 bus and pixel grabbers.

It supports operating with internal or external D-PHY, with up to 4 lanes, or without any D-PHY. The current code only supports the latter case.

It also support dynamic mapping of the CSI-2 virtual channels to the associated pixel grabbers, but that isn't allowed at the moment either.

---
 MAINTAINERS                                  |   7 +
 drivers/media/platform/Kconfig               |   1 +
 drivers/media/platform/Makefile              |   2 +
 drivers/media/platform/cadence/Kconfig       |  23 ++
 drivers/media/platform/cadence/Makefile      |   1 +
 drivers/media/platform/cadence/cdns-csi2rx.c | 500 +++++++++++++++++++++++++++
 6 files changed, 534 insertions(+)
 create mode 100644 drivers/media/platform/cadence/Kconfig
 create mode 100644 drivers/media/platform/cadence/Makefile
 create mode 100644 drivers/media/platform/cadence/cdns-csi2rx.c
MAINTAINERS +7 -0
index 6e950b8b4a41..5092d5518a5f 100644
@@ -3148,6 +3148,13 @@ S:	Supported
 F:	Documentation/filesystems/caching/cachefiles.txt
 F:	fs/cachefiles/
 
+CADENCE MIPI-CSI2 BRIDGES
+M:	Maxime Ripard <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/cdns,*.txt
+F:	drivers/media/platform/cadence/cdns-csi2*
+
 CADET FM/AM RADIO RECEIVER DRIVER
 M:	Hans Verkuil <[email protected]>
 L:	[email protected]
drivers/media/platform/Kconfig +1 -0
index 614fbef08ddc..c001b646d441 100644
@@ -26,6 +26,7 @@ config VIDEO_VIA_CAMERA
 #
 # Platform multimedia device configuration
 #
+source "drivers/media/platform/cadence/Kconfig"
 
 source "drivers/media/platform/davinci/Kconfig"
 
drivers/media/platform/Makefile +2 -0
index 7f3080437be6..3d29082fcf72 100644
@@ -3,6 +3,8 @@
 # Makefile for the video capture/playback device drivers.
 #
 
+obj-$(CONFIG_VIDEO_CADENCE)		+= cadence/
+
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
 
 obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
drivers/media/platform/cadence/Kconfig new file +23 -0
new file mode 100644
index 000000000000..70c95d79c8f7
@@ -0,0 +1,23 @@
+config VIDEO_CADENCE
+	bool "Cadence Video Devices"
+	help
+	  If you have a media device designed by Cadence, say Y.
+
+	  Note that this option doesn't include new drivers in the kernel:
+	  saying N will just cause Kconfig to skip all the questions about
+	  Cadence media devices.
+
+if VIDEO_CADENCE
+
+config VIDEO_CADENCE_CSI2RX
+	tristate "Cadence MIPI-CSI2 RX Controller"
+	depends on MEDIA_CONTROLLER
+	depends on VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  Support for the Cadence MIPI CSI2 Receiver controller.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called cdns-csi2rx.
+
+endif
drivers/media/platform/cadence/Makefile new file +1 -0
new file mode 100644
index 000000000000..99a4086b7448
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_CADENCE_CSI2RX)	+= cdns-csi2rx.o
drivers/media/platform/cadence/cdns-csi2rx.c new file +500 -0

500 lines not on this page · raw message

Signature · 1 line
2.14.3