public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] media: ov7251: Remap "reset" to "enable" for OV7251
@ 2024-11-08 14:50 Andy Shevchenko
  2024-11-08 14:57 ` Hans de Goede
  2024-11-08 16:06 ` Sakari Ailus
  0 siblings, 2 replies; 14+ messages in thread
From: Andy Shevchenko @ 2024-11-08 14:50 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Sakari Ailus, Mauro Carvalho Chehab, Andy Shevchenko,
	Hans de Goede

The driver of OmniVision OV7251 expects "enable" pin instead of "reset".
Remap "reset" to "enable" and update polarity.

In particular, the Linux kernel can't load the camera sensor
driver on Microsoft Surface Book without this change:

 ov7251 i2c-INT347E:00: supply vdddo not found, using dummy regulator
 ov7251 i2c-INT347E:00: supply vddd not found, using dummy regulator
 ov7251 i2c-INT347E:00: supply vdda not found, using dummy regulator
 ov7251 i2c-INT347E:00: cannot get enable gpio
 ov7251 i2c-INT347E:00: probe with driver ov7251 failed with error -2

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/media/i2c/ov7251.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
index 30f61e04ecaf..7b35add1e0ed 100644
--- a/drivers/media/i2c/ov7251.c
+++ b/drivers/media/i2c/ov7251.c
@@ -1696,7 +1696,21 @@ static int ov7251_probe(struct i2c_client *client)
 		return PTR_ERR(ov7251->analog_regulator);
 	}
 
+	/*
+	 * The device-tree bindings call this pin "enable", but the
+	 * datasheet describes the pin as "reset (active low with internal
+	 * pull down resistor)". The ACPI tables describing this sensor
+	 * on, e.g., the Microsoft Surface Book use the ACPI equivalent of
+	 * "reset" as pin name, which ACPI glue code then maps to "reset".
+	 * Check for a "reset" pin if there is no "enable" pin.
+	 */
 	ov7251->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
+	if (IS_ERR(ov7251->enable_gpio) &&
+	    PTR_ERR(ov7251->enable_gpio) != -EPROBE_DEFER) {
+		ov7251->enable_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+		if (!IS_ERR(ov7251->enable_gpio))
+			gpiod_toggle_active_low(ov7251->enable_gpio);
+	}
 	if (IS_ERR(ov7251->enable_gpio)) {
 		dev_err(dev, "cannot get enable gpio\n");
 		return PTR_ERR(ov7251->enable_gpio);
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-01-20 17:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 14:50 [PATCH v1 1/1] media: ov7251: Remap "reset" to "enable" for OV7251 Andy Shevchenko
2024-11-08 14:57 ` Hans de Goede
2024-11-08 16:06 ` Sakari Ailus
2024-11-08 16:28   ` Andy Shevchenko
2024-11-08 16:42     ` Sakari Ailus
2024-11-08 18:19       ` Hans de Goede
2024-11-11  7:55         ` Sakari Ailus
2024-11-11  9:46           ` Hans de Goede
2025-01-16 14:48             ` Andy Shevchenko
2025-01-20  9:39               ` Sakari Ailus
2025-01-20 13:30                 ` Hans de Goede
2025-01-20 16:05                   ` Laurent Pinchart
2025-01-20 16:37                     ` Hans de Goede
2025-01-20 17:03                     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox