Devicetree
 help / color / mirror / Atom feed
* [PATCH v4 0/2] regulator: rpi-panel-v2: Add vcc-supply
@ 2026-11-04  8:10 Shashank Maurya
  2026-11-04  8:10 ` [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property Shashank Maurya
  2026-11-04  8:10 ` [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support Shashank Maurya
  0 siblings, 2 replies; 6+ messages in thread
From: Shashank Maurya @ 2026-11-04  8:10 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Marek Vasut
  Cc: linux-kernel, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Shashank Maurya

This series adds a vcc-supply property to both the dt-binding and the
driver:

- Patch 1/2: dt-bindings - documents the vcc-supply property as an
    optional property.
  - Patch 2/2: driver - uses devm_regulator_get() to obtain and enable
    the vcc supply at the start of probe, before any I2C access.

---
Changes in v4:
- Rebased onto the latest regulator for-next branch.
- No functional changes.
- Link to v3: https://patch.msgid.link/20260922-rpi_reg-v3-0-9214321c4070@oss.qualcomm.com

Changes in v3:
- dt-bindings: make vcc-supply optional instead of required, to preserve
  compatibility with existing device trees that do not describe the
  supply.
- Driver is unchanged from v2: devm_regulator_get() returns a dummy
  regulator when the supply is absent, so an optional binding needs no
  driver change.
- Link to v2: https://patch.msgid.link/20260907-rpi_reg-v2-0-0c59aa60d31f@oss.qualcomm.com

Changes in v2:
  - Made vcc-supply required instead of optional (devm_regulator_get()
    instead of devm_regulator_get_optional()).
  - Added vcc-supply to the required list in the dt-binding schema.

Changes in v1:
  - Initial submission with optional vcc-supply support.

To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Florian Fainelli <florian.fainelli@broadcom.com>
To: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
To: Marek Vasut <marek.vasut+renesas@mailbox.org>
Cc: linux-kernel@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-rpi-kernel@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org

---
Shashank Maurya (2):
      dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property
      regulator: rpi-panel-v2: Add vcc-supply support

 .../raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml    |  4 ++++
 drivers/regulator/rpi-panel-v2-regulator.c                   | 12 ++++++++++++
 2 files changed, 16 insertions(+)
---
base-commit: 5436a50a0b44b448f965e928507b5159059dee57
change-id: 20260907-rpi_reg-8c6885b35e5b

Best regards,
--  
Shashank Maurya <shashank.maurya@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property
  2026-11-04  8:10 [PATCH v4 0/2] regulator: rpi-panel-v2: Add vcc-supply Shashank Maurya
@ 2026-11-04  8:10 ` Shashank Maurya
  2026-11-04 17:05   ` Rob Herring
  2026-11-04  8:10 ` [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support Shashank Maurya
  1 sibling, 1 reply; 6+ messages in thread
From: Shashank Maurya @ 2026-11-04  8:10 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Marek Vasut
  Cc: linux-kernel, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Shashank Maurya

Add an optional vcc-supply property to the Raspberry Pi 7" touchscreen
panel V2 regulator binding. The panel controller MCU is powered from an
external power rail, which has to be supplied before any I2C
communication can take place.

The property is optional so that existing device trees which do not
describe the supply remain valid.

Signed-off-by: Shashank Maurya <shashank.maurya@oss.qualcomm.com>
---
 .../regulator/raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml   | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml b/Documentation/devicetree/bindings/regulator/raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml
index 37b9ed371b67..3e2cbcad6490 100644
--- a/Documentation/devicetree/bindings/regulator/raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml
+++ b/Documentation/devicetree/bindings/regulator/raspberrypi,7inch-touchscreen-panel-regulator-v2.yaml
@@ -35,6 +35,9 @@ properties:
     const: 3
     description: See ../../pwm/pwm.yaml for description of the cell formats.
 
+  vcc-supply:
+    description: Regulator supplying power to the panel controller.
+
 additionalProperties: false
 
 required:
@@ -55,6 +58,7 @@ examples:
         gpio-controller;
         #gpio-cells = <2>;
         #pwm-cells = <3>;
+        vcc-supply = <&vcc_reg>;
       };
     };
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support
  2026-11-04  8:10 [PATCH v4 0/2] regulator: rpi-panel-v2: Add vcc-supply Shashank Maurya
  2026-11-04  8:10 ` [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property Shashank Maurya
@ 2026-11-04  8:10 ` Shashank Maurya
  2026-11-04  8:16   ` sashiko-bot
  2026-11-04 13:23   ` Mark Brown
  1 sibling, 2 replies; 6+ messages in thread
From: Shashank Maurya @ 2026-11-04  8:10 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Marek Vasut
  Cc: linux-kernel, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Shashank Maurya

The Raspberry Pi 7" touchscreen panel V2 MCU is powered from an external
power rail which has to be enabled before any I2C register access is
attempted. Use devm_regulator_get() to obtain the vcc supply and enable
it at the start of probe.

devm_regulator_get() returns a dummy regulator when the supply is not
described in the device tree, so device trees without a vcc-supply
property keep working as before.

Signed-off-by: Shashank Maurya <shashank.maurya@oss.qualcomm.com>
---
 drivers/regulator/rpi-panel-v2-regulator.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/regulator/rpi-panel-v2-regulator.c b/drivers/regulator/rpi-panel-v2-regulator.c
index 30b78aa75ee3..e54d675962e7 100644
--- a/drivers/regulator/rpi-panel-v2-regulator.c
+++ b/drivers/regulator/rpi-panel-v2-regulator.c
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/pwm.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 
 /* I2C registers of the microcontroller. */
 #define REG_ID		0x01
@@ -66,10 +67,21 @@ static int rpi_panel_v2_i2c_probe(struct i2c_client *i2c)
 		.parent		= &i2c->dev,
 		.reg_set_base	= REG_POWERON,
 	};
+	struct regulator *vcc;
 	struct regmap *regmap;
 	struct pwm_chip *pc;
 	int ret;
 
+	vcc = devm_regulator_get(&i2c->dev, "vcc");
+	if (IS_ERR(vcc))
+		return dev_err_probe(&i2c->dev, PTR_ERR(vcc),
+				     "Failed to get vcc supply\n");
+
+	ret = regulator_enable(vcc);
+	if (ret)
+		return dev_err_probe(&i2c->dev, ret,
+				     "Failed to enable vcc supply\n");
+
 	pc = devm_pwmchip_alloc(&i2c->dev, 1, 0);
 	if (IS_ERR(pc))
 		return PTR_ERR(pc);

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support
  2026-11-04  8:10 ` [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support Shashank Maurya
@ 2026-11-04  8:16   ` sashiko-bot
  2026-11-04 13:23   ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-04  8:16 UTC (permalink / raw)
  To: Shashank Maurya; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] regulator: rpi-panel-v2: leaked enable count in rpi_panel_v2_i2c_probe()
--

commit e10aa8754cb62ec300b893710f2607ab6d8e3548
Author: Shashank Maurya <shashank.maurya@oss.qualcomm.com>

regulator: rpi-panel-v2: Add vcc-supply support

This commit adds support for acquiring and enabling the vcc power supply in
rpi_panel_v2_i2c_probe() before accessing the panel MCU over I2C.

> diff --git a/drivers/regulator/rpi-panel-v2-regulator.c b/drivers/regulator/rpi-panel-v2-regulator.c
> index 30b78aa75ee38..e54d675962e71 100644
> --- a/drivers/regulator/rpi-panel-v2-regulator.c
> +++ b/drivers/regulator/rpi-panel-v2-regulator.c

[ ... ]

> @@ -66,10 +67,21 @@ static int rpi_panel_v2_i2c_probe(struct i2c_client *i2c)
>  		.parent		= &i2c->dev,
>  		.reg_set_base	= REG_POWERON,
>  	};
> +	struct regulator *vcc;
>  	struct regmap *regmap;
>  	struct pwm_chip *pc;
>  	int ret;
>  
> +	vcc = devm_regulator_get(&i2c->dev, "vcc");
> +	if (IS_ERR(vcc))
> +		return dev_err_probe(&i2c->dev, PTR_ERR(vcc),
> +				     "Failed to get vcc supply\n");
> +
> +	ret = regulator_enable(vcc);
> +	if (ret)
> +		return dev_err_probe(&i2c->dev, ret,
> +				     "Failed to enable vcc supply\n");

[Severity: High]
As reported by Sashiko on v2 [1], does this leak the vcc regulator enable
count when a subsequent call in rpi_panel_v2_i2c_probe() fails (such as
devm_pwmchip_alloc(), devm_regmap_init_i2c(), devm_gpio_regmap_register(), or
devm_pwmchip_add()), or when the driver is unbound?

Because vcc is acquired with devm_regulator_get() and enabled with an
unmanaged regulator_enable(), devres cleanup calls:

  devm_regulator_release()
    -> regulator_put()
      -> _regulator_put()

while regulator->enable_count is still 1, triggering
WARN_ON(regulator->enable_count) in _regulator_put() and leaving the
underlying regulator_dev use_count permanently elevated.

Should rpi_panel_v2_i2c_probe() use devm_regulator_get_enable(&i2c->dev,
"vcc") instead so that a devm action is registered to disable the supply
before releasing it?

[1] https://lore.kernel.org/r/20260907055129.010E71F00A3A@smtp.kernel.org

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104-rpi_reg-v4-0-3578e794ff45@oss.qualcomm.com?part=2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support
  2026-11-04  8:10 ` [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support Shashank Maurya
  2026-11-04  8:16   ` sashiko-bot
@ 2026-11-04 13:23   ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-11-04 13:23 UTC (permalink / raw)
  To: Shashank Maurya
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Marek Vasut, linux-kernel,
	devicetree, linux-rpi-kernel, linux-arm-kernel

> The Raspberry Pi 7" touchscreen panel V2 MCU is powered from an external
> power rail which has to be enabled before any I2C register access is
> attempted. Use devm_regulator_get() to obtain the vcc supply and enable
> it at the start of probe.

> +	ret = regulator_enable(vcc);
> +	if (ret)
> +		return dev_err_probe(&i2c->dev, ret,
> +				     "Failed to enable vcc supply\n");

Nothing ever undoes this enable.

-- 
Mark Brown <broonie@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property
  2026-11-04  8:10 ` [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property Shashank Maurya
@ 2026-11-04 17:05   ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2026-11-04 17:05 UTC (permalink / raw)
  To: Shashank Maurya
  Cc: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Conor Dooley,
	Florian Fainelli, Broadcom internal kernel review list,
	Marek Vasut, linux-kernel, devicetree, linux-rpi-kernel,
	linux-arm-kernel

On Wed, Nov 04, 2026 at 01:40:47PM +0530, Shashank Maurya wrote:
> Add an optional vcc-supply property to the Raspberry Pi 7" touchscreen
> panel V2 regulator binding. The panel controller MCU is powered from an
> external power rail, which has to be supplied before any I2C
> communication can take place.
> 
> The property is optional so that existing device trees which do not
> describe the supply remain valid.
> 
> Signed-off-by: Shashank Maurya <shashank.maurya@oss.qualcomm.com>

Missing Krzysztof's ack.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-04 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  8:10 [PATCH v4 0/2] regulator: rpi-panel-v2: Add vcc-supply Shashank Maurya
2026-11-04  8:10 ` [PATCH v4 1/2] dt-bindings: regulator: rpi-panel-v2: Add vcc-supply property Shashank Maurya
2026-11-04 17:05   ` Rob Herring
2026-11-04  8:10 ` [PATCH v4 2/2] regulator: rpi-panel-v2: Add vcc-supply support Shashank Maurya
2026-11-04  8:16   ` sashiko-bot
2026-11-04 13:23   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox