1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/iio/adc/st,stm32-dfsdm-adc.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: STMicroelectronics STM32 DFSDM ADC device driver
8
9maintainers:
10  - Fabrice Gasnier <fabrice.gasnier@st.com>
11  - Olivier Moysan <olivier.moysan@st.com>
12
13description: |
14  STM32 DFSDM ADC is a sigma delta analog-to-digital converter dedicated to
15  interface external sigma delta modulators to STM32 micro controllers.
16  It is mainly targeted for:
17  - Sigma delta modulators (motor control, metering...)
18  - PDM microphones (audio digital microphone)
19
20  It features up to 8 serial digital interfaces (SPI or Manchester) and
21  up to 4 filters on stm32h7 or 6 filters on stm32mp1.
22
23  Each child node matches with a filter instance.
24
25properties:
26  compatible:
27    enum:
28      - st,stm32h7-dfsdm
29      - st,stm32mp1-dfsdm
30
31  reg:
32    maxItems: 1
33
34  clocks:
35    items:
36      - description:
37          Internal clock used for DFSDM digital processing and control blocks.
38          dfsdm clock can also feed CLKOUT, when CLKOUT is used.
39      - description: audio clock can be used as an alternate to feed CLKOUT.
40    minItems: 1
41    maxItems: 2
42
43  clock-names:
44    items:
45      - const: dfsdm
46      - const: audio
47    minItems: 1
48    maxItems: 2
49
50  "#address-cells":
51    const: 1
52
53  "#size-cells":
54    const: 0
55
56  spi-max-frequency:
57    description:
58      SPI clock OUT frequency (Hz). Requested only for SPI master mode.
59      This clock must be set according to the "clock" property.
60      Frequency must be a multiple of the rcc clock frequency.
61      If not, SPI CLKOUT frequency will not be accurate.
62    maximum: 20000000
63
64required:
65  - compatible
66  - reg
67  - clocks
68  - clock-names
69  - "#address-cells"
70  - "#size-cells"
71
72additionalProperties: false
73
74patternProperties:
75  "^filter@[0-9]+$":
76    type: object
77    description: child node
78
79    properties:
80      compatible:
81        enum:
82          - st,stm32-dfsdm-adc
83          - st,stm32-dfsdm-dmic
84
85      reg:
86        description: Specifies the DFSDM filter instance used.
87        maxItems: 1
88
89      interrupts:
90        maxItems: 1
91
92      st,adc-channels:
93        description: |
94          List of single-ended channels muxed for this ADC.
95          On stm32h7 and stm32mp1:
96          - For st,stm32-dfsdm-adc: up to 8 channels numbered from 0 to 7.
97          - For st,stm32-dfsdm-dmic: 1 channel numbered from 0 to 7.
98        $ref: /schemas/types.yaml#/definitions/uint32-array
99        items:
100          minimum: 0
101          maximum: 7
102
103      st,adc-channel-names:
104        description: List of single-ended channel names.
105
106      st,filter-order:
107        description: |
108          SinC filter order from 0 to 5.
109          - 0: FastSinC
110          - [1-5]: order 1 to 5.
111          For audio purpose it is recommended to use order 3 to 5.
112        $ref: /schemas/types.yaml#/definitions/uint32
113        items:
114          minimum: 0
115          maximum: 5
116
117      "#io-channel-cells":
118        const: 1
119
120      st,adc-channel-types:
121        description: |
122          Single-ended channel input type.
123          - "SPI_R": SPI with data on rising edge (default)
124          - "SPI_F": SPI with data on falling edge
125          - "MANCH_R": manchester codec, rising edge = logic 0, falling edge = logic 1
126          - "MANCH_F": manchester codec, rising edge = logic 1, falling edge = logic 0
127        items:
128          enum: [ SPI_R, SPI_F, MANCH_R, MANCH_F ]
129        $ref: /schemas/types.yaml#/definitions/non-unique-string-array
130
131      st,adc-channel-clk-src:
132        description: |
133          Conversion clock source.
134          - "CLKIN": external SPI clock (CLKIN x)
135          - "CLKOUT": internal SPI clock (CLKOUT) (default)
136          - "CLKOUT_F": internal SPI clock divided by 2 (falling edge).
137          - "CLKOUT_R": internal SPI clock divided by 2 (rising edge).
138        items:
139          enum: [ CLKIN, CLKOUT, CLKOUT_F, CLKOUT_R ]
140        $ref: /schemas/types.yaml#/definitions/non-unique-string-array
141
142      st,adc-alt-channel:
143        description:
144          Must be defined if two sigma delta modulators are
145          connected on same SPI input.
146          If not set, channel n is connected to SPI input n.
147          If set, channel n is connected to SPI input n + 1.
148        type: boolean
149
150      st,filter0-sync:
151        description:
152          Set to 1 to synchronize with DFSDM filter instance 0.
153          Used for multi microphones synchronization.
154        type: boolean
155
156      dmas:
157        maxItems: 1
158
159      dma-names:
160        items:
161          - const: rx
162
163    required:
164      - compatible
165      - reg
166      - interrupts
167      - st,adc-channels
168      - st,adc-channel-names
169      - st,filter-order
170      - "#io-channel-cells"
171
172    allOf:
173      - if:
174          properties:
175            compatible:
176              contains:
177                const: st,stm32-dfsdm-adc
178
179      - then:
180          properties:
181            st,adc-channels:
182              minItems: 1
183              maxItems: 8
184
185            st,adc-channel-names:
186              minItems: 1
187              maxItems: 8
188
189            st,adc-channel-types:
190              minItems: 1
191              maxItems: 8
192
193            st,adc-channel-clk-src:
194              minItems: 1
195              maxItems: 8
196
197            io-channels:
198              description:
199                From common IIO binding. Used to pipe external sigma delta
200                modulator or internal ADC output to DFSDM channel.
201
202          required:
203            - io-channels
204
205      - if:
206          properties:
207            compatible:
208              contains:
209                const: st,stm32-dfsdm-dmic
210
211      - then:
212          properties:
213            st,adc-channels:
214              maxItems: 1
215
216            st,adc-channel-names:
217              maxItems: 1
218
219            st,adc-channel-types:
220              maxItems: 1
221
222            st,adc-channel-clk-src:
223              maxItems: 1
224
225          required:
226            - dmas
227            - dma-names
228
229          patternProperties:
230            "^dfsdm-dai+$":
231              type: object
232              description: child node
233
234              properties:
235                compatible:
236                  enum:
237                    - st,stm32h7-dfsdm-dai
238
239                "#sound-dai-cells":
240                  const: 0
241
242                io-channels:
243                  description:
244                    From common IIO binding. Used to pipe external sigma delta
245                    modulator or internal ADC output to DFSDM channel.
246
247              required:
248                - compatible
249                - "#sound-dai-cells"
250                - io-channels
251
252allOf:
253  - if:
254      properties:
255        compatible:
256          contains:
257            const: st,stm32h7-dfsdm
258
259  - then:
260      patternProperties:
261        "^filter@[0-9]+$":
262          properties:
263            reg:
264              items:
265                minimum: 0
266                maximum: 3
267
268  - if:
269      properties:
270        compatible:
271          contains:
272            const: st,stm32mp1-dfsdm
273
274  - then:
275      patternProperties:
276        "^filter@[0-9]+$":
277          properties:
278            reg:
279              items:
280                minimum: 0
281                maximum: 5
282
283examples:
284  - |
285    #include <dt-bindings/interrupt-controller/arm-gic.h>
286    #include <dt-bindings/clock/stm32mp1-clks.h>
287    dfsdm: dfsdm@4400d000 {
288      compatible = "st,stm32mp1-dfsdm";
289      reg = <0x4400d000 0x800>;
290      clocks = <&rcc DFSDM_K>, <&rcc ADFSDM_K>;
291      clock-names = "dfsdm", "audio";
292      #address-cells = <1>;
293      #size-cells = <0>;
294
295      dfsdm0: filter@0 {
296        compatible = "st,stm32-dfsdm-dmic";
297        reg = <0>;
298        interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
299        dmas = <&dmamux1 101 0x400 0x01>;
300        dma-names = "rx";
301        #io-channel-cells = <1>;
302        st,adc-channels = <1>;
303        st,adc-channel-names = "dmic0";
304        st,adc-channel-types = "SPI_R";
305        st,adc-channel-clk-src = "CLKOUT";
306        st,filter-order = <5>;
307
308        asoc_pdm0: dfsdm-dai {
309          compatible = "st,stm32h7-dfsdm-dai";
310          #sound-dai-cells = <0>;
311          io-channels = <&dfsdm0 0>;
312        };
313      };
314
315      dfsdm_pdm1: filter@1 {
316        compatible = "st,stm32-dfsdm-adc";
317        reg = <1>;
318        interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
319        dmas = <&dmamux1 102 0x400 0x01>;
320        dma-names = "rx";
321        #io-channel-cells = <1>;
322        st,adc-channels = <2 3>;
323        st,adc-channel-names = "in2", "in3";
324        st,adc-channel-types = "SPI_R", "SPI_R";
325        st,adc-channel-clk-src = "CLKOUT_F", "CLKOUT_F";
326        io-channels = <&sd_adc2 &sd_adc3>;
327        st,filter-order = <1>;
328      };
329    };
330
331...
332