Skip to content

Commit 99d30e2

Browse files
Umang JainHans Verkuil
authored andcommitted
media: imx335: Fix reset-gpio handling
Rectify the logical value of reset-gpio so that it is set to 0 (disabled) during power-on and to 1 (enabled) during power-off. Set the reset-gpio to GPIO_OUT_HIGH at initialization time to make sure it starts off in reset. Also drop the "Set XCLR" comment which is not-so-informative. The existing usage of imx335 had reset-gpios polarity inverted (GPIO_ACTIVE_HIGH) in their device-tree sources. With this patch included, those DTS will not be able to stream imx335 anymore. The reset-gpio polarity will need to be rectified in the device-tree sources as shown in [1] example, in order to get imx335 functional again (as it remains in reset prior to this fix). Cc: [email protected] Fixes: 45d19b5 ("media: i2c: Add imx335 camera sensor driver") Reviewed-by: Laurent Pinchart <[email protected]> Link: https://lore.kernel.org/linux-media/[email protected]/ Signed-off-by: Umang Jain <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 84ea288 commit 99d30e2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/media/i2c/imx335.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
997997

998998
/* Request optional reset pin */
999999
imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset",
1000-
GPIOD_OUT_LOW);
1000+
GPIOD_OUT_HIGH);
10011001
if (IS_ERR(imx335->reset_gpio)) {
10021002
dev_err(imx335->dev, "failed to get reset gpio %ld\n",
10031003
PTR_ERR(imx335->reset_gpio));
@@ -1110,8 +1110,7 @@ static int imx335_power_on(struct device *dev)
11101110

11111111
usleep_range(500, 550); /* Tlow */
11121112

1113-
/* Set XCLR */
1114-
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
1113+
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
11151114

11161115
ret = clk_prepare_enable(imx335->inclk);
11171116
if (ret) {
@@ -1124,7 +1123,7 @@ static int imx335_power_on(struct device *dev)
11241123
return 0;
11251124

11261125
error_reset:
1127-
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
1126+
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
11281127
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
11291128

11301129
return ret;
@@ -1141,7 +1140,7 @@ static int imx335_power_off(struct device *dev)
11411140
struct v4l2_subdev *sd = dev_get_drvdata(dev);
11421141
struct imx335 *imx335 = to_imx335(sd);
11431142

1144-
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
1143+
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
11451144
clk_disable_unprepare(imx335->inclk);
11461145
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
11471146

0 commit comments

Comments
 (0)