Commit cf9ab879 authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Mauro Carvalho Chehab

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: default avatarJacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: default avatarLuca Weiss <luca@z3ntu.xyz>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 8004c91e
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment