Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dt-bindings: leds: Add pattern initialization from Device Tree

Document new led-pattern property for initialization of LED triggers.
The property format is trigger-specific (except being array of
integers). For pattern trigger, the explanation of pattern format was
moved to a common file shared with sysfs ABI.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

authored by

Krzysztof Kozlowski and committed by
Jacek Anaszewski
1dd70937 bfeffd15

+64 -48
+3 -48
Documentation/ABI/testing/sysfs-class-led-trigger-pattern
··· 7 7 timer. It can do gradual dimming and step change of brightness. 8 8 9 9 The pattern is given by a series of tuples, of brightness and 10 - duration (ms). The LED is expected to traverse the series and 11 - each brightness value for the specified duration. Duration of 12 - 0 means brightness should immediately change to new value, and 13 - writing malformed pattern deactivates any active one. 10 + duration (ms). 14 11 15 - 1. For gradual dimming, the dimming interval now is set as 50 16 - milliseconds. So the tuple with duration less than dimming 17 - interval (50ms) is treated as a step change of brightness, 18 - i.e. the subsequent brightness will be applied without adding 19 - intervening dimming intervals. 20 - 21 - The gradual dimming format of the software pattern values should be: 22 - "brightness_1 duration_1 brightness_2 duration_2 brightness_3 23 - duration_3 ...". For example: 24 - 25 - echo 0 1000 255 2000 > pattern 26 - 27 - It will make the LED go gradually from zero-intensity to max (255) 28 - intensity in 1000 milliseconds, then back to zero intensity in 2000 29 - milliseconds: 30 - 31 - LED brightness 32 - ^ 33 - 255-| / \ / \ / 34 - | / \ / \ / 35 - | / \ / \ / 36 - | / \ / \ / 37 - 0-| / \/ \/ 38 - +---0----1----2----3----4----5----6------------> time (s) 39 - 40 - 2. To make the LED go instantly from one brightness value to another, 41 - we should use zero-time lengths (the brightness must be same as 42 - the previous tuple's). So the format should be: 43 - "brightness_1 duration_1 brightness_1 0 brightness_2 duration_2 44 - brightness_2 0 ...". For example: 45 - 46 - echo 0 1000 0 0 255 2000 255 0 > pattern 47 - 48 - It will make the LED stay off for one second, then stay at max brightness 49 - for two seconds: 50 - 51 - LED brightness 52 - ^ 53 - 255-| +---------+ +---------+ 54 - | | | | | 55 - | | | | | 56 - | | | | | 57 - 0-| -----+ +----+ +---- 58 - +---0----1----2----3----4----5----6------------> time (s) 12 + The exact format is described in: 13 + Documentation/devicetree/bindings/leds/leds-trigger-pattern.txt 59 14 60 15 What: /sys/class/leds/<led>/hw_pattern 61 16 Date: September 2018
+12
Documentation/devicetree/bindings/leds/common.txt
··· 37 37 "ide-disk" - LED indicates IDE disk activity (deprecated), 38 38 in new implementations use "disk-activity" 39 39 "timer" - LED flashes at a fixed, configurable rate 40 + "pattern" - LED alters the brightness for the specified duration with one 41 + software timer (requires "led-pattern" property) 42 + 43 + - led-pattern : Array of integers with default pattern for certain triggers. 44 + Each trigger may parse this property differently: 45 + - one-shot : two numbers specifying delay on and delay off (in ms), 46 + - timer : two numbers specifying delay on and delay off (in ms), 47 + - pattern : the pattern is given by a series of tuples, of 48 + brightness and duration (in ms). The exact format is 49 + described in: 50 + Documentation/devicetree/bindings/leds/leds-trigger-pattern.txt 51 + 40 52 41 53 - led-max-microamp : Maximum LED supply current in microamperes. This property 42 54 can be made mandatory for the board configurations
+49
Documentation/devicetree/bindings/leds/leds-trigger-pattern.txt
··· 1 + * Pattern format for LED pattern trigger 2 + 3 + The pattern is given by a series of tuples, of brightness and duration (ms). 4 + The LED is expected to traverse the series and each brightness value for the 5 + specified duration. Duration of 0 means brightness should immediately change to 6 + new value, and writing malformed pattern deactivates any active one. 7 + 8 + 1. For gradual dimming, the dimming interval now is set as 50 milliseconds. So 9 + the tuple with duration less than dimming interval (50ms) is treated as a step 10 + change of brightness, i.e. the subsequent brightness will be applied without 11 + adding intervening dimming intervals. 12 + 13 + The gradual dimming format of the software pattern values should be: 14 + "brightness_1 duration_1 brightness_2 duration_2 brightness_3 duration_3 ...". 15 + For example (using sysfs interface): 16 + 17 + echo 0 1000 255 2000 > pattern 18 + 19 + It will make the LED go gradually from zero-intensity to max (255) intensity in 20 + 1000 milliseconds, then back to zero intensity in 2000 milliseconds: 21 + 22 + LED brightness 23 + ^ 24 + 255-| / \ / \ / 25 + | / \ / \ / 26 + | / \ / \ / 27 + | / \ / \ / 28 + 0-| / \/ \/ 29 + +---0----1----2----3----4----5----6------------> time (s) 30 + 31 + 2. To make the LED go instantly from one brightness value to another, we should 32 + use zero-time lengths (the brightness must be same as the previous tuple's). So 33 + the format should be: "brightness_1 duration_1 brightness_1 0 brightness_2 34 + duration_2 brightness_2 0 ...". 35 + For example (using sysfs interface): 36 + 37 + echo 0 1000 0 0 255 2000 255 0 > pattern 38 + 39 + It will make the LED stay off for one second, then stay at max brightness for 40 + two seconds: 41 + 42 + LED brightness 43 + ^ 44 + 255-| +---------+ +---------+ 45 + | | | | | 46 + | | | | | 47 + | | | | | 48 + 0-| -----+ +----+ +---- 49 + +---0----1----2----3----4----5----6------------> time (s)