Re: [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support

From: Sakari Ailus

Date: Fri Mar 20 2026 - 17:34:45 EST


Hi Antoine,

Thanks for the patch.

On Fri, Mar 20, 2026 at 09:25:21AM +0000, Antoine Bernard wrote:
> From: Antoine Bernard <zalnir@xxxxxxxxx>
>
> The Xiaomi Pad 6 tablet uses the OV13B10 sensor with a device tree
> match and dvdd/dovdd voltage supply specified.
>
> Add support for optional dvdd and dovdd voltage supply, and add
> a device tree match so that the rear camera can work on such tablets
> without an ACPI.
>
> Signed-off-by: Antoine Bernard <zalnir@xxxxxxxxx>
> ---
> drivers/media/i2c/ov13b10.c | 53 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c
> index 5421874732bc..47eced60542c 100644
> --- a/drivers/media/i2c/ov13b10.c
> +++ b/drivers/media/i2c/ov13b10.c
> @@ -708,7 +708,11 @@ struct ov13b10 {
> struct v4l2_ctrl_handler ctrl_handler;
>
> struct clk *img_clk;
> +
> struct regulator *avdd;
> + struct regulator *dvdd;
> + struct regulator *dovdd;

Could you use the regulator bulk API instead of adding each separately?

> +
> struct gpio_desc *reset;
>
> /* V4L2 Controls */
> @@ -1197,6 +1201,10 @@ static int ov13b10_power_off(struct device *dev)
>
> if (ov13b10->avdd)
> regulator_disable(ov13b10->avdd);
> + if (ov13b10->dvdd)
> + regulator_disable(ov13b10->dvdd);
> + if (ov13b10->dovdd)
> + regulator_disable(ov13b10->dovdd);
>
> clk_disable_unprepare(ov13b10->img_clk);
>
> @@ -1224,6 +1232,24 @@ static int ov13b10_power_on(struct device *dev)
> }
> }
>
> + if (ov13b10->dvdd) {
> + ret = regulator_enable(ov13b10->dvdd);
> + if (ret < 0) {
> + dev_err(dev, "failed to enable dvdd: %d", ret);
> + clk_disable_unprepare(ov13b10->img_clk);
> + return ret;
> + }
> + }
> +
> + if (ov13b10->dovdd) {
> + ret = regulator_enable(ov13b10->dovdd);
> + if (ret < 0) {
> + dev_err(dev, "failed to enable dovdd: %d", ret);
> + clk_disable_unprepare(ov13b10->img_clk);
> + return ret;

Error handling needs some work here.

> + }
> + }
> +
> gpiod_set_value_cansleep(ov13b10->reset, 0);
> /* 5ms to wait ready after XSHUTDN assert */
> usleep_range(5000, 5500);
> @@ -1500,6 +1526,24 @@ static int ov13b10_get_pm_resources(struct ov13b10 *ov13b)
> "failed to get avdd regulator\n");
> }
>
> + ov13b->dvdd = devm_regulator_get_optional(ov13b->dev, "dvdd");
> + if (IS_ERR(ov13b->dvdd)) {
> + ret = PTR_ERR(ov13b->dvdd);
> + ov13b->dvdd = NULL;
> + if (ret != -ENODEV)
> + return dev_err_probe(ov13b->dev, ret,
> + "failed to get dvdd regulator\n");
> + }
> +
> + ov13b->dovdd = devm_regulator_get_optional(ov13b->dev, "dovdd");
> + if (IS_ERR(ov13b->dovdd)) {
> + ret = PTR_ERR(ov13b->dovdd);
> + ov13b->dovdd = NULL;
> + if (ret != -ENODEV)
> + return dev_err_probe(ov13b->dev, ret,
> + "failed to get dovdd regulator\n");
> + }
> +
> return 0;
> }
>
> @@ -1700,11 +1744,20 @@ static const struct acpi_device_id ov13b10_acpi_ids[] = {
> MODULE_DEVICE_TABLE(acpi, ov13b10_acpi_ids);
> #endif
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id ov13b10_of_match[] = {
> + {.compatible = "ovti,ov13b10"},

{ Spaces inside braces, please. }

> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, ov13b10_of_match);
> +#endif
> +
> static struct i2c_driver ov13b10_i2c_driver = {
> .driver = {
> .name = "ov13b10",
> .pm = pm_ptr(&ov13b10_pm_ops),
> .acpi_match_table = ACPI_PTR(ov13b10_acpi_ids),
> + .of_match_table = of_match_ptr(ov13b10_of_match),

No need for of_match_ptr() here -- ACPI supports device probing through
of_match_table, too.

> },
> .probe = ov13b10_probe,
> .remove = ov13b10_remove,

--
Regards,

Sakari Ailus