[PATCH RFC v2 15/16] media: imx219: Allow driver probe with missing sensor
From: Mattijs Korpershoek
Date: Wed Nov 18 2026 - 07:44:47 EST
When media fault tolerance is enabled, probe() should complete even when
a sensor is disconnected.
Currently, the driver reads the CHIP_ID over i2c in the probe().
When we can't read CHIP_ID, the probe errors out, which result in the
v4l2-subdev not being created.
Extract imx219_read_chip_id() from imx219_identify_module() so that
probe can distinguish an unreachable sensor (I2C read failure) from a
wrong sensor (CHIP_ID mismatch).
When the sensor is unreachable, skip the LP-11 state initialization and
continue probe so the v4l2-subdev and media entity are created.
Note that a CHIP_ID mismatch remains a fatal error.
Signed-off-by: Mattijs Korpershoek <mkorpershoek@xxxxxxxxxx>
---
drivers/media/i2c/imx219.c | 74 ++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 38 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 1580562093e8..02d065fb88d0 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1099,25 +1099,9 @@ static int imx219_get_regulators(struct imx219 *imx219)
imx219->supplies);
}
-/* Verify chip ID */
-static int imx219_identify_module(struct imx219 *imx219)
+static int imx219_read_chip_id(struct imx219 *imx219, u64 *chip_id)
{
- struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
- int ret;
- u64 val;
-
- ret = cci_read(imx219->regmap, IMX219_REG_CHIP_ID, &val, NULL);
- if (ret)
- return dev_err_probe(&client->dev, ret,
- "failed to read chip id %x\n",
- IMX219_CHIP_ID);
-
- if (val != IMX219_CHIP_ID)
- return dev_err_probe(&client->dev, -EIO,
- "chip id mismatch: %x!=%llx\n",
- IMX219_CHIP_ID, val);
-
- return 0;
+ return cci_read(imx219->regmap, IMX219_REG_CHIP_ID, chip_id, NULL);
}
static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)
@@ -1194,6 +1178,7 @@ static int imx219_probe(struct i2c_client *client)
struct device *dev = &client->dev;
struct imx219 *imx219;
int ret;
+ u64 val;
imx219 = devm_kzalloc(&client->dev, sizeof(*imx219), GFP_KERNEL);
if (!imx219)
@@ -1235,36 +1220,49 @@ static int imx219_probe(struct i2c_client *client)
"failed to get reset gpio\n");
/*
- * The sensor must be powered for imx219_identify_module()
+ * The sensor must be powered for imx219_read_chip_id()
* to be able to read the CHIP_ID register
*/
ret = imx219_power_on(dev);
if (ret)
return ret;
- ret = imx219_identify_module(imx219);
- if (ret)
- goto error_power_off;
-
- /*
- * Sensor doesn't enter LP-11 state upon power up until and unless
- * streaming is started, so upon power up switch the modes to:
- * streaming -> standby
- */
- ret = cci_write(imx219->regmap, IMX219_REG_MODE_SELECT,
- IMX219_MODE_STREAMING, NULL);
- if (ret < 0)
+ /* Verify chip ID */
+ ret = imx219_read_chip_id(imx219, &val);
+ if (ret) {
+ if (!media_fault_tolerance_enabled()) {
+ dev_err_probe(&client->dev, ret,
+ "failed to read chip id %x\n",
+ IMX219_CHIP_ID);
+ goto error_power_off;
+ }
+ dev_dbg(&client->dev, "failed to read chip id %x\n", IMX219_CHIP_ID);
+ } else if (val != IMX219_CHIP_ID) {
+ ret = dev_err_probe(&client->dev, -EIO,
+ "chip id mismatch: %x!=%llx\n",
+ IMX219_CHIP_ID, val);
goto error_power_off;
+ } else {
+ /*
+ * Sensor doesn't enter LP-11 state upon power up until and unless
+ * streaming is started, so upon power up switch the modes to:
+ * streaming -> standby
+ */
+ ret = cci_write(imx219->regmap, IMX219_REG_MODE_SELECT,
+ IMX219_MODE_STREAMING, NULL);
+ if (ret < 0)
+ goto error_power_off;
- usleep_range(100, 110);
+ usleep_range(100, 110);
- /* put sensor back to standby mode */
- ret = cci_write(imx219->regmap, IMX219_REG_MODE_SELECT,
- IMX219_MODE_STANDBY, NULL);
- if (ret < 0)
- goto error_power_off;
+ /* put sensor back to standby mode */
+ ret = cci_write(imx219->regmap, IMX219_REG_MODE_SELECT,
+ IMX219_MODE_STANDBY, NULL);
+ if (ret < 0)
+ goto error_power_off;
- usleep_range(100, 110);
+ usleep_range(100, 110);
+ }
ret = imx219_init_controls(imx219);
if (ret)
--
2.56.0