build/patch/kernel/archive/sunxi-6.5/patches.megous/media-i2c-imx258-Add-support-for-powerdown-gpio.patch

61 lines
1.7 KiB
Diff
Raw Normal View History

From fd09cde97972b965a729d23b0e42eed41171eeee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Fri, 22 Oct 2021 18:10:18 +0200
Subject: [PATCH 330/464] 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 <megi@xff.cz>
---
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 e196565e846e..2c0e691466fe 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -613,6 +613,8 @@ struct imx258 {
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *exposure;
+ struct gpio_desc *pwdn_gpio;
+
/* Current mode */
const struct imx258_mode *cur_mode;
@@ -1011,6 +1013,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");
@@ -1025,6 +1029,8 @@ static int imx258_power_off(struct device *dev)
clk_disable_unprepare(imx258->clk);
+ gpiod_set_value_cansleep(imx258->pwdn_gpio, 1);
+
return 0;
}
@@ -1299,6 +1305,12 @@ static int imx258_probe(struct i2c_client *client)
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);
--
2.34.1