xref: /freebsd/share/man/man9/ofw_graph.9 (revision a0409676120c1e558d0ade943019934e0f15118d)
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.\" $FreeBSD$
24.\"
25.Dd April 10, 2019
26.Dt ofw_graph 9
27.Os
28.Sh NAME
29.Nm ofw_graph ,
30.Nm ofw_graph_get_port_by_idx ,
31.Nm ofw_graph_port_get_num_endpoints ,
32.Nm ofw_graph_get_endpoint_by_idx ,
33.Nm ofw_graph_get_remote_endpoint ,
34.Nm ofw_graph_get_remote_parent ,
35.Nm ofw_graph_get_device_by_port_ep ,
36.Nd Helpers for the graph bindings
37.Sh SYNOPSIS
38.In dev/ofw/openfirm.h
39.In dev/ofw/ofw_graph.h
40.Ft phandle_t
41.Fn ofw_graph_get_port_by_idx "phandle_t node" "uint32_t idx"
42.Ft size_t
43.Fn ofw_graph_port_get_num_endpoints "phandle_t port"
44.Ft phandle_t
45.Fn ofw_graph_get_endpoint_by_idx "phandle_t port" "uint32_t idx"
46.Ft phandle_t
47.Fn ofw_graph_get_remote_endpoint "phandle_t endpoint"
48.Ft phandle_t
49.Fn ofw_graph_get_remote_parent "phandle_t remote"
50.Ft device_t
51.Fn ofw_graph_get_device_by_port_ep "phandle_t node" "uint32_t port_id" "uin32_t ep_id"
52.Sh DESCRIPTION
53.Pp
54The ofw_graph functions are helpers to parse the DTS graph bindings
55.Pp
56.Fn ofw_graph_get_port_by_idx
57return the port with id
58.Fa idx .
59It will first check node named
60.Fa port@idx
61and then fallback on checking the
62.Fa ports
63child for a child node matching the id.
64If no ports matching
65.Fa idx
66is found the function return 0.
67.Pp
68.Fn ofw_graph_port_get_num_endpoints
69returns the number of endpoints a port node have.
70.Pp
71.Fn ofw_graph_get_endpoint_by_idx
72return the endpoint with id
73.Fa idx .
74It will first check if there is a single child named
75.Fa endpoint
76and returns it if there is.
77If there is multiple endpoints it will check the
78.Fa reg
79property and returns the correct
80.Fa phandle_t
81or 0 if none match.
82.Pp
83.Fn ofw_graph_get_remote_endpoint
84returns the
85.Fa remote-endpoint
86property if it exists or 0.
87.Pp
88.Fn ofw_graph_get_remote_parent
89returns the device node corresponding to the
90.Fa remote-endpoint
91phandle or 0 if none.
92.Fn ofw_graph_get_device_by_port_ep
93returns the device associated with the port and endpoint or
94.Fa NULL
95if none.
96The device driver should have called
97.Fn OF_device_register_xref
98before.
99.Fn
100.Sh HISTORY
101The
102.Nm ofw_graph
103functions first appeared in
104.Fx 13.0 .
105The
106.Nm ofw_graph
107functions and manual page were written by
108.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
109