]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/OF_node_from_xref.9
accept_filter(9): Fix a mandoc related error
[FreeBSD/FreeBSD.git] / share / man / man9 / OF_node_from_xref.9
1 .\"
2 .\" Copyright (c) 2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 .\"
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd April 9, 2018
29 .Dt OF_NODE_FROM_XREF 9
30 .Os
31 .Sh NAME
32 .Nm OF_node_from_xref ,
33 .Nm OF_xref_from_node
34 .Nd convert between kernel phandle and effective phandle
35 .Sh SYNOPSIS
36 .In dev/ofw/ofw_bus.h
37 .In dev/ofw/ofw_bus_subr.h
38 .Ft phandle_t
39 .Fn OF_node_from_xref "phandle_t xref"
40 .Ft phandle_t
41 .Fn OF_xref_from_node "phandle_t node"
42 .Sh DESCRIPTION
43 .Pp
44 Some OpenFirmware implementations (FDT, IBM) have a concept
45 of effective phandle or xrefs.
46 They are used to cross-reference device tree nodes.
47 For instance, a framebuffer controller may refer to a GPIO
48 controller and pin that controls the backlight.
49 In this example, the GPIO node would have a cell (32-bit integer)
50 property with a reserved name like "phandle" or "linux,phandle"
51 whose value uniquely identifies the node.
52 The actual name depends on the implementation.
53 The framebuffer node would have a property with the name
54 described by device bindings (device-specific set of properties).
55 It can be a cell property or a combined property with one part
56 of it being a cell.
57 The value of the framebuffer node's property would be the same
58 as the value of the GPIO "phandle" property so it can be said
59 that the framebuffer node refers to the GPIO node.
60 The kernel uses internal logic to assign unique identifiers
61 to the device tree nodes, and these values do not match
62 the values of "phandle" properties.
63 .Fn OF_node_from_xref
64 and
65 .Fn OF_xref_from_node
66 are used to perform conversion between these two kinds of node
67 identifiers.
68 .Pp
69 .Fn OF_node_from_xref
70 returns the kernel phandle for the effective phandle
71 .Fa xref .
72 If one cannot be found or the OpenFirmware implementation
73 does not support effective phandles, the function returns
74 the input value.
75 .Pp
76 .Fn OF_xref_from_xref
77 returns the effective phandle for the kernel phandle
78 .Fa xref .
79 If one cannot be found or the OpenFirmware implementation
80 does not support effective phandles, the function returns
81 the input value.
82 .Sh EXAMPLES
83 .Bd -literal
84     phandle_t panelnode, panelxref;
85     char *model;
86
87     if (OF_getencprop(node, "lcd-panel", &panelxref) <= 0)
88         return;
89
90     panelnode = OF_node_from_xref(panelxref);
91     if (OF_getprop_alloc(hdminode, "model", (void **)&model) <= 0)
92         return;
93 .Ed
94 .Sh SEE ALSO
95 .Xr OF_device_from_xref 9
96 .Xr OF_device_register_xref 9
97 .Sh AUTHORS
98 .An -nosplit
99 This manual page was written by
100 .An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org .