Skip to contentSkip to conversation

media: hi556: Add support for powerdown GPIO

PATCH New Ivaylo Ilchev 1 participant 1 message Nov 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: hi556: Add support for powerdown GPIO

From: Ivaylo Ilchev <[email protected]>

On the Lenovo IdeaPad Duet 3 11IAN8 the INT3472 discrete power controller for the Hi-556 sensor describes a powerdown GPIO (type 0x01) in addition to the reset GPIO. The int3472 driver maps it to the "powerdown" con_id, but the hi556 driver never requests it, so the line stays asserted. The sensor then does not respond on I2C and probe fails:

hi556 i2c-INT3537:00: failed to find sensor: -5

Request the optional powerdown GPIO, deassert it on power-up before releasing reset and assert it again on power-down.

Tested on a Lenovo IdeaPad Duet 3 11IAN8 (82XK): with this change the sensor is detected (chip ID 0x0556) and streams through libcamera.

---
 drivers/media/i2c/hi556.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/media/i2c/hi556.c +13 -0
index 8750786..e4353ab 100644
@@ -647,6 +647,7 @@ struct hi556 {
 
 	/* GPIOs, clocks, etc. */
 	struct gpio_desc *reset_gpio;
+	struct gpio_desc *powerdown_gpio;
 	struct clk *clk;
 	struct regulator_bulk_data supplies[ARRAY_SIZE(hi556_supply_names)];
 
@@ -1284,6 +1285,7 @@ static int hi556_suspend(struct device *dev)
 	struct hi556 *hi556 = to_hi556(sd);
 
 	gpiod_set_value_cansleep(hi556->reset_gpio, 1);
+	gpiod_set_value_cansleep(hi556->powerdown_gpio, 1);
 	regulator_bulk_disable(ARRAY_SIZE(hi556_supply_names),
 			       hi556->supplies);
 	clk_disable_unprepare(hi556->clk);
@@ -1308,6 +1310,11 @@ static int hi556_resume(struct device *dev)
 		return ret;
 	}
 
+	if (hi556->powerdown_gpio) {
+		gpiod_set_value_cansleep(hi556->powerdown_gpio, 0);
+		usleep_range(2000, 2200);
+	}
+
 	if (hi556->reset_gpio) {
 		/* Assert reset for at least 2ms on back to back off-on */
 		usleep_range(2000, 2200);
@@ -1343,6 +1350,12 @@ static int hi556_probe(struct i2c_client *client)
 		return dev_err_probe(hi556->dev, PTR_ERR(hi556->reset_gpio),
 				     "failed to get reset GPIO\n");
 
+	hi556->powerdown_gpio = devm_gpiod_get_optional(hi556->dev, "powerdown",
+							GPIOD_OUT_HIGH);
+	if (IS_ERR(hi556->powerdown_gpio))
+		return dev_err_probe(hi556->dev, PTR_ERR(hi556->powerdown_gpio),
+				     "failed to get powerdown GPIO\n");
+
 	hi556->clk = devm_v4l2_sensor_clk_get(hi556->dev, "clk");
 	if (IS_ERR(hi556->clk))
 		return dev_err_probe(hi556->dev, PTR_ERR(hi556->clk),
Signature · 1 line
2.53.0