Hi Jacopo, Thank you for the patch. On Thu, Mar 10, 2022 at 02:08:27PM +0100, Jacopo Mondi wrote: > The OV5670 has a powerdown and reset pin, named respectively "PWDN" and > "XSHUTDOWN". > > Optionally probe the gpios connected to the pins during the driver probe > routine. > > Signed-off-by: Jacopo Mondi <jacopo@xxxxxxxxxx> Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > --- > drivers/media/i2c/ov5670.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c > index cba310aec011..ca5191d043ce 100644 > --- a/drivers/media/i2c/ov5670.c > +++ b/drivers/media/i2c/ov5670.c > @@ -1842,6 +1842,10 @@ struct ov5670 { > /* Regulators */ > struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES]; > > + /* Power-down and reset gpios. */ > + struct gpio_desc *pwdn_gpio; /* PWDNB pin. */ > + struct gpio_desc *reset_gpio; /* XSHUTDOWN pin. */ > + > /* To serialize asynchronus callbacks */ > struct mutex mutex; > > @@ -2494,6 +2498,23 @@ static int ov5670_regulators_probe(struct ov5670 *ov5670) > ov5670->supplies); > } > > +static int ov5670_gpio_probe(struct ov5670 *ov5670) > +{ > + struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); > + > + ov5670->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "pwdn", > + GPIOD_OUT_LOW); > + if (IS_ERR(ov5670->pwdn_gpio)) > + return PTR_ERR(ov5670->pwdn_gpio); > + > + ov5670->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", > + GPIOD_OUT_LOW); > + if (IS_ERR(ov5670->reset_gpio)) > + return PTR_ERR(ov5670->reset_gpio); > + > + return 0; > +} > + > static int ov5670_probe(struct i2c_client *client) > { > struct ov5670 *ov5670; > @@ -2522,6 +2543,12 @@ static int ov5670_probe(struct i2c_client *client) > goto error_print; > } > > + ret = ov5670_gpio_probe(ov5670); > + if (ret) { > + err_msg = "GPIO probe failed"; > + goto error_print; > + } > + > full_power = acpi_dev_state_d0(&client->dev); > if (full_power) { > /* Check module identity */ -- Regards, Laurent Pinchart