From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Zhi Mao (毛智)" <zhi.mao@mediatek.com>
Cc: "heiko@sntech.de" <heiko@sntech.de>,
"tomi.valkeinen@ideasonboard.com"
<tomi.valkeinen@ideasonboard.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"yunkec@chromium.org" <yunkec@chromium.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.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>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"bingbu.cao@intel.com" <bingbu.cao@intel.com>,
"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
Project_Global_Chrome_Upstream_Group
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
"10572168@qq.com" <10572168@qq.com>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"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:01:04 +0200 [thread overview]
Message-ID: <20240220030104.GF20376@pendragon.ideasonboard.com> (raw)
In-Reply-To: <598f62bbb55157eec1e23dd1dbc307fea3851b21.camel@mediatek.com>
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.
> > > + usleep_range(GC08A3_MIN_SLEEP_US, GC08A3_MAX_SLEEP_US);
> > > +
> > > + return 0;
> > > +}
[snip]
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2024-02-20 3:01 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 [this message]
2024-02-20 5:45 ` Zhi Mao (毛智)
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=20240220030104.GF20376@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.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=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 \
--cc=zhi.mao@mediatek.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).