summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-12-04 15:39:39 +0300
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2023-12-13 15:21:20 +0300
commit846a37cf470f489ad1713e143083d17630c73056 (patch)
tree1c07898394a09b9148960b88fbc285265a0a2610 /drivers/media
parent1a140854bc8c9d258ddb31912b80f63faf760144 (diff)
downloadlinux-846a37cf470f489ad1713e143083d17630c73056.tar.xz
media: ov2740: Add support for external clock
On some ACPI platforms, such as Chromebooks the ACPI methods to change the power-state (_PS0 and _PS3) fully take care of powering on/off the sensor. On other ACPI platforms, such as e.g. various ThinkPad models with IPU6 + ov2740 sensor, the sensor driver must control the reset GPIO and the sensor's clock itself. Add support for having the driver control an optional clock. Reviewed-by: Bingbu Cao <bingbu.cao@intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/ov2740.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index fef1b6f3f316..653cd96bb156 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -3,6 +3,7 @@
#include <asm/unaligned.h>
#include <linux/acpi.h>
+#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
@@ -336,6 +337,7 @@ struct ov2740 {
/* GPIOs, clocks */
struct gpio_desc *reset_gpio;
+ struct clk *clk;
/* Current mode */
const struct ov2740_mode *cur_mode;
@@ -1071,6 +1073,7 @@ static int ov2740_suspend(struct device *dev)
struct ov2740 *ov2740 = to_ov2740(sd);
gpiod_set_value_cansleep(ov2740->reset_gpio, 1);
+ clk_disable_unprepare(ov2740->clk);
return 0;
}
@@ -1078,6 +1081,11 @@ static int ov2740_resume(struct device *dev)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct ov2740 *ov2740 = to_ov2740(sd);
+ int ret;
+
+ ret = clk_prepare_enable(ov2740->clk);
+ if (ret)
+ return ret;
gpiod_set_value_cansleep(ov2740->reset_gpio, 0);
msleep(20);
@@ -1105,6 +1113,11 @@ static int ov2740_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(ov2740->reset_gpio),
"failed to get reset GPIO\n");
+ ov2740->clk = devm_clk_get_optional(dev, "clk");
+ if (IS_ERR(ov2740->clk))
+ return dev_err_probe(dev, PTR_ERR(ov2740->clk),
+ "failed to get clock\n");
+
v4l2_i2c_subdev_init(&ov2740->sd, client, &ov2740_subdev_ops);
ov2740->sd.internal_ops = &ov2740_internal_ops;
full_power = acpi_dev_state_d0(&client->dev);