Linux Media Controller development
 help / color / mirror / Atom feed
From: Muzaffer Kadir via B4 Relay <devnull+muzafferkadir.mainlining.org@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: git@luigi311.com, pavel@ucw.cz, tomm.merciai@gmail.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	phone-devel@vger.kernel.org,
	"Muzaffer Kadir" <muzafferkadir@mainlining.org>,
	"Ondřej Jirman" <megi@xff.cz>
Subject: [PATCH v2 2/2] media: i2c: imx258: Add reset-gpio support
Date: Sat, 29 Aug 2026 16:06:34 +0300	[thread overview]
Message-ID: <20260829-imx258-add-reset-gpio-patch-v2-2-bfd27891e225@mainlining.org> (raw)
In-Reply-To: <20260829-imx258-add-reset-gpio-patch-v2-0-bfd27891e225@mainlining.org>

From: Muzaffer Kadir <muzafferkadir@mainlining.org>

reset-gpio is already documented in dt-bindings but never implemented
in the driver.

Signed-off-by: Muzaffer Kadir <muzafferkadir@mainlining.org>
---
 drivers/media/i2c/imx258.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index 9c3a6579df0d..4a0663e816b5 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -9,6 +9,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/unaligned.h>
+#include <linux/gpio/consumer.h>
 
 #include <media/v4l2-cci.h>
 #include <media/v4l2-ctrls.h>
@@ -681,6 +682,7 @@ struct imx258 {
 
 	struct clk *clk;
 	struct regulator_bulk_data supplies[IMX258_NUM_SUPPLIES];
+	struct gpio_desc *reset_gpio;
 };
 
 static inline struct imx258 *to_imx258(struct v4l2_subdev *_sd)
@@ -1127,10 +1129,23 @@ static int imx258_power_on(struct device *dev)
 	ret = clk_prepare_enable(imx258->clk);
 	if (ret) {
 		dev_err(dev, "failed to enable clock\n");
-		regulator_bulk_disable(IMX258_NUM_SUPPLIES, imx258->supplies);
+		goto err_disable_regulators;
+	}
+
+	ret = gpiod_set_value_cansleep(imx258->reset_gpio, 0);
+	if (ret) {
+		dev_err(dev, "failed to deassert reset\n");
+		goto err_disable_clk;
 	}
 	fsleep(400);
 
+	return ret;
+
+err_disable_clk:
+	clk_disable_unprepare(imx258->clk);
+err_disable_regulators:
+	regulator_bulk_disable(IMX258_NUM_SUPPLIES, imx258->supplies);
+
 	return ret;
 }
 
@@ -1139,6 +1154,7 @@ static int imx258_power_off(struct device *dev)
 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx258 *imx258 = to_imx258(sd);
 
+	gpiod_set_value_cansleep(imx258->reset_gpio, 1);
 	clk_disable_unprepare(imx258->clk);
 	regulator_bulk_disable(IMX258_NUM_SUPPLIES, imx258->supplies);
 
@@ -1383,6 +1399,12 @@ static int imx258_probe(struct i2c_client *client)
 		return ret;
 	}
 
+	imx258->reset_gpio = devm_gpiod_get_optional(imx258->dev, "reset",
+		GPIOD_OUT_HIGH);
+	if (IS_ERR(imx258->reset_gpio))
+		return dev_err_probe(imx258->dev, PTR_ERR(imx258->reset_gpio),
+				     "Failed to get reset-gpios\n");
+
 	ret = imx258_get_regulators(imx258);
 	if (ret)
 		return dev_err_probe(imx258->dev, ret,

-- 
2.54.0



  parent reply	other threads:[~2026-08-29 13:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29 13:06 [PATCH v2 0/2] Add Reset GPIO to imx258 Muzaffer Kadir via B4 Relay
2026-08-29 13:06 ` [PATCH v2 1/2] media: i2c: imx258: Add wait after enabling Muzaffer Kadir via B4 Relay
2026-08-30  7:36   ` Rudraksha Gupta
2026-08-29 13:06 ` Muzaffer Kadir via B4 Relay [this message]
2026-08-30  7:37   ` [PATCH v2 2/2] media: i2c: imx258: Add reset-gpio support Rudraksha Gupta

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=20260829-imx258-add-reset-gpio-patch-v2-2-bfd27891e225@mainlining.org \
    --to=devnull+muzafferkadir.mainlining.org@kernel.org \
    --cc=git@luigi311.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=megi@xff.cz \
    --cc=muzafferkadir@mainlining.org \
    --cc=pavel@ucw.cz \
    --cc=phone-devel@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomm.merciai@gmail.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