* [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support
@ 2026-03-20 9:25 Antoine Bernard
2026-03-20 21:34 ` Sakari Ailus
0 siblings, 1 reply; 4+ messages in thread
From: Antoine Bernard @ 2026-03-20 9:25 UTC (permalink / raw)
To: Arec Kao, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sakari Ailus, Liam Girdwood, Mark Brown,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: ~postmarketos/upstreaming@lists.sr.ht
From: Antoine Bernard <zalnir@proton.me>
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@proton.me>
---
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;
+
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;
+ }
+ }
+
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"},
+ { /* 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),
},
.probe = ov13b10_probe,
.remove = ov13b10_remove,
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support
2026-03-20 9:25 [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support Antoine Bernard
@ 2026-03-20 21:34 ` Sakari Ailus
2026-03-21 4:57 ` Antoine Bernard
0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2026-03-20 21:34 UTC (permalink / raw)
To: Antoine Bernard
Cc: Arec Kao, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Liam Girdwood, Mark Brown,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Hi Antoine,
Thanks for the patch.
On Fri, Mar 20, 2026 at 09:25:21AM +0000, Antoine Bernard wrote:
> From: Antoine Bernard <zalnir@proton.me>
>
> 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@proton.me>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support
2026-03-20 21:34 ` Sakari Ailus
@ 2026-03-21 4:57 ` Antoine Bernard
2026-03-23 9:34 ` Sakari Ailus
0 siblings, 1 reply; 4+ messages in thread
From: Antoine Bernard @ 2026-03-21 4:57 UTC (permalink / raw)
To: Sakari Ailus
Cc: Arec Kao, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Liam Girdwood, Mark Brown,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Thanks for reviewing the patch.
This is my first time sending patches to LKML, so please do
understand if I make some mistakes.
--
> Error handling needs some work here.
Could you perhaps tell me in detail? The logic is same as with
avdd, so I am not quite sure how to refactor these.
> ACPI supports device probing through of_match_table, too.
I thought this was needed, because embedded devices don't have
ACPI. Is it possible to not use of_match_ptr() and instead do
.of_match_table = ov13b10_of_match directly?
--
Best regards,
Antoine
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support
2026-03-21 4:57 ` Antoine Bernard
@ 2026-03-23 9:34 ` Sakari Ailus
0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2026-03-23 9:34 UTC (permalink / raw)
To: Antoine Bernard
Cc: Arec Kao, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Liam Girdwood, Mark Brown,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Hi Antoine,
On Sat, Mar 21, 2026 at 04:57:10AM +0000, Antoine Bernard wrote:
> Thanks for reviewing the patch.
>
> This is my first time sending patches to LKML, so please do
> understand if I make some mistakes.
> --
> > Error handling needs some work here.
>
> Could you perhaps tell me in detail? The logic is same as with
> avdd, so I am not quite sure how to refactor these.
What happens if enabling the last regulator fails?
>
> > ACPI supports device probing through of_match_table, too.
>
> I thought this was needed, because embedded devices don't have
> ACPI. Is it possible to not use of_match_ptr() and instead do
> .of_match_table = ov13b10_of_match directly?
Yes, please.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-23 9:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 9:25 [PATCH 1/3] media: i2c: ov13b10: Add dvdd, dovdd and device tree support Antoine Bernard
2026-03-20 21:34 ` Sakari Ailus
2026-03-21 4:57 ` Antoine Bernard
2026-03-23 9:34 ` Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox