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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Matthias Fend and committed by
Hans Verkuil
03dca184 1eefe42e

+15 -1
+1 -1
drivers/media/i2c/Kconfig
··· 792 792 793 793 config VIDEO_DW9714 794 794 tristate "DW9714 lens voice coil support" 795 - depends on I2C && VIDEO_DEV 795 + depends on GPIOLIB && I2C && VIDEO_DEV 796 796 select MEDIA_CONTROLLER 797 797 select VIDEO_V4L2_SUBDEV_API 798 798 select V4L2_ASYNC
+14
drivers/media/i2c/dw9714.c
··· 2 2 // Copyright (c) 2015--2017 Intel Corporation. 3 3 4 4 #include <linux/delay.h> 5 + #include <linux/gpio/consumer.h> 5 6 #include <linux/i2c.h> 6 7 #include <linux/module.h> 7 8 #include <linux/pm_runtime.h> ··· 39 38 struct v4l2_subdev sd; 40 39 u16 current_val; 41 40 struct regulator *vcc; 41 + struct gpio_desc *powerdown_gpio; 42 42 }; 43 43 44 44 static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl *ctrl) ··· 147 145 if (ret) 148 146 return ret; 149 147 148 + gpiod_set_value_cansleep(dw9714_dev->powerdown_gpio, 0); 149 + 150 150 usleep_range(1000, 2000); 151 151 152 152 return 0; ··· 156 152 157 153 static int dw9714_power_down(struct dw9714_device *dw9714_dev) 158 154 { 155 + gpiod_set_value_cansleep(dw9714_dev->powerdown_gpio, 1); 156 + 159 157 return regulator_disable(dw9714_dev->vcc); 160 158 } 161 159 ··· 174 168 dw9714_dev->vcc = devm_regulator_get(&client->dev, "vcc"); 175 169 if (IS_ERR(dw9714_dev->vcc)) 176 170 return PTR_ERR(dw9714_dev->vcc); 171 + 172 + dw9714_dev->powerdown_gpio = devm_gpiod_get_optional(&client->dev, 173 + "powerdown", 174 + GPIOD_OUT_HIGH); 175 + if (IS_ERR(dw9714_dev->powerdown_gpio)) 176 + return dev_err_probe(&client->dev, 177 + PTR_ERR(dw9714_dev->powerdown_gpio), 178 + "could not get powerdown gpio\n"); 177 179 178 180 rval = dw9714_power_up(dw9714_dev); 179 181 if (rval)