1# SPDX-License-Identifier: GPL-2.0-only
2# Copyright (C) 2020 Renesas Electronics Corp.
3%YAML 1.2
4---
5$id: http://devicetree.org/schemas/media/renesas,vin.yaml#
6$schema: http://devicetree.org/meta-schemas/core.yaml#
7
8title: Renesas R-Car Video Input (VIN)
9
10maintainers:
11  - Niklas Söderlund <niklas.soderlund@ragnatech.se>
12
13description:
14  The R-Car Video Input (VIN) device provides video input capabilities for the
15  Renesas R-Car family of devices.
16
17  Each VIN instance has a single parallel input that supports RGB and YUV video,
18  with both external synchronization and BT.656 synchronization for the latter.
19  Depending on the instance the VIN input is connected to external SoC pins, or
20  on Gen3 and RZ/G2 platforms to a CSI-2 receiver.
21
22properties:
23  compatible:
24    oneOf:
25      - items:
26          - enum:
27              - renesas,vin-r8a7743  # RZ/G1M
28              - renesas,vin-r8a7744  # RZ/G1N
29              - renesas,vin-r8a7745  # RZ/G1E
30              - renesas,vin-r8a77470 # RZ/G1C
31              - renesas,vin-r8a7790  # R-Car H2
32              - renesas,vin-r8a7791  # R-Car M2-W
33              - renesas,vin-r8a7792  # R-Car V2H
34              - renesas,vin-r8a7793  # R-Car M2-N
35              - renesas,vin-r8a7794  # R-Car E2
36          - const: renesas,rcar-gen2-vin # Generic R-Car Gen2 or RZ/G1
37
38      - items:
39          - enum:
40              - renesas,vin-r8a774a1 # RZ/G2M
41              - renesas,vin-r8a774b1 # RZ/G2N
42              - renesas,vin-r8a774c0 # RZ/G2E
43              - renesas,vin-r8a7778  # R-Car M1
44              - renesas,vin-r8a7779  # R-Car H1
45              - renesas,vin-r8a7795  # R-Car H3
46              - renesas,vin-r8a7796  # R-Car M3-W
47              - renesas,vin-r8a77965 # R-Car M3-N
48              - renesas,vin-r8a77970 # R-Car V3M
49              - renesas,vin-r8a77980 # R-Car V3H
50              - renesas,vin-r8a77990 # R-Car E3
51              - renesas,vin-r8a77995 # R-Car D3
52
53  reg:
54    maxItems: 1
55
56  interrupts:
57    maxItems: 1
58
59  clocks:
60    maxItems: 1
61
62  power-domains:
63    maxItems: 1
64
65  resets:
66    maxItems: 1
67
68  #The per-board settings for Gen2 and RZ/G1 platforms:
69  port:
70    type: object
71    description:
72      A node containing a parallel input with a single endpoint definitions as
73      documented in
74      Documentation/devicetree/bindings/media/video-interfaces.txt
75
76    properties:
77      endpoint:
78        type: object
79
80        properties:
81          hsync-active:
82            description:
83              If both HSYNC and VSYNC polarities are not specified, embedded
84              synchronization is selected.
85            default: 1
86
87          vsync-active:
88            description:
89              If both HSYNC and VSYNC polarities are not specified, embedded
90              synchronization is selected.
91            default: 1
92
93          field-active-even: true
94
95          bus-width: true
96
97          data-shift: true
98
99          data-enable-active:
100            description: Polarity of CLKENB signal
101            default: 1
102
103          pclk-sample: true
104
105          data-active: true
106
107          remote-endpoint: true
108
109        required:
110          - remote-endpoint
111
112        additionalProperties: false
113
114    additionalProperties: false
115
116  #The per-board settings for Gen3 and RZ/G2 platforms:
117  renesas,id:
118    description: VIN channel number
119    allOf:
120      - $ref: /schemas/types.yaml#/definitions/uint32
121      - minimum: 0
122      - maximum: 15
123
124  ports:
125    type: object
126    description:
127      A node containing input nodes with endpoint definitions as documented in
128      Documentation/devicetree/bindings/media/video-interfaces.txt
129
130    properties:
131      port@0:
132        type: object
133        description:
134          Input port node, single endpoint describing a parallel input source.
135
136        properties:
137          reg:
138            const: 0
139
140          endpoint:
141            type: object
142
143            properties:
144              hsync-active:
145                description:
146                  If both HSYNC and VSYNC polarities are not specified, embedded
147                  synchronization is selected.
148                default: 1
149
150              vsync-active:
151                description:
152                  If both HSYNC and VSYNC polarities are not specified, embedded
153                  synchronization is selected.
154                default: 1
155
156              field-active-even: true
157
158              bus-width: true
159
160              data-shift: true
161
162              data-enable-active:
163                description: Polarity of CLKENB signal
164                default: 1
165
166              pclk-sample: true
167
168              data-active: true
169
170              remote-endpoint: true
171
172            required:
173              - remote-endpoint
174
175            additionalProperties: false
176
177        required:
178          - endpoint
179
180        additionalProperties: false
181
182      port@1:
183        type: object
184        description:
185          Input port node, multiple endpoints describing all the R-Car CSI-2
186          modules connected the VIN.
187
188        properties:
189          '#address-cells':
190            const: 1
191
192          '#size-cells':
193            const: 0
194
195          reg:
196            const: 1
197
198          endpoint@0:
199            type: object
200            description: Endpoint connected to CSI20.
201
202            properties:
203              reg:
204                const: 0
205
206              remote-endpoint: true
207
208            required:
209              - reg
210              - remote-endpoint
211
212            additionalProperties: false
213
214          endpoint@1:
215            type: object
216            description: Endpoint connected to CSI21.
217
218            properties:
219              reg:
220                const: 1
221
222              remote-endpoint: true
223
224            required:
225              - reg
226              - remote-endpoint
227
228            additionalProperties: false
229
230          endpoint@2:
231            type: object
232            description: Endpoint connected to CSI40.
233
234            properties:
235              reg:
236                const: 2
237
238              remote-endpoint: true
239
240            required:
241              - reg
242              - remote-endpoint
243
244            additionalProperties: false
245
246          endpoint@3:
247            type: object
248            description: Endpoint connected to CSI41.
249
250            properties:
251              reg:
252                const: 3
253
254              remote-endpoint: true
255
256            required:
257              - reg
258              - remote-endpoint
259
260            additionalProperties: false
261
262        anyOf:
263          - required:
264            - endpoint@0
265          - required:
266            - endpoint@1
267          - required:
268            - endpoint@2
269          - required:
270            - endpoint@3
271
272        additionalProperties: false
273
274required:
275  - compatible
276  - reg
277  - interrupts
278  - clocks
279  - power-domains
280  - resets
281
282if:
283  properties:
284    compatible:
285      contains:
286        enum:
287          - renesas,vin-r8a7778
288          - renesas,vin-r8a7779
289          - renesas,rcar-gen2-vin
290then:
291  required:
292    - port
293else:
294  required:
295    - renesas,id
296    - ports
297
298additionalProperties: false
299
300examples:
301  # Device node example for Gen2 platform
302  - |
303    #include <dt-bindings/clock/r8a7790-cpg-mssr.h>
304    #include <dt-bindings/interrupt-controller/arm-gic.h>
305    #include <dt-bindings/power/r8a7790-sysc.h>
306
307    vin1: vin@e6ef1000 {
308            compatible = "renesas,vin-r8a7790",
309                         "renesas,rcar-gen2-vin";
310            reg = <0 0xe6ef1000 0 0x1000>;
311            interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
312            clocks = <&cpg CPG_MOD 810>;
313            power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
314            resets = <&cpg 810>;
315
316            port {
317                    vin1ep0: endpoint {
318                            remote-endpoint = <&adv7180>;
319                            bus-width = <8>;
320                    };
321            };
322    };
323
324  # Device node example for Gen3 platform with only CSI-2
325  - |
326    #include <dt-bindings/clock/r8a7795-cpg-mssr.h>
327    #include <dt-bindings/interrupt-controller/arm-gic.h>
328    #include <dt-bindings/power/r8a7795-sysc.h>
329
330    vin0: video@e6ef0000 {
331            compatible = "renesas,vin-r8a7795";
332            reg = <0 0xe6ef0000 0 0x1000>;
333            interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
334            clocks = <&cpg CPG_MOD 811>;
335            power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
336            resets = <&cpg 811>;
337            renesas,id = <0>;
338
339            ports {
340                    #address-cells = <1>;
341                    #size-cells = <0>;
342
343                    port@1 {
344                            #address-cells = <1>;
345                            #size-cells = <0>;
346
347                            reg = <1>;
348
349                            vin0csi20: endpoint@0 {
350                                    reg = <0>;
351                                    remote-endpoint= <&csi20vin0>;
352                            };
353                            vin0csi40: endpoint@2 {
354                                    reg = <2>;
355                                    remote-endpoint= <&csi40vin0>;
356                            };
357                    };
358            };
359    };
360
361  # Device node example for Gen3 platform with CSI-2 and parallel
362  - |
363    #include <dt-bindings/clock/r8a77970-cpg-mssr.h>
364    #include <dt-bindings/interrupt-controller/arm-gic.h>
365    #include <dt-bindings/power/r8a77970-sysc.h>
366
367    vin2: video@e6ef2000 {
368            compatible = "renesas,vin-r8a77970";
369            reg = <0 0xe6ef2000 0 0x1000>;
370            interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
371            clocks = <&cpg CPG_MOD 809>;
372            power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
373            resets = <&cpg 809>;
374            renesas,id = <2>;
375
376            ports {
377                    #address-cells = <1>;
378                    #size-cells = <0>;
379
380                    port@0 {
381                            reg = <0>;
382
383                            vin2_in: endpoint {
384                                    remote-endpoint = <&adv7612_out>;
385                                    hsync-active = <0>;
386                                    vsync-active = <0>;
387                            };
388                    };
389
390                    port@1 {
391                            #address-cells = <1>;
392                            #size-cells = <0>;
393
394                            reg = <1>;
395
396                            vin2csi40: endpoint@2 {
397                                    reg = <2>;
398                                    remote-endpoint = <&csi40vin2>;
399                            };
400                    };
401            };
402    };
403