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    $ref: /schemas/types.yaml#/definitions/uint32
120    minimum: 0
121    maximum: 15
122
123  ports:
124    type: object
125    description:
126      A node containing input nodes with endpoint definitions as documented in
127      Documentation/devicetree/bindings/media/video-interfaces.txt
128
129    properties:
130      port@0:
131        type: object
132        description:
133          Input port node, single endpoint describing a parallel input source.
134
135        properties:
136          reg:
137            const: 0
138
139          endpoint:
140            type: object
141
142            properties:
143              hsync-active:
144                description:
145                  If both HSYNC and VSYNC polarities are not specified, embedded
146                  synchronization is selected.
147                default: 1
148
149              vsync-active:
150                description:
151                  If both HSYNC and VSYNC polarities are not specified, embedded
152                  synchronization is selected.
153                default: 1
154
155              field-active-even: true
156
157              bus-width: true
158
159              data-shift: true
160
161              data-enable-active:
162                description: Polarity of CLKENB signal
163                default: 1
164
165              pclk-sample: true
166
167              data-active: true
168
169              remote-endpoint: true
170
171            required:
172              - remote-endpoint
173
174            additionalProperties: false
175
176        required:
177          - endpoint
178
179        additionalProperties: false
180
181      port@1:
182        type: object
183        description:
184          Input port node, multiple endpoints describing all the R-Car CSI-2
185          modules connected the VIN.
186
187        properties:
188          '#address-cells':
189            const: 1
190
191          '#size-cells':
192            const: 0
193
194          reg:
195            const: 1
196
197          endpoint@0:
198            type: object
199            description: Endpoint connected to CSI20.
200
201            properties:
202              reg:
203                const: 0
204
205              remote-endpoint: true
206
207            required:
208              - reg
209              - remote-endpoint
210
211            additionalProperties: false
212
213          endpoint@1:
214            type: object
215            description: Endpoint connected to CSI21.
216
217            properties:
218              reg:
219                const: 1
220
221              remote-endpoint: true
222
223            required:
224              - reg
225              - remote-endpoint
226
227            additionalProperties: false
228
229          endpoint@2:
230            type: object
231            description: Endpoint connected to CSI40.
232
233            properties:
234              reg:
235                const: 2
236
237              remote-endpoint: true
238
239            required:
240              - reg
241              - remote-endpoint
242
243            additionalProperties: false
244
245          endpoint@3:
246            type: object
247            description: Endpoint connected to CSI41.
248
249            properties:
250              reg:
251                const: 3
252
253              remote-endpoint: true
254
255            required:
256              - reg
257              - remote-endpoint
258
259            additionalProperties: false
260
261        anyOf:
262          - required:
263              - endpoint@0
264          - required:
265              - endpoint@1
266          - required:
267              - endpoint@2
268          - required:
269              - endpoint@3
270
271        additionalProperties: false
272
273required:
274  - compatible
275  - reg
276  - interrupts
277  - clocks
278  - power-domains
279  - resets
280
281if:
282  properties:
283    compatible:
284      contains:
285        enum:
286          - renesas,vin-r8a7778
287          - renesas,vin-r8a7779
288          - renesas,rcar-gen2-vin
289then:
290  required:
291    - port
292else:
293  required:
294    - renesas,id
295    - ports
296
297additionalProperties: false
298
299examples:
300  # Device node example for Gen2 platform
301  - |
302    #include <dt-bindings/clock/r8a7790-cpg-mssr.h>
303    #include <dt-bindings/interrupt-controller/arm-gic.h>
304    #include <dt-bindings/power/r8a7790-sysc.h>
305
306    vin1: vin@e6ef1000 {
307            compatible = "renesas,vin-r8a7790",
308                         "renesas,rcar-gen2-vin";
309            reg = <0xe6ef1000 0x1000>;
310            interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
311            clocks = <&cpg CPG_MOD 810>;
312            power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
313            resets = <&cpg 810>;
314
315            port {
316                    vin1ep0: endpoint {
317                            remote-endpoint = <&adv7180>;
318                            bus-width = <8>;
319                    };
320            };
321    };
322
323  # Device node example for Gen3 platform with only CSI-2
324  - |
325    #include <dt-bindings/clock/r8a7795-cpg-mssr.h>
326    #include <dt-bindings/interrupt-controller/arm-gic.h>
327    #include <dt-bindings/power/r8a7795-sysc.h>
328
329    vin0: video@e6ef0000 {
330            compatible = "renesas,vin-r8a7795";
331            reg = <0xe6ef0000 0x1000>;
332            interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
333            clocks = <&cpg CPG_MOD 811>;
334            power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
335            resets = <&cpg 811>;
336            renesas,id = <0>;
337
338            ports {
339                    #address-cells = <1>;
340                    #size-cells = <0>;
341
342                    port@1 {
343                            #address-cells = <1>;
344                            #size-cells = <0>;
345
346                            reg = <1>;
347
348                            vin0csi20: endpoint@0 {
349                                    reg = <0>;
350                                    remote-endpoint= <&csi20vin0>;
351                            };
352                            vin0csi40: endpoint@2 {
353                                    reg = <2>;
354                                    remote-endpoint= <&csi40vin0>;
355                            };
356                    };
357            };
358    };
359
360  # Device node example for Gen3 platform with CSI-2 and parallel
361  - |
362    #include <dt-bindings/clock/r8a77970-cpg-mssr.h>
363    #include <dt-bindings/interrupt-controller/arm-gic.h>
364    #include <dt-bindings/power/r8a77970-sysc.h>
365
366    vin2: video@e6ef2000 {
367            compatible = "renesas,vin-r8a77970";
368            reg = <0xe6ef2000 0x1000>;
369            interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
370            clocks = <&cpg CPG_MOD 809>;
371            power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
372            resets = <&cpg 809>;
373            renesas,id = <2>;
374
375            ports {
376                    #address-cells = <1>;
377                    #size-cells = <0>;
378
379                    port@0 {
380                            reg = <0>;
381
382                            vin2_in: endpoint {
383                                    remote-endpoint = <&adv7612_out>;
384                                    hsync-active = <0>;
385                                    vsync-active = <0>;
386                            };
387                    };
388
389                    port@1 {
390                            #address-cells = <1>;
391                            #size-cells = <0>;
392
393                            reg = <1>;
394
395                            vin2csi40: endpoint@2 {
396                                    reg = <2>;
397                                    remote-endpoint = <&csi40vin2>;
398                            };
399                    };
400            };
401    };
402