linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benoit Parrot <bparrot@ti.com>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media <linux-media@vger.kernel.org>,
	<devicetree@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Patch 4/6] media: i2c: ov2659: Add optional powerdown gpio handling
Date: Sun, 15 Sep 2019 15:27:20 -0500	[thread overview]
Message-ID: <20190915202720.63saxa7fbifn3qf3@ti.com> (raw)
In-Reply-To: <CA+V-a8stmX2WmJEQRvvdOfHiFNgmEbtPTWtn+Fuq2h8SW4N3Hw@mail.gmail.com>

Lad, Prabhakar <prabhakar.csengg@gmail.com> wrote on Sat [2019-Sep-14 11:33:42 +0100]:
> Hi Benoit,
> 
> On Thu, Sep 12, 2019 at 1:58 PM Benoit Parrot <bparrot@ti.com> wrote:
> >
> > On some board it is possible that the sensor 'powerdown'
> > pin might be controlled with a gpio instead of being
> > tied to always powered.
> >
> > This patch add support to specify an optional gpio
> > which will be set at probe time and remained on.
> >
> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> > ---
> >  drivers/media/i2c/Kconfig  |  2 +-
> >  drivers/media/i2c/ov2659.c | 13 +++++++++++++
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> > index 7eee1812bba3..315c1d8bdb7b 100644
> > --- a/drivers/media/i2c/Kconfig
> > +++ b/drivers/media/i2c/Kconfig
> > @@ -634,7 +634,7 @@ config VIDEO_OV2640
> >  config VIDEO_OV2659
> >         tristate "OmniVision OV2659 sensor support"
> >         depends on VIDEO_V4L2 && I2C
> > -       depends on MEDIA_CAMERA_SUPPORT
> > +       depends on MEDIA_CAMERA_SUPPORT && GPIOLIB
> >         select V4L2_FWNODE
> >         help
> >           This is a Video4Linux2 sensor driver for the OmniVision
> > diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
> > index efbe6dc720e2..c64f73bef336 100644
> > --- a/drivers/media/i2c/ov2659.c
> > +++ b/drivers/media/i2c/ov2659.c
> > @@ -32,6 +32,8 @@
> >  #include <linux/module.h>
> >  #include <linux/of.h>
> >  #include <linux/of_graph.h>
> > +#include <linux/of_gpio.h>
> > +#include <linux/gpio/consumer.h>
> >  #include <linux/slab.h>
> >  #include <linux/uaccess.h>
> >  #include <linux/videodev2.h>
> > @@ -232,6 +234,8 @@ struct ov2659 {
> >         struct sensor_register *format_ctrl_regs;
> >         struct ov2659_pll_ctrl pll;
> >         int streaming;
> > +       /* used to control the sensor powerdownN pin */
> > +       struct gpio_desc *pwrdn_gpio;
> >  };
> >
> >  static const struct sensor_register ov2659_init_regs[] = {
> > @@ -1391,6 +1395,7 @@ static int ov2659_probe(struct i2c_client *client)
> >         struct v4l2_subdev *sd;
> >         struct ov2659 *ov2659;
> >         struct clk *clk;
> > +       struct gpio_desc *gpio;
> 
> you don't need the local var here you can just assign it directly to pwrdn_gpio.

Ok.

> 
> >         int ret;
> >
> >         if (!pdata) {
> > @@ -1414,6 +1419,14 @@ static int ov2659_probe(struct i2c_client *client)
> >             ov2659->xvclk_frequency > 27000000)
> >                 return -EINVAL;
> >
> > +       /* Optional gpio don't fail if not present */
> > +       gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
> > +                                      GPIOD_OUT_HIGH);
> > +       if (IS_ERR(gpio))
> > +               return PTR_ERR(gpio);
> > +
> > +       ov2659->pwrdn_gpio = gpio;
> > +
> apart from assigning it you don't actually use it.
> 
> you will also have to read the reset gpio pin and implement
> ov2659_set_power() and
> call it in appropriate places/ s_power ?

Well I am not sure I want to go that far.
On most board I have the sensor is always powered as soon as the board gets
powered. Which is why we go through a S/W reset before starting a stream.

I didn't want to change the logic here too much.

I'll check this out a little more.

Benoit

> 
> Cheers,
> --Prabhakar Lad

  reply	other threads:[~2019-09-15 20:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 13:00 [Patch 0/6] media: i2c: ov2659: maintenance series Benoit Parrot
2019-09-12 13:00 ` [Patch 1/6] media: i2c: ov2659: Fix for image wrap-around in lower resolution Benoit Parrot
2019-09-12 13:00 ` [Patch 2/6] media: i2c: ov2659: Fix sensor detection to actually fail when device is not present Benoit Parrot
2019-09-12 13:00 ` [Patch 3/6] media: dt-bindings: ov2659: add powerdown-gpios optional property Benoit Parrot
2019-09-14 10:11   ` Lad, Prabhakar
2019-09-15 20:21     ` Benoit Parrot
2019-09-12 13:00 ` [Patch 4/6] media: i2c: ov2659: Add optional powerdown gpio handling Benoit Parrot
2019-09-14 10:33   ` Lad, Prabhakar
2019-09-15 20:27     ` Benoit Parrot [this message]
2019-09-12 13:00 ` [Patch 5/6] media: i2c: ov2659: Fix missing 720p register config Benoit Parrot
2019-09-12 13:00 ` [Patch 6/6] media: i2c: ov2659: Switch to SPDX Licensing Benoit Parrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190915202720.63saxa7fbifn3qf3@ti.com \
    --to=bparrot@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).