From: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Bryan Wu <cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Richard Purdie <rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org>,
Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH RFC 1/2] leds: add DT support for LEDs wired to supply and default brightness
Date: Tue, 18 Feb 2014 13:09:28 +0000 [thread overview]
Message-ID: <E1WFkQS-0005JS-L5@rmk-PC.arm.linux.org.uk> (raw)
Some PWM outputs are wired such that the LED they're controlling is
connected to supply rather than ground. Therefore, the duty cycle
needs to be inverted to make the LED behave as it should do.
We also provide a way to specify the default brightness when a
trigger is not specified.
Signed-off-by: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
=-DO NOT APPLY-=
Documentation/devicetree/bindings/leds/leds-pwm.txt | 3 +++
drivers/leds/leds-pwm.c | 15 +++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
index 7297107cf832..ffcb74ab61fd 100644
=-DO NOT APPLY-= a/Documentation/devicetree/bindings/leds/leds-pwm.txt
=+DO NOT APPLY+= b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -13,6 +13,9 @@ node's name represents the name of the corresponding LED.
For the pwms and pwm-names property please refer to:
Documentation/devicetree/bindings/pwm/pwm.txt
- max-brightness : Maximum brightness possible for the LED
=+DO NOT APPLY+=- default-brightness : (optional) Default brightness for the LED
=+DO NOT APPLY+=- active-low : (optional) For PWMs where the LED is wired to supply
=+DO NOT APPLY+= rather than ground.
- label : (optional)
see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger : (optional)
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 605047428b5a..fe2cd849b593 100644
=-DO NOT APPLY-= a/drivers/leds/leds-pwm.c
=+DO NOT APPLY+= b/drivers/leds/leds-pwm.c
@@ -70,6 +70,10 @@ static void led_pwm_set(struct led_classdev *led_cdev,
duty *= brightness;
do_div(duty, max);
=+DO NOT APPLY+=
=+DO NOT APPLY+= if (led_dat->active_low)
=+DO NOT APPLY+= duty = led_dat->period - duty;
=+DO NOT APPLY+=
led_dat->duty = duty;
if (led_dat->can_sleep)
@@ -93,6 +97,10 @@ static int led_pwm_create_of(struct platform_device *pdev,
for_each_child_of_node(pdev->dev.of_node, child) {
struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
=+DO NOT APPLY+= led_dat->cdev.brightness_set = led_pwm_set;
=+DO NOT APPLY+= led_dat->cdev.brightness = LED_OFF;
=+DO NOT APPLY+= led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
=+DO NOT APPLY+=
led_dat->cdev.name = of_get_property(child, "label",
NULL) ? : child->name;
@@ -110,10 +118,9 @@ static int led_pwm_create_of(struct platform_device *pdev,
"linux,default-trigger", NULL);
of_property_read_u32(child, "max-brightness",
&led_dat->cdev.max_brightness);
-
- led_dat->cdev.brightness_set = led_pwm_set;
- led_dat->cdev.brightness = LED_OFF;
- led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
=+DO NOT APPLY+= of_property_read_u32(child, "default-brightness",
=+DO NOT APPLY+= &led_dat->cdev.brightness);
=+DO NOT APPLY+= led_dat->active_low = of_property_read_bool(child, "active-low");
led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
if (led_dat->can_sleep)
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
reply other threads:[~2014-02-18 13:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1WFkQS-0005JS-L5@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel-lfz/pmaqli7xmaaqvzeohq@public.gmane.org \
--cc=cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).