All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] leds: pwm: add flag to start without PWM init
@ 2020-03-09  8:24 Denis Osterland-Heim
  2020-03-09 19:42 ` Jacek Anaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Osterland-Heim @ 2020-03-09  8:24 UTC (permalink / raw)
  To: dmurphy, pavel, mark.rutland, jacek.anaszewski, robh+dt
  Cc: linux-kernel, Denis Osterland-Heim, linux-leds, devicetree

This patch add "pwm,uninitalized" devicetree flag support to pwm
leds, which allows to defer pwm init to first use of led.

This allows to configure the PWM early in bootloader to let the LED
blink until an application in Linux userspace set something different.

Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
---
Hi,

I want to ask if such a patch is intresting for mainline and
if it is woth to think about how to represent this state to user space.

Regards Denis

 Documentation/devicetree/bindings/leds/leds-pwm.txt |  1 +
 drivers/leds/leds-pwm.c                             | 10 ++++++++--
 include/linux/leds_pwm.h                            |  1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
index 6c6583c35f2f..4f58df631fc9 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -19,6 +19,7 @@ LED sub-node properties:
   see Documentation/devicetree/bindings/leds/common.txt
 - linux,default-trigger :  (optional)
   see Documentation/devicetree/bindings/leds/common.txt
+- pwm,uninitalized : defer PWM init to first brightness change of led
 
 Example:
 
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 8b6965a563e9..02c90f05602a 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -97,7 +97,8 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
 	 * FIXME: pwm_apply_args() should be removed when switching to the
 	 * atomic PWM API.
 	 */
-	pwm_apply_args(led_data->pwm);
+	if (!led->pwm_uninitialized)
+		pwm_apply_args(led_data->pwm);
 
 	pwm_get_args(led_data->pwm, &pargs);
 
@@ -108,7 +109,9 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
 	ret = devm_led_classdev_register(dev, &led_data->cdev);
 	if (ret == 0) {
 		priv->num_leds++;
-		led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
+		if (!led->pwm_uninitialized)
+			led_pwm_set(&led_data->cdev,
+					led_data->cdev.brightness);
 	} else {
 		dev_err(dev, "failed to register PWM led for %s: %d\n",
 			led->name, ret);
@@ -143,6 +146,9 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
 		fwnode_property_read_u32(fwnode, "max-brightness",
 					 &led.max_brightness);
 
+		led.pwm_uninitialized = fwnode_property_read_bool(fwnode,
+							"pwm,uninitialized");
+
 		ret = led_pwm_add(dev, priv, &led, fwnode);
 		if (ret) {
 			fwnode_handle_put(fwnode);
diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
index 93d101d28943..0b04dfd43654 100644
--- a/include/linux/leds_pwm.h
+++ b/include/linux/leds_pwm.h
@@ -10,6 +10,7 @@ struct led_pwm {
 	const char	*default_trigger;
 	unsigned	pwm_id __deprecated;
 	u8 		active_low;
+	u8		pwm_uninitialized;
 	unsigned 	max_brightness;
 	unsigned	pwm_period_ns;
 };
-- 
2.25.1



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 
- For general information on data protection and your respective rights please visit https://www.diehl.com/group/en/transparency-and-information-obligations/

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

* Re: [RFC PATCH] leds: pwm: add flag to start without PWM init
  2020-03-09  8:24 [RFC PATCH] leds: pwm: add flag to start without PWM init Denis Osterland-Heim
@ 2020-03-09 19:42 ` Jacek Anaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Jacek Anaszewski @ 2020-03-09 19:42 UTC (permalink / raw)
  To: Denis Osterland-Heim, dmurphy, pavel, mark.rutland, robh+dt
  Cc: linux-kernel, linux-leds, devicetree

Hi Denis,

There is already a property for that purpose: default-state = "keep";

Please just use it instead.

Best regards,
Jacek Anaszewski

On 3/9/20 9:24 AM, Denis Osterland-Heim wrote:
> This patch add "pwm,uninitalized" devicetree flag support to pwm
> leds, which allows to defer pwm init to first use of led.
> 
> This allows to configure the PWM early in bootloader to let the LED
> blink until an application in Linux userspace set something different.
> 
> Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
> ---
> Hi,
> 
> I want to ask if such a patch is intresting for mainline and
> if it is woth to think about how to represent this state to user space.
> 
> Regards Denis
> 
>  Documentation/devicetree/bindings/leds/leds-pwm.txt |  1 +
>  drivers/leds/leds-pwm.c                             | 10 ++++++++--
>  include/linux/leds_pwm.h                            |  1 +
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> index 6c6583c35f2f..4f58df631fc9 100644
> --- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
> +++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> @@ -19,6 +19,7 @@ LED sub-node properties:
>    see Documentation/devicetree/bindings/leds/common.txt
>  - linux,default-trigger :  (optional)
>    see Documentation/devicetree/bindings/leds/common.txt
> +- pwm,uninitalized : defer PWM init to first brightness change of led
>  
>  Example:
>  
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index 8b6965a563e9..02c90f05602a 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -97,7 +97,8 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
>  	 * FIXME: pwm_apply_args() should be removed when switching to the
>  	 * atomic PWM API.
>  	 */
> -	pwm_apply_args(led_data->pwm);
> +	if (!led->pwm_uninitialized)
> +		pwm_apply_args(led_data->pwm);
>  
>  	pwm_get_args(led_data->pwm, &pargs);
>  
> @@ -108,7 +109,9 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
>  	ret = devm_led_classdev_register(dev, &led_data->cdev);
>  	if (ret == 0) {
>  		priv->num_leds++;
> -		led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
> +		if (!led->pwm_uninitialized)
> +			led_pwm_set(&led_data->cdev,
> +					led_data->cdev.brightness);
>  	} else {
>  		dev_err(dev, "failed to register PWM led for %s: %d\n",
>  			led->name, ret);
> @@ -143,6 +146,9 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
>  		fwnode_property_read_u32(fwnode, "max-brightness",
>  					 &led.max_brightness);
>  
> +		led.pwm_uninitialized = fwnode_property_read_bool(fwnode,
> +							"pwm,uninitialized");
> +
>  		ret = led_pwm_add(dev, priv, &led, fwnode);
>  		if (ret) {
>  			fwnode_handle_put(fwnode);
> diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
> index 93d101d28943..0b04dfd43654 100644
> --- a/include/linux/leds_pwm.h
> +++ b/include/linux/leds_pwm.h
> @@ -10,6 +10,7 @@ struct led_pwm {
>  	const char	*default_trigger;
>  	unsigned	pwm_id __deprecated;
>  	u8 		active_low;
> +	u8		pwm_uninitialized;
>  	unsigned 	max_brightness;
>  	unsigned	pwm_period_ns;
>  };
> 



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

end of thread, other threads:[~2020-03-09 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09  8:24 [RFC PATCH] leds: pwm: add flag to start without PWM init Denis Osterland-Heim
2020-03-09 19:42 ` Jacek Anaszewski

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.