xref: /freebsd/share/man/man9/ofw_graph.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
19a4eed0bSEmmanuel Vadot.\" Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
29a4eed0bSEmmanuel Vadot.\"
39a4eed0bSEmmanuel Vadot.\" Redistribution and use in source and binary forms, with or without
49a4eed0bSEmmanuel Vadot.\" modification, are permitted provided that the following conditions
59a4eed0bSEmmanuel Vadot.\" are met:
69a4eed0bSEmmanuel Vadot.\" 1. Redistributions of source code must retain the above copyright
79a4eed0bSEmmanuel Vadot.\"    notice, this list of conditions and the following disclaimer.
89a4eed0bSEmmanuel Vadot.\" 2. Redistributions in binary form must reproduce the above copyright
99a4eed0bSEmmanuel Vadot.\"    notice, this list of conditions and the following disclaimer in the
109a4eed0bSEmmanuel Vadot.\"    documentation and/or other materials provided with the distribution.
119a4eed0bSEmmanuel Vadot.\"
129a4eed0bSEmmanuel Vadot.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
139a4eed0bSEmmanuel Vadot.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
149a4eed0bSEmmanuel Vadot.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
159a4eed0bSEmmanuel Vadot.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
169a4eed0bSEmmanuel Vadot.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
179a4eed0bSEmmanuel Vadot.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
189a4eed0bSEmmanuel Vadot.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
199a4eed0bSEmmanuel Vadot.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
209a4eed0bSEmmanuel Vadot.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
219a4eed0bSEmmanuel Vadot.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
229a4eed0bSEmmanuel Vadot.\"
239a4eed0bSEmmanuel Vadot.Dd April 10, 2019
249a4eed0bSEmmanuel Vadot.Dt ofw_graph 9
259a4eed0bSEmmanuel Vadot.Os
269a4eed0bSEmmanuel Vadot.Sh NAME
279a4eed0bSEmmanuel Vadot.Nm ofw_graph ,
289a4eed0bSEmmanuel Vadot.Nm ofw_graph_get_port_by_idx ,
299a4eed0bSEmmanuel Vadot.Nm ofw_graph_port_get_num_endpoints ,
309a4eed0bSEmmanuel Vadot.Nm ofw_graph_get_endpoint_by_idx ,
319a4eed0bSEmmanuel Vadot.Nm ofw_graph_get_remote_endpoint ,
329a4eed0bSEmmanuel Vadot.Nm ofw_graph_get_remote_parent ,
33*32068667SChristian Brueffer.Nm ofw_graph_get_device_by_port_ep
349a4eed0bSEmmanuel Vadot.Nd Helpers for the graph bindings
359a4eed0bSEmmanuel Vadot.Sh SYNOPSIS
369a4eed0bSEmmanuel Vadot.In dev/ofw/openfirm.h
379a4eed0bSEmmanuel Vadot.In dev/ofw/ofw_graph.h
389a4eed0bSEmmanuel Vadot.Ft phandle_t
399a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_port_by_idx "phandle_t node" "uint32_t idx"
409a4eed0bSEmmanuel Vadot.Ft size_t
419a4eed0bSEmmanuel Vadot.Fn ofw_graph_port_get_num_endpoints "phandle_t port"
429a4eed0bSEmmanuel Vadot.Ft phandle_t
439a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_endpoint_by_idx "phandle_t port" "uint32_t idx"
449a4eed0bSEmmanuel Vadot.Ft phandle_t
459a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_remote_endpoint "phandle_t endpoint"
469a4eed0bSEmmanuel Vadot.Ft phandle_t
479a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_remote_parent "phandle_t remote"
489a4eed0bSEmmanuel Vadot.Ft device_t
499a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_device_by_port_ep "phandle_t node" "uint32_t port_id" "uin32_t ep_id"
509a4eed0bSEmmanuel Vadot.Sh DESCRIPTION
519a4eed0bSEmmanuel VadotThe ofw_graph functions are helpers to parse the DTS graph bindings
529a4eed0bSEmmanuel Vadot.Pp
539a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_port_by_idx
549a4eed0bSEmmanuel Vadotreturn the port with id
559a4eed0bSEmmanuel Vadot.Fa idx .
569a4eed0bSEmmanuel VadotIt will first check node named
579a4eed0bSEmmanuel Vadot.Fa port@idx
589a4eed0bSEmmanuel Vadotand then fallback on checking the
599a4eed0bSEmmanuel Vadot.Fa ports
6055ed6718SBenedict Reuschlingchild for a child node matching the id.
6155ed6718SBenedict ReuschlingIf no ports matching
629a4eed0bSEmmanuel Vadot.Fa idx
639a4eed0bSEmmanuel Vadotis found the function return 0.
649a4eed0bSEmmanuel Vadot.Pp
659a4eed0bSEmmanuel Vadot.Fn ofw_graph_port_get_num_endpoints
669a4eed0bSEmmanuel Vadotreturns the number of endpoints a port node have.
679a4eed0bSEmmanuel Vadot.Pp
689a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_endpoint_by_idx
699a4eed0bSEmmanuel Vadotreturn the endpoint with id
709a4eed0bSEmmanuel Vadot.Fa idx .
719a4eed0bSEmmanuel VadotIt will first check if there is a single child named
729a4eed0bSEmmanuel Vadot.Fa endpoint
7355ed6718SBenedict Reuschlingand returns it if there is.
7455ed6718SBenedict ReuschlingIf there is multiple endpoints it will check the
759a4eed0bSEmmanuel Vadot.Fa reg
769a4eed0bSEmmanuel Vadotproperty and returns the correct
779a4eed0bSEmmanuel Vadot.Fa phandle_t
789a4eed0bSEmmanuel Vadotor 0 if none match.
799a4eed0bSEmmanuel Vadot.Pp
809a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_remote_endpoint
819a4eed0bSEmmanuel Vadotreturns the
829a4eed0bSEmmanuel Vadot.Fa remote-endpoint
839a4eed0bSEmmanuel Vadotproperty if it exists or 0.
849a4eed0bSEmmanuel Vadot.Pp
859a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_remote_parent
869a4eed0bSEmmanuel Vadotreturns the device node corresponding to the
879a4eed0bSEmmanuel Vadot.Fa remote-endpoint
889a4eed0bSEmmanuel Vadotphandle or 0 if none.
899a4eed0bSEmmanuel Vadot.Fn ofw_graph_get_device_by_port_ep
909a4eed0bSEmmanuel Vadotreturns the device associated with the port and endpoint or
919a4eed0bSEmmanuel Vadot.Fa NULL
9255ed6718SBenedict Reuschlingif none.
9355ed6718SBenedict ReuschlingThe device driver should have called
949a4eed0bSEmmanuel Vadot.Fn OF_device_register_xref
959a4eed0bSEmmanuel Vadotbefore.
969a4eed0bSEmmanuel Vadot.Sh HISTORY
979a4eed0bSEmmanuel VadotThe
989a4eed0bSEmmanuel Vadot.Nm ofw_graph
999a4eed0bSEmmanuel Vadotfunctions first appeared in
1009a4eed0bSEmmanuel Vadot.Fx 13.0 .
1019a4eed0bSEmmanuel VadotThe
1029a4eed0bSEmmanuel Vadot.Nm ofw_graph
1039a4eed0bSEmmanuel Vadotfunctions and manual page were written by
1049a4eed0bSEmmanuel Vadot.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
105