From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <bgolaszewski@baylibre.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Nicolas Boichat" <drinkcat@chromium.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Cao Bing Bu" <bingbu.cao@intel.com>,
srv_heupstream <srv_heupstream@mediatek.com>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>,
"list@263.net:IOMMU DRIVERS <iommu@lists.linux-foundation.org>,
Joerg Roedel <joro@8bytes.org>,"
<linux-arm-kernel@lists.infradead.org>,
"Sj Huang" <sj.huang@mediatek.com>,
"Linux Media Mailing List" <linux-media@vger.kernel.org>,
linux-devicetree <devicetree@vger.kernel.org>,
"Louis Kuo" <louis.kuo@mediatek.com>,
"Shengnan Wang (王圣男)" <shengnan.wang@mediatek.com>,
dongchun.zhu@mediatek.com
Subject: Re: [V8, 2/2] media: i2c: ov02a10: Add OV02A10 image sensor driver
Date: Mon, 15 Jun 2020 15:24:26 +0800 [thread overview]
Message-ID: <1592205866.8804.686.camel@mhfsdcap03> (raw)
In-Reply-To: <CAAFQd5CboZ9aFhUyKPES_2oO_AKAOh3Pg8D+9YpfmzJ8v-yFHw@mail.gmail.com>
Hi Tomasz,
On Fri, 2020-06-12 at 20:49 +0200, Tomasz Figa wrote:
> On Fri, Jun 12, 2020 at 11:33 AM Dongchun Zhu <dongchun.zhu@mediatek.com> wrote:
> >
> > Hi Tomasz,
> >
> > On Wed, 2020-06-10 at 18:36 +0000, Tomasz Figa wrote:
> > > On Sat, May 23, 2020 at 12:50:15PM +0800, Dongchun Zhu wrote:
> > > > Hi Tomasz,
> > > >
> > > > Thanks for the review. My replies are as below.
> > > >
> > > > On Thu, 2020-05-21 at 19:32 +0000, Tomasz Figa wrote:
> > > > > Hi Dongchun,
> > > > >
> > > > > On Sat, May 09, 2020 at 04:06:27PM +0800, Dongchun Zhu wrote:
> > > [snip]
> > > > > > +{
> > > > > > + struct i2c_client *client = to_i2c_client(dev);
> > > > > > + struct v4l2_subdev *sd = i2c_get_clientdata(client);
> > > > > > + struct ov02a10 *ov02a10 = to_ov02a10(sd);
> > > > > > + int ret;
> > > > > > +
> > > > > > + gpiod_set_value_cansleep(ov02a10->n_rst_gpio, 0);
> > > > > > + gpiod_set_value_cansleep(ov02a10->pd_gpio, 0);
> > > > > > +
> > > > > > + ret = clk_prepare_enable(ov02a10->eclk);
> > > > > > + if (ret < 0) {
> > > > > > + dev_err(dev, "failed to enable eclk\n");
> > > > > > + return ret;
> > > > > > + }
> > > > > > +
> > > > > > + ret = regulator_bulk_enable(OV02A10_NUM_SUPPLIES, ov02a10->supplies);
> > > > > > + if (ret < 0) {
> > > > > > + dev_err(dev, "failed to enable regulators\n");
> > > > > > + goto disable_clk;
> > > > > > + }
> > > > > > + usleep_range(5000, 6000);
> > > > > > +
> > > > > > + gpiod_set_value_cansleep(ov02a10->pd_gpio, 1);
> > > > >
> > > > > This is a "powerdown" GPIO. It must be set to 0 if the sensor is to be
> > > > > powered on.
> > > > >
> > > >
> > > > The value set by gpiod_set_value_cansleep() API actually depends upon
> > > > GPIO polarity defined in DT.
> > > > Since I set GPIO_ACTIVE_LOW to powerdown,
> > > > gpiod_set_value_cansleep(gpio_desc, value) would set !value to
> > > > gpio_desc.
> > > > Thus here powerdown would be low-state when sensor is powered on.
> > > > For GPIO polarity, I also post a comment to the binding patch.
> > > >
> > >
> > > That's true. However, this makes the driver really confusing. If someone
> > > reads this code and compares with the datasheet, it looks incorrect,
> > > because in the datasheet the powerdown GPIO needs to be configured low
> > > for the sensor to operate.
> > >
> > > I'd recommend defining the binding in a way that makes it clear in the driver code
> > > that it implementes the power sequencing as per the datasheet.
> > >
> >
> > Uh-huh...
> > But it all depends on how we look at the powerdown GPIO.
> > Or where should we define the active low or active high, the driver or
> > DT?
> >
> > My initial idea is using DT GPIO polarity to describe sensor active
> > polarity according to the datasheet.
> > As an active low shutdown signal is equivalent to an active high enable
> > signal.
> >
>
> Okay, I discussed this offline with Laurent and Sakari and we also
> found the guidelines of the Linux GPIO subsystem on this [1].
>
> The conclusion is that the pin names in the driver or DT must not
> contain any negation prefixes and the driver needs to care only about
> the logical function of the pin, such as "powerdown" or "reset". In
> case of this driver, we should call the pins "rst" and "pd" and
> setting them to 1 would trigger the reset and power down respectively.
> The physical signal polarity must be configured in DT using the
> polarity flags.
>
> [1] https://www.kernel.org/doc/html/latest/driver-api/gpio/consumer.html#the-active-low-and-open-drain-semantics
>
Thank you for the sharing.
If driver only focus on the logical function of GPIO pins,
'n_rst_gpio' may need to be renamed back to the 1st version 'rst_gpio'.
> Best regards,
> Tomasz
next prev parent reply other threads:[~2020-06-15 7:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 8:06 [V8, 0/2] media: i2c: Add support for OV02A10 sensor Dongchun Zhu
2020-05-09 8:06 ` [V8, 1/2] media: dt-bindings: media: i2c: Document OV02A10 bindings Dongchun Zhu
2020-05-11 16:02 ` Rob Herring
2020-05-11 19:54 ` Sakari Ailus
2020-05-12 2:40 ` Dongchun Zhu
2020-05-21 18:59 ` Tomasz Figa
2020-05-24 20:33 ` Sakari Ailus
2020-05-21 19:35 ` Tomasz Figa
2020-05-22 9:44 ` Dongchun Zhu
2020-05-09 8:06 ` [V8, 2/2] media: i2c: ov02a10: Add OV02A10 image sensor driver Dongchun Zhu
2020-05-11 8:51 ` Sakari Ailus
2020-05-11 11:52 ` Dongchun Zhu
2020-05-11 9:33 ` Andy Shevchenko
2020-05-11 12:06 ` Dongchun Zhu
2020-05-21 19:32 ` Tomasz Figa
2020-05-23 4:50 ` Dongchun Zhu
2020-06-10 18:36 ` Tomasz Figa
2020-06-12 9:31 ` Dongchun Zhu
2020-06-12 18:49 ` Tomasz Figa
2020-06-15 7:24 ` Dongchun Zhu [this message]
2020-06-15 8:44 ` Andy Shevchenko
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=1592205866.8804.686.camel@mhfsdcap03 \
--to=dongchun.zhu@mediatek.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=bingbu.cao@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=drinkcat@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=louis.kuo@mediatek.com \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=shengnan.wang@mediatek.com \
--cc=sj.huang@mediatek.com \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@chromium.org \
/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).