linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>,
	krzysztof.kozlowski@canonical.com,
	jeanmichel.hautbois@ideasonboard.com,
	laurent.pinchart@ideasonboard.com, paul.kocialkowski@bootlin.com,
	sakari.ailus@iki.fi, paul.elder@ideasonboard.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org (open list:OMNIVISION OV5670 SENSOR
	DRIVER)
Subject: [PATCH v3 5/8] media: i2c: ov5670: Probe GPIOs
Date: Tue, 29 Mar 2022 11:01:30 +0200	[thread overview]
Message-ID: <20220329090133.338073-6-jacopo@jmondi.org> (raw)
In-Reply-To: <20220329090133.338073-1-jacopo@jmondi.org>

The OV5670 has a powerdown and reset pin, named respectively "PWDN" and
"XSHUTDOWN".

Optionally probe the gpios connected to the pins during the driver probe
routine.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/i2c/ov5670.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index 9ddd259a4015..9e69b4008917 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -3,6 +3,7 @@
 
 #include <linux/acpi.h>
 #include <linux/clk.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -1843,6 +1844,10 @@ struct ov5670 {
 	/* Regulators */
 	struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES];
 
+	/* Power-down and reset gpios. */
+	struct gpio_desc *pwdn_gpio; /* PWDNB pin. */
+	struct gpio_desc *reset_gpio; /* XSHUTDOWN pin. */
+
 	/* To serialize asynchronus callbacks */
 	struct mutex mutex;
 
@@ -2495,6 +2500,23 @@ static int ov5670_regulators_probe(struct ov5670 *ov5670)
 				       ov5670->supplies);
 }
 
+static int ov5670_gpio_probe(struct ov5670 *ov5670)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
+
+	ov5670->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
+						    GPIOD_OUT_LOW);
+	if (IS_ERR(ov5670->pwdn_gpio))
+		return PTR_ERR(ov5670->pwdn_gpio);
+
+	ov5670->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
+						     GPIOD_OUT_LOW);
+	if (IS_ERR(ov5670->reset_gpio))
+		return PTR_ERR(ov5670->reset_gpio);
+
+	return 0;
+}
+
 static int ov5670_probe(struct i2c_client *client)
 {
 	struct ov5670 *ov5670;
@@ -2536,6 +2558,12 @@ static int ov5670_probe(struct i2c_client *client)
 		goto error_print;
 	}
 
+	ret = ov5670_gpio_probe(ov5670);
+	if (ret) {
+		err_msg = "GPIO probe failed";
+		goto error_print;
+	}
+
 	full_power = acpi_dev_state_d0(&client->dev);
 	if (full_power) {
 		/* Check module identity */
-- 
2.35.1


  parent reply	other threads:[~2022-03-29  9:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  9:01 [PATCH v3 0/8] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 1/8] media: dt-bindings: i2c: Document ov5670 Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 2/8] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2022-03-30  5:30   ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 3/8] media: i2c: ov5670: Probe clocks " Jacopo Mondi
2022-03-30  5:31   ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 4/8] media: i2c: ov5670: Probe regulators Jacopo Mondi
2022-03-29  9:01 ` Jacopo Mondi [this message]
2022-03-29  9:01 ` [PATCH v3 6/8] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2022-03-31 10:08   ` Sakari Ailus
2022-03-31 10:33     ` Laurent Pinchart
2022-03-31 12:34       ` Sakari Ailus
2022-04-27  9:57   ` Sakari Ailus
2022-04-27  9:59     ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 7/8] media: i2c: ov5670: Implement init_cfg Jacopo Mondi
2022-03-30  5:33   ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 8/8] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220329090133.338073-6-jacopo@jmondi.org \
    --to=jacopo@jmondi.org \
    --cc=chiranjeevi.rapolu@intel.com \
    --cc=jeanmichel.hautbois@ideasonboard.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).