Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: ov5695: Use V4L2 legacy sensor clock helper

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 never been allowed. The "clocks" property is set in the
upstream DT sources and the "clock-frequency" property isn't. The driver
retrieves the clock and sets its rate to a fixed value. It then
retrieves the rate from the clock, and fails probing if the value
doesn't match. 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>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
0e14d99c 0f1e46fc

+2 -6
+2 -6
drivers/media/i2c/ov5695.c
··· 1264 1264 ov5695->client = client; 1265 1265 ov5695->cur_mode = &supported_modes[0]; 1266 1266 1267 - ov5695->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk"); 1267 + ov5695->xvclk = devm_v4l2_sensor_clk_get_legacy(dev, "xvclk", true, 1268 + OV5695_XVCLK_FREQ); 1268 1269 if (IS_ERR(ov5695->xvclk)) 1269 1270 return dev_err_probe(dev, PTR_ERR(ov5695->xvclk), 1270 1271 "Failed to get xvclk\n"); 1271 1272 1272 - ret = clk_set_rate(ov5695->xvclk, OV5695_XVCLK_FREQ); 1273 - if (ret < 0) { 1274 - dev_err(dev, "Failed to set xvclk rate (24MHz)\n"); 1275 - return ret; 1276 - } 1277 1273 if (clk_get_rate(ov5695->xvclk) != OV5695_XVCLK_FREQ) 1278 1274 dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n"); 1279 1275