Merge branch 'pwm-dmtimer-fixes' into omap-for-v5.0/fixes-v2
[sfrench/cifs-2.6.git] / Documentation / devicetree / bindings / media / video-interfaces.txt
1 Common bindings for video receiver and transmitter interfaces
2
3 General concept
4 ---------------
5
6 Video data pipelines usually consist of external devices, e.g. camera sensors,
7 controlled over an I2C, SPI or UART bus, and SoC internal IP blocks, including
8 video DMA engines and video data processors.
9
10 SoC internal blocks are described by DT nodes, placed similarly to other SoC
11 blocks.  External devices are represented as child nodes of their respective
12 bus controller nodes, e.g. I2C.
13
14 Data interfaces on all video devices are described by their child 'port' nodes.
15 Configuration of a port depends on other devices participating in the data
16 transfer and is described by 'endpoint' subnodes.
17
18 device {
19         ...
20         ports {
21                 #address-cells = <1>;
22                 #size-cells = <0>;
23
24                 port@0 {
25                         ...
26                         endpoint@0 { ... };
27                         endpoint@1 { ... };
28                 };
29                 port@1 { ... };
30         };
31 };
32
33 If a port can be configured to work with more than one remote device on the same
34 bus, an 'endpoint' child node must be provided for each of them.  If more than
35 one port is present in a device node or there is more than one endpoint at a
36 port, or port node needs to be associated with a selected hardware interface,
37 a common scheme using '#address-cells', '#size-cells' and 'reg' properties is
38 used.
39
40 All 'port' nodes can be grouped under optional 'ports' node, which allows to
41 specify #address-cells, #size-cells properties independently for the 'port'
42 and 'endpoint' nodes and any child device nodes a device might have.
43
44 Two 'endpoint' nodes are linked with each other through their 'remote-endpoint'
45 phandles.  An endpoint subnode of a device contains all properties needed for
46 configuration of this device for data exchange with other device.  In most
47 cases properties at the peer 'endpoint' nodes will be identical, however they
48 might need to be different when there is any signal modifications on the bus
49 between two devices, e.g. there are logic signal inverters on the lines.
50
51 It is allowed for multiple endpoints at a port to be active simultaneously,
52 where supported by a device.  For example, in case where a data interface of
53 a device is partitioned into multiple data busses, e.g. 16-bit input port
54 divided into two separate ITU-R BT.656 8-bit busses.  In such case bus-width
55 and data-shift properties can be used to assign physical data lines to each
56 endpoint node (logical bus).
57
58 Documenting bindings for devices
59 --------------------------------
60
61 All required and optional bindings the device supports shall be explicitly
62 documented in device DT binding documentation. This also includes port and
63 endpoint nodes for the device, including unit-addresses and reg properties where
64 relevant.
65
66 Please also see Documentation/devicetree/bindings/graph.txt .
67
68 Required properties
69 -------------------
70
71 If there is more than one 'port' or more than one 'endpoint' node or 'reg'
72 property is present in port and/or endpoint nodes the following properties
73 are required in a relevant parent node:
74
75  - #address-cells : number of cells required to define port/endpoint
76                     identifier, should be 1.
77  - #size-cells    : should be zero.
78
79
80 Optional properties
81 -------------------
82
83 - flash-leds: An array of phandles, each referring to a flash LED, a sub-node
84   of the LED driver device node.
85
86 - lens-focus: A phandle to the node of the focus lens controller.
87
88 - rotation: The device, typically an image sensor, is not mounted upright,
89   but a number of degrees counter clockwise. Typical values are 0 and 180
90   (upside down).
91
92
93 Optional endpoint properties
94 ----------------------------
95
96 - remote-endpoint: phandle to an 'endpoint' subnode of a remote device node.
97 - slave-mode: a boolean property indicating that the link is run in slave mode.
98   The default when this property is not specified is master mode. In the slave
99   mode horizontal and vertical synchronization signals are provided to the
100   slave device (data source) by the master device (data sink). In the master
101   mode the data source device is also the source of the synchronization signals.
102 - bus-type: data bus type. Possible values are:
103   1 - MIPI CSI-2 C-PHY
104   2 - MIPI CSI1
105   3 - CCP2
106   4 - MIPI CSI-2 D-PHY
107   5 - Parallel
108   6 - Bt.656
109 - bus-width: number of data lines actively used, valid for the parallel busses.
110 - data-shift: on the parallel data busses, if bus-width is used to specify the
111   number of data lines, data-shift can be used to specify which data lines are
112   used, e.g. "bus-width=<8>; data-shift=<2>;" means, that lines 9:2 are used.
113 - hsync-active: active state of the HSYNC signal, 0/1 for LOW/HIGH respectively.
114 - vsync-active: active state of the VSYNC signal, 0/1 for LOW/HIGH respectively.
115   Note, that if HSYNC and VSYNC polarities are not specified, embedded
116   synchronization may be required, where supported.
117 - data-active: similar to HSYNC and VSYNC, specifies data line polarity.
118 - data-enable-active: similar to HSYNC and VSYNC, specifies the data enable
119   signal polarity.
120 - field-even-active: field signal level during the even field data transmission.
121 - pclk-sample: sample data on rising (1) or falling (0) edge of the pixel clock
122   signal.
123 - sync-on-green-active: active state of Sync-on-green (SoG) signal, 0/1 for
124   LOW/HIGH respectively.
125 - data-lanes: an array of physical data lane indexes. Position of an entry
126   determines the logical lane number, while the value of an entry indicates
127   physical lane, e.g. for 2-lane MIPI CSI-2 bus we could have
128   "data-lanes = <1 2>;", assuming the clock lane is on hardware lane 0.
129   If the hardware does not support lane reordering, monotonically
130   incremented values shall be used from 0 or 1 onwards, depending on
131   whether or not there is also a clock lane. This property is valid for
132   serial busses only (e.g. MIPI CSI-2).
133 - clock-lanes: an array of physical clock lane indexes. Position of an entry
134   determines the logical lane number, while the value of an entry indicates
135   physical lane, e.g. for a MIPI CSI-2 bus we could have "clock-lanes = <0>;",
136   which places the clock lane on hardware lane 0. This property is valid for
137   serial busses only (e.g. MIPI CSI-2). Note that for the MIPI CSI-2 bus this
138   array contains only one entry.
139 - clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous
140   clock mode.
141 - link-frequencies: Allowed data bus frequencies. For MIPI CSI-2, for
142   instance, this is the actual frequency of the bus, not bits per clock per
143   lane value. An array of 64-bit unsigned integers.
144 - lane-polarities: an array of polarities of the lanes starting from the clock
145   lane and followed by the data lanes in the same order as in data-lanes.
146   Valid values are 0 (normal) and 1 (inverted). The length of the array
147   should be the combined length of data-lanes and clock-lanes properties.
148   If the lane-polarities property is omitted, the value must be interpreted
149   as 0 (normal). This property is valid for serial busses only.
150 - strobe: Whether the clock signal is used as clock (0) or strobe (1). Used
151   with CCP2, for instance.
152
153 Example
154 -------
155
156 The example snippet below describes two data pipelines.  ov772x and imx074 are
157 camera sensors with a parallel and serial (MIPI CSI-2) video bus respectively.
158 Both sensors are on the I2C control bus corresponding to the i2c0 controller
159 node.  ov772x sensor is linked directly to the ceu0 video host interface.
160 imx074 is linked to ceu0 through the MIPI CSI-2 receiver (csi2). ceu0 has a
161 (single) DMA engine writing captured data to memory.  ceu0 node has a single
162 'port' node which may indicate that at any time only one of the following data
163 pipelines can be active: ov772x -> ceu0 or imx074 -> csi2 -> ceu0.
164
165         ceu0: ceu@fe910000 {
166                 compatible = "renesas,sh-mobile-ceu";
167                 reg = <0xfe910000 0xa0>;
168                 interrupts = <0x880>;
169
170                 mclk: master_clock {
171                         compatible = "renesas,ceu-clock";
172                         #clock-cells = <1>;
173                         clock-frequency = <50000000>;   /* Max clock frequency */
174                         clock-output-names = "mclk";
175                 };
176
177                 port {
178                         #address-cells = <1>;
179                         #size-cells = <0>;
180
181                         /* Parallel bus endpoint */
182                         ceu0_1: endpoint@1 {
183                                 reg = <1>;              /* Local endpoint # */
184                                 remote = <&ov772x_1_1>; /* Remote phandle */
185                                 bus-width = <8>;        /* Used data lines */
186                                 data-shift = <2>;       /* Lines 9:2 are used */
187
188                                 /* If hsync-active/vsync-active are missing,
189                                    embedded BT.656 sync is used */
190                                 hsync-active = <0>;     /* Active low */
191                                 vsync-active = <0>;     /* Active low */
192                                 data-active = <1>;      /* Active high */
193                                 pclk-sample = <1>;      /* Rising */
194                         };
195
196                         /* MIPI CSI-2 bus endpoint */
197                         ceu0_0: endpoint@0 {
198                                 reg = <0>;
199                                 remote = <&csi2_2>;
200                         };
201                 };
202         };
203
204         i2c0: i2c@fff20000 {
205                 ...
206                 ov772x_1: camera@21 {
207                         compatible = "ovti,ov772x";
208                         reg = <0x21>;
209                         vddio-supply = <&regulator1>;
210                         vddcore-supply = <&regulator2>;
211
212                         clock-frequency = <20000000>;
213                         clocks = <&mclk 0>;
214                         clock-names = "xclk";
215
216                         port {
217                                 /* With 1 endpoint per port no need for addresses. */
218                                 ov772x_1_1: endpoint {
219                                         bus-width = <8>;
220                                         remote-endpoint = <&ceu0_1>;
221                                         hsync-active = <1>;
222                                         vsync-active = <0>; /* Who came up with an
223                                                                inverter here ?... */
224                                         data-active = <1>;
225                                         pclk-sample = <1>;
226                                 };
227                         };
228                 };
229
230                 imx074: camera@1a {
231                         compatible = "sony,imx074";
232                         reg = <0x1a>;
233                         vddio-supply = <&regulator1>;
234                         vddcore-supply = <&regulator2>;
235
236                         clock-frequency = <30000000>;   /* Shared clock with ov772x_1 */
237                         clocks = <&mclk 0>;
238                         clock-names = "sysclk";         /* Assuming this is the
239                                                            name in the datasheet */
240                         port {
241                                 imx074_1: endpoint {
242                                         clock-lanes = <0>;
243                                         data-lanes = <1 2>;
244                                         remote-endpoint = <&csi2_1>;
245                                 };
246                         };
247                 };
248         };
249
250         csi2: csi2@ffc90000 {
251                 compatible = "renesas,sh-mobile-csi2";
252                 reg = <0xffc90000 0x1000>;
253                 interrupts = <0x17a0>;
254                 #address-cells = <1>;
255                 #size-cells = <0>;
256
257                 port@1 {
258                         compatible = "renesas,csi2c";   /* One of CSI2I and CSI2C. */
259                         reg = <1>;                      /* CSI-2 PHY #1 of 2: PHY_S,
260                                                            PHY_M has port address 0,
261                                                            is unused. */
262                         csi2_1: endpoint {
263                                 clock-lanes = <0>;
264                                 data-lanes = <2 1>;
265                                 remote-endpoint = <&imx074_1>;
266                         };
267                 };
268                 port@2 {
269                         reg = <2>;                      /* port 2: link to the CEU */
270
271                         csi2_2: endpoint {
272                                 remote-endpoint = <&ceu0_0>;
273                         };
274                 };
275         };