Skip to content

Commit 1cb7b39

Browse files
Vladimir ZapolskiyHans Verkuil
authored andcommitted
media: i2c: og01a1b: Add management of optional reset GPIO
Omnivision OG01A1B camera sensor may have a connected active low GPIO to XSHUTDOWN pad, and if so, include it into sensor power up sequence. Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent a95ffde commit 1cb7b39

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

drivers/media/i2c/og01a1b.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/acpi.h>
66
#include <linux/clk.h>
77
#include <linux/delay.h>
8+
#include <linux/gpio/consumer.h>
89
#include <linux/i2c.h>
910
#include <linux/module.h>
1011
#include <linux/pm_runtime.h>
@@ -420,6 +421,7 @@ static const struct og01a1b_mode supported_modes[] = {
420421

421422
struct og01a1b {
422423
struct clk *xvclk;
424+
struct gpio_desc *reset_gpio;
423425

424426
struct v4l2_subdev sd;
425427
struct media_pad pad;
@@ -987,7 +989,11 @@ static int og01a1b_power_on(struct device *dev)
987989
if (ret)
988990
return ret;
989991

990-
if (og01a1b->xvclk)
992+
gpiod_set_value_cansleep(og01a1b->reset_gpio, 0);
993+
994+
if (og01a1b->reset_gpio)
995+
usleep_range(5 * USEC_PER_MSEC, 6 * USEC_PER_MSEC);
996+
else if (og01a1b->xvclk)
991997
usleep_range(delay, 2 * delay);
992998

993999
return 0;
@@ -1004,6 +1010,8 @@ static int og01a1b_power_off(struct device *dev)
10041010

10051011
clk_disable_unprepare(og01a1b->xvclk);
10061012

1013+
gpiod_set_value_cansleep(og01a1b->reset_gpio, 1);
1014+
10071015
return 0;
10081016
}
10091017

@@ -1044,6 +1052,13 @@ static int og01a1b_probe(struct i2c_client *client)
10441052
return ret;
10451053
}
10461054

1055+
og01a1b->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
1056+
GPIOD_OUT_LOW);
1057+
if (IS_ERR(og01a1b->reset_gpio)) {
1058+
dev_err(&client->dev, "cannot get reset GPIO\n");
1059+
return PTR_ERR(og01a1b->reset_gpio);
1060+
}
1061+
10471062
/* The sensor must be powered on to read the CHIP_ID register */
10481063
ret = og01a1b_power_on(&client->dev);
10491064
if (ret)

0 commit comments

Comments
 (0)