1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/sound/st,stm32-sai.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: STMicroelectronics STM32 Serial Audio Interface (SAI)
8
9maintainers:
10  - Olivier Moysan <olivier.moysan@foss.st.com>
11
12description:
13  The SAI interface (Serial Audio Interface) offers a wide set of audio
14  protocols as I2S standards, LSB or MSB-justified, PCM/DSP, TDM, and AC'97.
15  The SAI contains two independent audio sub-blocks. Each sub-block has
16  its own clock generator and I/O lines controller.
17
18properties:
19  compatible:
20    enum:
21      - st,stm32f4-sai
22      - st,stm32h7-sai
23
24  reg:
25    items:
26      - description: Base address and size of SAI common register set.
27      - description: Base address and size of SAI identification register set.
28    minItems: 1
29
30  ranges:
31    maxItems: 1
32
33  interrupts:
34    maxItems: 1
35
36  resets:
37    maxItems: 1
38
39  "#address-cells":
40    const: 1
41
42  "#size-cells":
43    const: 1
44
45  clocks:
46    maxItems: 3
47
48  clock-names:
49    maxItems: 3
50
51required:
52  - compatible
53  - reg
54  - ranges
55  - "#address-cells"
56  - "#size-cells"
57  - clocks
58  - clock-names
59
60patternProperties:
61  "^audio-controller@[0-9a-f]+$":
62    type: object
63    description:
64      Two subnodes corresponding to SAI sub-block instances A et B
65      can be defined. Subnode can be omitted for unsused sub-block.
66
67    properties:
68      compatible:
69        description: Compatible for SAI sub-block A or B.
70        pattern: "st,stm32-sai-sub-[ab]"
71
72      "#sound-dai-cells":
73        const: 0
74
75      reg:
76        maxItems: 1
77
78      clocks:
79        items:
80          - description: sai_ck clock feeding the internal clock generator.
81          - description: MCLK clock from a SAI set as master clock provider.
82        minItems: 1
83
84      clock-names:
85        items:
86          - const: sai_ck
87          - const: MCLK
88        minItems: 1
89
90      dmas:
91        maxItems: 1
92
93      dma-names:
94        description: |
95          rx: SAI sub-block is configured as a capture DAI.
96          tx: SAI sub-block is configured as a playback DAI.
97        enum: [ rx, tx ]
98
99      st,sync:
100        description:
101          Configure the SAI sub-block as slave of another SAI sub-block.
102          By default SAI sub-block is in asynchronous mode.
103          Must contain the phandle and index of the SAI sub-block providing
104          the synchronization.
105        $ref: /schemas/types.yaml#/definitions/phandle-array
106        items:
107          - items:
108              - description: phandle of the SAI sub-block
109              - description: index of the SAI sub-block
110
111      st,iec60958:
112        description:
113          If set, support S/PDIF IEC6958 protocol for playback.
114          IEC60958 protocol is not available for capture.
115          By default, custom protocol is assumed, meaning that protocol is
116          configured according to protocol defined in related DAI link node,
117          such as i2s, left justified, right justified, dsp and pdm protocols.
118        $ref: /schemas/types.yaml#/definitions/flag
119
120      "#clock-cells":
121        description: Configure the SAI device as master clock provider.
122        const: 0
123
124    required:
125      - compatible
126      - "#sound-dai-cells"
127      - reg
128      - clocks
129      - clock-names
130      - dmas
131      - dma-names
132
133allOf:
134  - if:
135      properties:
136        compatible:
137          contains:
138            const: st,stm32f4-sai
139
140  - then:
141      properties:
142        clocks:
143          items:
144            - description: x8k, SAI parent clock for sampling rates multiple of 8kHz.
145            - description: x11k, SAI parent clock for sampling rates multiple of 11.025kHz.
146
147        clock-names:
148          items:
149            - const: x8k
150            - const: x11k
151
152  - else:
153      properties:
154        clocks:
155          items:
156            - description: pclk feeds the peripheral bus interface.
157            - description: x8k, SAI parent clock for sampling rates multiple of 8kHz.
158            - description: x11k, SAI parent clock for sampling rates multiple of 11.025kHz.
159
160        clock-names:
161          items:
162            - const: pclk
163            - const: x8k
164            - const: x11k
165
166additionalProperties: false
167
168examples:
169  - |
170    #include <dt-bindings/interrupt-controller/arm-gic.h>
171    #include <dt-bindings/clock/stm32mp1-clks.h>
172    #include <dt-bindings/reset/stm32mp1-resets.h>
173    sai2: sai@4400b000 {
174      compatible = "st,stm32h7-sai";
175      #address-cells = <1>;
176      #size-cells = <1>;
177      ranges = <0 0x4400b000 0x400>;
178      reg = <0x4400b000 0x4>, <0x4400b3f0 0x10>;
179      clocks = <&rcc SAI2>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
180      clock-names = "pclk", "x8k", "x11k";
181      pinctrl-names = "default", "sleep";
182      pinctrl-0 = <&sai2a_pins_a>, <&sai2b_pins_b>;
183      pinctrl-1 = <&sai2a_sleep_pins_a>, <&sai2b_sleep_pins_b>;
184
185      sai2a: audio-controller@4400b004 {
186        #sound-dai-cells = <0>;
187        compatible = "st,stm32-sai-sub-a";
188        reg = <0x4 0x1c>;
189        dmas = <&dmamux1 89 0x400 0x01>;
190        dma-names = "tx";
191        clocks = <&rcc SAI2_K>;
192        clock-names = "sai_ck";
193      };
194    };
195
196...
197