]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: i2c: s5k6a3: Use V4L2 legacy sensor clock helper
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 12 Aug 2025 21:46:10 +0000 (00:46 +0300)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 9 Sep 2025 13:59:20 +0000 (15:59 +0200)
Several camera sensor drivers access the "clock-frequency" property
directly to retrieve the external clock rate, or modify the clock rate
of the external clock programmatically. Both behaviours are valid on a
subset of ACPI platforms, but are considered deprecated on OF platforms,
and do not support ACPI platforms that implement MIPI DisCo for Imaging.
Implementing them manually in drivers is deprecated, as that can
encourage copying deprecated behaviour for OF platforms in new drivers,
and lead to differences in behaviour between drivers. Instead, drivers
that need to preserve the deprecated OF behaviour should use the
devm_v4l2_sensor_clk_get_legacy() helper.

This driver supports OF platforms only. The "clocks" property has always
been specified as mandatory in the DT bindings and the "clock-frequency"
property has initially been optional. Both properties were initially set
in the upstream DT sources. The driver retrieves the clock, retrieves
the clock rate from the "clock-frequency" property if available or uses
a fixed default otherwise, and sets the clock rate. This is deprecated
behaviour for OF.

Switch to using the devm_v4l2_sensor_clk_get_legacy() helper. This
preserves setting the clock rate on OF platforms. Should support for OF
platforms that set the clock rate through clock-frequency be considered
unneeded in the future, the driver will only need to switch to
devm_v4l2_sensor_clk_get() without any other change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/s5k6a3.c

index 4bf5f122b113b23e86b33a92b8fb77fbac40d03b..ba6477e88da36f8102268d4c024b78f840083ed9 100644 (file)
@@ -51,7 +51,6 @@ enum {
  * @lock: mutex protecting the structure's members below
  * @format: media bus format at the sensor's source pad
  * @clock: pointer to &struct clk.
- * @clock_frequency: clock frequency
  * @power_count: stores state if device is powered
  */
 struct s5k6a3 {
@@ -63,7 +62,6 @@ struct s5k6a3 {
        struct mutex lock;
        struct v4l2_mbus_framefmt format;
        struct clk *clock;
-       u32 clock_frequency;
        int power_count;
 };
 
@@ -192,10 +190,6 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor)
        int i = S5K6A3_SUPP_VDDA;
        int ret;
 
-       ret = clk_set_rate(sensor->clock, sensor->clock_frequency);
-       if (ret < 0)
-               return ret;
-
        ret = pm_runtime_get(sensor->dev);
        if (ret < 0)
                goto error_rpm_put;
@@ -292,7 +286,9 @@ static int s5k6a3_probe(struct i2c_client *client)
        mutex_init(&sensor->lock);
        sensor->dev = dev;
 
-       sensor->clock = devm_v4l2_sensor_clk_get(sensor->dev, S5K6A3_CLK_NAME);
+       sensor->clock = devm_v4l2_sensor_clk_get_legacy(sensor->dev,
+                                                       S5K6A3_CLK_NAME, false,
+                                                       S5K6A3_DEFAULT_CLK_FREQ);
        if (IS_ERR(sensor->clock))
                return dev_err_probe(sensor->dev, PTR_ERR(sensor->clock),
                                     "failed to get extclk\n");
@@ -302,13 +298,6 @@ static int s5k6a3_probe(struct i2c_client *client)
        if (ret)
                return ret;
 
-       if (of_property_read_u32(dev->of_node, "clock-frequency",
-                                &sensor->clock_frequency)) {
-               sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ;
-               dev_info(dev, "using default %u Hz clock frequency\n",
-                                       sensor->clock_frequency);
-       }
-
        for (i = 0; i < S5K6A3_NUM_SUPPLIES; i++)
                sensor->supplies[i].supply = s5k6a3_supply_names[i];