xref: /linux/Documentation/devicetree/bindings/leds/common.yaml (revision 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d)
1# SPDX-License-Identifier: GPL-2.0-only
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/leds/common.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Common leds properties
8
9maintainers:
10  - Jacek Anaszewski <jacek.anaszewski@gmail.com>
11  - Pavel Machek <pavel@ucw.cz>
12
13description:
14  LED and flash LED devices provide the same basic functionality as current
15  regulators, but extended with LED and flash LED specific features like
16  blinking patterns, flash timeout, flash faults and external flash strobe mode.
17
18  Many LED devices expose more than one current output that can be connected
19  to one or more discrete LED component. Since the arrangement of connections
20  can influence the way of the LED device initialization, the LED components
21  have to be tightly coupled with the LED device binding. They are represented
22  by child nodes of the parent LED device binding.
23
24properties:
25  led-sources:
26    description:
27      List of device current outputs the LED is connected to. The outputs are
28      identified by the numbers that must be defined in the LED device binding
29      documentation.
30    $ref: /schemas/types.yaml#/definitions/uint32-array
31
32  function:
33    description:
34      LED function. Use one of the LED_FUNCTION_* prefixed definitions
35      from the header include/dt-bindings/leds/common.h. If there is no
36      matching LED_FUNCTION available, add a new one.
37    $ref: /schemas/types.yaml#/definitions/string
38
39  color:
40    description:
41      Color of the LED. Use one of the LED_COLOR_ID_* prefixed definitions from
42      the header include/dt-bindings/leds/common.h. If there is no matching
43      LED_COLOR_ID available, add a new one.
44    $ref: /schemas/types.yaml#/definitions/uint32
45    minimum: 0
46    maximum: 14
47
48  function-enumerator:
49    description:
50      Integer to be used when more than one instance of the same function is
51      needed, differing only with an ordinal number.
52    $ref: /schemas/types.yaml#/definitions/uint32
53
54  label:
55    description:
56      The label for this LED. If omitted, the label is taken from the node name
57      (excluding the unit address). It has to uniquely identify a device, i.e.
58      no other LED class device can be assigned the same label. This property is
59      deprecated - use 'function' and 'color' properties instead.
60      function-enumerator has no effect when this property is present.
61
62  default-state:
63    description:
64      The initial state of the LED. If the LED is already on or off and the
65      default-state property is set to the same value, then no glitch should be
66      produced where the LED momentarily turns off (or on). The "keep" setting
67      will keep the LED at whatever its current state is, without producing a
68      glitch.
69    $ref: /schemas/types.yaml#/definitions/string
70    enum:
71      - on
72      - off
73      - keep
74    default: off
75
76  default-intensity:
77    description:
78      The initial intensity of the LED color component. As the intensity of
79      each sub-LED is multiplied with the overall brightness, without this
80      property on a sub-LED, it may effectively be initialized at minimum
81      brightness regardless of its linux,default-trigger and default-brightness
82      properties.
83    $ref: /schemas/types.yaml#/definitions/uint32
84    default: 0
85
86  linux,default-trigger:
87    description:
88      This parameter, if present, is a string defining the trigger assigned to
89      the LED.
90    $ref: /schemas/types.yaml#/definitions/string
91
92    oneOf:
93      - enum:
94            # LED will act as a back-light, controlled by the framebuffer system
95          - backlight
96            # LED will turn on (see also "default-state" property)
97          - default-on
98            # LED "double" flashes at a load average based rate
99          - heartbeat
100            # LED indicates disk activity
101          - disk-activity
102            # LED indicates disk read activity
103          - disk-read
104            # LED indicates disk write activity
105          - disk-write
106            # LED flashes at a fixed, configurable rate
107          - timer
108            # LED alters the brightness for the specified duration with one software
109            # timer (requires "led-pattern" property)
110          - pattern
111            # LED indicates mic mute state
112          - audio-micmute
113            # LED indicates audio mute state
114          - audio-mute
115            # LED indicates bluetooth power state
116          - bluetooth-power
117            # LED indicates camera flash state
118          - flash
119            # LED indicates level of GPIO input referenced by trigger-sources
120          - gpio
121            # LED indicated keyboard capslock
122          - kbd-capslock
123            # LED indicates MTD memory activity
124          - mtd
125            # LED indicates NAND memory activity (deprecated),
126            # in new implementations use "mtd"
127          - nand-disk
128            # LED indicates network activity
129          - netdev
130            # No trigger assigned to the LED. This is the default mode
131            # if trigger is absent
132          - none
133            # LED indicates remote control feedback
134          - rc-feedback
135            # LED indicates camera torch state
136          - torch
137            # LED indicates USB gadget activity
138          - usb-gadget
139            # LED indicates USB host activity
140          - usb-host
141            # LED indicates USB port state
142          - usbport
143        # LED is triggered by CPU activity
144      - pattern: "^cpu[0-9]*$"
145        # LED is triggered by Bluetooth activity
146      - pattern: "^hci[0-9]+-power$"
147        # LED is triggered by SD/MMC activity
148      - pattern: "^mmc[0-9]+$"
149        # LED is triggered by WLAN activity
150      - pattern: "^phy[0-9]+tx$"
151
152  led-pattern:
153    description: |
154      Array of integers with default pattern for certain triggers.
155
156      Each trigger may parse this property differently:
157        - one-shot : two numbers specifying delay on and delay off (in ms),
158        - timer : two numbers specifying delay on and delay off (in ms),
159        - pattern : the pattern is given by a series of tuples, of
160          brightness and duration (in ms).  The exact format is
161          described in:
162          Documentation/devicetree/bindings/leds/leds-trigger-pattern.txt
163    $ref: /schemas/types.yaml#/definitions/uint32-matrix
164    items:
165      minItems: 2
166      maxItems: 2
167
168  led-max-microamp:
169    description:
170      Maximum LED supply current in microamperes. This property can be made
171      mandatory for the board configurations introducing a risk of hardware
172      damage in case an excessive current is set.
173      For flash LED controllers with configurable current this property is
174      mandatory for the LEDs in the non-flash modes (e.g. torch or indicator).
175
176  max-brightness:
177    description:
178      Normally, the maximum brightness is determined by the hardware, and this
179      property is not required. This property is used to set a software limit.
180      It could happen that an LED is made so bright that it gets damaged or
181      causes damage due to restrictions in a specific system, such as mounting
182      conditions.
183      Note that this flag is mainly used for PWM-LEDs, where it is not possible
184      to map brightness to current. Drivers for other controllers should use
185      led-max-microamp.
186    $ref: /schemas/types.yaml#/definitions/uint32
187
188  default-brightness:
189    description:
190      Brightness to be set if LED's default state is on. Used only during
191      initialization. If the option is not set then max brightness is used.
192    $ref: /schemas/types.yaml#/definitions/uint32
193
194  panic-indicator:
195    description:
196      This property specifies that the LED should be used, if at all possible,
197      as a panic indicator.
198    type: boolean
199
200  retain-state-shutdown:
201    description:
202      This property specifies that the LED should not be turned off or changed
203      when the system shuts down.
204    type: boolean
205
206  trigger-sources:
207    description: |
208      List of devices which should be used as a source triggering this LED
209      activity. Some LEDs can be related to a specific device and should somehow
210      indicate its state. E.g. USB 2.0 LED may react to device(s) in a USB 2.0
211      port(s).
212      Another common example is switch or router with multiple Ethernet ports
213      each of them having its own LED assigned (assuming they are not
214      hardwired). In such cases this property should contain phandle(s) of
215      related source device(s).
216      Another example is a GPIO line that will be monitored and mirror the
217      state of the line (with or without inversion flags) to the LED.
218      In many cases LED can be related to more than one device (e.g. one USB LED
219      vs. multiple USB ports). Each source should be represented by a node in
220      the device tree and be referenced by a phandle and a set of phandle
221      arguments. A length of arguments should be specified by the
222      #trigger-source-cells property in the source node.
223    $ref: /schemas/types.yaml#/definitions/phandle-array
224
225  active-high:
226    type: boolean
227    description:
228      Makes LED active high. To turn the LED ON, line needs to be
229      set to high voltage instead of low.
230
231  active-low:
232    type: boolean
233    description:
234      Makes LED active low. To turn the LED ON, line needs to be
235      set to low voltage instead of high.
236
237  inactive-high-impedance:
238    type: boolean
239    description:
240      Set LED to high-impedance mode to turn the LED OFF. LED might also
241      describe this mode as tristate.
242
243  # Required properties for flash LED child nodes:
244  flash-max-microamp:
245    description:
246      Maximum flash LED supply current in microamperes. Required for flash LED
247      nodes with configurable current.
248
249  flash-max-timeout-us:
250    description:
251      Maximum timeout in microseconds after which the flash LED is turned off.
252      Required for flash LED nodes with configurable timeout.
253
254allOf:
255  - if:
256      required:
257        - active-low
258    then:
259      properties:
260        active-high: false
261
262additionalProperties: true
263
264examples:
265  - |
266    #include <dt-bindings/gpio/gpio.h>
267    #include <dt-bindings/leds/common.h>
268
269    led-controller {
270        compatible = "gpio-leds";
271
272        led-0 {
273            function = LED_FUNCTION_STATUS;
274            linux,default-trigger = "heartbeat";
275            gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
276        };
277
278        led-1 {
279            function = LED_FUNCTION_USB;
280            gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
281            trigger-sources = <&ohci_port1>, <&ehci_port1>;
282        };
283    };
284
285  - |
286    #include <dt-bindings/leds/common.h>
287
288    led-controller {
289        compatible = "maxim,max77693-led";
290
291        led {
292            function = LED_FUNCTION_FLASH;
293            color = <LED_COLOR_ID_WHITE>;
294            led-sources = <0>, <1>;
295            led-max-microamp = <50000>;
296            flash-max-microamp = <320000>;
297            flash-max-timeout-us = <500000>;
298        };
299    };
300
301  - |
302    #include <dt-bindings/leds/common.h>
303
304    i2c {
305        #address-cells = <1>;
306        #size-cells = <0>;
307
308        led-controller@30 {
309            compatible = "panasonic,an30259a";
310            reg = <0x30>;
311            #address-cells = <1>;
312            #size-cells = <0>;
313
314            led@1 {
315                reg = <1>;
316                linux,default-trigger = "heartbeat";
317                function = LED_FUNCTION_INDICATOR;
318                function-enumerator = <1>;
319            };
320
321            led@2 {
322                reg = <2>;
323                function = LED_FUNCTION_INDICATOR;
324                function-enumerator = <2>;
325            };
326
327            led@3 {
328                reg = <3>;
329                function = LED_FUNCTION_INDICATOR;
330                function-enumerator = <3>;
331            };
332        };
333    };
334
335...
336