[PATCH v1 19/55] media: i2c: imx415: Use the v4l2 helper for obtaining the clock

Mehdi Djait posted 55 patches 3 months, 3 weeks ago
[PATCH v1 19/55] media: i2c: imx415: Use the v4l2 helper for obtaining the clock
Posted by Mehdi Djait 3 months, 3 weeks ago
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.

Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.

Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>

diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index 9f37779bd611..f7897660f44f 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -1251,7 +1251,7 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
 		return dev_err_probe(sensor->dev, PTR_ERR(sensor->reset),
 				     "failed to get reset GPIO\n");
 
-	sensor->clk = devm_clk_get(sensor->dev, "inck");
+	sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, "inck");
 	if (IS_ERR(sensor->clk))
 		return dev_err_probe(sensor->dev, PTR_ERR(sensor->clk),
 				     "failed to get clock\n");
Re: [PATCH v1 19/55] media: i2c: imx415: Use the v4l2 helper for obtaining the clock
Posted by Michael Riesch 3 months, 2 weeks ago
Hi Mehdi,

Thanks for your patch!

On 6/19/25 19:59, Mehdi Djait wrote:
> devm_clk_get() fails on ACPI-based platforms, where firmware does not
> provide a direct reference to the clock producer.
> 
> Replace devm_clk_get() with the new v4l2 helper
> devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
> 
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> 
> diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
> index 9f37779bd611..f7897660f44f 100644
> --- a/drivers/media/i2c/imx415.c
> +++ b/drivers/media/i2c/imx415.c
> @@ -1251,7 +1251,7 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
>  		return dev_err_probe(sensor->dev, PTR_ERR(sensor->reset),
>  				     "failed to get reset GPIO\n");
>  
> -	sensor->clk = devm_clk_get(sensor->dev, "inck");
> +	sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, "inck");

Matthias Fend discovered a while ago that the driver is not in agreement
with the DT binding, which does not require a certain clock name.
However, the corresponding patch [0] has not landed in v6.16-rc1 AFAIK.

Can we translate the line above directly to
    sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, NULL);
?

Best regards,
Michael

>  	if (IS_ERR(sensor->clk))
>  		return dev_err_probe(sensor->dev, PTR_ERR(sensor->clk),
>  				     "failed to get clock\n");


[0] https://lore.kernel.org/all/20250514-imx415-v1-1-bb29fa622bb1@emfend.at/