Skip to contentSkip to conversation

media: i2c: OV8865 image sensor support

PATCH Superseded Paul Kocialkowski 3 participants 7 messages Nov 13, 2020 – Nov 27, 2020

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover media: i2c: OV8865 image sensor support

This series adds support for the OV8865 image sensor, as a V4L2 subdev driver. Although an initial series was submitted by Kévin L'hôpital some weeks ago, this version is significantly new and should be considered a new series.

The final patch (not for merge) shows how to enable the OV8865 on the Banana Pi Camera Board v2 with the Banana Pi M3.

Changes since v1:
- Used runtime pm;
- Used assigned-clock-rate;
- Removed clock name;
- Returned closest size in set_fmt;
- Removed unneeded references to v4l2 controls;
- Removed unneeded structure packing attribute;
- Removed i2c device table;
- Dual-licensed bindings;
- Used SPDX tags.

Cheers,

Paul

Kévin L'hôpital (1):
ARM: dts: sun8i: a83t: bananapi-m3: Enable MIPI CSI-2 with OV8865

Paul Kocialkowski (2):
dt-bindings: media: i2c: Add OV8865 bindings documentation
media: i2c: Add support for the OV8865 image sensor

 .../bindings/media/i2c/ovti,ov8865.yaml       |  120 +
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts  |   99 +
 drivers/media/i2c/Kconfig                     |   13 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/ov8865.c                    | 3043 +++++++++++++++++
 5 files changed, 3276 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml
 create mode 100644 drivers/media/i2c/ov8865.c
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/3 dt-bindings: media: i2c: Add OV8865 bindings documentation

This introduces YAML bindings documentation for the OV8865 image sensor.

---
 .../bindings/media/i2c/ovti,ov8865.yaml       | 120 ++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml new file +120 -0
new file mode 100644
index 000000000000..47af90d6ebea
@@ -0,0 +1,120 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov8865.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OmniVision OV8865 Image Sensor Device Tree Bindings
+
+maintainers:
+  - Paul Kocialkowski <[email protected]>
+
+properties:
+  compatible:
+    const: ovti,ov8865
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: EXTCLK Clock
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-rates:
+    maxItems: 1
+
+  dvdd-supply:
+    description: Digital Domain Power Supply
+
+  avdd-supply:
+    description: Analog Domain Power Supply (internal AVDD is used if missing)
+
+  dovdd-supply:
+    description: I/O Domain Power Supply
+
+  powerdown-gpios:
+    maxItems: 1
+    description: Power Down Pin GPIO Control (active low)
+
+  reset-gpios:
+    maxItems: 1
+    description: Reset Pin GPIO Control (active low)
+
+  port:
+    type: object
+    description: MIPI CSI-2 transmitter port
+
+    properties:
+      endpoint:
+        type: object
+
+        properties:
+          remote-endpoint: true
+
+          data-lanes:
+            minItems: 1
+            maxItems: 4
+
+        required:
+          - bus-type
+          - data-lanes
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - assigned-clocks
+  - assigned-clock-rates
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/sun8i-a83t-ccu.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c2 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ov8865: camera@36 {
+            compatible = "ovti,ov8865";
+            reg = <0x36>;
+
+            pinctrl-names = "default";
+            pinctrl-0 = <&csi_mclk_pin>;
+
+            clocks = <&ccu CLK_CSI_MCLK>;
+            assigned-clocks = <&ccu CLK_CSI_MCLK>;
+            assigned-clock-rates = <24000000>;
+
+            avdd-supply = <&reg_ov8865_avdd>;
+            dovdd-supply = <&reg_ov8865_dovdd>;
+            dvdd-supply = <&reg_ov8865_dvdd>;
+
+            powerdown-gpios = <&pio 4 17 GPIO_ACTIVE_LOW>; /* PE17 */
+            reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* PE16 */
+
+            port {
+                ov8865_out_mipi_csi2: endpoint {
+                    bus-type = <4>; /* MIPI CSI-2 D-PHY */
+                    clock-lanes = <0>;
+                    data-lanes = <1 2 3 4>;
+
+                    remote-endpoint = <&mipi_csi2_in_ov8865>;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.28.0
maintainer Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: media: i2c: Add OV8865 bindings documentation

Quoted 11 lines · Paul Kocialkowski

This introduces YAML bindings documentation for the OV8865 image sensor.

---
 .../bindings/media/i2c/ovti,ov8865.yaml       | 120 ++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml
maintainer
#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: media: i2c: Add OV8865 bindings documentation

In reply to Paul Kocialkowski

Hi Paul,

Quoted 71 lines · Paul Kocialkowski

This introduces YAML bindings documentation for the OV8865 image sensor.

---
 .../bindings/media/i2c/ovti,ov8865.yaml       | 120 ++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml new file +54 -0
new file mode 100644
index 000000000000..47af90d6ebea
@@ -0,0 +1,120 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov8865.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OmniVision OV8865 Image Sensor Device Tree Bindings
+
+maintainers:
+  - Paul Kocialkowski <[email protected]>
+
+properties:
+  compatible:
+    const: ovti,ov8865
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: EXTCLK Clock
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-rates:
+    maxItems: 1
+
+  dvdd-supply:
+    description: Digital Domain Power Supply
+
+  avdd-supply:
+    description: Analog Domain Power Supply (internal AVDD is used if missing)
+
+  dovdd-supply:
+    description: I/O Domain Power Supply
+
+  powerdown-gpios:
+    maxItems: 1
+    description: Power Down Pin GPIO Control (active low)
+
+  reset-gpios:
+    maxItems: 1
+    description: Reset Pin GPIO Control (active low)
+
+  port:
+    type: object
+    description: MIPI CSI-2 transmitter port
+
+    properties:
+      endpoint:
+        type: object
+
+        properties:

Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml new file +10 -0
+          remote-endpoint: true
+
+          data-lanes:
+            minItems: 1
+            maxItems: 4
+
+        required:
+          - bus-type
+          - data-lanes
+          - remote-endpoint

link-frequencies seems to be still missing here (same with the example).

Signature · 1 line
Sakari Ailus
#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: media: i2c: Add OV8865 bindings documentation

Hi Sakari,

Quoted 78 lines · Sakari Ailus

Hi Paul,

Quoted 75 lines · Paul Kocialkowski

This introduces YAML bindings documentation for the OV8865 image sensor.

---
 .../bindings/media/i2c/ovti,ov8865.yaml       | 120 ++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml new file +58 -0
new file mode 100644
index 000000000000..47af90d6ebea
@@ -0,0 +1,120 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov8865.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OmniVision OV8865 Image Sensor Device Tree Bindings
+
+maintainers:
+  - Paul Kocialkowski <[email protected]>
+
+properties:
+  compatible:
+    const: ovti,ov8865
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: EXTCLK Clock
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-rates:
+    maxItems: 1
+
+  dvdd-supply:
+    description: Digital Domain Power Supply
+
+  avdd-supply:
+    description: Analog Domain Power Supply (internal AVDD is used if missing)
+
+  dovdd-supply:
+    description: I/O Domain Power Supply
+
+  powerdown-gpios:
+    maxItems: 1
+    description: Power Down Pin GPIO Control (active low)
+
+  reset-gpios:
+    maxItems: 1
+    description: Reset Pin GPIO Control (active low)
+
+  port:
+    type: object
+    description: MIPI CSI-2 transmitter port
+
+    properties:
+      endpoint:
+        type: object
+
+        properties:
+          remote-endpoint: true
+
+          data-lanes:
+            minItems: 1
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml line 64

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml new file +6 -0
+            maxItems: 4
+
+        required:
+          - bus-type
+          - data-lanes
+          - remote-endpoint

link-frequencies seems to be still missing here (same with the example).

Oh my bad, you're right.

Note that I found an issue in this series (as well as the ov5648 one) so I will be reposting them anyways (likely later today).

Cheers,

Paul

Signature · 3 lines
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#5 lore raw

PATCH v2 2/3 media: i2c: Add support for the OV8865 image sensor

In reply to Paul Kocialkowski

The OV8865 is a 8 Mpx CMOS image sensor producing 3264x2448 at 30 fps. Other modes (including some with sub-sampling) are available too. It outputs 10-bit bayer CFA data through a MIPI CSI-2 interface with up to 4 lanes supported.

Some register initialisation sequences are still needed for this driver, as they cover registers for which no documentation is available.

This work is based on the first version of the driver submitted by Kévin L'hôpital, which was adapted to mainline from the Allwinner BSP. This version is a rewrite of the first version that matches the structure of the OV5648 driver, with explicit PLL configuration, all the necessary mode-specific fields, associatied registers and reduced static sequences.

It was tested with the Banana Pi Camera Board v3 and the Banana Pi M3.

---
 drivers/media/i2c/Kconfig  |   13 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/ov8865.c | 3043 ++++++++++++++++++++++++++++++++++++
 3 files changed, 3057 insertions(+)
 create mode 100644 drivers/media/i2c/ov8865.c
drivers/media/i2c/Kconfig +13 -0
index f971225893a1..95f8b4366b1a 100644
@@ -1047,6 +1047,19 @@ config VIDEO_OV8856
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov8856.
 
+config VIDEO_OV8865
+	tristate "OmniVision OV8865 sensor support"
+	depends on I2C && VIDEO_V4L2
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor driver for OmniVision
+	  OV8865 camera sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ov8865.
+
 config VIDEO_OV9640
 	tristate "OmniVision OV9640 sensor support"
 	depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
index 15d4d6382582..505c2067e780 100644
@@ -82,6 +82,7 @@ obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV772X) += ov772x.o
 obj-$(CONFIG_VIDEO_OV7740) += ov7740.o
 obj-$(CONFIG_VIDEO_OV8856) += ov8856.o
+obj-$(CONFIG_VIDEO_OV8865) += ov8865.o
 obj-$(CONFIG_VIDEO_OV9640) += ov9640.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
drivers/media/i2c/ov8865.c new file +3043 -0

2,974 lines not on this page · raw message

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

Signature · 1 line
2.28.0

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

#6 lore raw

PATCH v2 3/3 ARM: dts: sun8i: a83t: bananapi-m3: Enable MIPI CSI-2 with OV8865

In reply to Paul Kocialkowski

From: Kévin L'hôpital <[email protected]>

The Bananapi M3 supports a camera module which includes an OV8865 sensor connected via the parallel CSI interface and an OV8865 sensor connected via MIPI CSI-2.

The I2C2 bus is shared by the two sensors as well as the (active-low) reset signal, but each sensor has it own shutdown line.

---
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 99 ++++++++++++++++++++
 1 file changed, 99 insertions(+)
arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts +99 -0
index 431f70234d36..1915040b39bf 100644
@@ -85,6 +85,30 @@ green {
 		};
 	};
 
+	reg_ov8865_avdd: ov8865-avdd {
+		compatible = "regulator-fixed";
+		regulator-name = "ov8865-avdd";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		vin-supply = <&reg_dldo4>;
+	};
+
+	reg_ov8865_dovdd: ov8865-dovdd {
+		compatible = "regulator-fixed";
+		regulator-name = "ov8865-dovdd";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		vin-supply = <&reg_dldo4>;
+	};
+
+	reg_ov8865_dvdd: ov8865-dvdd {
+		compatible = "regulator-fixed";
+		regulator-name = "ov8865-dvdd";
+		regulator-min-microvolt = <1200000>;
+		regulator-max-microvolt = <1200000>;
+		vin-supply = <&reg_eldo1>;
+	};
+
 	reg_usb1_vbus: reg-usb1-vbus {
 		compatible = "regulator-fixed";
 		regulator-name = "usb1-vbus";
@@ -115,6 +139,17 @@ &cpu100 {
 	cpu-supply = <&reg_dcdc3>;
 };
 
+&csi {
+	status = "okay";
+};
+
+&csi_in {
+	csi_in_mipi_csi2: endpoint {
+		bus-type = <4>; /* CSI2_DPHY */
+		remote-endpoint = <&mipi_csi2_out_csi>;
+	};
+};
+
 &de {
 	status = "okay";
 };
@@ -147,6 +182,37 @@ hdmi_out_con: endpoint {
 	};
 };
 
+&i2c2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c2_pe_pins>;
+	status = "okay";
+
+	ov8865: camera@36 {
+		compatible = "ovti,ov8865";
+		reg = <0x36>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&csi_mclk_pin>;
+		clocks = <&ccu CLK_CSI_MCLK>;
+		assigned-clocks = <&ccu CLK_CSI_MCLK>;
+		assigned-clock-rates = <24000000>;
+		avdd-supply = <&reg_ov8865_avdd>;
+		dovdd-supply = <&reg_ov8865_dovdd>;
+		dvdd-supply = <&reg_ov8865_dvdd>;
+		powerdown-gpios = <&pio 4 17 GPIO_ACTIVE_LOW>; /* PE17 */
+		reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* PE16 */
+
+		port {
+			ov8865_out_mipi_csi2: endpoint {
+				bus-type = <4>; /* MIPI CSI-2 D-PHY */
+				clock-lanes = <0>;
+				data-lanes = <1 2 3 4>;
+
+				remote-endpoint = <&mipi_csi2_in_ov8865>;
+			};
+		};
+	};
+};
+
 &mdio {
 	rgmii_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
@@ -154,6 +220,26 @@ rgmii_phy: ethernet-phy@1 {
 	};
 };
 
+&mipi_csi2 {
+	status = "okay";
+};
+
+&mipi_csi2_in {
+	mipi_csi2_in_ov8865: endpoint {
+		bus-type = <4>; /* MIPI CSI-2 D-PHY */
+		clock-lanes = <0>;
+		data-lanes = <1 2 3 4>;
+
+		remote-endpoint = <&ov8865_out_mipi_csi2>;
+	};
+};
+
+&mipi_csi2_out {
+	mipi_csi2_out_csi: endpoint {
+		remote-endpoint = <&csi_in_mipi_csi2>;
+	};
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins>;
@@ -327,11 +413,24 @@ &reg_dldo3 {
 	regulator-name = "vcc-pd";
 };
 
+&reg_dldo4 {
+	regulator-always-on;
+	regulator-min-microvolt = <2800000>;
+	regulator-max-microvolt = <2800000>;
+	regulator-name = "avdd-csi";
+};
+
 &reg_drivevbus {
 	regulator-name = "usb0-vbus";
 	status = "okay";
 };
 
+&reg_eldo1 {
+	regulator-min-microvolt = <1200000>;
+	regulator-max-microvolt = <1200000>;
+	regulator-name = "dvdd-csi-r";
+};
+
 &reg_fldo1 {
 	regulator-min-microvolt = <1080000>;
 	regulator-max-microvolt = <1320000>;
Signature · 1 line
2.28.0