From: Benoit Parrot <bparrot@ti.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>, <linux-media@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [Patch v4 6/8] media: i2c: ov2659: Add powerdown/reset gpio handling
Date: Mon, 30 Sep 2019 07:29:46 -0500 [thread overview]
Message-ID: <20190930122946.2io4pkri4gy3pnkr@ti.com> (raw)
In-Reply-To: <20190930072857.GA19037@paasikivi.fi.intel.com>
Sakari Ailus <sakari.ailus@linux.intel.com> wrote on Mon [2019-Sep-30 10:28:57 +0300]:
> Hi Benoit,
>
> On Fri, Sep 27, 2019 at 01:47:20PM -0500, Benoit Parrot wrote:
> > On some board it is possible that the sensor 'powerdown' and or 'reset'
> > pin might be controlled by gpio instead of being tied.
> >
> > To implement we add pm_runtime support which will handle the power
> > up/down sequence when it is available otherwise the sensor will be
> > powered on at module insertion/probe and powered off at module removal.
> >
> > Now originally the driver assumed that the sensor would always stay
> > powered and keep its register setting. We cannot assume this anymore, so
> > every time we "power up" we need to re-program the initial registers
> > configuration first. This was previously done only at probe time.
> >
> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> > ---
> > drivers/media/i2c/Kconfig | 2 +-
> > drivers/media/i2c/ov2659.c | 88 +++++++++++++++++++++++++++++++++++++-
> > 2 files changed, 87 insertions(+), 3 deletions(-)
> >
> > 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 cd4625432264..7d0baa386644 100644
> > --- a/drivers/media/i2c/ov2659.c
> > +++ b/drivers/media/i2c/ov2659.c
> > @@ -22,9 +22,11 @@
> >
> > #include <linux/clk.h>
> > #include <linux/delay.h>
> > +#include <linux/gpio/consumer.h>
> > #include <linux/i2c.h>
> > #include <linux/module.h>
> > #include <linux/of_graph.h>
> > +#include <linux/pm_runtime.h>
> >
> > #include <media/i2c/ov2659.h>
> > #include <media/v4l2-ctrls.h>
> > @@ -218,6 +220,11 @@ struct ov2659 {
> > struct sensor_register *format_ctrl_regs;
> > struct ov2659_pll_ctrl pll;
> > int streaming;
> > + /* used to control the sensor PWDN pin */
> > + struct gpio_desc *pwdn_gpio;
> > + /* used to control the sensor RESETB pin */
> > + struct gpio_desc *resetb_gpio;
> > + int on;
>
> Please use runtime PM for this instead. It's hard to get this right
> otherwise.
So you mean, I should use the "if (!pm_runtime_get_if_in_use(dev))"
construct?
Ok I'll switch it to that, just using "on" was a little simple but I
already had it :).
>
> Access to "on" is not serialised with the power state changes. In this case
> e.g. drivers/media/i2c/ov5670.c is a good example. I think I'll see how I
> could improve smiapp as well.
Ok so that driver uses this pm method but does not actually power up or
down the sensor.
Benoit
>
> --
> Sakari Ailus
> sakari.ailus@linux.intel.com
next prev parent reply other threads:[~2019-09-30 12:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 18:47 [Patch v4 0/8] media: i2c: ov2659: maintenance series Benoit Parrot
2019-09-27 18:47 ` [Patch v4 1/8] media: i2c: ov2659: Fix for image wrap-around in lower resolution Benoit Parrot
2019-09-27 20:34 ` Lad, Prabhakar
2019-09-27 18:47 ` [Patch v4 2/8] media: i2c: ov2659: Fix sensor detection to actually fail when device is not present Benoit Parrot
2019-09-27 20:35 ` Lad, Prabhakar
2019-09-27 18:47 ` [Patch v4 3/8] media: i2c: ov2659: Cleanup include file list Benoit Parrot
2019-09-27 20:35 ` Lad, Prabhakar
2019-09-27 18:47 ` [Patch v4 4/8] media: i2c: ov2659: fix s_stream return value Benoit Parrot
2019-09-27 20:33 ` Lad, Prabhakar
2019-09-30 12:08 ` Benoit Parrot
2019-09-27 18:47 ` [Patch v4 5/8] media: dt-bindings: ov2659: add powerdown/reset-gpios optional property Benoit Parrot
2019-09-27 20:37 ` Lad, Prabhakar
2019-09-27 18:47 ` [Patch v4 6/8] media: i2c: ov2659: Add powerdown/reset gpio handling Benoit Parrot
2019-09-27 21:09 ` Lad, Prabhakar
2019-09-30 12:11 ` Benoit Parrot
2019-09-30 7:28 ` Sakari Ailus
2019-09-30 12:29 ` Benoit Parrot [this message]
2019-09-30 12:38 ` Sakari Ailus
2019-09-27 18:47 ` [Patch v4 7/8] media: i2c: ov2659: Fix missing 720p register config Benoit Parrot
2019-09-27 20:36 ` Lad, Prabhakar
2019-09-27 18:47 ` [Patch v4 8/8] media: i2c: ov2659: Switch to SPDX Licensing Benoit Parrot
2019-09-27 21:11 ` Lad, Prabhakar
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=20190930122946.2io4pkri4gy3pnkr@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=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).