mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
media: imx335: Fix reset-gpio handling
[ Upstream commit 99d30e2fdea4086be4e66e2deb10de854b547ab8 ]
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: stable@vger.kernel.org
Fixes: 45d19b5fb9 ("media: i2c: Add imx335 camera sensor driver")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/linux-media/20240729110437.199428-1-umang.jain@ideasonboard.com/
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1f66f02929
commit
fb4c3e7120
@@ -792,7 +792,7 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
|
|||||||
|
|
||||||
/* Request optional reset pin */
|
/* Request optional reset pin */
|
||||||
imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset",
|
imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset",
|
||||||
GPIOD_OUT_LOW);
|
GPIOD_OUT_HIGH);
|
||||||
if (IS_ERR(imx335->reset_gpio)) {
|
if (IS_ERR(imx335->reset_gpio)) {
|
||||||
dev_err(imx335->dev, "failed to get reset gpio %ld",
|
dev_err(imx335->dev, "failed to get reset gpio %ld",
|
||||||
PTR_ERR(imx335->reset_gpio));
|
PTR_ERR(imx335->reset_gpio));
|
||||||
@@ -898,8 +898,7 @@ static int imx335_power_on(struct device *dev)
|
|||||||
|
|
||||||
usleep_range(500, 550); /* Tlow */
|
usleep_range(500, 550); /* Tlow */
|
||||||
|
|
||||||
/* Set XCLR */
|
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
|
||||||
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(imx335->inclk);
|
ret = clk_prepare_enable(imx335->inclk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -912,7 +911,7 @@ static int imx335_power_on(struct device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_reset:
|
error_reset:
|
||||||
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
|
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
|
||||||
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
|
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -929,7 +928,7 @@ static int imx335_power_off(struct device *dev)
|
|||||||
struct v4l2_subdev *sd = dev_get_drvdata(dev);
|
struct v4l2_subdev *sd = dev_get_drvdata(dev);
|
||||||
struct imx335 *imx335 = to_imx335(sd);
|
struct imx335 *imx335 = to_imx335(sd);
|
||||||
|
|
||||||
gpiod_set_value_cansleep(imx335->reset_gpio, 0);
|
gpiod_set_value_cansleep(imx335->reset_gpio, 1);
|
||||||
clk_disable_unprepare(imx335->inclk);
|
clk_disable_unprepare(imx335->inclk);
|
||||||
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
|
regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user