[PATCH v5 2/2] media: i2c: ov13b10: support tps68470 regulator and gpio

Arun T posted 2 patches 6 days, 1 hour ago
There is a newer version of this series
[PATCH v5 2/2] media: i2c: ov13b10: support tps68470 regulator and gpio
Posted by Arun T 6 days, 1 hour ago
The OV13B10 sensor obtains clock and regulators from the TPS68470 PMIC.
Add TPS68470 regulator and GPIO names to the sensor power on

Signed-off-by: Arun T <arun.t@intel.com>
---
 drivers/media/i2c/ov13b10.c | 47 ++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c
index 5421874732bc..4b7b17afb64c 100644
--- a/drivers/media/i2c/ov13b10.c
+++ b/drivers/media/i2c/ov13b10.c
@@ -3,6 +3,7 @@
 
 #include <linux/acpi.h>
 #include <linux/clk.h>
+#include <linux/regulator/consumer.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
@@ -699,6 +700,12 @@ static const struct ov13b10_mode supported_2_lanes_modes[] = {
 	},
 };
 
+static const char * const ov13b10_supply_names[] = {
+	"dovdd",        /* Digital I/O power */
+	"avdd",         /* Analog power */
+	"dvdd",         /* Digital core power */
+};
+
 struct ov13b10 {
 	struct device *dev;
 
@@ -708,7 +715,7 @@ struct ov13b10 {
 	struct v4l2_ctrl_handler ctrl_handler;
 
 	struct clk *img_clk;
-	struct regulator *avdd;
+	struct regulator_bulk_data supplies[ARRAY_SIZE(ov13b10_supply_names)];
 	struct gpio_desc *reset;
 
 	/* V4L2 Controls */
@@ -1194,9 +1201,8 @@ static int ov13b10_power_off(struct device *dev)
 	struct ov13b10 *ov13b10 = to_ov13b10(sd);
 
 	gpiod_set_value_cansleep(ov13b10->reset, 1);
-
-	if (ov13b10->avdd)
-		regulator_disable(ov13b10->avdd);
+	regulator_bulk_disable(ARRAY_SIZE(ov13b10_supply_names),
+			       ov13b10->supplies);
 
 	clk_disable_unprepare(ov13b10->img_clk);
 
@@ -1214,14 +1220,12 @@ static int ov13b10_power_on(struct device *dev)
 		dev_err(dev, "failed to enable imaging clock: %d", ret);
 		return ret;
 	}
-
-	if (ov13b10->avdd) {
-		ret = regulator_enable(ov13b10->avdd);
-		if (ret < 0) {
-			dev_err(dev, "failed to enable avdd: %d", ret);
-			clk_disable_unprepare(ov13b10->img_clk);
-			return ret;
-		}
+	ret = regulator_bulk_enable(ARRAY_SIZE(ov13b10_supply_names),
+				    ov13b10->supplies);
+	if (ret < 0) {
+		dev_err(dev, "failed to enable regulators\n");
+		clk_disable_unprepare(ov13b10->img_clk);
+		return ret;
 	}
 
 	gpiod_set_value_cansleep(ov13b10->reset, 0);
@@ -1475,7 +1479,8 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
 	unsigned long freq;
 	int ret;
 
-	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
+	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset",
+					       GPIOD_OUT_LOW);
 	if (IS_ERR(ov13b->reset))
 		return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->reset),
 				     "failed to get reset gpio\n");
@@ -1491,15 +1496,15 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
 				     "external clock %lu is not supported\n",
 				     freq);
 
-	ov13b->avdd = devm_regulator_get_optional(ov13b->dev, "avdd");
-	if (IS_ERR(ov13b->avdd)) {
-		ret = PTR_ERR(ov13b->avdd);
-		ov13b->avdd = NULL;
-		if (ret != -ENODEV)
-			return dev_err_probe(ov13b->dev, ret,
-					     "failed to get avdd regulator\n");
-	}
+	for (unsigned int i = 0; i < ARRAY_SIZE(ov13b10_supply_names); i++)
+		ov13b->supplies[i].supply = ov13b10_supply_names[i];
 
+	ret = devm_regulator_bulk_get(ov13b->dev,
+				      ARRAY_SIZE(ov13b10_supply_names),
+				      ov13b->supplies);
+	if (ret)
+		return dev_err_probe(ov13b->dev, ret,
+				     "failed to get regulators\n");
 	return 0;
 }
 
-- 
2.43.0
Re: [PATCH v5 2/2] media: i2c: ov13b10: support tps68470 regulator and gpio
Posted by Dan Scally 6 days ago
Hi Arun, thanks for the revision

On 27/03/2026 13:39, Arun T wrote:
> The OV13B10 sensor obtains clock and regulators from the TPS68470 PMIC.
> Add TPS68470 regulator and GPIO names to the sensor power on

The commit message needs updating now really; it's changed since the early version. What it now does 
is switch to using the regulator bulk API to handle three regulators instead of just a single one. 
The GPIO changes are gone so you can skip mentioning them here. I would also not mention the 
TPS68470, as from the sensor driver's point of view it's irrelevant what device provides them. Maybe 
something like:

media: ov13b10: Support multiple regulators

The OV13B10 sensor driver currently handles a single regulator called "avdd", however the sensor can 
be supplied by up to three regulators. Update the driver to handle all of them together using the 
regulator bulk API.

> 
> Signed-off-by: Arun T <arun.t@intel.com>
> ---
>   drivers/media/i2c/ov13b10.c | 47 ++++++++++++++++++++-----------------
>   1 file changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c
> index 5421874732bc..4b7b17afb64c 100644
> --- a/drivers/media/i2c/ov13b10.c
> +++ b/drivers/media/i2c/ov13b10.c
> @@ -3,6 +3,7 @@
>   
>   #include <linux/acpi.h>
>   #include <linux/clk.h>
> +#include <linux/regulator/consumer.h>

Alphabetical ordering please; this should go after pm_runtime.h and before v4l2-ctrls.h

>   #include <linux/delay.h>
>   #include <linux/gpio/consumer.h>
>   #include <linux/i2c.h>
> @@ -699,6 +700,12 @@ static const struct ov13b10_mode supported_2_lanes_modes[] = {
>   	},
>   };
>   
> +static const char * const ov13b10_supply_names[] = {
> +	"dovdd",        /* Digital I/O power */
> +	"avdd",         /* Analog power */
> +	"dvdd",         /* Digital core power */
> +};
> +
>   struct ov13b10 {
>   	struct device *dev;
>   
> @@ -708,7 +715,7 @@ struct ov13b10 {
>   	struct v4l2_ctrl_handler ctrl_handler;
>   
>   	struct clk *img_clk;
> -	struct regulator *avdd;
> +	struct regulator_bulk_data supplies[ARRAY_SIZE(ov13b10_supply_names)];
>   	struct gpio_desc *reset;
>   
>   	/* V4L2 Controls */
> @@ -1194,9 +1201,8 @@ static int ov13b10_power_off(struct device *dev)
>   	struct ov13b10 *ov13b10 = to_ov13b10(sd);
>   
>   	gpiod_set_value_cansleep(ov13b10->reset, 1);
> -
> -	if (ov13b10->avdd)
> -		regulator_disable(ov13b10->avdd);
> +	regulator_bulk_disable(ARRAY_SIZE(ov13b10_supply_names),
> +			       ov13b10->supplies);
>   
>   	clk_disable_unprepare(ov13b10->img_clk);
>   
> @@ -1214,14 +1220,12 @@ static int ov13b10_power_on(struct device *dev)
>   		dev_err(dev, "failed to enable imaging clock: %d", ret);
>   		return ret;
>   	}
> -
> -	if (ov13b10->avdd) {
> -		ret = regulator_enable(ov13b10->avdd);
> -		if (ret < 0) {
> -			dev_err(dev, "failed to enable avdd: %d", ret);
> -			clk_disable_unprepare(ov13b10->img_clk);
> -			return ret;
> -		}
> +	ret = regulator_bulk_enable(ARRAY_SIZE(ov13b10_supply_names),
> +				    ov13b10->supplies);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to enable regulators\n");
> +		clk_disable_unprepare(ov13b10->img_clk);
> +		return ret;
>   	}
>   
>   	gpiod_set_value_cansleep(ov13b10->reset, 0);
> @@ -1475,7 +1479,8 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>   	unsigned long freq;
>   	int ret;
>   
> -	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
> +	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset",
> +					       GPIOD_OUT_LOW);

I think you can just drop this change.

Thanks
Dan

>   	if (IS_ERR(ov13b->reset))
>   		return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->reset),
>   				     "failed to get reset gpio\n");
> @@ -1491,15 +1496,15 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>   				     "external clock %lu is not supported\n",
>   				     freq);
>   
> -	ov13b->avdd = devm_regulator_get_optional(ov13b->dev, "avdd");
> -	if (IS_ERR(ov13b->avdd)) {
> -		ret = PTR_ERR(ov13b->avdd);
> -		ov13b->avdd = NULL;
> -		if (ret != -ENODEV)
> -			return dev_err_probe(ov13b->dev, ret,
> -					     "failed to get avdd regulator\n");
> -	}
> +	for (unsigned int i = 0; i < ARRAY_SIZE(ov13b10_supply_names); i++)
> +		ov13b->supplies[i].supply = ov13b10_supply_names[i];
>   
> +	ret = devm_regulator_bulk_get(ov13b->dev,
> +				      ARRAY_SIZE(ov13b10_supply_names),
> +				      ov13b->supplies);
> +	if (ret)
> +		return dev_err_probe(ov13b->dev, ret,
> +				     "failed to get regulators\n");
>   	return 0;
>   }
>
RE: [PATCH v5 2/2] media: i2c: ov13b10: support tps68470 regulator and gpio
Posted by T, Arun 5 days, 21 hours ago
Hi Dan,

Thanks for the review. I have updated V6 patch series as you suggested:

Updated below changes in V6 patch series.

- Changed consumer supply arrays from int3472_* to ovti13b1_* and update all references.
- Removed consumer supply zero-init fields
- Updated commit message for ov13b10 driver and rewritten for regulator bulk support
- Updated <linux/regulator/consumer.h> in alphabetical order

Thanks,
Arun T

-----Original Message-----
From: Dan Scally <dan.scally@ideasonboard.com> 
Sent: 27 March 2026 08:45 PM
To: T, Arun <arun.t@intel.com>; johannes.goede@oss.qualcomm.com
Cc: sakari.ailus@linux.intel.com; Kao, Arec <arec.kao@intel.com>; ilpo.jarvinen@linux.intel.com; platform-driver-x86@vger.kernel.org; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; Djait, Mehdi <mehdi.djait@intel.com>
Subject: Re: [PATCH v5 2/2] media: i2c: ov13b10: support tps68470 regulator and gpio

Hi Arun, thanks for the revision

On 27/03/2026 13:39, Arun T wrote:
> The OV13B10 sensor obtains clock and regulators from the TPS68470 PMIC.
> Add TPS68470 regulator and GPIO names to the sensor power on

The commit message needs updating now really; it's changed since the early version. What it now does is switch to using the regulator bulk API to handle three regulators instead of just a single one. 
The GPIO changes are gone so you can skip mentioning them here. I would also not mention the TPS68470, as from the sensor driver's point of view it's irrelevant what device provides them. Maybe something like:

media: ov13b10: Support multiple regulators

The OV13B10 sensor driver currently handles a single regulator called "avdd", however the sensor can be supplied by up to three regulators. Update the driver to handle all of them together using the regulator bulk API.

> 
> Signed-off-by: Arun T <arun.t@intel.com>
> ---
>   drivers/media/i2c/ov13b10.c | 47 ++++++++++++++++++++-----------------
>   1 file changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c 
> index 5421874732bc..4b7b17afb64c 100644
> --- a/drivers/media/i2c/ov13b10.c
> +++ b/drivers/media/i2c/ov13b10.c
> @@ -3,6 +3,7 @@
>   
>   #include <linux/acpi.h>
>   #include <linux/clk.h>
> +#include <linux/regulator/consumer.h>

Alphabetical ordering please; this should go after pm_runtime.h and before v4l2-ctrls.h

>   #include <linux/delay.h>
>   #include <linux/gpio/consumer.h>
>   #include <linux/i2c.h>
> @@ -699,6 +700,12 @@ static const struct ov13b10_mode supported_2_lanes_modes[] = {
>   	},
>   };
>   
> +static const char * const ov13b10_supply_names[] = {
> +	"dovdd",        /* Digital I/O power */
> +	"avdd",         /* Analog power */
> +	"dvdd",         /* Digital core power */
> +};
> +
>   struct ov13b10 {
>   	struct device *dev;
>   
> @@ -708,7 +715,7 @@ struct ov13b10 {
>   	struct v4l2_ctrl_handler ctrl_handler;
>   
>   	struct clk *img_clk;
> -	struct regulator *avdd;
> +	struct regulator_bulk_data 
> +supplies[ARRAY_SIZE(ov13b10_supply_names)];
>   	struct gpio_desc *reset;
>   
>   	/* V4L2 Controls */
> @@ -1194,9 +1201,8 @@ static int ov13b10_power_off(struct device *dev)
>   	struct ov13b10 *ov13b10 = to_ov13b10(sd);
>   
>   	gpiod_set_value_cansleep(ov13b10->reset, 1);
> -
> -	if (ov13b10->avdd)
> -		regulator_disable(ov13b10->avdd);
> +	regulator_bulk_disable(ARRAY_SIZE(ov13b10_supply_names),
> +			       ov13b10->supplies);
>   
>   	clk_disable_unprepare(ov13b10->img_clk);
>   
> @@ -1214,14 +1220,12 @@ static int ov13b10_power_on(struct device *dev)
>   		dev_err(dev, "failed to enable imaging clock: %d", ret);
>   		return ret;
>   	}
> -
> -	if (ov13b10->avdd) {
> -		ret = regulator_enable(ov13b10->avdd);
> -		if (ret < 0) {
> -			dev_err(dev, "failed to enable avdd: %d", ret);
> -			clk_disable_unprepare(ov13b10->img_clk);
> -			return ret;
> -		}
> +	ret = regulator_bulk_enable(ARRAY_SIZE(ov13b10_supply_names),
> +				    ov13b10->supplies);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to enable regulators\n");
> +		clk_disable_unprepare(ov13b10->img_clk);
> +		return ret;
>   	}
>   
>   	gpiod_set_value_cansleep(ov13b10->reset, 0); @@ -1475,7 +1479,8 @@ 
> static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>   	unsigned long freq;
>   	int ret;
>   
> -	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
> +	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset",
> +					       GPIOD_OUT_LOW);

I think you can just drop this change.

Thanks
Dan

>   	if (IS_ERR(ov13b->reset))
>   		return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->reset),
>   				     "failed to get reset gpio\n"); @@ -1491,15 +1496,15 @@ 
> static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>   				     "external clock %lu is not supported\n",
>   				     freq);
>   
> -	ov13b->avdd = devm_regulator_get_optional(ov13b->dev, "avdd");
> -	if (IS_ERR(ov13b->avdd)) {
> -		ret = PTR_ERR(ov13b->avdd);
> -		ov13b->avdd = NULL;
> -		if (ret != -ENODEV)
> -			return dev_err_probe(ov13b->dev, ret,
> -					     "failed to get avdd regulator\n");
> -	}
> +	for (unsigned int i = 0; i < ARRAY_SIZE(ov13b10_supply_names); i++)
> +		ov13b->supplies[i].supply = ov13b10_supply_names[i];
>   
> +	ret = devm_regulator_bulk_get(ov13b->dev,
> +				      ARRAY_SIZE(ov13b10_supply_names),
> +				      ov13b->supplies);
> +	if (ret)
> +		return dev_err_probe(ov13b->dev, ret,
> +				     "failed to get regulators\n");
>   	return 0;
>   }
>