Skip to contentSkip to conversation

media: ov08x40: Fix value of reset GPIO when requesting it

PATCH In review Hans de Goede 2 participants 4 messages Mar 1, 2025 – Mar 2, 2025

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

PATCH 1/2 media: ov08x40: Fix value of reset GPIO when requesting it

We should put/leave the sensor in reset when requesting the GPIO, after requesting it there are 2 possible scenarios and having the GPIO driven low is no good in either scenario:

1. The sensor was in ACPI D0 before probe() runs, in this case ov08x40_power_on() + ov08x40_identify_module() will run immediately after requesting the GPIO and ov08x40_power_on() starts with driving the GPIO high. So if the GPIO was already high it will very shortly be driven low, more of a spike to low then actually properly be driven low. Which may leave the sensor in a confused state.

If we request the GPIO to be high at request time then power_on() will driver it high again (no-op) and then sleep for 1-2 ms, so no spike.

2. The sensor was in ACPI D3 / off before probe(), in this case probe() leaves the sensor alone. But when the sensor is off its reset line should be driven high not low.

---
 drivers/media/i2c/ov08x40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov08x40.c +1 -1
index c2a399e3bb41..a4790e68f523 100644
@@ -2167,7 +2167,7 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev)
 		return dev_err_probe(dev, ret, "parsing endpoint failed\n");
 
 	ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset",
-						    GPIOD_OUT_LOW);
+						    GPIOD_OUT_HIGH);
 	if (IS_ERR(ov08x->reset_gpio)) {
 		ret = dev_err_probe(dev, PTR_ERR(ov08x->reset_gpio),
 				    "getting reset GPIO\n");
Signature · 1 line
2.48.1
#1 lore raw

PATCH 2/2 media: ov08x40: Log chip ID when identifying the chip

Debug log the chip ID after successfully identifying the chip, this is useful to see if the identification is done on probe() time or if it is delayed till the first stream on.

---
 drivers/media/i2c/ov08x40.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/ov08x40.c +1 -0
index a4790e68f523..cf0e41fc3071 100644
@@ -1955,6 +1955,7 @@ static int ov08x40_identify_module(struct ov08x40 *ov08x)
 		return -ENXIO;
 	}
 
+	dev_dbg(&client->dev, "chip id 0x%x\n", val);
 	ov08x->identified = true;
 
 	return 0;
Signature · 1 line
2.48.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] media: ov08x40: Log chip ID when identifying the chip

Quoted 14 lines · Hans de Goede

Debug log the chip ID after successfully identifying the chip, this is useful to see if the identification is done on probe() time or if it is delayed till the first stream on.

---
  drivers/media/i2c/ov08x40.c | 1 +
  1 file changed, 1 insertion(+)
drivers/media/i2c/ov08x40.c +0 -0
index a4790e68f523..cf0e41fc3071 100644

drivers/media/i2c/ov08x40.c static int ov08x40_identify_module(struct ov08x40 *ov08x) · line 1961

Quoted 7 lines
drivers/media/i2c/ov08x40.c +1 -0
@@ -1955,6 +1955,7 @@ static int ov08x40_identify_module(struct ov08x40 *ov08x)
  		return -ENXIO;
  	}
 
+	dev_dbg(&client->dev, "chip id 0x%x\n", val);
  	ov08x->identified = true;
 
  	return 0;
Reviewed-by on v1 1/2
#3 lore raw
In reply to Hans de Goede
Quoted 28 lines · Hans de Goede

We should put/leave the sensor in reset when requesting the GPIO, after requesting it there are 2 possible scenarios and having the GPIO driven low is no good in either scenario:

1. The sensor was in ACPI D0 before probe() runs, in this case ov08x40_power_on() + ov08x40_identify_module() will run immediately after requesting the GPIO and ov08x40_power_on() starts with driving the GPIO high. So if the GPIO was already high it will very shortly be driven low, more of a spike to low then actually properly be driven low. Which may leave the sensor in a confused state.

If we request the GPIO to be high at request time then power_on() will driver it high again (no-op) and then sleep for 1-2 ms, so no spike.

2. The sensor was in ACPI D3 / off before probe(), in this case probe() leaves the sensor alone. But when the sensor is off its reset line should be driven high not low.

---
  drivers/media/i2c/ov08x40.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov08x40.c +0 -0
index c2a399e3bb41..a4790e68f523 100644

drivers/media/i2c/ov08x40.c static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) · line 2173

Quoted 8 lines
drivers/media/i2c/ov08x40.c +1 -1
@@ -2167,7 +2167,7 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev)
  		return dev_err_probe(dev, ret, "parsing endpoint failed\n");
 
  	ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset",
-						    GPIOD_OUT_LOW);
+						    GPIOD_OUT_HIGH);
  	if (IS_ERR(ov08x->reset_gpio)) {
  		ret = dev_err_probe(dev, PTR_ERR(ov08x->reset_gpio),
  				    "getting reset GPIO\n");

Makes sense to me.