devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD
@ 2024-09-26 15:46 Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 1/4] media: ov08x40: Fix burst write sequence Bryan O'Donoghue
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 15:46 UTC (permalink / raw)
  To: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-media, linux-kernel, devicetree, Bryan O'Donoghue,
	stable

This series brings fixes and updates to ov08x40 which allows for use of
this sensor on the Qualcomm x1e80100 CRD but also on any other dts based
system.

Firstly there's a fix for the pseudo burst mode code that was added in
8f667d202384 ("media: ov08x40: Reduce start streaming time"). Not every I2C
controller can handle an arbitrary sized write, this is the case on
Qualcomm CAMSS/CCI I2C sensor interfaces which limit the transaction size
and communicate this limit via I2C quirks. A simple fix to optionally break
up the large submitted burst into chunks not exceeding adapter->quirk size
fixes.

Secondly then is addition of a yaml description for the ov08x40 and
extension of the driver to support OF probe and powering on of the power
rails from the driver instead of from ACPI.

Once done the sensor works without further modification on the Qualcomm
x1e80100 CRD.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
Bryan O'Donoghue (4):
      media: ov08x40: Fix burst write sequence
      media: dt-bindings: Add OmniVision OV08X40
      media: ov08x40: Rename ext_clk to xvclk
      media: ov08x40: Add OF probe support

 .../bindings/media/i2c/ovti,ov08x40.yaml           | 130 ++++++++++++++++
 drivers/media/i2c/ov08x40.c                        | 172 ++++++++++++++++++---
 2 files changed, 283 insertions(+), 19 deletions(-)
---
base-commit: 2b7275670032a98cba266bd1b8905f755b3e650f
change-id: 20240926-b4-master-24-11-25-ov08x40-c6f477aaa6a4

Best regards,
-- 
Bryan O'Donoghue <bryan.odonoghue@linaro.org>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] media: ov08x40: Fix burst write sequence
  2024-09-26 15:46 [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD Bryan O'Donoghue
@ 2024-09-26 15:46 ` Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40 Bryan O'Donoghue
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 15:46 UTC (permalink / raw)
  To: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-media, linux-kernel, devicetree, Bryan O'Donoghue,
	stable

It is necessary to account for I2C quirks in the burst mode path of this
driver. Not all I2C controllers can accept arbitrarily long writes and this
is represented in the quirks field of the adapter structure.

Prior to this patch the following error message is seen on a Qualcomm
X1E80100 CRD.

[   38.773524] i2c i2c-2: adapter quirk: msg too long (addr 0x0036, size 290, write)
[   38.781454] ov08x40 2-0036: Failed regs transferred: -95
[   38.787076] ov08x40 2-0036: ov08x40_start_streaming failed to set regs

Fix the error by breaking up the write sequence into the advertised maximum
write size of the quirks field if the quirks field is populated.

Fixes: 8f667d202384 ("media: ov08x40: Reduce start streaming time")
Cc: stable@vger.kernel.org # v6.9+
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # x1e80100-crd
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/i2c/ov08x40.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 48df077522ad0bb2b5f64a6def8844c02af6a193..be25e45175b1322145dca428e845242d8fea2698 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -1339,15 +1339,13 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x,
 	return 0;
 }
 
-static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg,
-				   u16 last_reg,  u8 val)
+static int __ov08x40_burst_fill_regs(struct i2c_client *client, u16 first_reg,
+				     u16 last_reg, size_t num_regs, u8 val)
 {
-	struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd);
 	struct i2c_msg msgs;
-	size_t i, num_regs;
+	size_t i;
 	int ret;
 
-	num_regs = last_reg - first_reg + 1;
 	msgs.addr = client->addr;
 	msgs.flags = 0;
 	msgs.len = 2 + num_regs;
@@ -1373,6 +1371,31 @@ static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg,
 	return 0;
 }
 
+static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg,
+				   u16 last_reg,  u8 val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd);
+	size_t num_regs, num_write_regs;
+	int ret;
+
+	num_regs = last_reg - first_reg + 1;
+	num_write_regs = num_regs;
+
+	if (client->adapter->quirks && client->adapter->quirks->max_write_len)
+		num_write_regs = client->adapter->quirks->max_write_len - 2;
+
+	while (first_reg < last_reg) {
+		ret = __ov08x40_burst_fill_regs(client, first_reg, last_reg,
+						num_write_regs, val);
+		if (ret)
+			return ret;
+
+		first_reg += num_write_regs;
+	}
+
+	return 0;
+}
+
 /* Write registers up to 4 at a time */
 static int ov08x40_write_reg(struct ov08x40 *ov08x,
 			     u16 reg, u32 len, u32 __val)

-- 
2.46.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40
  2024-09-26 15:46 [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 1/4] media: ov08x40: Fix burst write sequence Bryan O'Donoghue
@ 2024-09-26 15:46 ` Bryan O'Donoghue
  2024-09-26 15:53   ` Sakari Ailus
  2024-09-26 21:04   ` Rob Herring
  2024-09-26 15:46 ` [PATCH 3/4] media: ov08x40: Rename ext_clk to xvclk Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 4/4] media: ov08x40: Add OF probe support Bryan O'Donoghue
  3 siblings, 2 replies; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 15:46 UTC (permalink / raw)
  To: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-media, linux-kernel, devicetree, Bryan O'Donoghue

Add bindings for the already upstream OV08X40 to enable usage of this
sensor on dts based systems.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 .../bindings/media/i2c/ovti,ov08x40.yaml           | 130 +++++++++++++++++++++
 1 file changed, 130 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..250785f062d0146e8615d8f3e7700aebbd40b1dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
@@ -0,0 +1,130 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright (c) 2024 Linaro Ltd.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov08x40.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV08X40 CMOS Sensor
+
+maintainers:
+  - Bryan O'Donoghue <bryan.odonoghue@linaro.org>
+
+description: |-
+  The Omnivision OV08X40 is a 9.2 megapixel, CMOS image sensor which supports.
+  - Automatic black level calibration (ABLC)
+  - Programmable controls for frame rate, mirror and flip, binning, cropping
+    and windowing
+  - Output formats 10-bit 4C RGB RAW, 10-bit Bayer RAW
+  - 4-lane MIPI D-PHY TX @ 1 Gbps per lane
+  - 2-lane MPIP D-PHY TX @ 2 Gbps per lane
+  - Dynamic defect pixel cancellation
+  - Standard SCCB command interface
+
+properties:
+  compatible:
+    const: ovti,ov08x40
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      Input clock for the sensor.
+    items:
+      - const: xvclk
+
+  clock-frequency:
+    description:
+      Frequency of the xvclk clock in Hertz.
+
+  avdd-supply:
+    description: Analogue circuit voltage supply.
+
+  dovdd-supply:
+    description: I/O circuit voltage supply.
+
+  dvdd-supply:
+    description: Digital circuit voltage supply.
+
+  reset-gpios:
+    description: Active low GPIO connected to XSHUTDOWN pad of the sensor.
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - clock-frequency
+  - dovdd-supply
+  - avdd-supply
+  - dvdd-supply
+  - reset-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ov08x40: camera@36 {
+            compatible = "ovti,ov08x40";
+            reg = <0x36>;
+
+            reset-gpios = <&tlmm 111 GPIO_ACTIVE_LOW>;
+            pinctrl-names = "default";
+            pinctrl-0 = <&cam_rgb_defaultt>;
+
+            clocks = <&ov08x40_clk>;
+            clock-names = "xvclk";
+            clock-frequency = <19200000>;
+
+            avdd-supply = <&vreg_l7b_2p8>;
+            dvdd-supply = <&vreg_l7b_1p8>;
+            dovdd-supply = <&vreg_l3m_1p8>;
+
+            port {
+                ov08x40_ep: endpoint {
+                    remote-endpoint = <&csiphy4_ep>;
+                    data-lanes = <1 2 3 4>;
+                    link-frequencies = /bits/ 64 <400000000>;
+                };
+            };
+        };
+    };
+...

-- 
2.46.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] media: ov08x40: Rename ext_clk to xvclk
  2024-09-26 15:46 [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 1/4] media: ov08x40: Fix burst write sequence Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40 Bryan O'Donoghue
@ 2024-09-26 15:46 ` Bryan O'Donoghue
  2024-09-26 15:46 ` [PATCH 4/4] media: ov08x40: Add OF probe support Bryan O'Donoghue
  3 siblings, 0 replies; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 15:46 UTC (permalink / raw)
  To: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-media, linux-kernel, devicetree, Bryan O'Donoghue

The data-sheet and documentation for this part uses the name xvclk not
ext_clk for the input reference clock. Rename the variables and defines in
this driver to align as preparation for adding DT support where the name of
the clock in DT will be "xvclk".

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/i2c/ov08x40.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index be25e45175b1322145dca428e845242d8fea2698..3ab8b51df157af78fcccc1aaef73aedb2ae759c9 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -1215,7 +1215,7 @@ static const char * const ov08x40_test_pattern_menu[] = {
 /* Configurations for supported link frequencies */
 #define OV08X40_LINK_FREQ_400MHZ	400000000ULL
 #define OV08X40_SCLK_96MHZ		96000000ULL
-#define OV08X40_EXT_CLK			19200000
+#define OV08X40_XVCLK			19200000
 #define OV08X40_DATA_LANES		4
 
 /*
@@ -2081,21 +2081,21 @@ static int ov08x40_check_hwcfg(struct device *dev)
 	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	unsigned int i, j;
 	int ret;
-	u32 ext_clk;
+	u32 xvclk_rate;
 
 	if (!fwnode)
 		return -ENXIO;
 
 	ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
-				       &ext_clk);
+				       &xvclk_rate);
 	if (ret) {
 		dev_err(dev, "can't get clock frequency");
 		return ret;
 	}
 
-	if (ext_clk != OV08X40_EXT_CLK) {
+	if (xvclk_rate != OV08X40_XVCLK) {
 		dev_err(dev, "external clock %d is not supported",
-			ext_clk);
+			xvclk_rate);
 		return -EINVAL;
 	}
 

-- 
2.46.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] media: ov08x40: Add OF probe support
  2024-09-26 15:46 [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD Bryan O'Donoghue
                   ` (2 preceding siblings ...)
  2024-09-26 15:46 ` [PATCH 3/4] media: ov08x40: Rename ext_clk to xvclk Bryan O'Donoghue
@ 2024-09-26 15:46 ` Bryan O'Donoghue
  3 siblings, 0 replies; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 15:46 UTC (permalink / raw)
  To: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-media, linux-kernel, devicetree, Bryan O'Donoghue

The ACPI version of this driver "just works" on dts based systems with a
few extensions to facilitate.

- Add support for DT based probing
- Add support for taking the part out of reset via a GPIO reset pin
- Add in regulator bulk on/off logic for the power rails.

Once done this sensor works nicely on a Qualcomm X1E80100 CRD.

Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # x1e80100-crd
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/i2c/ov08x40.c | 129 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 120 insertions(+), 9 deletions(-)

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 3ab8b51df157af78fcccc1aaef73aedb2ae759c9..7e1f473a6661c2beb890ac81b72ba4782f29b076 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -3,10 +3,13 @@
 
 #include <asm-generic/unaligned.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 #include <linux/i2c.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-fwnode.h>
@@ -1279,6 +1282,12 @@ static const struct ov08x40_mode supported_modes[] = {
 	},
 };
 
+static const char * const ov08x40_supply_names[] = {
+	"dovdd",	/* Digital I/O power */
+	"avdd",		/* Analog power */
+	"dvdd",		/* Digital core power */
+};
+
 struct ov08x40 {
 	struct v4l2_subdev sd;
 	struct media_pad pad;
@@ -1291,6 +1300,10 @@ struct ov08x40 {
 	struct v4l2_ctrl *hblank;
 	struct v4l2_ctrl *exposure;
 
+	struct clk		*xvclk;
+	struct gpio_desc	*reset_gpio;
+	struct regulator_bulk_data supplies[ARRAY_SIZE(ov08x40_supply_names)];
+
 	/* Current mode */
 	const struct ov08x40_mode *cur_mode;
 
@@ -1303,6 +1316,61 @@ struct ov08x40 {
 
 #define to_ov08x40(_sd)	container_of(_sd, struct ov08x40, sd)
 
+static int ov08x40_power_on(struct device *dev)
+{
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
+	struct ov08x40 *ov08x = to_ov08x40(sd);
+	int ret;
+
+	if (is_acpi_node(dev_fwnode(dev)))
+		return 0;
+
+	ret = clk_prepare_enable(ov08x->xvclk);
+	if (ret < 0) {
+		dev_err(dev, "failed to enable xvclk\n");
+		return ret;
+	}
+
+	if (ov08x->reset_gpio) {
+		gpiod_set_value_cansleep(ov08x->reset_gpio, 1);
+		usleep_range(1000, 2000);
+	}
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(ov08x40_supply_names),
+				    ov08x->supplies);
+	if (ret < 0) {
+		dev_err(dev, "failed to enable regulators\n");
+		goto disable_clk;
+	}
+
+	gpiod_set_value_cansleep(ov08x->reset_gpio, 0);
+	usleep_range(1500, 1800);
+
+	return 0;
+
+disable_clk:
+	gpiod_set_value_cansleep(ov08x->reset_gpio, 1);
+	clk_disable_unprepare(ov08x->xvclk);
+
+	return ret;
+}
+
+static int ov08x40_power_off(struct device *dev)
+{
+	struct v4l2_subdev *sd = dev_get_drvdata(dev);
+	struct ov08x40 *ov08x = to_ov08x40(sd);
+
+	if (is_acpi_node(dev_fwnode(dev)))
+		return 0;
+
+	gpiod_set_value_cansleep(ov08x->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(ov08x40_supply_names),
+			       ov08x->supplies);
+	clk_disable_unprepare(ov08x->xvclk);
+
+	return 0;
+}
+
 /* Read registers up to 4 at a time */
 static int ov08x40_read_reg(struct ov08x40 *ov08x,
 			    u16 reg, u32 len, u32 *val)
@@ -2072,7 +2140,7 @@ static void ov08x40_free_controls(struct ov08x40 *ov08x)
 	mutex_destroy(&ov08x->mutex);
 }
 
-static int ov08x40_check_hwcfg(struct device *dev)
+static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev)
 {
 	struct v4l2_fwnode_endpoint bus_cfg = {
 		.bus_type = V4L2_MBUS_CSI2_DPHY
@@ -2093,6 +2161,32 @@ static int ov08x40_check_hwcfg(struct device *dev)
 		return ret;
 	}
 
+	if (!is_acpi_node(fwnode)) {
+		ov08x->xvclk = devm_clk_get(dev, "xvclk");
+		if (IS_ERR(ov08x->xvclk)) {
+			dev_err(dev, "could not get xvclk clock (%pe)\n",
+				ov08x->xvclk);
+			return PTR_ERR(ov08x->xvclk);
+		}
+
+		clk_set_rate(ov08x->xvclk, xvclk_rate);
+		xvclk_rate = clk_get_rate(ov08x->xvclk);
+
+		ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset",
+							    GPIOD_OUT_LOW);
+		if (IS_ERR(ov08x->reset_gpio))
+			return PTR_ERR(ov08x->reset_gpio);
+
+		for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++)
+			ov08x->supplies[i].supply = ov08x40_supply_names[i];
+
+		ret = devm_regulator_bulk_get(dev,
+					      ARRAY_SIZE(ov08x40_supply_names),
+					      ov08x->supplies);
+		if (ret)
+			return ret;
+	}
+
 	if (xvclk_rate != OV08X40_XVCLK) {
 		dev_err(dev, "external clock %d is not supported",
 			xvclk_rate);
@@ -2143,32 +2237,37 @@ static int ov08x40_check_hwcfg(struct device *dev)
 }
 
 static int ov08x40_probe(struct i2c_client *client)
-{
-	struct ov08x40 *ov08x;
+{	struct ov08x40 *ov08x;
 	int ret;
 	bool full_power;
 
+	ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL);
+	if (!ov08x)
+		return -ENOMEM;
+
 	/* Check HW config */
-	ret = ov08x40_check_hwcfg(&client->dev);
+	ret = ov08x40_check_hwcfg(ov08x, &client->dev);
 	if (ret) {
 		dev_err(&client->dev, "failed to check hwcfg: %d", ret);
 		return ret;
 	}
 
-	ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL);
-	if (!ov08x)
-		return -ENOMEM;
-
 	/* Initialize subdev */
 	v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops);
 
 	full_power = acpi_dev_state_d0(&client->dev);
 	if (full_power) {
+		ret = ov08x40_power_on(&client->dev);
+		if (ret) {
+			dev_err(&client->dev, "failed to power on\n");
+			return ret;
+		}
+
 		/* Check module identity */
 		ret = ov08x40_identify_module(ov08x);
 		if (ret) {
 			dev_err(&client->dev, "failed to find sensor: %d\n", ret);
-			return ret;
+			goto probe_power_off;
 		}
 	}
 
@@ -2210,6 +2309,9 @@ static int ov08x40_probe(struct i2c_client *client)
 error_handler_free:
 	ov08x40_free_controls(ov08x);
 
+probe_power_off:
+	ov08x40_power_off(&client->dev);
+
 	return ret;
 }
 
@@ -2224,6 +2326,8 @@ static void ov08x40_remove(struct i2c_client *client)
 
 	pm_runtime_disable(&client->dev);
 	pm_runtime_set_suspended(&client->dev);
+
+	ov08x40_power_off(&client->dev);
 }
 
 #ifdef CONFIG_ACPI
@@ -2235,10 +2339,17 @@ static const struct acpi_device_id ov08x40_acpi_ids[] = {
 MODULE_DEVICE_TABLE(acpi, ov08x40_acpi_ids);
 #endif
 
+static const struct of_device_id ov08x40_of_match[] = {
+	{ .compatible = "ovti,ov08x40" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ov08x40_of_match);
+
 static struct i2c_driver ov08x40_i2c_driver = {
 	.driver = {
 		.name = "ov08x40",
 		.acpi_match_table = ACPI_PTR(ov08x40_acpi_ids),
+		.of_match_table = ov08x40_of_match,
 	},
 	.probe = ov08x40_probe,
 	.remove = ov08x40_remove,

-- 
2.46.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40
  2024-09-26 15:46 ` [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40 Bryan O'Donoghue
@ 2024-09-26 15:53   ` Sakari Ailus
  2024-09-26 23:31     ` Bryan O'Donoghue
  2024-09-26 21:04   ` Rob Herring
  1 sibling, 1 reply; 9+ messages in thread
From: Sakari Ailus @ 2024-09-26 15:53 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: Jason Chen, Mauro Carvalho Chehab, Sergey Senozhatsky,
	Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-media, linux-kernel, devicetree

Hi Bryan,

Thanks for the set.

On Thu, Sep 26, 2024 at 04:46:38PM +0100, Bryan O'Donoghue wrote:
> Add bindings for the already upstream OV08X40 to enable usage of this
> sensor on dts based systems.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  .../bindings/media/i2c/ovti,ov08x40.yaml           | 130 +++++++++++++++++++++
>  1 file changed, 130 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..250785f062d0146e8615d8f3e7700aebbd40b1dc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
> @@ -0,0 +1,130 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +# Copyright (c) 2024 Linaro Ltd.
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/media/i2c/ovti,ov08x40.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Omnivision OV08X40 CMOS Sensor
> +
> +maintainers:
> +  - Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> +
> +description: |-
> +  The Omnivision OV08X40 is a 9.2 megapixel, CMOS image sensor which supports.
> +  - Automatic black level calibration (ABLC)
> +  - Programmable controls for frame rate, mirror and flip, binning, cropping
> +    and windowing
> +  - Output formats 10-bit 4C RGB RAW, 10-bit Bayer RAW
> +  - 4-lane MIPI D-PHY TX @ 1 Gbps per lane
> +  - 2-lane MPIP D-PHY TX @ 2 Gbps per lane
> +  - Dynamic defect pixel cancellation
> +  - Standard SCCB command interface
> +
> +properties:
> +  compatible:
> +    const: ovti,ov08x40
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +
> +  clock-names:
> +    description:
> +      Input clock for the sensor.
> +    items:
> +      - const: xvclk

This seems redundant.

> +
> +  clock-frequency:
> +    description:
> +      Frequency of the xvclk clock in Hertz.

Could you instead use the frequency already set, using assigned-clock* in
the example?

> +
> +  avdd-supply:
> +    description: Analogue circuit voltage supply.
> +
> +  dovdd-supply:
> +    description: I/O circuit voltage supply.
> +
> +  dvdd-supply:
> +    description: Digital circuit voltage supply.
> +
> +  reset-gpios:
> +    description: Active low GPIO connected to XSHUTDOWN pad of the sensor.
> +
> +  port:
> +    $ref: /schemas/graph.yaml#/$defs/port-base
> +    additionalProperties: false
> +
> +    properties:
> +      endpoint:
> +        $ref: /schemas/media/video-interfaces.yaml#
> +        unevaluatedProperties: false
> +
> +        properties:
> +          data-lanes:
> +            oneOf:
> +              - items:
> +                  - const: 1
> +                  - const: 2
> +              - items:
> +                  - const: 1
> +                  - const: 2
> +                  - const: 3
> +                  - const: 4
> +
> +          link-frequencies: true
> +
> +        required:
> +          - data-lanes
> +          - link-frequencies
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - clock-frequency
> +  - dovdd-supply
> +  - avdd-supply
> +  - dvdd-supply
> +  - reset-gpios
> +  - port
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        ov08x40: camera@36 {
> +            compatible = "ovti,ov08x40";
> +            reg = <0x36>;
> +
> +            reset-gpios = <&tlmm 111 GPIO_ACTIVE_LOW>;
> +            pinctrl-names = "default";
> +            pinctrl-0 = <&cam_rgb_defaultt>;
> +
> +            clocks = <&ov08x40_clk>;
> +            clock-names = "xvclk";
> +            clock-frequency = <19200000>;
> +
> +            avdd-supply = <&vreg_l7b_2p8>;
> +            dvdd-supply = <&vreg_l7b_1p8>;
> +            dovdd-supply = <&vreg_l3m_1p8>;
> +
> +            port {
> +                ov08x40_ep: endpoint {
> +                    remote-endpoint = <&csiphy4_ep>;
> +                    data-lanes = <1 2 3 4>;
> +                    link-frequencies = /bits/ 64 <400000000>;
> +                };
> +            };
> +        };
> +    };
> +...
> 

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40
  2024-09-26 15:46 ` [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40 Bryan O'Donoghue
  2024-09-26 15:53   ` Sakari Ailus
@ 2024-09-26 21:04   ` Rob Herring
  1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2024-09-26 21:04 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: Sakari Ailus, Jason Chen, Mauro Carvalho Chehab,
	Sergey Senozhatsky, Hans Verkuil, Krzysztof Kozlowski,
	Conor Dooley, linux-media, linux-kernel, devicetree

On Thu, Sep 26, 2024 at 04:46:38PM +0100, Bryan O'Donoghue wrote:
> Add bindings for the already upstream OV08X40 to enable usage of this
> sensor on dts based systems.

s/dts/DT/

> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  .../bindings/media/i2c/ovti,ov08x40.yaml           | 130 +++++++++++++++++++++
>  1 file changed, 130 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..250785f062d0146e8615d8f3e7700aebbd40b1dc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml
> @@ -0,0 +1,130 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +# Copyright (c) 2024 Linaro Ltd.
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/media/i2c/ovti,ov08x40.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Omnivision OV08X40 CMOS Sensor
> +
> +maintainers:
> +  - Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> +
> +description: |-

Drop the '-'.

> +  The Omnivision OV08X40 is a 9.2 megapixel, CMOS image sensor which supports.

supports:

> +  - Automatic black level calibration (ABLC)
> +  - Programmable controls for frame rate, mirror and flip, binning, cropping
> +    and windowing
> +  - Output formats 10-bit 4C RGB RAW, 10-bit Bayer RAW
> +  - 4-lane MIPI D-PHY TX @ 1 Gbps per lane
> +  - 2-lane MPIP D-PHY TX @ 2 Gbps per lane
> +  - Dynamic defect pixel cancellation
> +  - Standard SCCB command interface
> +

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40
  2024-09-26 15:53   ` Sakari Ailus
@ 2024-09-26 23:31     ` Bryan O'Donoghue
  2024-09-28  8:24       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 9+ messages in thread
From: Bryan O'Donoghue @ 2024-09-26 23:31 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Jason Chen, Mauro Carvalho Chehab, Sergey Senozhatsky,
	Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-media, linux-kernel, devicetree

On 26/09/2024 16:53, Sakari Ailus wrote:
>> +      - const: xvclk
> This seems redundant.

Right so you're saying you'd prefer something like this

drivers/media/i2c/ov8865.c

I can drop the dependency on "xvclk" as a dependency in this series.

>> +
>> +  clock-frequency:
>> +    description:
>> +      Frequency of the xvclk clock in Hertz.
> Could you instead use the frequency already set, using assigned-clock* in
> the example?

Almost certainly yes.

Yeah, I do that so.

---
bod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40
  2024-09-26 23:31     ` Bryan O'Donoghue
@ 2024-09-28  8:24       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-28  8:24 UTC (permalink / raw)
  To: Bryan O'Donoghue, Sakari Ailus
  Cc: Jason Chen, Mauro Carvalho Chehab, Sergey Senozhatsky,
	Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-media, linux-kernel, devicetree

On 27/09/2024 01:31, Bryan O'Donoghue wrote:
> On 26/09/2024 16:53, Sakari Ailus wrote:
>>> +      - const: xvclk
>> This seems redundant.
> 
> Right so you're saying you'd prefer something like this
> 
> drivers/media/i2c/ov8865.c
> 
> I can drop the dependency on "xvclk" as a dependency in this series.

Not sure what do you mean here. Drop the clock-names and
clock-frequency. Both are redundant. You should almost never have a
clock-frequency in your device bindings.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-28  8:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 15:46 [PATCH 0/4] ov08x40: Enable use of ov08x40 on Qualcomm X1E80100 CRD Bryan O'Donoghue
2024-09-26 15:46 ` [PATCH 1/4] media: ov08x40: Fix burst write sequence Bryan O'Donoghue
2024-09-26 15:46 ` [PATCH 2/4] media: dt-bindings: Add OmniVision OV08X40 Bryan O'Donoghue
2024-09-26 15:53   ` Sakari Ailus
2024-09-26 23:31     ` Bryan O'Donoghue
2024-09-28  8:24       ` Krzysztof Kozlowski
2024-09-26 21:04   ` Rob Herring
2024-09-26 15:46 ` [PATCH 3/4] media: ov08x40: Rename ext_clk to xvclk Bryan O'Donoghue
2024-09-26 15:46 ` [PATCH 4/4] media: ov08x40: Add OF probe support Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).