From: Robert Ijtsma via B4 Relay <devnull+robertijtsma.gmail.com@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Jacopo Mondi <jacopo@jmondi.org>,
Todor Tomov <todor.too@gmail.com>
Cc: Antoine Pichot <antoine.pichot@gmail.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Robert Ijtsma <robertijtsma@gmail.com>
Subject: [PATCH v2 1/3] media: i2c: ov7251: wait for software reset before global init
Date: Sat, 28 Nov 2026 21:41:07 +0100 [thread overview]
Message-ID: <20261128-ov7251-strobe-ncont-v2-1-9428bbb6347e@gmail.com> (raw)
In-Reply-To: <20261128-ov7251-strobe-ncont-v2-0-9428bbb6347e@gmail.com>
From: Robert Ijtsma <robertijtsma@gmail.com>
ov7251_set_power_on() writes software reset (0x0103 = 0x01) as the first
entry of ov7251_global_init_setting[] and immediately follows it with
the remaining common initialization registers.
Issue OV7251_SC_SOFTWARE_RESET explicitly and wait 5-10 ms for the
sensor to finish resetting before writing ov7251_global_init_setting[]
so subsequent I2C writes are not NACKed or lost during reset.
Fixes: d30bb512da3d ("media: Add a driver for the ov7251 camera sensor")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
drivers/media/i2c/ov7251.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
index 9e9bbee998ad..393260929f29 100644
--- a/drivers/media/i2c/ov7251.c
+++ b/drivers/media/i2c/ov7251.c
@@ -30,6 +30,8 @@
#define OV7251_SC_MODE_SELECT 0x0100
#define OV7251_SC_MODE_SELECT_SW_STANDBY 0x0
#define OV7251_SC_MODE_SELECT_STREAMING 0x1
+#define OV7251_SC_SOFTWARE_RESET 0x0103
+#define OV7251_SC_SOFTWARE_RESET_ASSERT 0x01
#define OV7251_CHIP_ID_HIGH 0x300a
#define OV7251_CHIP_ID_HIGH_BYTE 0x77
@@ -248,7 +250,6 @@ static const struct ov7251_pll_cfgs *ov7251_pll_cfgs[] = {
};
static const struct reg_value ov7251_global_init_setting[] = {
- { 0x0103, 0x01 },
{ 0x303b, 0x02 },
{ 0x3005, 0x00 },
{ 0x3012, 0xc0 },
@@ -698,17 +699,27 @@ static int ov7251_set_power_on(struct device *dev)
DIV_ROUND_UP(ov7251->xclk_freq, 1000));
usleep_range(wait_us, wait_us + 1000);
+ ret = ov7251_write_reg(ov7251, OV7251_SC_SOFTWARE_RESET,
+ OV7251_SC_SOFTWARE_RESET_ASSERT);
+ if (ret < 0)
+ goto err_power_off;
+
+ usleep_range(5000, 10000);
+
ret = ov7251_set_register_array(ov7251,
ov7251_global_init_setting,
ARRAY_SIZE(ov7251_global_init_setting));
if (ret < 0) {
dev_err(ov7251->dev, "error during global init\n");
- gpiod_set_value_cansleep(ov7251->enable_gpio, 0);
- clk_disable_unprepare(ov7251->xclk);
- ov7251_regulators_disable(ov7251);
- return ret;
+ goto err_power_off;
}
+ return 0;
+
+err_power_off:
+ gpiod_set_value_cansleep(ov7251->enable_gpio, 0);
+ clk_disable_unprepare(ov7251->xclk);
+ ov7251_regulators_disable(ov7251);
return ret;
}
--
2.56.0
next prev parent reply other threads:[~2026-11-28 20:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 20:41 [PATCH v2 0/3] media: i2c: ov7251: software reset settle, autosuspend, and non-continuous clock Robert Ijtsma via B4 Relay
2026-11-28 20:41 ` Robert Ijtsma via B4 Relay [this message]
2026-11-28 20:41 ` [PATCH v2 2/3] media: i2c: ov7251: use pm_runtime_put_autosuspend() Robert Ijtsma via B4 Relay
2026-11-28 20:41 ` [PATCH v2 3/3] media: i2c: ov7251: support non-continuous MIPI clock mode Robert Ijtsma via B4 Relay
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=20261128-ov7251-strobe-ncont-v2-1-9428bbb6347e@gmail.com \
--to=devnull+robertijtsma.gmail.com@kernel.org \
--cc=antoine.pichot@gmail.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=jacopo@jmondi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robertijtsma@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=todor.too@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
all inboxes | Powered by JetHome®