summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ov5670.c
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>2023-01-26 17:59:04 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-02-06 08:46:54 +0100
commitcf9ab879910f620fca10562ce9223b54463dff70 (patch)
tree14aa92b97b6e23330504485b506cdb7ea4bc3715 /drivers/media/i2c/ov5670.c
parent8004c91e20959c241fcc7c87f6f7bc880dc25a27 (diff)
downloadlinux-stable-cf9ab879910f620fca10562ce9223b54463dff70.tar.gz
linux-stable-cf9ab879910f620fca10562ce9223b54463dff70.tar.bz2
linux-stable-cf9ab879910f620fca10562ce9223b54463dff70.zip
media: i2c: ov5670: Probe regulators
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> Tested-by: Luca Weiss <luca@z3ntu.xyz> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/i2c/ov5670.c')
-rw-r--r--drivers/media/i2c/ov5670.c30
1 files changed, 30 insertions, 0 deletions
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 */