[1/4] media: i2c: ov2685: Make reset gpio optional

Message ID 20230129-ov2685-improvements-v1-1-f281bd49399c@z3ntu.xyz
State New
Headers
Series Improvements for OmniVision OV2685 driver |

Commit Message

Luca Weiss Jan. 29, 2023, 9:42 a.m. UTC
  In some setups XSHUTDOWN is connected to DOVDD when it's unused,
therefore treat the reset gpio as optional.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
 drivers/media/i2c/ov2685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jacopo Mondi Jan. 29, 2023, 11:22 a.m. UTC | #1
Hi Luca

On Sun, Jan 29, 2023 at 10:42:35AM +0100, Luca Weiss wrote:
> In some setups XSHUTDOWN is connected to DOVDD when it's unused,
> therefore treat the reset gpio as optional.

I don't have a datasheet for this sensor, but OV sensors usually have
to gpio lines to control powerdown and reset. Datasheets usually
suggest to hook one of the 2 to DOVDD and control the other from the
SoC. How is the sensor hooked up in your design ? No gpio lines is
controlled by the SoC ?

Another question is if we need to software-reset the sensor if no gpio
line is hooked up to XSHUTDOWN.

>
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
>  drivers/media/i2c/ov2685.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
> index a3b524f15d89..a422f4c8a2eb 100644
> --- a/drivers/media/i2c/ov2685.c
> +++ b/drivers/media/i2c/ov2685.c
> @@ -734,7 +734,7 @@ static int ov2685_probe(struct i2c_client *client,
>  	if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ)
>  		dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n");
>
> -	ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> +	ov2685->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
>  	if (IS_ERR(ov2685->reset_gpio)) {
>  		dev_err(dev, "Failed to get reset-gpios\n");
>  		return -EINVAL;
>
> --
> 2.39.1
>
  
Luca Weiss Jan. 29, 2023, 11:49 a.m. UTC | #2
On Sonntag, 29. Jänner 2023 12:22:49 CET Jacopo Mondi wrote:
> Hi Luca
> 
> On Sun, Jan 29, 2023 at 10:42:35AM +0100, Luca Weiss wrote:
> > In some setups XSHUTDOWN is connected to DOVDD when it's unused,
> > therefore treat the reset gpio as optional.
> 
> I don't have a datasheet for this sensor, but OV sensors usually have
> to gpio lines to control powerdown and reset. Datasheets usually
> suggest to hook one of the 2 to DOVDD and control the other from the
> SoC. How is the sensor hooked up in your design ? No gpio lines is
> controlled by the SoC ?

It looks like this sensor only has XSHUTDOWN pin and no extra reset pin.

In my setup there's the normal I2C & CSI & mclk hookups, but the supply lines 
and shutdown line are all just connected to regulator-fixed, so gpio-
controlled on/off regulators.

> 
> Another question is if we need to software-reset the sensor if no gpio
> line is hooked up to XSHUTDOWN.

The datasheet mentions it resets itself during power up (so when the supplies 
are turned on), so I don't think we need to add anything.

Regards
Luca

> 
> > Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> > ---
> > 
> >  drivers/media/i2c/ov2685.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
> > index a3b524f15d89..a422f4c8a2eb 100644
> > --- a/drivers/media/i2c/ov2685.c
> > +++ b/drivers/media/i2c/ov2685.c
> > @@ -734,7 +734,7 @@ static int ov2685_probe(struct i2c_client *client,
> > 
> >  	if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ)
> >  	
> >  		dev_warn(dev, "xvclk mismatched, modes are based on 
24MHz\n");
> > 
> > -	ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> > +	ov2685->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> > GPIOD_OUT_LOW);> 
> >  	if (IS_ERR(ov2685->reset_gpio)) {
> >  	
> >  		dev_err(dev, "Failed to get reset-gpios\n");
> >  		return -EINVAL;
> > 
> > --
> > 2.39.1
  
Jacopo Mondi Jan. 29, 2023, 1:05 p.m. UTC | #3
Hi Luca

On Sun, Jan 29, 2023 at 12:49:03PM +0100, Luca Weiss wrote:
> On Sonntag, 29. Jänner 2023 12:22:49 CET Jacopo Mondi wrote:
> > Hi Luca
> >
> > On Sun, Jan 29, 2023 at 10:42:35AM +0100, Luca Weiss wrote:
> > > In some setups XSHUTDOWN is connected to DOVDD when it's unused,
> > > therefore treat the reset gpio as optional.
> >
> > I don't have a datasheet for this sensor, but OV sensors usually have
> > to gpio lines to control powerdown and reset. Datasheets usually
> > suggest to hook one of the 2 to DOVDD and control the other from the
> > SoC. How is the sensor hooked up in your design ? No gpio lines is
> > controlled by the SoC ?
>
> It looks like this sensor only has XSHUTDOWN pin and no extra reset pin.
>

Ack, I see the same for OV2680 (for which I have a datasheet)

> In my setup there's the normal I2C & CSI & mclk hookups, but the supply lines
> and shutdown line are all just connected to regulator-fixed, so gpio-
> controlled on/off regulators.
>
> >
> > Another question is if we need to software-reset the sensor if no gpio
> > line is hooked up to XSHUTDOWN.
>
> The datasheet mentions it resets itself during power up (so when the supplies
> are turned on), so I don't think we need to add anything.
>

Thanks for the clarification!

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
   j


> Regards
> Luca
>
> >
> > > Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> > > ---
> > >
> > >  drivers/media/i2c/ov2685.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
> > > index a3b524f15d89..a422f4c8a2eb 100644
> > > --- a/drivers/media/i2c/ov2685.c
> > > +++ b/drivers/media/i2c/ov2685.c
> > > @@ -734,7 +734,7 @@ static int ov2685_probe(struct i2c_client *client,
> > >
> > >  	if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ)
> > >
> > >  		dev_warn(dev, "xvclk mismatched, modes are based on
> 24MHz\n");
> > >
> > > -	ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> > > +	ov2685->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> > > GPIOD_OUT_LOW);>
> > >  	if (IS_ERR(ov2685->reset_gpio)) {
> > >
> > >  		dev_err(dev, "Failed to get reset-gpios\n");
> > >  		return -EINVAL;
> > >
> > > --
> > > 2.39.1
>
>
>
>
  

Patch

diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
index a3b524f15d89..a422f4c8a2eb 100644
--- a/drivers/media/i2c/ov2685.c
+++ b/drivers/media/i2c/ov2685.c
@@ -734,7 +734,7 @@  static int ov2685_probe(struct i2c_client *client,
 	if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ)
 		dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n");
 
-	ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	ov2685->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ov2685->reset_gpio)) {
 		dev_err(dev, "Failed to get reset-gpios\n");
 		return -EINVAL;