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

62 lines
1.7 KiB
Diff

From 50f8948579fb2a24f4d8e6a42e7e1c9c2a07eccc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Fri, 22 Oct 2021 21:44:13 +0200
Subject: [PATCH 344/469] media: i2c: imx258: Add support for reset gpio
It was documented in DT, but not implemented.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/media/i2c/imx258.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index e7bbbd3093ca..fcff01eecbda 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -616,6 +616,7 @@ struct imx258 {
struct v4l2_ctrl *exposure;
struct gpio_desc *pwdn_gpio;
+ struct gpio_desc *reset_gpio;
/* Current mode */
const struct imx258_mode *cur_mode;
@@ -1021,7 +1022,11 @@ static int imx258_power_on(struct device *dev)
if (ret)
dev_err(dev, "failed to enable clock\n");
- return ret;
+ gpiod_set_value_cansleep(imx258->reset_gpio, 0);
+
+ usleep_range(400, 500);
+
+ return 0;
}
static int imx258_power_off(struct device *dev)
@@ -1031,6 +1036,7 @@ static int imx258_power_off(struct device *dev)
clk_disable_unprepare(imx258->clk);
+ gpiod_set_value_cansleep(imx258->reset_gpio, 1);
gpiod_set_value_cansleep(imx258->pwdn_gpio, 1);
return 0;
@@ -1316,6 +1322,12 @@ static int imx258_probe(struct i2c_client *client)
if (IS_ERR(imx258->pwdn_gpio))
return PTR_ERR(imx258->pwdn_gpio);
+ /* request optional reset pin */
+ imx258->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(imx258->reset_gpio))
+ return PTR_ERR(imx258->reset_gpio);
+
/* Initialize subdev */
v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops);
--
2.34.1