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 4/9] media: i2c: ov5670: Probe regulators
Date: Thu, 26 Jan 2023 17:59:04 +0100	[thread overview]
Message-ID: <20230126165909.121302-5-jacopo.mondi@ideasonboard.com> (raw)
In-Reply-To: <20230126165909.121302-1-jacopo.mondi@ideasonboard.com>

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.mondi@ideasonboard.com>
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 52b799a7491c..e71f13360480 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>
@@ -88,6 +89,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;
@@ -1836,6 +1845,9 @@ struct ov5670 {
 	/* xvclk input clock */
 	struct clk *xvclk;
 
+	/* Regulators */
+	struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES];
+
 	/* To serialize asynchronus callbacks */
 	struct mutex mutex;
 
@@ -2476,6 +2488,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;
@@ -2510,6 +2534,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.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 ` Jacopo Mondi [this message]
2023-01-26 16:59 ` [PATCH v6 5/9] media: i2c: ov5670: Probe GPIOs Jacopo Mondi
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-5-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.