18c2ecf20Sopenharmony_ciCommon bindings for device graphs
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciGeneral concept
48c2ecf20Sopenharmony_ci---------------
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciThe hierarchical organisation of the device tree is well suited to describe
78c2ecf20Sopenharmony_cicontrol flow to devices, but there can be more complex connections between
88c2ecf20Sopenharmony_cidevices that work together to form a logical compound device, following an
98c2ecf20Sopenharmony_ciarbitrarily complex graph.
108c2ecf20Sopenharmony_ciThere already is a simple directed graph between devices tree nodes using
118c2ecf20Sopenharmony_ciphandle properties pointing to other nodes to describe connections that
128c2ecf20Sopenharmony_cican not be inferred from device tree parent-child relationships. The device
138c2ecf20Sopenharmony_citree graph bindings described herein abstract more complex devices that can
148c2ecf20Sopenharmony_cihave multiple specifiable ports, each of which can be linked to one or more
158c2ecf20Sopenharmony_ciports of other devices.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciThese common bindings do not contain any information about the direction or
188c2ecf20Sopenharmony_citype of the connections, they just map their existence. Specific properties
198c2ecf20Sopenharmony_cimay be described by specialized bindings depending on the type of connection.
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciTo see how this binding applies to video pipelines, for example, see
228c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/media/video-interfaces.txt.
238c2ecf20Sopenharmony_ciHere the ports describe data interfaces, and the links between them are
248c2ecf20Sopenharmony_cithe connecting data buses. A single port with multiple connections can
258c2ecf20Sopenharmony_cicorrespond to multiple devices being connected to the same physical bus.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciOrganisation of ports and endpoints
288c2ecf20Sopenharmony_ci-----------------------------------
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciPorts are described by child 'port' nodes contained in the device node.
318c2ecf20Sopenharmony_ciEach port node contains an 'endpoint' subnode for each remote device port
328c2ecf20Sopenharmony_ciconnected to this port. If a single port is connected to more than one
338c2ecf20Sopenharmony_ciremote device, an 'endpoint' child node must be provided for each link.
348c2ecf20Sopenharmony_ciIf more than one port is present in a device node or there is more than one
358c2ecf20Sopenharmony_ciendpoint at a port, or a port node needs to be associated with a selected
368c2ecf20Sopenharmony_cihardware interface, a common scheme using '#address-cells', '#size-cells'
378c2ecf20Sopenharmony_ciand 'reg' properties is used to number the nodes.
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cidevice {
408c2ecf20Sopenharmony_ci        ...
418c2ecf20Sopenharmony_ci        #address-cells = <1>;
428c2ecf20Sopenharmony_ci        #size-cells = <0>;
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci        port@0 {
458c2ecf20Sopenharmony_ci	        #address-cells = <1>;
468c2ecf20Sopenharmony_ci	        #size-cells = <0>;
478c2ecf20Sopenharmony_ci		reg = <0>;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci                endpoint@0 {
508c2ecf20Sopenharmony_ci			reg = <0>;
518c2ecf20Sopenharmony_ci			...
528c2ecf20Sopenharmony_ci		};
538c2ecf20Sopenharmony_ci                endpoint@1 {
548c2ecf20Sopenharmony_ci			reg = <1>;
558c2ecf20Sopenharmony_ci			...
568c2ecf20Sopenharmony_ci		};
578c2ecf20Sopenharmony_ci        };
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci        port@1 {
608c2ecf20Sopenharmony_ci		reg = <1>;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci		endpoint { ... };
638c2ecf20Sopenharmony_ci	};
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciAll 'port' nodes can be grouped under an optional 'ports' node, which
678c2ecf20Sopenharmony_ciallows to specify #address-cells, #size-cells properties for the 'port'
688c2ecf20Sopenharmony_cinodes independently from any other child device nodes a device might
698c2ecf20Sopenharmony_cihave.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cidevice {
728c2ecf20Sopenharmony_ci        ...
738c2ecf20Sopenharmony_ci        ports {
748c2ecf20Sopenharmony_ci                #address-cells = <1>;
758c2ecf20Sopenharmony_ci                #size-cells = <0>;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci                port@0 {
788c2ecf20Sopenharmony_ci                        ...
798c2ecf20Sopenharmony_ci                        endpoint@0 { ... };
808c2ecf20Sopenharmony_ci                        endpoint@1 { ... };
818c2ecf20Sopenharmony_ci                };
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci                port@1 { ... };
848c2ecf20Sopenharmony_ci        };
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciLinks between endpoints
888c2ecf20Sopenharmony_ci-----------------------
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ciEach endpoint should contain a 'remote-endpoint' phandle property that points
918c2ecf20Sopenharmony_cito the corresponding endpoint in the port of the remote device. In turn, the
928c2ecf20Sopenharmony_ciremote endpoint should contain a 'remote-endpoint' property. If it has one, it
938c2ecf20Sopenharmony_cimust not point to anything other than the local endpoint. Two endpoints with
948c2ecf20Sopenharmony_citheir 'remote-endpoint' phandles pointing at each other form a link between the
958c2ecf20Sopenharmony_cicontaining ports.
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cidevice-1 {
988c2ecf20Sopenharmony_ci        port {
998c2ecf20Sopenharmony_ci                device_1_output: endpoint {
1008c2ecf20Sopenharmony_ci                        remote-endpoint = <&device_2_input>;
1018c2ecf20Sopenharmony_ci                };
1028c2ecf20Sopenharmony_ci        };
1038c2ecf20Sopenharmony_ci};
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cidevice-2 {
1068c2ecf20Sopenharmony_ci        port {
1078c2ecf20Sopenharmony_ci                device_2_input: endpoint {
1088c2ecf20Sopenharmony_ci                        remote-endpoint = <&device_1_output>;
1098c2ecf20Sopenharmony_ci                };
1108c2ecf20Sopenharmony_ci        };
1118c2ecf20Sopenharmony_ci};
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ciRequired properties
1148c2ecf20Sopenharmony_ci-------------------
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciIf there is more than one 'port' or more than one 'endpoint' node or 'reg'
1178c2ecf20Sopenharmony_ciproperty present in the port and/or endpoint nodes then the following
1188c2ecf20Sopenharmony_ciproperties are required in a relevant parent node:
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci - #address-cells : number of cells required to define port/endpoint
1218c2ecf20Sopenharmony_ci                    identifier, should be 1.
1228c2ecf20Sopenharmony_ci - #size-cells    : should be zero.
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciOptional endpoint properties
1258c2ecf20Sopenharmony_ci----------------------------
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci- remote-endpoint: phandle to an 'endpoint' subnode of a remote device node.
1288c2ecf20Sopenharmony_ci
129