xref: /linux/Documentation/firmware-guide/acpi/dsd/leds.rst (revision 2b2d4247e445b97113c5e61df8fbc0d756482ef8)
1*2b2d4247SSakari Ailus.. SPDX-License-Identifier: GPL-2.0
2*2b2d4247SSakari Ailus.. include:: <isonum.txt>
3*2b2d4247SSakari Ailus
4*2b2d4247SSakari Ailus========================================
5*2b2d4247SSakari AilusDescribing and referring to LEDs in ACPI
6*2b2d4247SSakari Ailus========================================
7*2b2d4247SSakari Ailus
8*2b2d4247SSakari AilusIndividual LEDs are described by hierarchical data extension [6] nodes under the
9*2b2d4247SSakari Ailusdevice node, the LED driver chip. The "reg" property in the LED specific nodes
10*2b2d4247SSakari Ailustells the numerical ID of each individual LED output to which the LEDs are
11*2b2d4247SSakari Ailusconnected. [3] The hierarchical data nodes are named "led@X", where X is the
12*2b2d4247SSakari Ailusnumber of the LED output.
13*2b2d4247SSakari Ailus
14*2b2d4247SSakari AilusReferring to LEDs in Device tree is documented in [4], in "flash-leds" property
15*2b2d4247SSakari Ailusdocumentation. In short, LEDs are directly referred to by using phandles.
16*2b2d4247SSakari Ailus
17*2b2d4247SSakari AilusWhile Device tree allows referring to any node in the tree[1], in ACPI
18*2b2d4247SSakari Ailusreferences are limited to device nodes only [2]. For this reason using the same
19*2b2d4247SSakari Ailusmechanism on ACPI is not possible. A mechanism to refer to non-device ACPI nodes
20*2b2d4247SSakari Ailusis documented in [7].
21*2b2d4247SSakari Ailus
22*2b2d4247SSakari AilusACPI allows (as does DT) using integer arguments after the reference. A
23*2b2d4247SSakari Ailuscombination of the LED driver device reference and an integer argument,
24*2b2d4247SSakari Ailusreferring to the "reg" property of the relevant LED, is used to identify
25*2b2d4247SSakari Ailusindividual LEDs. The value of the "reg" property is a contract between the
26*2b2d4247SSakari Ailusfirmware and software, it uniquely identifies the LED driver outputs.
27*2b2d4247SSakari Ailus
28*2b2d4247SSakari AilusUnder the LED driver device, The first hierarchical data extension package list
29*2b2d4247SSakari Ailusentry shall contain the string "led@" followed by the number of the LED,
30*2b2d4247SSakari Ailusfollowed by the referred object name. That object shall be named "LED" followed
31*2b2d4247SSakari Ailusby the number of the LED.
32*2b2d4247SSakari Ailus
33*2b2d4247SSakari AilusExample
34*2b2d4247SSakari Ailus=======
35*2b2d4247SSakari Ailus
36*2b2d4247SSakari AilusAn ASL example of a camera sensor device and a LED driver device for two LEDs is
37*2b2d4247SSakari Ailusshow below. Objects not relevant for LEDs or the references to them have been
38*2b2d4247SSakari Ailusomitted. ::
39*2b2d4247SSakari Ailus
40*2b2d4247SSakari Ailus	Device (LED)
41*2b2d4247SSakari Ailus	{
42*2b2d4247SSakari Ailus		Name (_DSD, Package () {
43*2b2d4247SSakari Ailus			ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
44*2b2d4247SSakari Ailus			Package () {
45*2b2d4247SSakari Ailus				Package () { "led@0", LED0 },
46*2b2d4247SSakari Ailus				Package () { "led@1", LED1 },
47*2b2d4247SSakari Ailus			}
48*2b2d4247SSakari Ailus		})
49*2b2d4247SSakari Ailus		Name (LED0, Package () {
50*2b2d4247SSakari Ailus			ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
51*2b2d4247SSakari Ailus			Package () {
52*2b2d4247SSakari Ailus				Package () { "reg", 0 },
53*2b2d4247SSakari Ailus				Package () { "flash-max-microamp", 1000000 },
54*2b2d4247SSakari Ailus				Package () { "flash-timeout-us", 200000 },
55*2b2d4247SSakari Ailus				Package () { "led-max-microamp", 100000 },
56*2b2d4247SSakari Ailus				Package () { "label", "white:flash" },
57*2b2d4247SSakari Ailus			}
58*2b2d4247SSakari Ailus		})
59*2b2d4247SSakari Ailus		Name (LED1, Package () {
60*2b2d4247SSakari Ailus			ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
61*2b2d4247SSakari Ailus			Package () {
62*2b2d4247SSakari Ailus				Package () { "reg", 1 },
63*2b2d4247SSakari Ailus				Package () { "led-max-microamp", 10000 },
64*2b2d4247SSakari Ailus				Package () { "label", "red:indicator" },
65*2b2d4247SSakari Ailus			}
66*2b2d4247SSakari Ailus		})
67*2b2d4247SSakari Ailus	}
68*2b2d4247SSakari Ailus
69*2b2d4247SSakari Ailus	Device (SEN)
70*2b2d4247SSakari Ailus	{
71*2b2d4247SSakari Ailus		Name (_DSD, Package () {
72*2b2d4247SSakari Ailus			ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
73*2b2d4247SSakari Ailus			Package () {
74*2b2d4247SSakari Ailus				Package () {
75*2b2d4247SSakari Ailus					"flash-leds",
76*2b2d4247SSakari Ailus					Package () { ^LED, "led@0", ^LED, "led@1" },
77*2b2d4247SSakari Ailus				}
78*2b2d4247SSakari Ailus			}
79*2b2d4247SSakari Ailus		})
80*2b2d4247SSakari Ailus	}
81*2b2d4247SSakari Ailus
82*2b2d4247SSakari Ailuswhere
83*2b2d4247SSakari Ailus::
84*2b2d4247SSakari Ailus
85*2b2d4247SSakari Ailus	LED	LED driver device
86*2b2d4247SSakari Ailus	LED0	First LED
87*2b2d4247SSakari Ailus	LED1	Second LED
88*2b2d4247SSakari Ailus	SEN	Camera sensor device (or another device the LED is related to)
89*2b2d4247SSakari Ailus
90*2b2d4247SSakari AilusReferences
91*2b2d4247SSakari Ailus==========
92*2b2d4247SSakari Ailus
93*2b2d4247SSakari Ailus[1] Device tree. <URL:http://www.devicetree.org>, referenced 2019-02-21.
94*2b2d4247SSakari Ailus
95*2b2d4247SSakari Ailus[2] Advanced Configuration and Power Interface Specification.
96*2b2d4247SSakari Ailus    <URL:https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf>,
97*2b2d4247SSakari Ailus    referenced 2019-02-21.
98*2b2d4247SSakari Ailus
99*2b2d4247SSakari Ailus[3] Documentation/devicetree/bindings/leds/common.txt
100*2b2d4247SSakari Ailus
101*2b2d4247SSakari Ailus[4] Documentation/devicetree/bindings/media/video-interfaces.txt
102*2b2d4247SSakari Ailus
103*2b2d4247SSakari Ailus[5] Device Properties UUID For _DSD.
104*2b2d4247SSakari Ailus    <URL:http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf>,
105*2b2d4247SSakari Ailus    referenced 2019-02-21.
106*2b2d4247SSakari Ailus
107*2b2d4247SSakari Ailus[6] Hierarchical Data Extension UUID For _DSD.
108*2b2d4247SSakari Ailus    <URL:http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.1.pdf>,
109*2b2d4247SSakari Ailus    referenced 2019-02-21.
110*2b2d4247SSakari Ailus
111*2b2d4247SSakari Ailus[7] Documentation/firmware-guide/acpi/dsd/data-node-references.rst
112