From: Martin Hecht <mhecht73@gmail.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, michael.roeder@avnet.eu,
martin.hecht@avnet.eu, Martin Hecht <mhecht73@gmail.com>,
Tommaso Merciai <tomm.merciai@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] media: i2c: alvium: Accelerated alvium_set_power
Date: Tue, 9 Sep 2025 13:22:51 +0200 [thread overview]
Message-ID: <20250909112252.2577949-1-mhecht73@gmail.com> (raw)
Now alvium_set_power tests if Alvium is up and running already
instead of waiting for the period of a full reboot. This safes
about 5-7 seconds delay for each connected camera what is already
booted especially when using multiple Alvium cameras or using
camera arrays.
The new function alvium_check is used by read_poll_timeout to check
whether a camera is connected on I2C and if it responds already.
Signed-off-by: Martin Hecht <mhecht73@gmail.com>
---
v2:
- added alvium_check to be used by read_poll_timeout as
suggested by Sakari
---
drivers/media/i2c/alvium-csi2.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c
index 5c1bab574394..c63af96d3b31 100644
--- a/drivers/media/i2c/alvium-csi2.c
+++ b/drivers/media/i2c/alvium-csi2.c
@@ -443,10 +443,8 @@ static int alvium_is_alive(struct alvium_dev *alvium)
alvium_read(alvium, REG_BCRM_MINOR_VERSION_R, &bcrm, &ret);
alvium_read(alvium, REG_BCRM_HEARTBEAT_RW, &hbeat, &ret);
- if (ret)
- return ret;
- return hbeat;
+ return ret;
}
static void alvium_print_avail_mipi_fmt(struct alvium_dev *alvium)
@@ -2364,8 +2362,25 @@ static int alvium_get_dt_data(struct alvium_dev *alvium)
return -EINVAL;
}
+static int alvium_check(struct alvium_dev *alvium, u64 *bcrm_major)
+{
+ struct device *dev = &alvium->i2c_client->dev;
+ int ret = 0;
+
+ ret = alvium_read(alvium, REG_BCRM_MAJOR_VERSION_R, bcrm_major, NULL);
+
+ if (ret)
+ return ret;
+
+ if (*bcrm_major != 0)
+ return 0;
+
+ return -ENODEV;
+}
+
static int alvium_set_power(struct alvium_dev *alvium, bool on)
{
+ u64 bcrm_major = 0;
int ret;
if (!on)
@@ -2375,9 +2390,12 @@ static int alvium_set_power(struct alvium_dev *alvium, bool on)
if (ret)
return ret;
- /* alvium boot time 7s */
- msleep(7000);
- return 0;
+ /* alvium boot time is up to 7.5s but test if its available already */
+ read_poll_timeout(alvium_check, bcrm_major, (bcrm_major == 0),
+ 250000, 7500000, false,
+ alvium, &bcrm_major);
+
+ return ret;
}
static int alvium_runtime_resume(struct device *dev)
@@ -2442,7 +2460,7 @@ static int alvium_probe(struct i2c_client *client)
if (ret)
goto err_powerdown;
- if (!alvium_is_alive(alvium)) {
+ if (alvium_is_alive(alvium)) {
ret = -ENODEV;
dev_err_probe(dev, ret, "Device detection failed\n");
goto err_powerdown;
--
2.43.0
next reply other threads:[~2025-09-09 11:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 11:22 Martin Hecht [this message]
2025-09-10 2:31 ` [PATCH v2] media: i2c: alvium: Accelerated alvium_set_power kernel test robot
2025-09-10 15:09 ` Sakari Ailus
2025-09-10 17:17 ` Martin Hecht
2025-09-11 6:39 ` Sakari Ailus
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=20250909112252.2577949-1-mhecht73@gmail.com \
--to=mhecht73@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=martin.hecht@avnet.eu \
--cc=mchehab@kernel.org \
--cc=michael.roeder@avnet.eu \
--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