All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] media: pwm-ir-tx: regulator support
@ 2026-11-02 15:22 ` Roman Vivchar
  0 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

This patch series adds optional power-supply property for PWM IR LED,
because some boards, like Xiaomi Redmi Note 9 phone, have the LED
connected to the eMMC power rail. If the eMMC is powered down, IR LED
can't function.

Patch 1 adds dt-bindings documentation for the power-supply property.
Patch 2 adds regulator management to the driver.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Roman Vivchar (2):
      dt-bindings: leds: irled: pwm-ir-tx: add power supply support
      media: pwm-ir-tx: add regulator support

 .../devicetree/bindings/leds/irled/pwm-ir-tx.yaml  |  4 +++
 drivers/media/rc/pwm-ir-tx.c                       | 37 +++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
---
base-commit: 5e6de6a2b522f659defacb1551d0465ba6ce13cf
change-id: 20261102-6768-irled-9e368faa84a7

Best regards,
--  
Roman Vivchar <rva333@protonmail.com>



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

* [PATCH 0/2] media: pwm-ir-tx: regulator support
@ 2026-11-02 15:22 ` Roman Vivchar
  0 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

This patch series adds optional power-supply property for PWM IR LED,
because some boards, like Xiaomi Redmi Note 9 phone, have the LED
connected to the eMMC power rail. If the eMMC is powered down, IR LED
can't function.

Patch 1 adds dt-bindings documentation for the power-supply property.
Patch 2 adds regulator management to the driver.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Roman Vivchar (2):
      dt-bindings: leds: irled: pwm-ir-tx: add power supply support
      media: pwm-ir-tx: add regulator support

 .../devicetree/bindings/leds/irled/pwm-ir-tx.yaml  |  4 +++
 drivers/media/rc/pwm-ir-tx.c                       | 37 +++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
---
base-commit: 5e6de6a2b522f659defacb1551d0465ba6ce13cf
change-id: 20261102-6768-irled-9e368faa84a7

Best regards,
--  
Roman Vivchar <rva333@protonmail.com>


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

* [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
  2026-11-02 15:22 ` Roman Vivchar
@ 2026-11-02 15:22   ` Roman Vivchar
  -1 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

From: Roman Vivchar <rva333@protonmail.com>

On some boards, the IR LED is connected to a switchable power rail, such
as an eMMC supply. If this regulator is disabled, IR transmission fails.

Add an optional power-supply property to document this regulator.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
 Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
index 7526e3149f72..35a601cc068b 100644
--- a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
+++ b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
@@ -23,6 +23,10 @@ properties:
   pwms:
     maxItems: 1
 
+  power-supply:
+    description:
+      The regulator controlling the current to the LED.
+
 required:
   - compatible
   - pwms

-- 
2.56.0



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

* [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
@ 2026-11-02 15:22   ` Roman Vivchar
  0 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

On some boards, the IR LED is connected to a switchable power rail, such
as an eMMC supply. If this regulator is disabled, IR transmission fails.

Add an optional power-supply property to document this regulator.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
 Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
index 7526e3149f72..35a601cc068b 100644
--- a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
+++ b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
@@ -23,6 +23,10 @@ properties:
   pwms:
     maxItems: 1
 
+  power-supply:
+    description:
+      The regulator controlling the current to the LED.
+
 required:
   - compatible
   - pwms

-- 
2.56.0


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

* [PATCH 2/2] media: pwm-ir-tx: add regulator support
  2026-11-02 15:22 ` Roman Vivchar
@ 2026-11-02 15:22   ` Roman Vivchar
  -1 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

From: Roman Vivchar <rva333@protonmail.com>

On some boards, the IR LED shares a power rail with other components.
If that rail is turned off, IR transmission can't function properly.

Add optional regulator support to ensure the power supply is enabled when
needed.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
 drivers/media/rc/pwm-ir-tx.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c
index 047472dc9244..f9c95d034493 100644
--- a/drivers/media/rc/pwm-ir-tx.c
+++ b/drivers/media/rc/pwm-ir-tx.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/hrtimer.h>
 #include <linux/completion.h>
 #include <media/rc-core.h>
@@ -19,6 +20,7 @@
 
 struct pwm_ir {
 	struct pwm_device *pwm;
+	struct regulator *reg;
 	struct hrtimer timer;
 	struct completion tx_done;
 	struct pwm_state *state;
@@ -63,10 +65,16 @@ static int pwm_ir_tx_sleep(struct rc_dev *dev, unsigned int *txbuf,
 	struct pwm_ir *pwm_ir = dev->priv;
 	struct pwm_device *pwm = pwm_ir->pwm;
 	struct pwm_state state;
-	int i;
+	int i, ret;
 	ktime_t edge;
 	long delta;
 
+	if (pwm_ir->reg) {
+		ret = regulator_enable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	pwm_init_state(pwm, &state);
 
 	state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
@@ -87,6 +95,12 @@ static int pwm_ir_tx_sleep(struct rc_dev *dev, unsigned int *txbuf,
 	state.enabled = false;
 	pwm_apply_might_sleep(pwm, &state);
 
+	if (pwm_ir->reg) {
+		ret = regulator_disable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	return count;
 }
 
@@ -96,6 +110,7 @@ static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf,
 	struct pwm_ir *pwm_ir = dev->priv;
 	struct pwm_device *pwm = pwm_ir->pwm;
 	struct pwm_state state;
+	int ret;
 
 	pwm_init_state(pwm, &state);
 
@@ -107,10 +122,22 @@ static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf,
 	pwm_ir->txbuf_index = 0;
 	pwm_ir->state = &state;
 
+	if (pwm_ir->reg) {
+		ret = regulator_enable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	hrtimer_start(&pwm_ir->timer, 0, HRTIMER_MODE_REL);
 
 	wait_for_completion(&pwm_ir->tx_done);
 
+	if (pwm_ir->reg) {
+		ret = regulator_disable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	return count;
 }
 
@@ -157,6 +184,14 @@ static int pwm_ir_probe(struct platform_device *pdev)
 	if (IS_ERR(pwm_ir->pwm))
 		return PTR_ERR(pwm_ir->pwm);
 
+	pwm_ir->reg = devm_regulator_get_optional(&pdev->dev, "power");
+	if (IS_ERR(pwm_ir->reg)) {
+		if (PTR_ERR(pwm_ir->reg) != -ENODEV)
+			return PTR_ERR(pwm_ir->reg);
+
+		pwm_ir->reg = NULL;
+	}
+
 	pwm_ir->carrier = 38000;
 	pwm_ir->duty_cycle = 50;
 

-- 
2.56.0



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

* [PATCH 2/2] media: pwm-ir-tx: add regulator support
@ 2026-11-02 15:22   ` Roman Vivchar
  0 siblings, 0 replies; 8+ messages in thread
From: Roman Vivchar @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Sean Young, Lee Jones, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Mauro Carvalho Chehab,
	Liam Girdwood, Mark Brown
  Cc: linux-media, linux-leds, devicetree, linux-kernel, Roman Vivchar

On some boards, the IR LED shares a power rail with other components.
If that rail is turned off, IR transmission can't function properly.

Add optional regulator support to ensure the power supply is enabled when
needed.

Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
 drivers/media/rc/pwm-ir-tx.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c
index 047472dc9244..f9c95d034493 100644
--- a/drivers/media/rc/pwm-ir-tx.c
+++ b/drivers/media/rc/pwm-ir-tx.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/hrtimer.h>
 #include <linux/completion.h>
 #include <media/rc-core.h>
@@ -19,6 +20,7 @@
 
 struct pwm_ir {
 	struct pwm_device *pwm;
+	struct regulator *reg;
 	struct hrtimer timer;
 	struct completion tx_done;
 	struct pwm_state *state;
@@ -63,10 +65,16 @@ static int pwm_ir_tx_sleep(struct rc_dev *dev, unsigned int *txbuf,
 	struct pwm_ir *pwm_ir = dev->priv;
 	struct pwm_device *pwm = pwm_ir->pwm;
 	struct pwm_state state;
-	int i;
+	int i, ret;
 	ktime_t edge;
 	long delta;
 
+	if (pwm_ir->reg) {
+		ret = regulator_enable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	pwm_init_state(pwm, &state);
 
 	state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
@@ -87,6 +95,12 @@ static int pwm_ir_tx_sleep(struct rc_dev *dev, unsigned int *txbuf,
 	state.enabled = false;
 	pwm_apply_might_sleep(pwm, &state);
 
+	if (pwm_ir->reg) {
+		ret = regulator_disable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	return count;
 }
 
@@ -96,6 +110,7 @@ static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf,
 	struct pwm_ir *pwm_ir = dev->priv;
 	struct pwm_device *pwm = pwm_ir->pwm;
 	struct pwm_state state;
+	int ret;
 
 	pwm_init_state(pwm, &state);
 
@@ -107,10 +122,22 @@ static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf,
 	pwm_ir->txbuf_index = 0;
 	pwm_ir->state = &state;
 
+	if (pwm_ir->reg) {
+		ret = regulator_enable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	hrtimer_start(&pwm_ir->timer, 0, HRTIMER_MODE_REL);
 
 	wait_for_completion(&pwm_ir->tx_done);
 
+	if (pwm_ir->reg) {
+		ret = regulator_disable(pwm_ir->reg);
+		if (ret)
+			return ret;
+	}
+
 	return count;
 }
 
@@ -157,6 +184,14 @@ static int pwm_ir_probe(struct platform_device *pdev)
 	if (IS_ERR(pwm_ir->pwm))
 		return PTR_ERR(pwm_ir->pwm);
 
+	pwm_ir->reg = devm_regulator_get_optional(&pdev->dev, "power");
+	if (IS_ERR(pwm_ir->reg)) {
+		if (PTR_ERR(pwm_ir->reg) != -ENODEV)
+			return PTR_ERR(pwm_ir->reg);
+
+		pwm_ir->reg = NULL;
+	}
+
 	pwm_ir->carrier = 38000;
 	pwm_ir->duty_cycle = 50;
 

-- 
2.56.0


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

* Re: [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
  2026-11-02 15:22   ` Roman Vivchar
  (?)
@ 2026-11-02 15:26   ` sashiko-bot
  -1 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-02 15:26 UTC (permalink / raw)
  To: Roman Vivchar; +Cc: linux-leds, lee

> From: Roman Vivchar <rva333@protonmail.com>
> 
> On some boards, the IR LED is connected to a switchable power rail, such
> as an eMMC supply. If this regulator is disabled, IR transmission fails.
> 
> Add an optional power-supply property to document this regulator.
> 
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102-6768-irled-v1-0-c7064f3afed1@protonmail.com?part=1


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

* Re: [PATCH 2/2] media: pwm-ir-tx: add regulator support
  2026-11-02 15:22   ` Roman Vivchar
  (?)
@ 2026-11-02 15:29   ` sashiko-bot
  -1 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-02 15:29 UTC (permalink / raw)
  To: Roman Vivchar; +Cc: linux-leds, lee

> From: Roman Vivchar <rva333@protonmail.com>
> 
> On some boards, the IR LED shares a power rail with other components.
> If that rail is turned off, IR transmission can't function properly.
> 
> Add optional regulator support to ensure the power supply is enabled when
> needed.
> 
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102-6768-irled-v1-0-c7064f3afed1@protonmail.com?part=2


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

end of thread, other threads:[~2026-11-02 15:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 15:22 [PATCH 0/2] media: pwm-ir-tx: regulator support Roman Vivchar via B4 Relay
2026-11-02 15:22 ` Roman Vivchar
2026-11-02 15:22 ` [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support Roman Vivchar via B4 Relay
2026-11-02 15:22   ` Roman Vivchar
2026-11-02 15:26   ` sashiko-bot
2026-11-02 15:22 ` [PATCH 2/2] media: pwm-ir-tx: add regulator support Roman Vivchar via B4 Relay
2026-11-02 15:22   ` Roman Vivchar
2026-11-02 15:29   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.