1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<table class="head">
<tr>
<td class="head-ltitle">OF_NODE_FROM_XREF(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">OF_NODE_FROM_XREF(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">OF_node_from_xref</code>,
<code class="Nm">OF_xref_from_node</code> — <span class="Nd">convert
between kernel phandle and effective phandle</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">dev/ofw/ofw_bus.h</a>></code>
<br/>
<code class="In">#include
<<a class="In">dev/ofw/ofw_bus_subr.h</a>></code></p>
<p class="Pp"><var class="Ft">phandle_t</var>
<br/>
<code class="Fn">OF_node_from_xref</code>(<var class="Fa" style="white-space: nowrap;">phandle_t
xref</var>);</p>
<p class="Pp"><var class="Ft">phandle_t</var>
<br/>
<code class="Fn">OF_xref_from_node</code>(<var class="Fa" style="white-space: nowrap;">phandle_t
node</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">Some OpenFirmware implementations (FDT, IBM) have a concept of
effective phandle or xrefs. They are used to cross-reference device tree
nodes. For instance, a framebuffer controller may refer to a GPIO controller
and pin that controls the backlight. In this example, the GPIO node would
have a cell (32-bit integer) property with a reserved name like
"phandle" or "linux,phandle" whose value uniquely
identifies the node. The actual name depends on the implementation. The
framebuffer node would have a property with the name described by device
bindings (device-specific set of properties). It can be a cell property or a
combined property with one part of it being a cell. The value of the
framebuffer node's property would be the same as the value of the GPIO
"phandle" property so it can be said that the framebuffer node
refers to the GPIO node. The kernel uses internal logic to assign unique
identifiers to the device tree nodes, and these values do not match the
values of "phandle" properties.
<a class="permalink" href="#OF_node_from_xref"><code class="Fn" id="OF_node_from_xref">OF_node_from_xref</code></a>()
and <code class="Fn">OF_xref_from_node</code>() are used to perform
conversion between these two kinds of node identifiers.</p>
<p class="Pp" id="OF_node_from_xref~2"><a class="permalink" href="#OF_node_from_xref~2"><code class="Fn">OF_node_from_xref</code></a>()
returns the kernel phandle for the effective phandle
<var class="Fa">xref</var>. If one cannot be found or the OpenFirmware
implementation does not support effective phandles, the function returns the
input value.</p>
<p class="Pp" id="OF_xref_from_node"><a class="permalink" href="#OF_xref_from_node"><code class="Fn">OF_xref_from_node</code></a>()
returns the effective phandle for the kernel phandle
<var class="Fa">node</var>. If one cannot be found or the OpenFirmware
implementation does not support effective phandles, the function returns the
input value.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre> phandle_t panelnode, panelxref;
char *model;
if (OF_getencprop(node, "lcd-panel", &panelxref) <= 0)
return;
panelnode = OF_node_from_xref(panelxref);
if (OF_getprop_alloc(hdminode, "model", (void **)&model) <= 0)
return;</pre>
</div>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">OF_device_from_xref(9)</a>,
<a class="Xr">OF_device_register_xref(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Oleksandr
Tymoshenko</span>
<<a class="Mt" href="mailto:gonzo@FreeBSD.org">gonzo@FreeBSD.org</a>>.</p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">April 9, 2018</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|