]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: i2c: s5c73m3: Use V4L2 legacy sensor clock helper
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 12 Aug 2025 21:46:08 +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. No DT bindings are available.
The "clocks" and "clock-frequency" properties were initially both 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/s5c73m3/s5c73m3-core.c
drivers/media/i2c/s5c73m3/s5c73m3.h

index 088184da5dea4c0c81bb314c69713dbbacb004e2..ab31ee2b596b214f982889cbfff051b5ff687b80 100644 (file)
@@ -1368,10 +1368,6 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)
                        goto err_reg_dis;
        }
 
-       ret = clk_set_rate(state->clock, state->mclk_frequency);
-       if (ret < 0)
-               goto err_reg_dis;
-
        ret = clk_prepare_enable(state->clock);
        if (ret < 0)
                goto err_reg_dis;
@@ -1556,19 +1552,14 @@ static int s5c73m3_get_dt_data(struct s5c73m3 *state)
        if (!node)
                return -EINVAL;
 
-       state->clock = devm_v4l2_sensor_clk_get(dev, S5C73M3_CLK_NAME);
+       state->clock = devm_v4l2_sensor_clk_get_legacy(dev, S5C73M3_CLK_NAME,
+                                                      false,
+                                                      S5C73M3_DEFAULT_MCLK_FREQ);
        if (IS_ERR(state->clock))
                return dev_err_probe(dev, PTR_ERR(state->clock),
                                     "Failed to get the clock %s\n",
                                     S5C73M3_CLK_NAME);
 
-       if (of_property_read_u32(node, "clock-frequency",
-                                &state->mclk_frequency)) {
-               state->mclk_frequency = S5C73M3_DEFAULT_MCLK_FREQ;
-               dev_info(dev, "using default %u Hz clock frequency\n",
-                                       state->mclk_frequency);
-       }
-
        /* Request GPIO lines asserted */
        state->stby = devm_gpiod_get(dev, "standby", GPIOD_OUT_HIGH);
        if (IS_ERR(state->stby))
index 627e80cf5b724c421f350025402031ea1079741e..68a19c2c8db8d2c9adc86a8792cdc58e84e201a3 100644 (file)
@@ -382,8 +382,6 @@ struct s5c73m3 {
 
        struct clk *clock;
 
-       /* External master clock frequency */
-       u32 mclk_frequency;
        /* Video bus type - MIPI-CSI2/parallel */
        enum v4l2_mbus_type bus_type;