57 lines
1.6 KiB
Diff
57 lines
1.6 KiB
Diff
From: Ondrej Jirman <megous@megous.com>
|
|
Date: Fri, 22 Oct 2021 18:10:18 +0200
|
|
Subject: [PATCH 20/36] media: i2c: imx258: Add support for powerdown gpio
|
|
|
|
On some boards powerdown signal needs to be deasserted for this
|
|
sensor to be enabled.
|
|
|
|
Signed-off-by: Ondrej Jirman <megous@megous.com>
|
|
---
|
|
drivers/media/i2c/imx258.c | 12 ++++++++++++
|
|
1 file changed, 12 insertions(+)
|
|
|
|
diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
|
|
index c249507..be5adcc 100644
|
|
--- a/drivers/media/i2c/imx258.c
|
|
+++ b/drivers/media/i2c/imx258.c
|
|
@@ -612,6 +612,8 @@ struct imx258 {
|
|
struct v4l2_ctrl *hblank;
|
|
struct v4l2_ctrl *exposure;
|
|
|
|
+ struct gpio_desc *pwdn_gpio;
|
|
+
|
|
/* Current mode */
|
|
const struct imx258_mode *cur_mode;
|
|
|
|
@@ -1010,6 +1012,8 @@ static int imx258_power_on(struct device *dev)
|
|
struct imx258 *imx258 = to_imx258(sd);
|
|
int ret;
|
|
|
|
+ gpiod_set_value_cansleep(imx258->pwdn_gpio, 0);
|
|
+
|
|
ret = clk_prepare_enable(imx258->clk);
|
|
if (ret)
|
|
dev_err(dev, "failed to enable clock\n");
|
|
@@ -1024,6 +1028,8 @@ static int imx258_power_off(struct device *dev)
|
|
|
|
clk_disable_unprepare(imx258->clk);
|
|
|
|
+ gpiod_set_value_cansleep(imx258->pwdn_gpio, 1);
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -1284,6 +1290,12 @@ static int imx258_probe(struct i2c_client *client)
|
|
if (ret || val != 180)
|
|
return -EINVAL;
|
|
|
|
+ /* request optional power down pin */
|
|
+ imx258->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
|
|
+ GPIOD_OUT_HIGH);
|
|
+ if (IS_ERR(imx258->pwdn_gpio))
|
|
+ return PTR_ERR(imx258->pwdn_gpio);
|
|
+
|
|
/* Initialize subdev */
|
|
v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops);
|
|
|