From: Stefan Wahren <wahrenst@gmx.net>
To: Jai Luthra <jai.luthra@ideasonboard.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Jacopo Mondi <jacopo@jmondi.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
David Plowman <david.plowman@raspberrypi.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Peter Robinson <pbrobinson@gmail.com>,
"Ivan T. Ivanov" <iivanov@suse.de>
Subject: Re: [PATCH 07/13] media: i2c: ov5647: Add support for regulator control.
Date: Sun, 2 Nov 2025 13:35:06 +0100 [thread overview]
Message-ID: <bf9f4a7f-3758-4877-8985-75bfe566745c@gmx.net> (raw)
In-Reply-To: <20251028-b4-rpi-ov5647-v1-7-098413454f5e@ideasonboard.com>
Am 28.10.25 um 08:27 schrieb Jai Luthra:
> From: Dave Stevenson <dave.stevenson@raspberrypi.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@raspberrypi.com>
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
> drivers/media/i2c/ov5647.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
> index a33e2d8edc114d302e830639cb7cb161f16a6208..598764638d518a28c8ac61ea590b996f09ecd45c 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>
> @@ -83,6 +84,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;
> @@ -104,6 +114,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;
> @@ -781,6 +792,12 @@ static int ov5647_power_on(struct device *dev)
>
> dev_dbg(dev, "OV5647 power on\n");
>
> + ret = regulator_bulk_enable(OV5647_NUM_SUPPLIES, sensor->supplies);
> + if (ret < 0) {
> + dev_err(dev, "Failed to enable regulators\n");
In case we want to log this, please add the return code as well
> + return ret;
> + }
> +
> if (sensor->pwdn) {
> gpiod_set_value_cansleep(sensor->pwdn, 0);
> msleep(PWDN_ACTIVE_DELAY_MS);
> @@ -812,6 +829,7 @@ static int ov5647_power_on(struct device *dev)
> clk_disable_unprepare(sensor->xclk);
> error_pwdn:
> gpiod_set_value_cansleep(sensor->pwdn, 1);
> + regulator_bulk_disable(OV5647_NUM_SUPPLIES, sensor->supplies);
>
> return ret;
> }
> @@ -841,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;
> }
> @@ -1341,6 +1360,18 @@ 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)
> +{
> + unsigned int i;
> +
> + for (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 device *dev)
> {
> struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);
> @@ -1489,6 +1520,12 @@ static int ov5647_probe(struct i2c_client *client)
> return -EINVAL;
> }
>
> + ret = ov5647_configure_regulators(dev, sensor);
> + if (ret) {
> + dev_err(dev, "Failed to get power regulators\n");
Please use dev_err_probe here
> + return ret;
> + }
> +
> mutex_init(&sensor->lock);
>
> sensor->mode = OV5647_DEFAULT_MODE;
>
next prev parent reply other threads:[~2025-11-02 12:35 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 7:27 [PATCH 00/13] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
2025-10-28 7:27 ` [PATCH 01/13] media: i2c: ov5647: Parse and register properties Jai Luthra
2025-11-02 10:20 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 02/13] media: i2c: ov5647: Correct pixel array offset Jai Luthra
2025-11-02 10:29 ` Jacopo Mondi
2025-11-06 12:09 ` Dave Stevenson
2025-10-28 7:27 ` [PATCH 03/13] media: i2c: ov5647: Correct minimum VBLANK value Jai Luthra
2025-11-02 10:30 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 04/13] media: i2c: ov5647: Fix v4l2-compliance failure subscribing to events Jai Luthra
2025-10-29 0:57 ` kernel test robot
2025-10-30 6:07 ` Jai Luthra
2025-10-28 7:27 ` [PATCH 05/13] media: i2c: ov5647: Sensor should report RAW color space Jai Luthra
2025-11-02 10:21 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 06/13] media: i2c: ov5647: Support HFLIP and VFLIP Jai Luthra
2025-11-02 10:50 ` Jacopo Mondi
2025-11-12 11:56 ` Jai Luthra
2025-11-12 14:35 ` Dave Stevenson
2025-11-12 14:51 ` Kieran Bingham
2025-11-12 15:34 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 07/13] media: i2c: ov5647: Add support for regulator control Jai Luthra
2025-11-02 10:57 ` Jacopo Mondi
2025-11-02 12:35 ` Stefan Wahren [this message]
2025-10-28 7:27 ` [PATCH 08/13] media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding Jai Luthra
2025-11-02 10:58 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 09/13] media: i2c: ov5647: Add control of V4L2_CID_HBLANK Jai Luthra
2025-11-02 11:07 ` Jacopo Mondi
2025-11-18 10:57 ` Jai Luthra
2025-10-28 7:27 ` [PATCH 10/13] media: i2c: ov5647: Tidy up mode registers to make the order common Jai Luthra
2025-11-02 11:13 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 11/13] media: i2c: ov5647: Separate out the common registers Jai Luthra
2025-10-28 7:27 ` [PATCH 12/13] media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes Jai Luthra
2025-11-02 11:16 ` Jacopo Mondi
2025-10-28 7:27 ` [PATCH 13/13] media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control Jai Luthra
2025-11-02 11:29 ` Jacopo Mondi
2025-11-18 11:28 ` Jai Luthra
2025-11-18 12:47 ` Dave Stevenson
2025-11-18 13:27 ` Jai Luthra
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=bf9f4a7f-3758-4877-8985-75bfe566745c@gmx.net \
--to=wahrenst@gmx.net \
--cc=dave.stevenson@raspberrypi.com \
--cc=david.plowman@raspberrypi.com \
--cc=iivanov@suse.de \
--cc=jacopo@jmondi.org \
--cc=jai.luthra@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=mchehab@kernel.org \
--cc=pbrobinson@gmail.com \
--cc=sakari.ailus@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®