Skip to contentSkip to conversation

media: i2c: ov8856 : remove ACPI node bypass mechanism

PATCH Superseded Serin Yeh 3 participants 4 messages Jul 23 – Aug 6

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Serin Yeh

author
#0 lore raw

PATCH v3 1/2 media: i2c: ov8856 : remove ACPI node bypass mechanism

The driver currently skips power-on and power-off sequences when running with ACPI devices by checking is_acpi_node(). This results in all power configuration steps (GPIO, and regulators) being bypassed.

Remove the is_acpi_node() checks to ensure that the full power sequence is always executed regardless of the firmware interface.

With these changes, the driver behaves consistently across DT and ACPI platforms and ensures correct hardware initialization.

Fixes d2fa1134a48b ("media: i2c: ov8856: Use V4L2 legacy sensor clock helper")
---
 drivers/media/i2c/ov8856.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/media/i2c/ov8856.c +10 -19
index 8bedb47cd7cf..9d2b0469a576 100644
@@ -2082,9 +2082,6 @@ static int ov8856_power_on(struct device *dev)
 	struct ov8856 *ov8856 = to_ov8856(sd);
 	int ret;
 
-	if (is_acpi_node(dev_fwnode(dev)))
-		return 0;
-
 	ret = clk_prepare_enable(ov8856->xvclk);
 	if (ret < 0) {
 		dev_err(dev, "failed to enable xvclk\n");
@@ -2120,9 +2117,6 @@ static int ov8856_power_off(struct device *dev)
 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct ov8856 *ov8856 = to_ov8856(sd);
 
-	if (is_acpi_node(dev_fwnode(dev)))
-		return 0;
-
 	gpiod_set_value_cansleep(ov8856->reset_gpio, 1);
 	regulator_bulk_disable(ARRAY_SIZE(ov8856_supply_names),
 			       ov8856->supplies);
@@ -2293,21 +2287,18 @@ static int ov8856_get_hwcfg(struct ov8856 *ov8856)
 		dev_warn(dev, "external clock rate %u is unsupported",
 			 xvclk_rate);
 
-	if (!is_acpi_node(fwnode)) {
-		ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
-							     GPIOD_OUT_LOW);
-		if (IS_ERR(ov8856->reset_gpio))
-			return PTR_ERR(ov8856->reset_gpio);
+	ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
+						     GPIOD_OUT_LOW);
+	if (IS_ERR(ov8856->reset_gpio))
+		return PTR_ERR(ov8856->reset_gpio);
 
-		for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)
-			ov8856->supplies[i].supply = ov8856_supply_names[i];
+	for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)
+		ov8856->supplies[i].supply = ov8856_supply_names[i];
 
-		ret = devm_regulator_bulk_get(dev,
-					      ARRAY_SIZE(ov8856_supply_names),
-					      ov8856->supplies);
-		if (ret)
-			return ret;
-	}
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ov8856_supply_names),
+				      ov8856->supplies);
+	if (ret)
+		return ret;
 
 	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
 	if (!ep)
Signature · 1 line
2.25.1
Reviewed-by on v3 1/2
#1 lore raw
Quoted 9 lines · Serin Yeh

The driver currently skips power-on and power-off sequences when running with ACPI devices by checking is_acpi_node(). This results in all power configuration steps (GPIO, and regulators) being bypassed.

Remove the is_acpi_node() checks to ensure that the full power sequence is always executed regardless of the firmware interface.

With these changes, the driver behaves consistently across DT and ACPI platforms and ensures correct hardware initialization.

I think your description in the cover letter should be incoporated into your commit log

"- Background: power resources on Intel ACPI platforms :
On Intel platforms the sensor is enumerated via ACPI, and an INT3472 "discrete" companion device (the power-logic-control driver under drivers/platform/x86/intel/int3472) registers the sensor's reset/powerdown GPIOs and the regulator supply.
These resources are therefore discoverable and usable through the standard gpiod/regulator lookups at probe time.

- Current symptom :
Previously the driver guarded both the GPIO/regulator acquisition in ov8856_get_hwcfg() and the whole power on/off sequence with is_acpi_node() and skipped them on ACPI. As a result the sensor was never powered or reset by the driver and probe failed when reading the chip ID in ov8856_identify_module(). Removing those checks makes the ACPI path behave like DT.

- Validation :
Tested on Intel platforms with kernel 6.17 and 7.0."

Then:

maintainer
#2 lore raw
In reply to Serin Yeh

Hi Serin,

Quoted 58 lines · Serin Yeh

The driver currently skips power-on and power-off sequences when running with ACPI devices by checking is_acpi_node(). This results in all power configuration steps (GPIO, and regulators) being bypassed.

Remove the is_acpi_node() checks to ensure that the full power sequence is always executed regardless of the firmware interface.

With these changes, the driver behaves consistently across DT and ACPI platforms and ensures correct hardware initialization.

Fixes d2fa1134a48b ("media: i2c: ov8856: Use V4L2 legacy sensor clock helper")
---
 drivers/media/i2c/ov8856.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/media/i2c/ov8856.c +5 -13
index 8bedb47cd7cf..9d2b0469a576 100644
@@ -2082,9 +2082,6 @@ static int ov8856_power_on(struct device *dev)
 	struct ov8856 *ov8856 = to_ov8856(sd);
 	int ret;
 
-	if (is_acpi_node(dev_fwnode(dev)))
-		return 0;
-
 	ret = clk_prepare_enable(ov8856->xvclk);
 	if (ret < 0) {
 		dev_err(dev, "failed to enable xvclk\n");
@@ -2120,9 +2117,6 @@ static int ov8856_power_off(struct device *dev)
 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct ov8856 *ov8856 = to_ov8856(sd);
 
-	if (is_acpi_node(dev_fwnode(dev)))
-		return 0;
-
 	gpiod_set_value_cansleep(ov8856->reset_gpio, 1);
 	regulator_bulk_disable(ARRAY_SIZE(ov8856_supply_names),
 			       ov8856->supplies);
@@ -2293,21 +2287,18 @@ static int ov8856_get_hwcfg(struct ov8856 *ov8856)
 		dev_warn(dev, "external clock rate %u is unsupported",
 			 xvclk_rate);
 
-	if (!is_acpi_node(fwnode)) {
-		ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
-							     GPIOD_OUT_LOW);
-		if (IS_ERR(ov8856->reset_gpio))
-			return PTR_ERR(ov8856->reset_gpio);
+	ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
+						     GPIOD_OUT_LOW);
+	if (IS_ERR(ov8856->reset_gpio))
+		return PTR_ERR(ov8856->reset_gpio);
 
-		for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)
-			ov8856->supplies[i].supply = ov8856_supply_names[i];
+	for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)

drivers/media/i2c/ov8856.c static int ov8856_get_hwcfg(struct ov8856 *ov8856) · line 2299

Quoted 10 lines
drivers/media/i2c/ov8856.c +3 -6
+		ov8856->supplies[i].supply = ov8856_supply_names[i];
 
-		ret = devm_regulator_bulk_get(dev,
-					      ARRAY_SIZE(ov8856_supply_names),
-					      ov8856->supplies);
-		if (ret)
-			return ret;
-	}
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ov8856_supply_names),
+				      ov8856->supplies);

Can you fix this (multiple devm_regulator_bulk_get() should never have been done) first in a separate patch, as Bryan suggested?

Quoted 5 lines
drivers/media/i2c/ov8856.c +2 -0
+	if (ret)
+		return ret;
 
 	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
 	if (!ep)
Signature · 3 lines
Regards,

Sakari Ailus
author
#3 lore raw

Hi Sakari,

Thanks for the review.

Quoted 71 lines

-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Wednesday, July 29, 2026 2:01 AM
To: Yeh, Serin <[email protected]>
Cc: [email protected]; Su, Jimmy <[email protected]>; Sapre, Sarang <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/2] media: i2c: ov8856 : remove ACPI node bypass mechanism

Hi Serin,

Quoted 61 lines · Serin Yeh

The driver currently skips power-on and power-off sequences when running with ACPI devices by checking is_acpi_node(). This results in all power configuration steps (GPIO, and regulators) being bypassed.

Remove the is_acpi_node() checks to ensure that the full power sequence is always executed regardless of the firmware interface.

With these changes, the driver behaves consistently across DT and ACPI platforms and ensures correct hardware initialization.

Fixes d2fa1134a48b ("media: i2c: ov8856: Use V4L2 legacy sensor clock

helper")

---
 drivers/media/i2c/ov8856.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/media/i2c/ov8856.c +0 -3
index 8bedb47cd7cf..9d2b0469a576 100644
@@ -2082,9 +2082,6 @@ static int ov8856_power_on(struct device *dev)
            struct ov8856 *ov8856 = to_ov8856(sd);
            int ret;
 
-           if (is_acpi_node(dev_fwnode(dev)))
-                           return 0;
-
            ret = clk_prepare_enable(ov8856->xvclk);
            if (ret < 0) {
                            dev_err(dev, "failed to enable xvclk\n"); @@ -2120,9 +2117,6 @@

static int ov8856_power_off(struct device *dev)

            struct v4l2_subdev *sd = dev_get_drvdata(dev);
            struct ov8856 *ov8856 = to_ov8856(sd);
drivers/media/i2c/ov8856.c +6 -10
-           if (is_acpi_node(dev_fwnode(dev)))
-                           return 0;
-
            gpiod_set_value_cansleep(ov8856->reset_gpio, 1);
            regulator_bulk_disable(ARRAY_SIZE(ov8856_supply_names),
                                                   ov8856->supplies);
@@ -2293,21 +2287,18 @@ static int ov8856_get_hwcfg(struct ov8856 *ov8856)
                            dev_warn(dev, "external clock rate %u is unsupported",
                                             xvclk_rate);
 
-           if (!is_acpi_node(fwnode)) {
-                           ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
-                                                                                                                GPIOD_OUT_LOW);
-                           if (IS_ERR(ov8856->reset_gpio))
-                                           return PTR_ERR(ov8856->reset_gpio);
+          ov8856->reset_gpio = devm_gpiod_get_optional(dev, "reset",
+                                                                                               GPIOD_OUT_LOW);
+          if (IS_ERR(ov8856->reset_gpio))
+                          return PTR_ERR(ov8856->reset_gpio);
 
-                           for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)
-                                           ov8856->supplies[i].supply = ov8856_supply_names[i];
+          for (i = 0; i < ARRAY_SIZE(ov8856_supply_names); i++)
+                          ov8856->supplies[i].supply = ov8856_supply_names[i];
 
Quoted 11 lines

drivers/media/i2c/ov8856.c static int ov8856_get_hwcfg(struct ov8856 *ov8856) · line 2299

Quoted 8 lines
drivers/media/i2c/ov8856.c +2 -6
-                           ret = devm_regulator_bulk_get(dev,
-                                                                                 ARRAY_SIZE(ov8856_supply_names),
-                                                                                 ov8856->supplies);
-                           if (ret)
-                                           return ret;
-           }
+          ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ov8856_supply_names),
+                                                                ov8856->supplies);

Can you fix this (multiple devm_regulator_bulk_get() should never have been done) first in a separate patch, as Bryan suggested?

After discussing this with you, I believe the devm_regulator_bulk_get() logic is clear. The devm_regulator_bulk_get() is currently guarded by the is_acpi_node() conditional branch rather than being placed inside a loop. I'll address Bryan's suggestion and modify the commit log in v4.

Thanks.

Regards,
Serin Yeh