All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>,
	Luca Weiss <luca@z3ntu.xyz>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH v6 5/9] media: i2c: ov5670: Probe GPIOs
Date: Thu, 26 Jan 2023 17:59:05 +0100	[thread overview]
Message-ID: <20230126165909.121302-6-jacopo.mondi@ideasonboard.com> (raw)
In-Reply-To: <20230126165909.121302-1-jacopo.mondi@ideasonboard.com>

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.mondi@ideasonboard.com>
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 e71f13360480..0290f33f619d 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>
@@ -1848,6 +1849,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;
 
@@ -2500,6 +2505,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;
@@ -2540,6 +2562,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.39.0


  parent reply	other threads:[~2023-01-26 16:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 16:59 [PATCH v6 0/9] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2023-01-26 16:59 ` [PATCH v6 1/9] media: dt-bindings: Add OV5670 Jacopo Mondi
2023-01-27 14:19   ` Krzysztof Kozlowski
2023-01-27 18:14     ` Jacopo Mondi
2023-01-27 19:58       ` Krzysztof Kozlowski
2023-01-27 20:38         ` Sakari Ailus
2023-01-27 20:44           ` Krzysztof Kozlowski
2023-01-28  9:58             ` Jacopo Mondi
2023-01-28 10:07               ` Sakari Ailus
2023-01-28 11:03                 ` Jacopo Mondi
2023-01-29 11:36                   ` Krzysztof Kozlowski
2023-01-28 11:27   ` [PATCH v6.1] " Jacopo Mondi
2023-01-29 11:40     ` Krzysztof Kozlowski
2023-01-29 12:11       ` Jacopo Mondi
2023-01-29 12:31         ` Krzysztof Kozlowski
2023-01-30 15:58         ` Rob Herring
2023-01-30 16:11           ` Jacopo Mondi
2023-01-29 11:40     ` Krzysztof Kozlowski
2023-01-26 16:59 ` [PATCH v6 2/9] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2023-01-26 16:59 ` [PATCH v6 3/9] media: i2c: ov5670: Use common clock framework Jacopo Mondi
2023-01-26 16:59 ` [PATCH v6 4/9] media: i2c: ov5670: Probe regulators Jacopo Mondi
2023-01-26 16:59 ` Jacopo Mondi [this message]
2023-01-26 16:59 ` [PATCH v6 6/9] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2023-01-26 16:59 ` [PATCH v6 7/9] media: i2c: ov5670: Implement init_cfg Jacopo Mondi
2023-01-26 16:59 ` [PATCH v6 8/9] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi
2023-01-28 17:57   ` Luca Weiss
2023-01-26 16:59 ` [PATCH v6 9/9] media: i2c: ov5670: Handle RO controls in set_ctrl Jacopo Mondi
2023-01-28 21:27 ` [PATCH v6 0/9] media: i2c: ov5670: OF support, runtime_pm, regulators Luca Weiss

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=20230126165909.121302-6-jacopo.mondi@ideasonboard.com \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=chiranjeevi.rapolu@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=mchehab@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.