Skip to contentSkip to conversation

media: i2c: Add driver for the Analog Devices ADDI9036 ToF front-end

PATCH In review Bogdan Togorean 3 participants 4 messages Oct 9, 2020 – Oct 13, 2020

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

PATCH v3 1/2 media: i2c: Add driver for the Analog Devices ADDI9036 ToF front-end

The ADDI9036 is a complete, 45 MHz, front-end solution for charge coupled device (CCD) time of flight (TOF) imaging applications.

It has 2-lane MIPI CSI-2 RAW12 data output and i2c control interface.

The programming of calibration and firmware is performed by driver using Linux Firmware API.

---
v3: fix warning issued by kernel test robot
return error in get_pad_format and handle it serialize access to framefmt
make use of PM runtime
devm_kcalloc instead of devm_kzalloc
add more validation on loaded firmware
specify the bus type before calling v4l2_fwnode_endpoint_parse() remove i2c table
remove some dev_dbg messages

---
 MAINTAINERS                        |  10 +
 drivers/media/i2c/Kconfig          |  14 +
 drivers/media/i2c/Makefile         |   1 +
 drivers/media/i2c/addi9036.c       | 785 +++++++++++++++++++++++++++++
 include/uapi/linux/v4l2-controls.h |   6 +
 5 files changed, 816 insertions(+)
 create mode 100644 drivers/media/i2c/addi9036.c
MAINTAINERS +10 -0
index 9a54806ebf02..1ebf2f3ebad7 100644
@@ -477,6 +477,16 @@ W:	http://wiki.analog.com/AD7879
 W:	http://ez.analog.com/community/linux-device-drivers
 F:	drivers/input/touchscreen/ad7879.c
 
+ADDI9036 TOF FRONTEND DRIVER
+M:	Bogdan Togorean <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	https://www.analog.com/en/products/addi9036.html
+W:	http://ez.analog.com/community/linux-device-drivers
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml
+F:	drivers/media/i2c/addi9036.c
+
 ADDRESS SPACE LAYOUT RANDOMIZATION (ASLR)
 M:	Jiri Kosina <[email protected]>
 S:	Maintained
drivers/media/i2c/Kconfig +14 -0
index c7ba76fee599..087dd307505d 100644
@@ -725,6 +725,20 @@ config VIDEO_APTINA_PLL
 config VIDEO_SMIAPP_PLL
 	tristate
 
+config VIDEO_ADDI9036
+	tristate "Analog Devices ADDI9036 ToF front-end support"
+	depends on I2C && VIDEO_V4L2
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	select REGMAP_I2C
+	help
+	  This is a Video4Linux2 driver for Analog Devices ADDI9036
+	  Time of Flight front-end.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called addi9036.
+
 config VIDEO_HI556
 	tristate "Hynix Hi-556 sensor support"
 	depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
index f0a77473979d..631a7c7612ca 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_VIDEO_AK7375)  += ak7375.o
 obj-$(CONFIG_VIDEO_DW9714)  += dw9714.o
 obj-$(CONFIG_VIDEO_DW9768)  += dw9768.o
 obj-$(CONFIG_VIDEO_DW9807_VCM)  += dw9807-vcm.o
+obj-$(CONFIG_VIDEO_ADDI9036) += addi9036.o
 obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
 obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
 obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
drivers/media/i2c/addi9036.c new file +785 -0

785 lines not on this page · raw message

include/uapi/linux/v4l2-controls.h +6 -0
index 62271418c1be..f88b56479bc1 100644
@@ -198,6 +198,12 @@ enum v4l2_colorfx {
  */
 #define V4L2_CID_USER_ATMEL_ISC_BASE		(V4L2_CID_USER_BASE + 0x10c0)
 
+/*
+ * The base for the addi9036 driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ADDI9036_BASE		(V4L2_CID_USER_BASE + 0x10e0)
+
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
  * and the 'MPEG' part of the define is historical */
Signature · 1 line
2.28.0
#1 lore raw

PATCH v3 2/2 media: dt-bindings: media: i2c: Add bindings for ADDI9036

Add YAML device tree bindings for Analog Devices Inc. ADDI9036 CCD TOF front-end.

---
v3: drop I2C reg description
specify maxItems on reset-gpios property

---
 .../bindings/media/i2c/adi,addi9036.yaml      | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml
Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml new file +76 -0
new file mode 100644
index 000000000000..067b08ad8f53
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/adi,addi9036.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADDI9036 VGA CCD Time of Flight Sensor
+
+maintainers:
+  - Bogdan Togorean <[email protected]>
+
+description: |-
+  The ADDI9036 is a complete, 45 MHz, front-end solution for charge coupled
+  device (CCD) time of flight (TOF) imaging applications. It is programmable
+  through I2C interface. Image data is sent through MIPI CSI-2 2 lanes and
+  can output two RAW12 packed data streams. One is IR and the other is Depth.
+  Each data stream is on a separate or same MIPI Virtual Channel, depending
+  on configuration and each have 640x480 resolution.
+
+properties:
+  compatible:
+    const: adi,addi9036
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+    description: |-
+      Reference to the GPIO connected to the RST/SYNC pin, if any.
+      Must be released (set high) after all supplies are applied.
+
+  # See ../video-interfaces.txt for more details
+  port:
+    type: object
+    properties:
+      endpoint:
+        type: object
+        properties:
+          data-lanes:
+            description: |-
+              The sensor supports two-lane operation.
+              For two-lane operation the property must be set to <1 2>.
+            items:
+              - const: 1
+              - const: 2
+
+required:
+  - compatible
+  - reg
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        addi9036: addi9036_tof@64 {
+            compatible = "adi,addi9036";
+            reg = <0x64>;
+
+            reset-gpios = <&gpio 41 1>;
+
+            port {
+                addi9036_ep: endpoint {
+                    remote-endpoint = <&csi1_ep>;
+                    data-lanes = <1 2>;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.28.0
maintainer Reviewed-by on v3 2/2
#2 lore raw

Re: [PATCH v3 2/2] media: dt-bindings: media: i2c: Add bindings for ADDI9036

Quoted 12 lines · Bogdan Togorean

Add YAML device tree bindings for Analog Devices Inc. ADDI9036 CCD TOF front-end.

---
v3: drop I2C reg description
specify maxItems on reset-gpios property

---
 .../bindings/media/i2c/adi,addi9036.yaml      | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml
#3 lore raw

Re: [PATCH v3 2/2] media: dt-bindings: media: i2c: Add bindings for ADDI9036

In reply to Bogdan Togorean

Hi Bogdan,

Quoted 54 lines · Bogdan Togorean

Add YAML device tree bindings for Analog Devices Inc. ADDI9036 CCD TOF front-end.

---
v3: drop I2C reg description
specify maxItems on reset-gpios property

---
 .../bindings/media/i2c/adi,addi9036.yaml      | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml
Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml new file +36 -0
new file mode 100644
index 000000000000..067b08ad8f53
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/adi,addi9036.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADDI9036 VGA CCD Time of Flight Sensor
+
+maintainers:
+  - Bogdan Togorean <[email protected]>
+
+description: |-
+  The ADDI9036 is a complete, 45 MHz, front-end solution for charge coupled
+  device (CCD) time of flight (TOF) imaging applications. It is programmable
+  through I2C interface. Image data is sent through MIPI CSI-2 2 lanes and
+  can output two RAW12 packed data streams. One is IR and the other is Depth.
+  Each data stream is on a separate or same MIPI Virtual Channel, depending
+  on configuration and each have 640x480 resolution.
+
+properties:
+  compatible:
+    const: adi,addi9036
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+    description: |-
+      Reference to the GPIO connected to the RST/SYNC pin, if any.
+      Must be released (set high) after all supplies are applied.
+
+  # See ../video-interfaces.txt for more details
+  port:
+    type: object
+    properties:

Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml line 46

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml new file +10 -0
+      endpoint:
+        type: object
+        properties:
+          data-lanes:
+            description: |-
+              The sensor supports two-lane operation.
+              For two-lane operation the property must be set to <1 2>.
+            items:
+              - const: 1
+              - const: 2

If, as we discussed, the hardware does not support one lane operation (or other lane configurations I presume), you don't need data-lanes property.

Quoted 33 lines
Documentation/devicetree/bindings/media/i2c/adi,addi9036.yaml new file +30 -0
+
+required:
+  - compatible
+  - reg
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        addi9036: addi9036_tof@64 {
+            compatible = "adi,addi9036";
+            reg = <0x64>;
+
+            reset-gpios = <&gpio 41 1>;
+
+            port {
+                addi9036_ep: endpoint {
+                    remote-endpoint = <&csi1_ep>;
+                    data-lanes = <1 2>;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.28.0
Signature · 1 line
Sakari Ailus