xref: /freebsd/share/man/man9/ofw_graph.9 (revision 1c4ee7dfb8affed302171232b0f612e6bcba3c10)
1.\" Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
16.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22.\"
23.Dd April 10, 2019
24.Dt ofw_graph 9
25.Os
26.Sh NAME
27.Nm ofw_graph ,
28.Nm ofw_graph_get_port_by_idx ,
29.Nm ofw_graph_port_get_num_endpoints ,
30.Nm ofw_graph_get_endpoint_by_idx ,
31.Nm ofw_graph_get_remote_endpoint ,
32.Nm ofw_graph_get_remote_parent ,
33.Nm ofw_graph_get_device_by_port_ep
34.Nd Helpers for the graph bindings
35.Sh SYNOPSIS
36.In dev/ofw/openfirm.h
37.In dev/ofw/ofw_graph.h
38.Ft phandle_t
39.Fn ofw_graph_get_port_by_idx "phandle_t node" "uint32_t idx"
40.Ft size_t
41.Fn ofw_graph_port_get_num_endpoints "phandle_t port"
42.Ft phandle_t
43.Fn ofw_graph_get_endpoint_by_idx "phandle_t port" "uint32_t idx"
44.Ft phandle_t
45.Fn ofw_graph_get_remote_endpoint "phandle_t endpoint"
46.Ft phandle_t
47.Fn ofw_graph_get_remote_parent "phandle_t remote"
48.Ft device_t
49.Fn ofw_graph_get_device_by_port_ep "phandle_t node" "uint32_t port_id" "uin32_t ep_id"
50.Sh DESCRIPTION
51The ofw_graph functions are helpers to parse the DTS graph bindings
52.Pp
53.Fn ofw_graph_get_port_by_idx
54return the port with id
55.Fa idx .
56It will first check node named
57.Fa port@idx
58and then fallback on checking the
59.Fa ports
60child for a child node matching the id.
61If no ports matching
62.Fa idx
63is found the function return 0.
64.Pp
65.Fn ofw_graph_port_get_num_endpoints
66returns the number of endpoints a port node have.
67.Pp
68.Fn ofw_graph_get_endpoint_by_idx
69return the endpoint with id
70.Fa idx .
71It will first check if there is a single child named
72.Fa endpoint
73and returns it if there is.
74If there is multiple endpoints it will check the
75.Fa reg
76property and returns the correct
77.Fa phandle_t
78or 0 if none match.
79.Pp
80.Fn ofw_graph_get_remote_endpoint
81returns the
82.Fa remote-endpoint
83property if it exists or 0.
84.Pp
85.Fn ofw_graph_get_remote_parent
86returns the device node corresponding to the
87.Fa remote-endpoint
88phandle or 0 if none.
89.Fn ofw_graph_get_device_by_port_ep
90returns the device associated with the port and endpoint or
91.Fa NULL
92if none.
93The device driver should have called
94.Fn OF_device_register_xref
95before.
96.Sh HISTORY
97The
98.Nm ofw_graph
99functions first appeared in
100.Fx 13.0 .
101The
102.Nm ofw_graph
103functions and manual page were written by
104.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
105