From 2277fa71865dca6e2c06f74f8a8b081679fdc5a6 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Fri, 22 Oct 2021 21:44:13 +0200 Subject: [PATCH 469/478] media: i2c: imx258: Add support for reset gpio It was documented in DT, but not implemented. Signed-off-by: Ondrej Jirman --- 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 ab6dfe7509ee..111b07e90c71 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; @@ -1303,6 +1309,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.35.3