[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <te5zzhmux2dbwrudgiugjyqsxdmj5qqqued3ys5nnav4gys5wh@zuglcnehcyv2>
Date: Mon, 1 Dec 2025 15:59:48 +0100
From: Jacopo Mondi <jacopo.mondi@...asonboard.com>
To: Jai Luthra <jai.luthra@...asonboard.com>
Cc: Sakari Ailus <sakari.ailus@...ux.intel.com>,
Dave Stevenson <dave.stevenson@...pberrypi.com>, Jacopo Mondi <jacopo@...ndi.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>, Naushir Patuck <naush@...pberrypi.com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Kieran Bingham <kieran.bingham@...asonboard.com>, David Plowman <david.plowman@...pberrypi.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>, Peter Robinson <pbrobinson@...il.com>,
Stefan Wahren <wahrenst@....net>, "Ivan T. Ivanov" <iivanov@...e.de>,
Jacopo Mondi <jacopo.mondi@...asonboard.com>
Subject: Re: [PATCH v2 06/16] media: i2c: ov5647: Add support for regulator
control
Hi Jai
On Tue, Nov 18, 2025 at 05:32:59PM +0530, Jai Luthra wrote:
> From: Dave Stevenson <dave.stevenson@...pberrypi.com>
>
> The driver supported using GPIOs to control the shutdown line,
> but no regulator control.
>
> Add regulator hooks.
>
> Signed-off-by: Dave Stevenson <dave.stevenson@...pberrypi.com>
> Signed-off-by: Jai Luthra <jai.luthra@...asonboard.com>
> ---
> drivers/media/i2c/ov5647.c | 43 ++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 40 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
> index c0f1121b025e5592d6fd4d5fd23e4262dde2d84c..dbc134af06a26e0e31b12a6360d794afa8bad5dd 100644
> --- a/drivers/media/i2c/ov5647.c
> +++ b/drivers/media/i2c/ov5647.c
> @@ -20,6 +20,7 @@
> #include <linux/module.h>
> #include <linux/of_graph.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/slab.h>
> #include <linux/videodev2.h>
> #include <media/v4l2-ctrls.h>
> @@ -81,6 +82,15 @@
> #define OV5647_EXPOSURE_DEFAULT 1000
> #define OV5647_EXPOSURE_MAX 65535
>
> +/* regulator supplies */
> +static const char * const ov5647_supply_names[] = {
> + "avdd", /* Analog power */
> + "dovdd", /* Digital I/O power */
> + "dvdd", /* Digital core power */
> +};
> +
> +#define OV5647_NUM_SUPPLIES ARRAY_SIZE(ov5647_supply_names)
> +
> struct regval_list {
> u16 addr;
> u8 data;
> @@ -102,6 +112,7 @@ struct ov5647 {
> struct mutex lock;
> struct clk *xclk;
> struct gpio_desc *pwdn;
> + struct regulator_bulk_data supplies[OV5647_NUM_SUPPLIES];
> bool clock_ncont;
> struct v4l2_ctrl_handler ctrls;
> const struct ov5647_mode *mode;
> @@ -777,11 +788,20 @@ static int ov5647_power_on(struct device *dev)
>
> dev_dbg(dev, "OV5647 power on\n");
>
> - if (sensor->pwdn) {
> - gpiod_set_value_cansleep(sensor->pwdn, 0);
> - msleep(PWDN_ACTIVE_DELAY_MS);
> + ret = regulator_bulk_enable(OV5647_NUM_SUPPLIES, sensor->supplies);
> + if (ret < 0) {
> + dev_err(dev, "Failed to enable regulators: %d\n", ret);
> + return ret;
> + }
> +
> + ret = gpiod_set_value_cansleep(sensor->pwdn, 0);
> + if (ret < 0) {
> + dev_err(dev, "pwdn gpio set value failed: %d\n", ret);
> + goto error_reg_disable;
> }
>
> + msleep(PWDN_ACTIVE_DELAY_MS);
> +
That's loooong
But a comment on the delay seems to justify it and it was there
already, so
Reviewed-by: Jacopo Mondi <jacopo.mondi@...asonboard.com>
Thanks
j
> ret = clk_prepare_enable(sensor->xclk);
> if (ret < 0) {
> dev_err(dev, "clk prepare enable failed\n");
> @@ -808,6 +828,8 @@ static int ov5647_power_on(struct device *dev)
> clk_disable_unprepare(sensor->xclk);
> error_pwdn:
> gpiod_set_value_cansleep(sensor->pwdn, 1);
> +error_reg_disable:
> + regulator_bulk_disable(OV5647_NUM_SUPPLIES, sensor->supplies);
>
> return ret;
> }
> @@ -837,6 +859,7 @@ static int ov5647_power_off(struct device *dev)
>
> clk_disable_unprepare(sensor->xclk);
> gpiod_set_value_cansleep(sensor->pwdn, 1);
> + regulator_bulk_disable(OV5647_NUM_SUPPLIES, sensor->supplies);
>
> return 0;
> }
> @@ -1284,6 +1307,16 @@ static const struct v4l2_ctrl_ops ov5647_ctrl_ops = {
> .s_ctrl = ov5647_s_ctrl,
> };
>
> +static int ov5647_configure_regulators(struct device *dev,
> + struct ov5647 *sensor)
> +{
> + for (unsigned int i = 0; i < OV5647_NUM_SUPPLIES; i++)
> + sensor->supplies[i].supply = ov5647_supply_names[i];
> +
> + return devm_regulator_bulk_get(dev, OV5647_NUM_SUPPLIES,
> + sensor->supplies);
> +}
> +
> static int ov5647_init_controls(struct ov5647 *sensor)
> {
> struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);
> @@ -1416,6 +1449,10 @@ static int ov5647_probe(struct i2c_client *client)
> return -EINVAL;
> }
>
> + ret = ov5647_configure_regulators(dev, sensor);
> + if (ret)
> + dev_err_probe(dev, ret, "Failed to get power regulators\n");
> +
> mutex_init(&sensor->lock);
>
> sensor->mode = OV5647_DEFAULT_MODE;
>
> --
> 2.51.1
>
>
Powered by blists - more mailing lists