[PATCH v2 2/2] media: i2c: ov13b10: Support tps68470 regulator and gpio

Arun T posted 2 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v2 2/2] media: i2c: ov13b10: Support tps68470 regulator and gpio
Posted by Arun T 1 month, 1 week ago
Ov13b10 sensor get clock and regulator from TPS68470 PMIC.
Added tps68470 regulator/gpio names in 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..228ffe5ada70 100644
--- a/drivers/media/i2c/ov13b10.c
+++ b/drivers/media/i2c/ov13b10.c
@@ -11,6 +11,7 @@
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-fwnode.h>
+#include <linux/regulator/consumer.h>
 
 #define OV13B10_REG_VALUE_08BIT		1
 #define OV13B10_REG_VALUE_16BIT		2
@@ -699,6 +700,13 @@ 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 +716,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 +1202,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 +1221,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);
@@ -1473,7 +1478,7 @@ static void ov13b10_free_controls(struct ov13b10 *ov13b)
 static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
 {
 	unsigned long freq;
-	int ret;
+	int ret, i;
 
 	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ov13b->reset))
@@ -1481,6 +1486,7 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
 				     "failed to get reset gpio\n");
 
 	ov13b->img_clk = devm_v4l2_sensor_clk_get(ov13b->dev, NULL);
+
 	if (IS_ERR(ov13b->img_clk))
 		return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->img_clk),
 				     "failed to get imaging clock\n");
@@ -1491,15 +1497,14 @@ 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 (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 v2 2/2] media: i2c: ov13b10: Support tps68470 regulator and gpio
Posted by Sakari Ailus 1 month, 1 week ago
Hi Arun,

On Fri, Feb 27, 2026 at 07:05:42PM +0530, Arun T wrote:
> Ov13b10 sensor get clock and regulator from TPS68470 PMIC.
> Added tps68470 regulator/gpio names in power_on

Sentences end in a period. Also rewrap this one.

> 
> 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..228ffe5ada70 100644
> --- a/drivers/media/i2c/ov13b10.c
> +++ b/drivers/media/i2c/ov13b10.c
> @@ -11,6 +11,7 @@
>  #include <media/v4l2-ctrls.h>
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-fwnode.h>
> +#include <linux/regulator/consumer.h>

Please arrange alphabetically.

>  
>  #define OV13B10_REG_VALUE_08BIT		1
>  #define OV13B10_REG_VALUE_16BIT		2
> @@ -699,6 +700,13 @@ 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 */
> +};
> +

Extra newline.

> +
>  struct ov13b10 {
>  	struct device *dev;
>  
> @@ -708,7 +716,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 +1202,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 +1221,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);
> @@ -1473,7 +1478,7 @@ static void ov13b10_free_controls(struct ov13b10 *ov13b)
>  static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>  {
>  	unsigned long freq;
> -	int ret;
> +	int ret, i;

unsigned int, please, and you can declare this just for the loop.

>  
>  	ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
>  	if (IS_ERR(ov13b->reset))
> @@ -1481,6 +1486,7 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
>  				     "failed to get reset gpio\n");
>  
>  	ov13b->img_clk = devm_v4l2_sensor_clk_get(ov13b->dev, NULL);
> +

Unrelated change (and no, I wouldn't do it).

>  	if (IS_ERR(ov13b->img_clk))
>  		return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->img_clk),
>  				     "failed to get imaging clock\n");
> @@ -1491,15 +1497,14 @@ 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 (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);

Indentation.

While at it, could you run

	$ ./scripts/checkpatch.pl --strict --max-line-length=80

on this?

> +	if (ret)
> +		return dev_err_probe(ov13b->dev, ret,
> +				     "failed to get regulators\n");
>  	return 0;
>  }
>  

-- 
Regards,

Sakari Ailus