Re: [PATCH v1 00/55] media: Add a helper for obtaining the clock producer

From: Hans de Goede
Date: Sun Jun 22 2025 - 07:45:43 EST


Hi,

On 21-Jun-25 4:28 PM, Michael Riesch wrote:
> Hi Mehdi,
>
> Thanks for your work!
>
> On 6/19/25 19:58, Mehdi Djait 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.
>
> Out of curiosity: How is this problem specific to V4L2? Does one need a
> similar helper in other subsystems?

Clocks on ACPI platforms are typically managed by ACPI through either
ACPI power-resources or through the _PS0 an _PS3 methods (power on/off)
on the ACPI fwnode for the device.

Camera sensors are special in that the sensor driver wants to know
the clock frequency to e.g. program its PLLs and that clk-freq is
specified through a device-property on ACPI since the clk is
otherwise typically not managed by Linux.

Most other drivers used on x86 don't really care about the clk-frequency,
they simply assume the clk-freq is what the hw needs / is the default
expected clk freq.

Regards,

Hans