media: pwm-ir-tx: regulator support
Subsystems (5)
cover media: pwm-ir-tx: regulator support
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.
---
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,
Signature · 1 line
Roman Vivchar <[email protected]>
PATCH 1/2 dt-bindings: leds: irled: pwm-ir-tx: add power supply support
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.
--- Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml +4 -0
@@ -23,6 +23,10 @@ properties: pwms: maxItems: 1 + power-supply: + description: + The regulator controlling the current to the LED. + required: - compatible - pwms
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
From: Roman Vivchar <[email protected]>
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
In reply to Roman VivcharQuoted 9 lines · 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 <[email protected]>--- Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Best regards,
Krzysztof
Re: (subset) [PATCH 1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
In reply to Roman VivcharQuoted 4 lines · 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.
Applied, thanks!
[1/2] dt-bindings: leds: irled: pwm-ir-tx: add power supply support
commit: 3aec3445e63e3bc1cfd7c198b903d01b5bb9b27e
--
Lee Jones [李琼斯]
PATCH 2/2 media: pwm-ir-tx: add regulator support
In reply to Roman VivcharOn 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.
--- drivers/media/rc/pwm-ir-tx.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/media/rc/pwm-ir-tx.c +36 -1
@@ -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 ;
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 2/2] media: pwm-ir-tx: add regulator support
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
From: Roman Vivchar <[email protected]>
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2