1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/leds/leds-qcom-lpg.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Qualcomm Light Pulse Generator
8
9maintainers:
10  - Bjorn Andersson <bjorn.andersson@linaro.org>
11
12description: >
13  The Qualcomm Light Pulse Generator consists of three different hardware blocks;
14  a ramp generator with lookup table (LUT), the light pulse generator and a three
15  channel current sink. These blocks are found in a wide range of Qualcomm PMICs.
16
17properties:
18  compatible:
19    oneOf:
20      - enum:
21          - qcom,pm660l-lpg
22          - qcom,pm8150b-lpg
23          - qcom,pm8150l-lpg
24          - qcom,pm8350c-pwm
25          - qcom,pm8916-pwm
26          - qcom,pm8941-lpg
27          - qcom,pm8994-lpg
28          - qcom,pmc8180c-lpg
29          - qcom,pmi632-lpg
30          - qcom,pmi8950-pwm
31          - qcom,pmi8994-lpg
32          - qcom,pmi8998-lpg
33          - qcom,pmk8550-pwm
34      - items:
35          - enum:
36              - qcom,pm6150l-lpg
37          - const: qcom,pm8150l-lpg
38      - items:
39          - enum:
40              - qcom,pm8550-pwm
41          - const: qcom,pm8350c-pwm
42      - items:
43          - enum:
44              - qcom,pm8937-pwm
45          - const: qcom,pm8916-pwm
46
47  "#pwm-cells":
48    const: 2
49
50  "#address-cells":
51    const: 1
52
53  "#size-cells":
54    const: 0
55
56  qcom,power-source:
57    $ref: /schemas/types.yaml#/definitions/uint32
58    description:
59      power-source used to drive the output, as defined in the datasheet.
60      Should be specified if the TRILED block is present
61    enum: [0, 1, 3]
62
63  qcom,dtest:
64    $ref: /schemas/types.yaml#/definitions/uint32-matrix
65    description: >
66      A list of integer pairs, where each pair represent the dtest line the
67      particular channel should be connected to and the flags denoting how the
68      value should be outputted, as defined in the datasheet. The number of
69      pairs should be the same as the number of channels.
70    items:
71      items:
72        - description: dtest line to attach
73        - description: flags for the attachment
74
75  nvmem:
76    description: >
77      This property is required for PMICs that supports PPG, which is when a
78      PMIC stores LPG per-channel data and pattern LUT in SDAM modules instead
79      of in a LUT peripheral. For PMICs, such as PM8350C, per-channel data
80      and pattern LUT is separated into 2 SDAM modules. In that case, phandles
81      to both SDAM modules need to be specified.
82    minItems: 1
83    maxItems: 2
84
85  nvmem-names:
86    minItems: 1
87    items:
88      - const: lpg_chan_sdam
89      - const: lut_sdam
90
91  qcom,pbs:
92    $ref: /schemas/types.yaml#/definitions/phandle
93    description: >
94      Phandle of the Qualcomm Programmable Boot Sequencer node (PBS).
95      PBS node is used to trigger LPG pattern sequences for PMICs that support
96      single SDAM PPG.
97
98  multi-led:
99    type: object
100    $ref: leds-class-multicolor.yaml#
101    unevaluatedProperties: false
102
103    properties:
104      "#address-cells":
105        const: 1
106
107      "#size-cells":
108        const: 0
109
110    patternProperties:
111      "^led@[0-9a-f]$":
112        type: object
113        $ref: common.yaml#
114        unevaluatedProperties: false
115
116        properties:
117          reg:
118            maxItems: 1
119
120        required:
121          - reg
122
123patternProperties:
124  "^led@[0-9a-f]$":
125    type: object
126    $ref: common.yaml#
127    unevaluatedProperties: false
128
129    properties:
130      reg:
131        maxItems: 1
132
133    required:
134      - reg
135
136required:
137  - compatible
138
139additionalProperties: false
140
141allOf:
142  - if:
143      properties:
144        compatible:
145          contains:
146            enum:
147              - qcom,pm660l-lpg
148              - qcom,pm8150b-lpg
149              - qcom,pm8150l-lpg
150              - qcom,pm8916-pwm
151              - qcom,pm8941-lpg
152              - qcom,pm8994-lpg
153              - qcom,pmc8180c-lpg
154              - qcom,pmi8950-pwm
155              - qcom,pmi8994-lpg
156              - qcom,pmi8998-lpg
157              - qcom,pmk8550-pwm
158    then:
159      properties:
160        nvmem: false
161        nvmem-names: false
162
163  - if:
164      properties:
165        compatible:
166          contains:
167            const: qcom,pmi632-lpg
168    then:
169      properties:
170        nvmem:
171          maxItems: 1
172        nvmem-names:
173          maxItems: 1
174
175  - if:
176      properties:
177        compatible:
178          contains:
179            enum:
180              - qcom,pm8350c-pwm
181    then:
182      properties:
183        nvmem:
184          minItems: 2
185        nvmem-names:
186          minItems: 2
187
188examples:
189  - |
190    #include <dt-bindings/leds/common.h>
191
192    led-controller {
193      compatible = "qcom,pmi8994-lpg";
194
195      #address-cells = <1>;
196      #size-cells = <0>;
197
198      qcom,power-source = <1>;
199
200      qcom,dtest = <0 0>,
201                   <0 0>,
202                   <0 0>,
203                   <4 1>;
204
205      led@1 {
206        reg = <1>;
207        color = <LED_COLOR_ID_GREEN>;
208        function = LED_FUNCTION_INDICATOR;
209        function-enumerator = <1>;
210      };
211
212      led@2 {
213        reg = <2>;
214        color = <LED_COLOR_ID_GREEN>;
215        function = LED_FUNCTION_INDICATOR;
216        function-enumerator = <0>;
217        default-state = "on";
218      };
219
220      led@3 {
221        reg = <3>;
222        color = <LED_COLOR_ID_GREEN>;
223        function = LED_FUNCTION_INDICATOR;
224        function-enumerator = <2>;
225      };
226
227      led@4 {
228        reg = <4>;
229        color = <LED_COLOR_ID_GREEN>;
230        function = LED_FUNCTION_INDICATOR;
231        function-enumerator = <3>;
232      };
233    };
234  - |
235    #include <dt-bindings/leds/common.h>
236
237    led-controller {
238      compatible = "qcom,pmi8994-lpg";
239
240      #address-cells = <1>;
241      #size-cells = <0>;
242
243      qcom,power-source = <1>;
244
245      multi-led {
246        color = <LED_COLOR_ID_RGB>;
247        function = LED_FUNCTION_STATUS;
248
249        #address-cells = <1>;
250        #size-cells = <0>;
251
252        led@1 {
253          reg = <1>;
254          color = <LED_COLOR_ID_RED>;
255        };
256
257        led@2 {
258          reg = <2>;
259          color = <LED_COLOR_ID_GREEN>;
260        };
261
262        led@3 {
263          reg = <3>;
264          color = <LED_COLOR_ID_BLUE>;
265        };
266      };
267    };
268  - |
269    pwm-controller {
270      compatible = "qcom,pm8916-pwm";
271      #pwm-cells = <2>;
272    };
273  - |
274    #include <dt-bindings/leds/common.h>
275
276    led-controller {
277      compatible = "qcom,pmi632-lpg";
278      #address-cells = <1>;
279      #size-cells = <0>;
280      #pwm-cells = <2>;
281      nvmem-names = "lpg_chan_sdam";
282      nvmem = <&pmi632_sdam_7>;
283      qcom,pbs = <&pmi632_pbs_client3>;
284
285      led@1 {
286        reg = <1>;
287        color = <LED_COLOR_ID_RED>;
288        label = "red";
289      };
290
291      led@2 {
292        reg = <2>;
293        color = <LED_COLOR_ID_GREEN>;
294        label = "green";
295      };
296
297      led@3 {
298        reg = <3>;
299        color = <LED_COLOR_ID_BLUE>;
300        label = "blue";
301      };
302    };
303