Linux Media Controller development
 help / color / mirror / Atom feed
From: "Zhi Mao (毛智)" <zhi.mao@mediatek.com>
To: "laurent.pinchart@ideasonboard.com" <laurent.pinchart@ideasonboard.com>
Cc: "heiko@sntech.de" <heiko@sntech.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"yunkec@chromium.org" <yunkec@chromium.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"dan.scally@ideasonboard.com" <dan.scally@ideasonboard.com>,
	"gerald.loacker@wolfvision.net" <gerald.loacker@wolfvision.net>,
	"Shengnan Wang (王圣男)" <shengnan.wang@mediatek.com>,
	"hdegoede@redhat.com" <hdegoede@redhat.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
	"Yaya Chang (張雅清)" <Yaya.Chang@mediatek.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"jacopo.mondi@ideasonboard.com" <jacopo.mondi@ideasonboard.com>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"bingbu.cao@intel.com" <bingbu.cao@intel.com>,
	"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
	"tomi.valkeinen@ideasonboard.com"
	<tomi.valkeinen@ideasonboard.com>,
	"10572168@qq.com" <10572168@qq.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"macromorgan@hotmail.com" <macromorgan@hotmail.com>
Subject: Re: [PATCH v4 2/2] media: i2c: Add GC08A3 image sensor driver
Date: Tue, 20 Feb 2024 05:45:54 +0000	[thread overview]
Message-ID: <115698c0c549e747026cc8841a3bd571533f8e6f.camel@mediatek.com> (raw)
In-Reply-To: <20240220030104.GF20376@pendragon.ideasonboard.com>

Hi Laurent,

Thanks for you reply.
I'd like to ask for advice about how to contrl "reset-pin", please
check the below comments.

On Tue, 2024-02-20 at 05:01 +0200, Laurent Pinchart wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Hi Zhi,
> 
> On Tue, Feb 20, 2024 at 02:12:26AM +0000, Zhi Mao (毛智) wrote:
> > On Tue, 2024-02-06 at 20:45 +0200, Laurent Pinchart wrote:
> > > On Sun, Feb 04, 2024 at 02:15:38PM +0800, Zhi Mao wrote:
> > > > Add a V4L2 sub-device driver for Galaxycore GC08A3 image
> sensor.
> > > >
> > > > Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
> > > > ---
> > > >  drivers/media/i2c/Kconfig  |   10 +
> > > >  drivers/media/i2c/Makefile |    1 +
> > > >  drivers/media/i2c/gc08a3.c | 1448
> ++++++++++++++++++++++++++++++++++++
> > > >  3 files changed, 1459 insertions(+)
> > > >  create mode 100644 drivers/media/i2c/gc08a3.c
> 
> [snip]
> 
> > > > diff --git a/drivers/media/i2c/gc08a3.c
> b/drivers/media/i2c/gc08a3.c
> > > > new file mode 100644
> > > > index 000000000000..3fc7fffb815c
> > > > --- /dev/null
> > > > +++ b/drivers/media/i2c/gc08a3.c
> > > > @@ -0,0 +1,1448 @@
> 
> [snip]
> 
> > > > +static int gc08a3_power_on(struct device *dev)
> > > > +{
> > > > +struct i2c_client *client = to_i2c_client(dev);
> > > > +struct v4l2_subdev *sd = i2c_get_clientdata(client);
> > > > +struct gc08a3 *gc08a3 = to_gc08a3(sd);
> > > > +int ret;
> > > > +
> > > > +ret = regulator_bulk_enable(ARRAY_SIZE(gc08a3_supply_name),
> > > > +    gc08a3->supplies);
> > > > +if (ret < 0) {
> > > > +dev_err(gc08a3->dev, "failed to enable regulators: %d\n",
> ret);
> > > > +return ret;
> > > > +}
> > > > +
> > > > +ret = clk_prepare_enable(gc08a3->xclk);
> > > > +if (ret < 0) {
> > > > +regulator_bulk_disable(ARRAY_SIZE(gc08a3_supply_name),
> > > > +       gc08a3->supplies);
> > > > +dev_err(gc08a3->dev, "clk prepare enable failed\n");
> > > > +return ret;
> > > > +}
> > > > +
> > > > +usleep_range(GC08A3_MIN_SLEEP_US, GC08A3_MAX_SLEEP_US);
> > > > +
> > > > +gpiod_set_value_cansleep(gc08a3->reset_gpio, 1);
> > >
> > > Are you asserting reset when powering on ? That sounds wrong, you
> should
> > > de-assert reset here (and acquire the reset gpio in probe() with
> > > GPIOD_OUT_HIGH). Drivers should use logical levels for GPIOs,
> setting a
> > > GPIO named "reset" to 1 should assert the reset signal, even if
> the
> > > physical signal is active low. You may have the wrong polarity in
> the
> > > device tree.
> >
> > According to the sensor power sequence sepc, "reset" pin should be
> pull
> > from low to high after "dovdd/dvdd/avdd" power on, so I follow this
> > power sequece to pull "reset" pin high in software flow.
> 
> From a hardware point of view that's right, but the Linux kernel
> handles
> logical level of GPIOs. If a GPIO is named "reset", it is expected
> that
> calling
> 
> gpiod_set_value_cansleep(gc08a3->reset_gpio, 1);
> 
> will "assert" the reset signal, setting it to a logical "reset =
> true"
> level. This maps to the hardware 0V output level, as the signal is
> active-low. To achieve this, define the reset GPIO as active low in
> DT,
> and the GPIO framework will invert the signal for you. You should
> then
> call
> 
> gpiod_set_value_cansleep(gc08a3->reset_gpio, 1);
> 
> in the driver when you want to assert reset (set it to 0V), and
> 
> gpiod_set_value_cansleep(gc08a3->reset_gpio, 0);
> 
> when you want to deassert it (set it to 3.3V, or whatever the I/O
> voltage for the signal is).
> 
> This way all driver use logical states, and the inversion is handled
> in
> DT.
> 

Sensor power sequence as below:
                      ------------------
                     | | |
                     | | | 
dvdd/avdd/dovdd  --------
                               ---------
                              |
                              |
reset-pin        -------------

In order to match this power sequece, "reset-pin" contrl flow is below:
1. config the "reset-pin" is "active-high" in DTS:
    reset-gpios = <&pio 19 GPIO_ACTIVE_HIGH>;

2. image sensor driver probe function:
gc08a3->reset_gpio = devm_gpiod_get(dev, "reset",
GPIOD_OUT_LOW);  //init "reset-pin" is low

3. image sensor driver power_on function:
gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); //pull "reset-pin"
high 

so, the expect state of "reset-pin" is from low to high.
If I am wrong, please correct me.

> > > > +usleep_range(GC08A3_MIN_SLEEP_US, GC08A3_MAX_SLEEP_US);
> > > > +
> > > > +return 0;
> > > > +}
> 
> [snip]
> 
> -- 
> Regards,
> 
> Laurent Pinchart

  reply	other threads:[~2024-02-20  5:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-04  6:15 [PATCH v4 0/2] media: i2c: Add support for GC08A3 sensor Zhi Mao
2024-02-04  6:15 ` [PATCH v4 1/2] media: dt-bindings: i2c: add GalaxyCore GC08A3 image sensor Zhi Mao
2024-02-04 13:50   ` Laurent Pinchart
2024-02-07 14:42   ` AngeloGioacchino Del Regno
2024-02-04  6:15 ` [PATCH v4 2/2] media: i2c: Add GC08A3 image sensor driver Zhi Mao
2024-02-06 18:45   ` Laurent Pinchart
2024-02-20  2:12     ` Zhi Mao (毛智)
2024-02-20  3:01       ` Laurent Pinchart
2024-02-20  5:45         ` Zhi Mao (毛智) [this message]
2024-02-20  7:25           ` sakari.ailus
2024-02-21  2:37             ` Zhi Mao (毛智)
2024-02-21  7:43               ` sakari.ailus
2024-02-27  1:36                 ` Zhi Mao (毛智)
2024-02-07 14:42   ` AngeloGioacchino Del Regno
2024-02-20  2:21     ` Zhi Mao (毛智)

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=115698c0c549e747026cc8841a3bd571533f8e6f.camel@mediatek.com \
    --to=zhi.mao@mediatek.com \
    --cc=10572168@qq.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Yaya.Chang@mediatek.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bingbu.cao@intel.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gerald.loacker@wolfvision.net \
    --cc=hdegoede@redhat.com \
    --cc=heiko@sntech.de \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=macromorgan@hotmail.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=tomi.valkeinen@ideasonboard.com \
    --cc=yunkec@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