All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] OV9281 support
@ 2022-07-11  8:16 Alexander Stein
  2022-07-11  8:16 ` [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

Hi,

this series adds support for OV9281 which is quite similar to OV9282.
This includes:
* a small cleanup (Patch 1)
* adding a new compatible (Patch 2 & 3)
* adding support for regulators (Patch 4 & 5)
* Fix reading ID register on VC MIPI OV9281 (Patch 6)

The regulator support is based on the driver from Raspberry Pi downstream kernel
[1], the ID register read fix as well. Please refer to [2] why this fix is
required. I can confirm this is necessary by checking with a Logic analyzer on
the i2c bus.

Best regards,
Alexander

[1] https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/media/i2c/ov9281.c
[2] https://github.com/raspberrypi/linux/commit/58deee7c917e1c3c5e37987c3a89ad19d791f58a

Alexander Stein (6):
  media: i2c: ov9282: remove unused and unset i2c_client member
  media: dt-bindings: media: Add compatible for ov9281
  media: i2c: ov9282: Add ov9281 compatible
  media: dt-bindings: media: ov9282: Add power supply properties
  media: i2c: ov9282: Add regulator support
  media: i2c: ov9282: Fix device detection

 .../bindings/media/i2c/ovti,ov9282.yaml       | 14 ++++-
 drivers/media/i2c/ov9282.c                    | 54 +++++++++++++++++--
 2 files changed, 63 insertions(+), 5 deletions(-)

-- 
2.25.1


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

* [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11 19:34   ` Alessandrelli, Daniele
  2022-07-11  8:16 ` [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

This is not need anyway as the i2c_client is stored in v4l2_subdev.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/media/i2c/ov9282.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 2e0b315801e5..3269c1983bd5 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -123,7 +123,6 @@ struct ov9282_mode {
  */
 struct ov9282 {
 	struct device *dev;
-	struct i2c_client *client;
 	struct v4l2_subdev sd;
 	struct media_pad pad;
 	struct gpio_desc *reset_gpio;
-- 
2.25.1


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

* [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
  2022-07-11  8:16 ` [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11  9:17   ` Krzysztof Kozlowski
  2022-07-11  8:16 ` [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

This is a slightly different hardware with identical software interface.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
index bf115ab9d926..285f8c85f253 100644
--- a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
@@ -16,10 +16,13 @@ description:
   sensor with an active array size of 1296H x 816V. It is programmable through
   I2C interface. The I2C client address is fixed to 0x60/0x70 as per sensor data
   sheet. Image data is sent through MIPI CSI-2.
+  OV9281 has a different lens chief ray angle.
 
 properties:
   compatible:
-    const: ovti,ov9282
+    enum:
+      - ovti,ov9281
+      - ovti,ov9282
   reg:
     description: I2C address
     maxItems: 1
-- 
2.25.1


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

* [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
  2022-07-11  8:16 ` [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
  2022-07-11  8:16 ` [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11 19:34   ` Alessandrelli, Daniele
  2022-07-11  8:16 ` [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

According to product brief they are identical from software point of view.
Differences are a different chief ray angle (CRA) and the package.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/media/i2c/ov9282.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 3269c1983bd5..04fda8222e07 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -1114,6 +1114,7 @@ static const struct dev_pm_ops ov9282_pm_ops = {
 };
 
 static const struct of_device_id ov9282_of_match[] = {
+	{ .compatible = "ovti,ov9281" },
 	{ .compatible = "ovti,ov9282" },
 	{ }
 };
-- 
2.25.1


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

* [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
                   ` (2 preceding siblings ...)
  2022-07-11  8:16 ` [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11  9:17   ` Krzysztof Kozlowski
  2022-07-11 12:02   ` Krzysztof Kozlowski
  2022-07-11  8:16 ` [PATCH 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
  2022-07-11  8:16 ` [PATCH 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
  5 siblings, 2 replies; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

Add regulators for each power domain.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 .../devicetree/bindings/media/i2c/ovti,ov9282.yaml       | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
index 285f8c85f253..9abfaabd373a 100644
--- a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
@@ -39,6 +39,15 @@ properties:
     description: Reference to the GPIO connected to the XCLR pin, if any.
     maxItems: 1
 
+  avdd-supply:
+    description: Analog power supply
+
+  dovdd-supply:
+    description: Digital I/O power supply
+
+  dvdd-supply:
+    description: Digital core supply
+
   port:
     additionalProperties: false
     $ref: /schemas/graph.yaml#/$defs/port-base
-- 
2.25.1


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

* [PATCH 5/6] media: i2c: ov9282: Add regulator support
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
                   ` (3 preceding siblings ...)
  2022-07-11  8:16 ` [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11 19:54   ` Alessandrelli, Daniele
  2022-07-11  8:16 ` [PATCH 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
  5 siblings, 1 reply; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

Need in case the sensors is supplied by a switchable regulator.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/media/i2c/ov9282.c | 41 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 04fda8222e07..c3faf11a99b5 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -11,6 +11,7 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
 
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-fwnode.h>
@@ -55,6 +56,14 @@
 #define OV9282_REG_MIN		0x00
 #define OV9282_REG_MAX		0xfffff
 
+static const char * const ov9282_supply_names[] = {
+	"avdd",		/* Analog power */
+	"dovdd",	/* Digital I/O power */
+	"dvdd",		/* Digital core power */
+};
+
+#define OV9282_NUM_SUPPLIES ARRAY_SIZE(ov9282_supply_names)
+
 /**
  * struct ov9282_reg - ov9282 sensor register
  * @address: Register address
@@ -127,6 +136,7 @@ struct ov9282 {
 	struct media_pad pad;
 	struct gpio_desc *reset_gpio;
 	struct clk *inclk;
+	struct regulator_bulk_data supplies[OV9282_NUM_SUPPLIES];
 	struct v4l2_ctrl_handler ctrl_handler;
 	struct v4l2_ctrl *link_freq_ctrl;
 	struct v4l2_ctrl *pclk_ctrl;
@@ -883,10 +893,18 @@ static int ov9282_power_on(struct device *dev)
 		goto error_reset;
 	}
 
+	ret = regulator_bulk_enable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
+	if (ret) {
+		dev_err(dev, "Failed to enable regulators\n");
+		goto disable_clk;
+	}
+
 	usleep_range(400, 600);
 
 	return 0;
 
+disable_clk:
+	clk_disable_unprepare(ov9282->inclk);
 error_reset:
 	gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
 
@@ -903,6 +921,11 @@ static int ov9282_power_off(struct device *dev)
 {
 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct ov9282 *ov9282 = to_ov9282(sd);
+	int ret;
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
+	if (ret)
+		dev_err(ov9282->dev, "Failed to disable supplies: %d\n", ret);
 
 	gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
 
@@ -996,6 +1019,18 @@ static int ov9282_init_controls(struct ov9282 *ov9282)
 	return 0;
 }
 
+static int ov9282_configure_regulators(struct ov9282 *ov9282)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(ov9282->supplies); i++)
+		ov9282->supplies[i].supply = ov9282_supply_names[i];
+
+	return devm_regulator_bulk_get(ov9282->dev,
+				       ARRAY_SIZE(ov9282->supplies),
+				       ov9282->supplies);
+}
+
 /**
  * ov9282_probe() - I2C client device binding
  * @client: pointer to i2c client device
@@ -1022,6 +1057,12 @@ static int ov9282_probe(struct i2c_client *client)
 		return ret;
 	}
 
+	ret = ov9282_configure_regulators(ov9282);
+	if (ret) {
+		dev_err(&client->dev, "Failed to get power regulators\n");
+		return ret;
+	}
+
 	mutex_init(&ov9282->mutex);
 
 	ret = ov9282_power_on(ov9282->dev);
-- 
2.25.1


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

* [PATCH 6/6] media: i2c: ov9282: Fix device detection
  2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
                   ` (4 preceding siblings ...)
  2022-07-11  8:16 ` [PATCH 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
@ 2022-07-11  8:16 ` Alexander Stein
  2022-07-11 19:58   ` Alessandrelli, Daniele
  5 siblings, 1 reply; 15+ messages in thread
From: Alexander Stein @ 2022-07-11  8:16 UTC (permalink / raw)
  To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski
  Cc: Alexander Stein, linux-media, devicetree

Apparently the Vision Components model (VC MIPI OV9281) does not support
address auto-increment, so probe fails with:
ov9282 2-0060: chip id mismatch: 9281!=92ff
Instead two a 1 byte reads to combine the result.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/media/i2c/ov9282.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index c3faf11a99b5..c507d9d4531a 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -761,11 +761,16 @@ static int ov9282_set_stream(struct v4l2_subdev *sd, int enable)
 static int ov9282_detect(struct ov9282 *ov9282)
 {
 	int ret;
+	u32 id[2];
 	u32 val;
 
-	ret = ov9282_read_reg(ov9282, OV9282_REG_ID, 2, &val);
-	if (ret)
-		return ret;
+	ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
+			      1, &id[1]);
+	if (!ret)
+		ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
+				      1, &id[0]);
+	val = id[1];
+	val |= (id[0] << 8);
 
 	if (val != OV9282_ID) {
 		dev_err(ov9282->dev, "chip id mismatch: %x!=%x",
-- 
2.25.1


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

* Re: [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281
  2022-07-11  8:16 ` [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
@ 2022-07-11  9:17   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2022-07-11  9:17 UTC (permalink / raw)
  To: Alexander Stein, Paul J . Murphy, Daniele Alessandrelli,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski
  Cc: linux-media, devicetree

On 11/07/2022 10:16, Alexander Stein wrote:
> This is a slightly different hardware with identical software interface.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

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

* Re: [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties
  2022-07-11  8:16 ` [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
@ 2022-07-11  9:17   ` Krzysztof Kozlowski
  2022-07-11 11:45     ` Alexander Stein
  2022-07-11 12:02   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 15+ messages in thread
From: Krzysztof Kozlowski @ 2022-07-11  9:17 UTC (permalink / raw)
  To: Alexander Stein, Paul J . Murphy, Daniele Alessandrelli,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski
  Cc: linux-media, devicetree

On 11/07/2022 10:16, Alexander Stein wrote:
> Add regulators for each power domain.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
>  .../devicetree/bindings/media/i2c/ovti,ov9282.yaml       | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> index 285f8c85f253..9abfaabd373a 100644
> --- a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> @@ -39,6 +39,15 @@ properties:
>      description: Reference to the GPIO connected to the XCLR pin, if any.
>      maxItems: 1
>  
> +  avdd-supply:
> +    description: Analog power supply
> +
> +  dovdd-supply:
> +    description: Digital I/O power supply
> +
> +  dvdd-supply:
> +    description: Digital core supply
> +

Are all these valid for both variants/devices?


Best regards,
Krzysztof

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

* Re: Re: [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties
  2022-07-11  9:17   ` Krzysztof Kozlowski
@ 2022-07-11 11:45     ` Alexander Stein
  0 siblings, 0 replies; 15+ messages in thread
From: Alexander Stein @ 2022-07-11 11:45 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, linux-media, devicetree

Hello Krzysztof,

Am Montag, 11. Juli 2022, 11:17:41 CEST schrieb Krzysztof Kozlowski:
> On 11/07/2022 10:16, Alexander Stein wrote:
> > Add regulators for each power domain.
> > 
> > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > ---
> > 
> >  .../devicetree/bindings/media/i2c/ovti,ov9282.yaml       | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> > b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml index
> > 285f8c85f253..9abfaabd373a 100644
> > --- a/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> > +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov9282.yaml
> > 
> > @@ -39,6 +39,15 @@ properties:
> >      description: Reference to the GPIO connected to the XCLR pin, if any.
> >      maxItems: 1
> > 
> > +  avdd-supply:
> > +    description: Analog power supply
> > +
> > +  dovdd-supply:
> > +    description: Digital I/O power supply
> > +
> > +  dvdd-supply:
> > +    description: Digital core supply
> > +
> 
> Are all these valid for both variants/devices?

I cannot say for sure due to lack of datasheet, but given that other model 
bindings like ov8865 [1] or ov5640 [2] have the same regulators, I think it is 
safe to assume these are valid for ov9281 and ov9282 as well.

Best regards,
Alexander

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/
Documentation/devicetree/bindings/media/i2c/ovti,ov8865.yaml#n29
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/
Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml



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

* Re: [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties
  2022-07-11  8:16 ` [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
  2022-07-11  9:17   ` Krzysztof Kozlowski
@ 2022-07-11 12:02   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2022-07-11 12:02 UTC (permalink / raw)
  To: Alexander Stein, Paul J . Murphy, Daniele Alessandrelli,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski
  Cc: linux-media, devicetree

On 11/07/2022 10:16, Alexander Stein wrote:
> Add regulators for each power domain.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

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

* Re: [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member
  2022-07-11  8:16 ` [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
@ 2022-07-11 19:34   ` Alessandrelli, Daniele
  0 siblings, 0 replies; 15+ messages in thread
From: Alessandrelli, Daniele @ 2022-07-11 19:34 UTC (permalink / raw)
  To: Murphy, Paul J, mchehab, alexander.stein, krzysztof.kozlowski+dt,
	robh+dt
  Cc: linux-media, devicetree

On Mon, 2022-07-11 at 10:16 +0200, Alexander Stein wrote:
> This is not need anyway as the i2c_client is stored in v4l2_subdev.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Acked-by: Daniele Alessandrelli <daniele.alessandrelli@intel.com>

> ---
>  drivers/media/i2c/ov9282.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index 2e0b315801e5..3269c1983bd5 100644
> --- a/drivers/media/i2c/ov9282.c
> +++ b/drivers/media/i2c/ov9282.c
> @@ -123,7 +123,6 @@ struct ov9282_mode {
>   */
>  struct ov9282 {
>         struct device *dev;
> -       struct i2c_client *client;
>         struct v4l2_subdev sd;
>         struct media_pad pad;
>         struct gpio_desc *reset_gpio;


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

* Re: [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible
  2022-07-11  8:16 ` [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
@ 2022-07-11 19:34   ` Alessandrelli, Daniele
  0 siblings, 0 replies; 15+ messages in thread
From: Alessandrelli, Daniele @ 2022-07-11 19:34 UTC (permalink / raw)
  To: Murphy, Paul J, mchehab, alexander.stein, krzysztof.kozlowski+dt,
	robh+dt
  Cc: linux-media, devicetree

On Mon, 2022-07-11 at 10:16 +0200, Alexander Stein wrote:
> According to product brief they are identical from software point of
> view.
> Differences are a different chief ray angle (CRA) and the package.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Acked-by: Daniele Alessandrelli <daniele.alessandrelli@intel.com>

> ---
>  drivers/media/i2c/ov9282.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index 3269c1983bd5..04fda8222e07 100644
> --- a/drivers/media/i2c/ov9282.c
> +++ b/drivers/media/i2c/ov9282.c
> @@ -1114,6 +1114,7 @@ static const struct dev_pm_ops ov9282_pm_ops =
> {
>  };
>  
>  static const struct of_device_id ov9282_of_match[] = {
> +       { .compatible = "ovti,ov9281" },
>         { .compatible = "ovti,ov9282" },
>         { }
>  };


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

* Re: [PATCH 5/6] media: i2c: ov9282: Add regulator support
  2022-07-11  8:16 ` [PATCH 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
@ 2022-07-11 19:54   ` Alessandrelli, Daniele
  0 siblings, 0 replies; 15+ messages in thread
From: Alessandrelli, Daniele @ 2022-07-11 19:54 UTC (permalink / raw)
  To: Murphy, Paul J, mchehab, alexander.stein, krzysztof.kozlowski+dt,
	robh+dt
  Cc: linux-media, devicetree

On Mon, 2022-07-11 at 10:16 +0200, Alexander Stein wrote:
> Need in case the sensors is supplied by a switchable regulator.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
>  drivers/media/i2c/ov9282.c | 41 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index 04fda8222e07..c3faf11a99b5 100644
> --- a/drivers/media/i2c/ov9282.c
> +++ b/drivers/media/i2c/ov9282.c
> @@ -11,6 +11,7 @@
>  #include <linux/i2c.h>
>  #include <linux/module.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include <media/v4l2-ctrls.h>
>  #include <media/v4l2-fwnode.h>
> @@ -55,6 +56,14 @@
>  #define OV9282_REG_MIN         0x00
>  #define OV9282_REG_MAX         0xfffff
>  
> +static const char * const ov9282_supply_names[] = {
> +       "avdd",         /* Analog power */
> +       "dovdd",        /* Digital I/O power */
> +       "dvdd",         /* Digital core power */
> +};
> +
> +#define OV9282_NUM_SUPPLIES ARRAY_SIZE(ov9282_supply_names)
> +
>  /**
>   * struct ov9282_reg - ov9282 sensor register
>   * @address: Register address
> @@ -127,6 +136,7 @@ struct ov9282 {
>         struct media_pad pad;
>         struct gpio_desc *reset_gpio;
>         struct clk *inclk;
> +       struct regulator_bulk_data supplies[OV9282_NUM_SUPPLIES];
>         struct v4l2_ctrl_handler ctrl_handler;
>         struct v4l2_ctrl *link_freq_ctrl;
>         struct v4l2_ctrl *pclk_ctrl;
> @@ -883,10 +893,18 @@ static int ov9282_power_on(struct device *dev)
>                 goto error_reset;
>         }
>  
> +       ret = regulator_bulk_enable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
> +       if (ret) {
> +               dev_err(dev, "Failed to enable regulators\n");
> +               goto disable_clk;
> +       }
> +
>         usleep_range(400, 600);
>  
>         return 0;
>  
> +disable_clk:
> +       clk_disable_unprepare(ov9282->inclk);
>  error_reset:
>         gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
>  
> @@ -903,6 +921,11 @@ static int ov9282_power_off(struct device *dev)
>  {
>         struct v4l2_subdev *sd = dev_get_drvdata(dev);
>         struct ov9282 *ov9282 = to_ov9282(sd);
> +       int ret;
> +
> +       ret = regulator_bulk_disable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
> +       if (ret)
> +               dev_err(ov9282->dev, "Failed to disable supplies: %d\n", ret);

I'm not sure that checking the return value is needed.
'regulator_bulk_disable()' already prints an error message in case of
failure.

The majority of the drivers in "drivers/media/i2c" don't seem to check
it.

>  
>         gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
>  
> @@ -996,6 +1019,18 @@ static int ov9282_init_controls(struct ov9282 *ov9282)
>         return 0;
>  }
>  
> +static int ov9282_configure_regulators(struct ov9282 *ov9282)

I would call this function something like 'ov9282_get_regulators()'.

> +{
> +       unsigned int i;
> +
> +       for (i = 0; i < ARRAY_SIZE(ov9282->supplies); i++)
> +               ov9282->supplies[i].supply = ov9282_supply_names[i];
> +
> +       return devm_regulator_bulk_get(ov9282->dev,
> +                                      ARRAY_SIZE(ov9282->supplies),
> +                                      ov9282->supplies);
> +}
> +
>  /**
>   * ov9282_probe() - I2C client device binding
>   * @client: pointer to i2c client device
> @@ -1022,6 +1057,12 @@ static int ov9282_probe(struct i2c_client *client)
>                 return ret;
>         }
>  
> +       ret = ov9282_configure_regulators(ov9282);
> +       if (ret) {
> +               dev_err(&client->dev, "Failed to get power regulators\n");
> +               return ret;
> +       }
> +
>         mutex_init(&ov9282->mutex);
>  
>         ret = ov9282_power_on(ov9282->dev);


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

* Re: [PATCH 6/6] media: i2c: ov9282: Fix device detection
  2022-07-11  8:16 ` [PATCH 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
@ 2022-07-11 19:58   ` Alessandrelli, Daniele
  0 siblings, 0 replies; 15+ messages in thread
From: Alessandrelli, Daniele @ 2022-07-11 19:58 UTC (permalink / raw)
  To: Murphy, Paul J, mchehab, alexander.stein, krzysztof.kozlowski+dt,
	robh+dt
  Cc: linux-media, devicetree

On Mon, 2022-07-11 at 10:16 +0200, Alexander Stein wrote:
> Apparently the Vision Components model (VC MIPI OV9281) does not
> support
> address auto-increment, so probe fails with:
> ov9282 2-0060: chip id mismatch: 9281!=92ff
> Instead two a 1 byte reads to combine the result.

I think some word is missing from this last statement.

> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
>  drivers/media/i2c/ov9282.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index c3faf11a99b5..c507d9d4531a 100644
> --- a/drivers/media/i2c/ov9282.c
> +++ b/drivers/media/i2c/ov9282.c
> @@ -761,11 +761,16 @@ static int ov9282_set_stream(struct v4l2_subdev
> *sd, int enable)
>  static int ov9282_detect(struct ov9282 *ov9282)
>  {
>         int ret;
> +       u32 id[2];
>         u32 val;
>  
> -       ret = ov9282_read_reg(ov9282, OV9282_REG_ID, 2, &val);
> -       if (ret)
> -               return ret;
> +       ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
> +                             1, &id[1]);

Please add a comment explaining why reading one byte at a time is
needed.

> +       if (!ret)
> +               ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
> +                                     1, &id[0]);

Shouldn't we return in case of error? As the original code was doing?

> +       val = id[1];
> +       val |= (id[0] << 8);
>  
>         if (val != OV9282_ID) {
>                 dev_err(ov9282->dev, "chip id mismatch: %x!=%x",


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

end of thread, other threads:[~2022-07-11 19:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11  8:16 [PATCH 0/6] OV9281 support Alexander Stein
2022-07-11  8:16 ` [PATCH 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
2022-07-11 19:34   ` Alessandrelli, Daniele
2022-07-11  8:16 ` [PATCH 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
2022-07-11  9:17   ` Krzysztof Kozlowski
2022-07-11  8:16 ` [PATCH 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
2022-07-11 19:34   ` Alessandrelli, Daniele
2022-07-11  8:16 ` [PATCH 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
2022-07-11  9:17   ` Krzysztof Kozlowski
2022-07-11 11:45     ` Alexander Stein
2022-07-11 12:02   ` Krzysztof Kozlowski
2022-07-11  8:16 ` [PATCH 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
2022-07-11 19:54   ` Alessandrelli, Daniele
2022-07-11  8:16 ` [PATCH 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
2022-07-11 19:58   ` Alessandrelli, Daniele

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.