Re: [PATCH v1 00/55] media: Add a helper for obtaining the clock producer
From: Lad, Prabhakar
Date: Tue Jun 24 2025 - 16:35:47 EST
On Thu, Jun 19, 2025 at 7:00 PM Mehdi Djait <mehdi.djait@xxxxxxxxxxxxxxx> wrote:
>
> Hello everyone,
>
> Here is my v1 for the new helper v4l2_devm_sensor_clk_get()
>
> Any testing of the patches is GREATLY APPRECIATED! Especially the two
> drivers with the special ACPI case:
> 1) OV8865
> 2) OV2680
>
>
> Background
> ----------
>
> A reference to the clock producer is not available to the kernel
> in ACPI-based platforms but the sensor drivers still need them.
>
> devm_clk_get() will return an error and the probe function will fail.
>
>
> Solution
> --------
>
> Introduce a generic helper for v4l2 sensor drivers on both DT- and ACPI-based
> platforms.
>
> This helper behaves the same as clk_get_optional() except where there is
> no clock producer like in ACPI-based platforms.
>
> For ACPI-based platforms the function will read the "clock-frequency"
> ACPI _DSD property and register a fixed frequency clock with the frequency
> indicated in the property.
>
>
> Solution for special ACPI case
> ------------------------------
>
> This function also handles the special ACPI-based system case where:
>
> 1) The clock-frequency _DSD property is present.
> 2) A reference to the clock producer is present, where the clock is provided
> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>
> In this case try to set the clock-frequency value to the provided clock.
>
>
> RFC History
> -----------
>
> RFC v4 -> RFC v5:
> Suggested by Arnd Bergmann:
> - removed IS_REACHABLE(CONFIG_COMMON_CLK). IS_REACHABLE() is actually
> discouraged [1]. COFIG_COMMON_CLK is a bool, so IS_ENABLED() will be the
> right solution here
> Suggested by Hans de Goede:
> - added handling for the special ACPI-based system case, where
> both a reference to the clock-provider and the _DSD
> clock-frequency are present.
> - updated the function's kernel-doc and the commit msg
> to mention this special case.
> Link RFC v4: https://lore.kernel.org/linux-media/20250321130329.342236-1-mehdi.djait@xxxxxxxxxxxxxxx/
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/Documentation/kbuild/kconfig-language.rst?h=next-20250513&id=700bd25bd4f47a0f4e02e0a25dde05f1a6b16eea
>
> RFC v3 -> RFC v4:
> Suggested by Laurent:
> - removed the #ifdef to use IS_REACHABLE(CONFIG_COMMON_CLK)
> - changed to kasprintf() to allocate the clk name when id is NULL and
> used the __free(kfree) scope-based cleanup helper when
> defining the variable to hold the allocated name
> Link v3: https://lore.kernel.org/linux-media/20250321093814.18159-1-mehdi.djait@xxxxxxxxxxxxxxx/
>
> RFC v2 -> RFC v3:
> - Added #ifdef CONFIG_COMMON_CLK for the ACPI case
> Link v2: https://lore.kernel.org/linux-media/20250310122305.209534-1-mehdi.djait@xxxxxxxxxxxxxxx/
>
> RFC v1 -> RFC v2:
> Suggested by Sakari:
> - removed clk_name
> - removed the IS_ERR() check
> - improved the kernel-doc comment and commit msg
> Link v1: https://lore.kernel.org/linux-media/20250227092643.113939-1-mehdi.djait@xxxxxxxxxxxxxxx
>
> Mehdi Djait (55):
> media: v4l2-common: Add a helper for obtaining the clock producer
> Documentation: media: camera-sensor: Mention
> v4l2_devm_sensor_clk_get() for obtaining the clock
> media: i2c: imx219: Use the v4l2 helper for obtaining the clock
> media: i2c: mt9p031: Use the v4l2 helper for obtaining the clock
> media: i2c: ov2659: Use the v4l2 helper for obtaining the clock
> media: i2c: ov2685: Use the v4l2 helper for obtaining the clock
> media: i2c: ov5640: Use the v4l2 helper for obtaining the clock
> media: i2c: ov5645: Use the v4l2 helper for obtaining the clock
For all the above,
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
Cheers,
Prabhakar