From: Bryan O'Donoghue <bod@kernel.org>
To: Richard Acayan <mailingradian@gmail.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Tianshu Qiu <tian.shu.qiu@intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-media@vger.kernel.org
Cc: Robert Mader <robert.mader@collabora.com>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Subject: Re: [PATCH v4 2/5] media: i2c: imx355: Support devicetree and power management
Date: Fri, 12 Dec 2025 01:49:43 +0000 [thread overview]
Message-ID: <6d6c3c08-5e99-4cfa-bf85-b664770f00bc@kernel.org> (raw)
In-Reply-To: <20251211014846.16602-3-mailingradian@gmail.com>
On 11/12/2025 01:48, Richard Acayan wrote:
> A device tree compatible makes it possible for this driver to be used on
> Open Firmware devices. Initialization of power-managed resources such as
> the reset GPIO and voltage regulators can be specified in the device
> tree and handled by the driver. Add support for this so the Pixel 3a can
> use the driver.
>
> Signed-off-by: Richard Acayan <mailingradian@gmail.com>
> ---
> drivers/media/i2c/imx355.c | 118 ++++++++++++++++++++++++++++++++++---
> 1 file changed, 110 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
> index 776107efe386..c225bb8959bd 100644
> --- a/drivers/media/i2c/imx355.c
> +++ b/drivers/media/i2c/imx355.c
> @@ -3,9 +3,13 @@
>
> #include <linux/acpi.h>
> #include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/i2c.h>
> #include <linux/module.h>
> +#include <linux/of.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/unaligned.h>
>
> #include <media/v4l2-ctrls.h>
> @@ -125,6 +129,15 @@ struct imx355 {
> * Protect access to sensor v4l2 controls.
> */
> struct mutex mutex;
> +
> + struct gpio_desc *reset_gpio;
> + struct regulator_bulk_data supplies[3];
> +};
> +
> +static const char * const imx355_supply_names[] = {
> + "avdd",
> + "dvdd",
> + "dovdd",
> };
>
> static const struct imx355_reg imx355_global_regs[] = {
> @@ -1515,6 +1528,54 @@ static const struct v4l2_subdev_internal_ops imx355_internal_ops = {
> .open = imx355_open,
> };
>
> +static int imx355_power_off(struct device *dev)
> +{
> + struct i2c_client *client = container_of(dev, struct i2c_client, dev);
> + struct v4l2_subdev *sd = i2c_get_clientdata(client);
> + struct imx355 *imx355 = to_imx355(sd);
> +
> + gpiod_set_value_cansleep(imx355->reset_gpio, 0);
> +
> + regulator_bulk_disable(ARRAY_SIZE(imx355->supplies), imx355->supplies);
> + clk_disable_unprepare(imx355->clk);
> +
> + return 0;
> +}
> +
> +static int imx355_power_on(struct device *dev)
> +{
> + struct i2c_client *client = container_of(dev, struct i2c_client, dev);
> + struct v4l2_subdev *sd = i2c_get_clientdata(client);
> + struct imx355 *imx355 = to_imx355(sd);
> + int ret;
> +
> + ret = clk_prepare_enable(imx355->clk);
> + if (ret) {
> + dev_err(dev, "failed to enable clocks: %d\n", ret);
> + return ret;
> + }
> +
> + ret = regulator_bulk_enable(ARRAY_SIZE(imx355->supplies),
> + imx355->supplies);
> + if (ret) {
> + dev_err(dev, "failed to enable regulators: %d\n", ret);
> + goto error_disable_clocks;
> + }
> +
> + usleep_range(5000, 5100);
> + gpiod_set_value_cansleep(imx355->reset_gpio, 1);
> + usleep_range(8000, 8100);
> +
I'd suggest taking the chip through an explicit reset sequence -
including appropriate delays here.
The code as-is assumes the reset line is logic 0, which it may not be.
Better to whack reset, give some reasonable amount of time for reset to
complete, unwhack - delay and then off you go.
That way you've put the chip into a known state and probably you don't
have the documentation but, if you had the documentation you'd see the
chip mandates such a start-up sequence anyway.
---
bod
next prev parent reply other threads:[~2025-12-12 1:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 1:48 [PATCH v4 0/5] media: i2c: IMX355 for the Pixel 3a Richard Acayan
2025-12-11 1:48 ` [PATCH v4 1/5] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan
2025-12-11 3:12 ` Krzysztof Kozlowski
2025-12-11 3:26 ` Rob Herring (Arm)
2025-12-11 5:02 ` Krzysztof Kozlowski
2025-12-12 0:23 ` Richard Acayan
2025-12-11 5:05 ` Krzysztof Kozlowski
2025-12-11 9:35 ` Vladimir Zapolskiy
2025-12-11 11:02 ` Vladimir Zapolskiy
2025-12-13 21:50 ` Richard Acayan
2025-12-13 21:52 ` Richard Acayan
2025-12-11 1:48 ` [PATCH v4 2/5] media: i2c: imx355: Support devicetree and power management Richard Acayan
2025-12-11 9:37 ` David Heidelberg
2025-12-11 11:00 ` Vladimir Zapolskiy
2025-12-12 1:43 ` Krzysztof Kozlowski
2025-12-12 1:45 ` Krzysztof Kozlowski
2025-12-12 1:49 ` Bryan O'Donoghue [this message]
2025-12-11 1:48 ` [PATCH v4 3/5] arm64: dts: qcom: sdm670: remove camss endpoint nodes Richard Acayan
2025-12-11 10:46 ` Vladimir Zapolskiy
2025-12-12 1:39 ` Bryan O'Donoghue
2025-12-11 1:48 ` [PATCH v4 4/5] arm64: dts: qcom: sdm670: add camera mclk pins Richard Acayan
2025-12-11 10:47 ` Vladimir Zapolskiy
2025-12-12 1:40 ` Bryan O'Donoghue
2025-12-13 11:01 ` David Heidelberg
2025-12-11 1:48 ` [PATCH v4 5/5] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan
2025-12-11 5:16 ` Dmitry Baryshkov
2025-12-12 0:41 ` Richard Acayan
2025-12-12 1:45 ` Bryan O'Donoghue
2025-12-12 2:19 ` Richard Acayan
2025-12-12 2:20 ` Bryan O'Donoghue
2025-12-12 19:22 ` Dmitry Baryshkov
2025-12-11 10:49 ` Vladimir Zapolskiy
2025-12-12 22:41 ` David Heidelberg
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=6d6c3c08-5e99-4cfa-bf85-b664770f00bc@kernel.org \
--to=bod@kernel.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mailingradian@gmail.com \
--cc=mchehab@kernel.org \
--cc=robert.mader@collabora.com \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tian.shu.qiu@intel.com \
--cc=vladimir.zapolskiy@linaro.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).