gjdwebserver-overlay/sys-kernel/pinephone-sources/files/0029-media-i2c-imx258-Add-support-for-reset-gpio.patch
2022-01-10 13:52:54 +01:00

58 lines
1.6 KiB
Diff

From: Ondrej Jirman <megous@megous.com>
Date: Fri, 22 Oct 2021 21:44:13 +0200
Subject: [PATCH 22/36] media: i2c: imx258: Add support for reset gpio
It was documented in DT, but not implemented.
Signed-off-by: Ondrej Jirman <megous@megous.com>
---
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 e64fadc..ec6e919 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -615,6 +615,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;
@@ -1020,7 +1021,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)
@@ -1030,6 +1035,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;
@@ -1301,6 +1307,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);