diff options
author | Matthias Fend <matthias.fend@emfend.at> | 2025-06-12 08:54:12 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2025-06-30 09:06:21 +0200 |
commit | 03dca1842421b068d6a65b8ae16e2191882c7753 (patch) | |
tree | 214e00367b0d989e1c09ddc439eedf84dbbb1d14 | |
parent | 1eefe42e9de503e422a9c925eebdbd215ee28966 (diff) |
media: dw9714: add support for powerdown pin
Add support for the powerdown pin (xSD), which can be used to put the VCM
driver into power down mode. This is useful, for example, if the VCM
driver's power supply cannot be controlled. The use of the powerdown pin is
optional.
Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r-- | drivers/media/i2c/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/i2c/dw9714.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 43e39bf22b6b..4b4c199da6ea 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -792,7 +792,7 @@ config VIDEO_AK7375 config VIDEO_DW9714 tristate "DW9714 lens voice coil support" - depends on I2C && VIDEO_DEV + depends on GPIOLIB && I2C && VIDEO_DEV select MEDIA_CONTROLLER select VIDEO_V4L2_SUBDEV_API select V4L2_ASYNC diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c index 2abd4fb5e7c0..1e7ad355a388 100644 --- a/drivers/media/i2c/dw9714.c +++ b/drivers/media/i2c/dw9714.c @@ -2,6 +2,7 @@ // Copyright (c) 2015--2017 Intel Corporation. #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/module.h> #include <linux/pm_runtime.h> @@ -38,6 +39,7 @@ struct dw9714_device { struct v4l2_subdev sd; u16 current_val; struct regulator *vcc; + struct gpio_desc *powerdown_gpio; }; static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl *ctrl) @@ -145,6 +147,8 @@ static int dw9714_power_up(struct dw9714_device *dw9714_dev) if (ret) return ret; + gpiod_set_value_cansleep(dw9714_dev->powerdown_gpio, 0); + usleep_range(1000, 2000); return 0; @@ -152,6 +156,8 @@ static int dw9714_power_up(struct dw9714_device *dw9714_dev) static int dw9714_power_down(struct dw9714_device *dw9714_dev) { + gpiod_set_value_cansleep(dw9714_dev->powerdown_gpio, 1); + return regulator_disable(dw9714_dev->vcc); } @@ -169,6 +175,14 @@ static int dw9714_probe(struct i2c_client *client) if (IS_ERR(dw9714_dev->vcc)) return PTR_ERR(dw9714_dev->vcc); + dw9714_dev->powerdown_gpio = devm_gpiod_get_optional(&client->dev, + "powerdown", + GPIOD_OUT_HIGH); + if (IS_ERR(dw9714_dev->powerdown_gpio)) + return dev_err_probe(&client->dev, + PTR_ERR(dw9714_dev->powerdown_gpio), + "could not get powerdown gpio\n"); + rval = dw9714_power_up(dw9714_dev); if (rval) return dev_err_probe(&client->dev, rval, |