* [PATCH v2 0/6] OV9281 support
@ 2022-07-15 7:48 Alexander Stein
2022-07-15 7:48 ` [PATCH v2 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 UTC (permalink / raw)
To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski
Cc: Alexander Stein, linux-media, devicetree
Hi,
this is the 2nd series adding 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)
Thanks for anyone doing review and giving a feedback.
Here are the changes in v2:
* Added Krzysztof's a-b for Patch 2 & 4
* Added Daniele's a-b for Patch 1 & 3
* Removed additional error message in ov9282_power_off
* Renamed function from ov9282_configure_regulators to ov9282_get_regulators
* Cleaned-up reading ID registers
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 | 56 ++++++++++++++++++-
2 files changed, 67 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/6] media: i2c: ov9282: remove unused and unset i2c_client member
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-15 7:48 ` [PATCH v2 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 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>
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/6] media: dt-bindings: media: Add compatible for ov9281
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
2022-07-15 7:48 ` [PATCH v2 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-15 7:48 ` [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 UTC (permalink / raw)
To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski
Cc: Alexander Stein, linux-media, devicetree, Krzysztof Kozlowski
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>
---
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] 14+ messages in thread
* [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
2022-07-15 7:48 ` [PATCH v2 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
2022-07-15 7:48 ` [PATCH v2 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-17 14:23 ` Sakari Ailus
2022-07-15 7:48 ` [PATCH v2 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
` (2 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 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>
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" },
{ }
};
--
2.25.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 4/6] media: dt-bindings: media: ov9282: Add power supply properties
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
` (2 preceding siblings ...)
2022-07-15 7:48 ` [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-15 7:48 ` [PATCH v2 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
2022-07-15 7:48 ` [PATCH v2 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
5 siblings, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 UTC (permalink / raw)
To: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski
Cc: Alexander Stein, linux-media, devicetree, Krzysztof Kozlowski
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>
---
.../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] 14+ messages in thread
* [PATCH v2 5/6] media: i2c: ov9282: Add regulator support
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
` (3 preceding siblings ...)
2022-07-15 7:48 ` [PATCH v2 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-17 14:17 ` Sakari Ailus
2022-07-15 7:48 ` [PATCH v2 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
5 siblings, 1 reply; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 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>
---
Changes in v2:
* Remove error message for failed regulator_bulk_disable()
* Rename ov9282_configure_regulators to ov9282_get_regulators
drivers/media/i2c/ov9282.c | 39 ++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 04fda8222e07..263cdffc558f 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,9 @@ static int ov9282_power_off(struct device *dev)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct ov9282 *ov9282 = to_ov9282(sd);
+ int ret;
+
+ regulator_bulk_disable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
@@ -996,6 +1017,18 @@ static int ov9282_init_controls(struct ov9282 *ov9282)
return 0;
}
+static int ov9282_get_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 +1055,12 @@ static int ov9282_probe(struct i2c_client *client)
return ret;
}
+ ret = ov9282_get_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] 14+ messages in thread
* [PATCH v2 6/6] media: i2c: ov9282: Fix device detection
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
` (4 preceding siblings ...)
2022-07-15 7:48 ` [PATCH v2 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
@ 2022-07-15 7:48 ` Alexander Stein
2022-07-17 14:22 ` Sakari Ailus
5 siblings, 1 reply; 14+ messages in thread
From: Alexander Stein @ 2022-07-15 7:48 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 do two 1 byte reads and combine the result.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v2:
* Fix commit message
* Add comment about prevented auto-increment
* Return early if reading ID register failed
* Reorder ID registers, smaller register number first
drivers/media/i2c/ov9282.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 263cdffc558f..532791304c3d 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -761,11 +761,24 @@ 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);
+ /*
+ * Some vendors prevent auto-increment, so each register has to
+ * be read separately
+ */
+ ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
+ 1, &id[0]);
if (ret)
return ret;
+ ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
+ 1, &id[1]);
+ if (ret)
+ return ret;
+
+ 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] 14+ messages in thread
* Re: [PATCH v2 5/6] media: i2c: ov9282: Add regulator support
2022-07-15 7:48 ` [PATCH v2 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
@ 2022-07-17 14:17 ` Sakari Ailus
2022-07-18 6:42 ` Alexander Stein
0 siblings, 1 reply; 14+ messages in thread
From: Sakari Ailus @ 2022-07-17 14:17 UTC (permalink / raw)
To: Alexander Stein
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hi Alexander,
Thanks for the set.
On Fri, Jul 15, 2022 at 09:48:57AM +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>
> ---
> Changes in v2:
> * Remove error message for failed regulator_bulk_disable()
> * Rename ov9282_configure_regulators to ov9282_get_regulators
>
> drivers/media/i2c/ov9282.c | 39 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index 04fda8222e07..263cdffc558f 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);
Please run the set through:
./scripts/checkpatch.pl --strict --max-line-length=80
> + 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,9 @@ 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 seems to be unused.
> +
> + regulator_bulk_disable(ARRAY_SIZE(ov9282->supplies), ov9282->supplies);
>
> gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
>
> @@ -996,6 +1017,18 @@ static int ov9282_init_controls(struct ov9282 *ov9282)
> return 0;
> }
>
> +static int ov9282_get_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 +1055,12 @@ static int ov9282_probe(struct i2c_client *client)
> return ret;
> }
>
> + ret = ov9282_get_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);
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 6/6] media: i2c: ov9282: Fix device detection
2022-07-15 7:48 ` [PATCH v2 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
@ 2022-07-17 14:22 ` Sakari Ailus
2022-07-18 6:45 ` Alexander Stein
2022-07-21 14:25 ` Alexander Stein
0 siblings, 2 replies; 14+ messages in thread
From: Sakari Ailus @ 2022-07-17 14:22 UTC (permalink / raw)
To: Alexander Stein
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hi Alexander,
On Fri, Jul 15, 2022 at 09:48:58AM +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 do two 1 byte reads and combine the result.
>
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
> Changes in v2:
> * Fix commit message
> * Add comment about prevented auto-increment
> * Return early if reading ID register failed
> * Reorder ID registers, smaller register number first
>
> drivers/media/i2c/ov9282.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> index 263cdffc558f..532791304c3d 100644
> --- a/drivers/media/i2c/ov9282.c
> +++ b/drivers/media/i2c/ov9282.c
> @@ -761,11 +761,24 @@ 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);
> + /*
> + * Some vendors prevent auto-increment, so each register has to
> + * be read separately
> + */
I suppose it still works for writes I guess? Would be nice to have this in
the comment.
> + ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
> + 1, &id[0]);
Fits on one line. Same below.
> if (ret)
> return ret;
> + ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
> + 1, &id[1]);
> + if (ret)
> + return ret;
> +
> + val = id[1];
> + val |= (id[0] << 8);
>
> if (val != OV9282_ID) {
> dev_err(ov9282->dev, "chip id mismatch: %x!=%x",
--
Sakari Ailus
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible
2022-07-15 7:48 ` [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
@ 2022-07-17 14:23 ` Sakari Ailus
2022-07-18 11:42 ` Alexander Stein
0 siblings, 1 reply; 14+ messages in thread
From: Sakari Ailus @ 2022-07-17 14:23 UTC (permalink / raw)
To: Alexander Stein
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hi Alexander,
On Fri, Jul 15, 2022 at 09:48:55AM +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" },
This should also be reflected in the entity name --- the user space
deserves to know it's a different device.
> { .compatible = "ovti,ov9282" },
> { }
> };
--
Sakari Ailus
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 5/6] media: i2c: ov9282: Add regulator support
2022-07-17 14:17 ` Sakari Ailus
@ 2022-07-18 6:42 ` Alexander Stein
0 siblings, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-18 6:42 UTC (permalink / raw)
To: Sakari Ailus
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hi Sakari,
Am Sonntag, 17. Juli 2022, 16:17:09 CEST schrieb Sakari Ailus:
> Hi Alexander,
>
> Thanks for the set.
>
> On Fri, Jul 15, 2022 at 09:48:57AM +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>
> > ---
> > Changes in v2:
> > * Remove error message for failed regulator_bulk_disable()
> > * Rename ov9282_configure_regulators to ov9282_get_regulators
> >
> > drivers/media/i2c/ov9282.c | 39 ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 39 insertions(+)
> >
> > diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> > index 04fda8222e07..263cdffc558f 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);
> Please run the set through:
>
> ./scripts/checkpatch.pl --strict --max-line-length=80
Thanks, will be fixed.
> > + 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,9 @@ 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 seems to be unused.
You are right, leftover from last cleanup. Will be removed.
Thanks and best regards,
Alexander
> > +
> > + regulator_bulk_disable(ARRAY_SIZE(ov9282->supplies), ov9282-
>supplies);
> >
> > gpiod_set_value_cansleep(ov9282->reset_gpio, 0);
> >
> > @@ -996,6 +1017,18 @@ static int ov9282_init_controls(struct ov9282
> > *ov9282)>
> > return 0;
> >
> > }
> >
> > +static int ov9282_get_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 +1055,12 @@ static int ov9282_probe(struct i2c_client *client)
> >
> > return ret;
> >
> > }
> >
> > + ret = ov9282_get_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] 14+ messages in thread
* Re: Re: [PATCH v2 6/6] media: i2c: ov9282: Fix device detection
2022-07-17 14:22 ` Sakari Ailus
@ 2022-07-18 6:45 ` Alexander Stein
2022-07-21 14:25 ` Alexander Stein
1 sibling, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-18 6:45 UTC (permalink / raw)
To: Sakari Ailus
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hello Sakari,
thanks for the feedback.
Am Sonntag, 17. Juli 2022, 16:22:01 CEST schrieb Sakari Ailus:
> Hi Alexander,
>
> On Fri, Jul 15, 2022 at 09:48:58AM +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 do two 1 byte reads and combine the result.
> >
> > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > ---
> > Changes in v2:
> > * Fix commit message
> > * Add comment about prevented auto-increment
> > * Return early if reading ID register failed
> > * Reorder ID registers, smaller register number first
> >
> > drivers/media/i2c/ov9282.c | 15 ++++++++++++++-
> > 1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> > index 263cdffc558f..532791304c3d 100644
> > --- a/drivers/media/i2c/ov9282.c
> > +++ b/drivers/media/i2c/ov9282.c
> > @@ -761,11 +761,24 @@ 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);
> > + /*
> > + * Some vendors prevent auto-increment, so each register has to
> > + * be read separately
> > + */
>
> I suppose it still works for writes I guess? Would be nice to have this in
> the comment.
Yes, I didn't notice any problems regarding writes. Will address this in the
comment.
> > + ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
> > + 1, &id[0]);
>
> Fits on one line. Same below.
Sure, will be changed.
Thanks and best regards,
Alexander
> > if (ret)
> >
> > return ret;
> >
> > + ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
> > + 1, &id[1]);
> > + if (ret)
> > + return ret;
> > +
> > + 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] 14+ messages in thread
* Re: [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible
2022-07-17 14:23 ` Sakari Ailus
@ 2022-07-18 11:42 ` Alexander Stein
0 siblings, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-18 11:42 UTC (permalink / raw)
To: Sakari Ailus
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Am Sonntag, 17. Juli 2022, 16:23:17 CEST schrieb Sakari Ailus:
> Hi Alexander,
>
> On Fri, Jul 15, 2022 at 09:48:55AM +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" },
>
> This should also be reflected in the entity name --- the user space
> deserves to know it's a different device.
Not so sure what to do here. v4l2_i2c_subdev_set_name is called from
v4l2_i2c_subdev_init() with devname=NULL. This should set the correct name.
According to it's documentation with the I²C device name, but apparently
v4l2_i2c_subdev_set_name uses the drivers name.
This seems a bug to me, but is outside of this driver.
Best regards,
Alexander
> > { .compatible = "ovti,ov9282" },
> > { }
> >
> > };
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 6/6] media: i2c: ov9282: Fix device detection
2022-07-17 14:22 ` Sakari Ailus
2022-07-18 6:45 ` Alexander Stein
@ 2022-07-21 14:25 ` Alexander Stein
1 sibling, 0 replies; 14+ messages in thread
From: Alexander Stein @ 2022-07-21 14:25 UTC (permalink / raw)
To: Sakari Ailus
Cc: Paul J . Murphy, Daniele Alessandrelli, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, linux-media, devicetree
Hi,
Am Sonntag, 17. Juli 2022, 16:22:01 CEST schrieb Sakari Ailus:
> Hi Alexander,
>
> On Fri, Jul 15, 2022 at 09:48:58AM +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 do two 1 byte reads and combine the result.
> >
> > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > ---
> > Changes in v2:
> > * Fix commit message
> > * Add comment about prevented auto-increment
> > * Return early if reading ID register failed
> > * Reorder ID registers, smaller register number first
> >
> > drivers/media/i2c/ov9282.c | 15 ++++++++++++++-
> > 1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> > index 263cdffc558f..532791304c3d 100644
> > --- a/drivers/media/i2c/ov9282.c
> > +++ b/drivers/media/i2c/ov9282.c
> > @@ -761,11 +761,24 @@ 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);
> > + /*
> > + * Some vendors prevent auto-increment, so each register has to
> > + * be read separately
> > + */
>
> I suppose it still works for writes I guess? Would be nice to have this in
> the comment.
>
> > + ret = ov9282_read_reg(ov9282, OV9282_REG_ID,
> > + 1, &id[0]);
>
> Fits on one line. Same below.
>
> > if (ret)
> >
> > return ret;
> >
> > + ret = ov9282_read_reg(ov9282, OV9282_REG_ID + 1,
> > + 1, &id[1]);
> > + if (ret)
> > + return ret;
> > +
> > + val = id[1];
> > + val |= (id[0] << 8);
> >
> > if (val != OV9282_ID) {
> >
> > dev_err(ov9282->dev, "chip id mismatch: %x!=%x",
imx290 is affected by the same problem. This can be handles by using regmap's
config option use_single_read=true.
Will convert to regmap to address this.
Best regards,
Alexander
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-07-21 14:25 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 7:48 [PATCH v2 0/6] OV9281 support Alexander Stein
2022-07-15 7:48 ` [PATCH v2 1/6] media: i2c: ov9282: remove unused and unset i2c_client member Alexander Stein
2022-07-15 7:48 ` [PATCH v2 2/6] media: dt-bindings: media: Add compatible for ov9281 Alexander Stein
2022-07-15 7:48 ` [PATCH v2 3/6] media: i2c: ov9282: Add ov9281 compatible Alexander Stein
2022-07-17 14:23 ` Sakari Ailus
2022-07-18 11:42 ` Alexander Stein
2022-07-15 7:48 ` [PATCH v2 4/6] media: dt-bindings: media: ov9282: Add power supply properties Alexander Stein
2022-07-15 7:48 ` [PATCH v2 5/6] media: i2c: ov9282: Add regulator support Alexander Stein
2022-07-17 14:17 ` Sakari Ailus
2022-07-18 6:42 ` Alexander Stein
2022-07-15 7:48 ` [PATCH v2 6/6] media: i2c: ov9282: Fix device detection Alexander Stein
2022-07-17 14:22 ` Sakari Ailus
2022-07-18 6:45 ` Alexander Stein
2022-07-21 14:25 ` Alexander Stein
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).