All of lore.kernel.org
 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 v2 4/8] media: i2c: ov5670: Probe regulators
Date: Mon, 14 Mar 2022 17:27:10 +0100	[thread overview]
Message-ID: <20220314162714.153970-5-jacopo@jmondi.org> (raw)
In-Reply-To: <20220314162714.153970-1-jacopo@jmondi.org>

The OV5670 has three power supplies (AVDD, DOVDD and DVDD).

Probe them in the driver to prepare controlling with runtime_pm
operations.

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

diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index 25d792794fc7..832355f65e52 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-event.h>
@@ -86,6 +87,14 @@ struct ov5670_link_freq_config {
 	const struct ov5670_reg_list reg_list;
 };
 
+static const char * const ov5670_supply_names[] = {
+	"avdd",		/* Analog power */
+	"dvdd",		/* Digital power */
+	"dovdd",	/* Digital output power */
+};
+
+#define OV5670_NUM_SUPPLIES ARRAY_SIZE(ov5670_supply_names)
+
 struct ov5670_mode {
 	/* Frame width in pixels */
 	u32 width;
@@ -1833,6 +1842,9 @@ struct ov5670 {
 	/* Current mode */
 	const struct ov5670_mode *cur_mode;
 
+	/* Regulators */
+	struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES];
+
 	/* To serialize asynchronus callbacks */
 	struct mutex mutex;
 
@@ -2473,6 +2485,18 @@ static const struct v4l2_subdev_internal_ops ov5670_internal_ops = {
 	.open = ov5670_open,
 };
 
+static int ov5670_regulators_probe(struct ov5670 *ov5670)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
+	unsigned int i;
+
+	for (i = 0; i < OV5670_NUM_SUPPLIES; i++)
+		ov5670->supplies[i].supply = ov5670_supply_names[i];
+
+	return devm_regulator_bulk_get(&client->dev, OV5670_NUM_SUPPLIES,
+				       ov5670->supplies);
+}
+
 static int ov5670_probe(struct i2c_client *client)
 {
 	struct ov5670 *ov5670;
@@ -2505,6 +2529,12 @@ static int ov5670_probe(struct i2c_client *client)
 	/* Initialize subdev */
 	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
 
+	ret = ov5670_regulators_probe(ov5670);
+	if (ret) {
+		err_msg = "Regulators 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-14 16:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 16:27 [PATCH v2 0/8] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 1/8] media: dt-bindings: i2c: Document ov5670 Jacopo Mondi
2022-03-15  7:32   ` Krzysztof Kozlowski
2022-03-15  7:59     ` Sakari Ailus
2022-03-15  8:03       ` Krzysztof Kozlowski
2022-03-15 12:47         ` Sakari Ailus
2022-03-15 12:57           ` Krzysztof Kozlowski
2022-03-15 13:01           ` Laurent Pinchart
2022-03-15 20:30             ` Sakari Ailus
2022-03-15  8:09       ` Laurent Pinchart
2022-03-15  8:41     ` Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 2/8] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 3/8] media: i2c: ov5670: Probe clocks " Jacopo Mondi
2022-03-15  8:11   ` Laurent Pinchart
2022-03-15  8:46     ` Jacopo Mondi
2022-03-15  8:52       ` Krzysztof Kozlowski
2022-03-15  8:56       ` Laurent Pinchart
2022-03-16  8:04         ` Sakari Ailus
2022-03-14 16:27 ` Jacopo Mondi [this message]
2022-03-14 16:27 ` [PATCH v2 5/8] media: i2c: ov5670: Probe GPIOs Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 6/8] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 7/8] media: i2c: ov5670: Implement init_cfg Jacopo Mondi
2022-03-15  8:13   ` Laurent Pinchart
2022-03-14 16:27 ` [PATCH v2 8/8] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi
2022-03-15  4:18   ` kernel test robot
2022-03-15 16:55     ` Nathan Chancellor
2022-03-15 16:55       ` Nathan Chancellor
2022-03-15  8:19   ` Laurent Pinchart

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=20220314162714.153970-5-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 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.