2 .\" Copyright (c) 2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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.
29 .Dt OF_DEVICE_FROM_XREF 9
32 .Nm OF_device_from_xref ,
33 .Nm OF_xref_from_device ,
34 .Nm OF_device_register_xref
35 .Nd "manage mappings between xrefs and devices"
38 .In dev/ofw/ofw_bus_subr.h
40 .Fn OF_device_register_xref "phandle_t xref" "device_t dev"
42 .Fn OF_device_from_xref "phandle_t xref"
44 .Fn OF_xref_from_device "device_t dev"
47 When a device tree node references another node, the driver may
48 need to get a device_t instance associated with the referenced node.
49 For instance, an Ethernet driver accessing a PHY device.
50 To make this possible, the kernel maintains a table that
51 maps effective handles to device_t instances.
53 .Fn OF_device_register_xref
54 adds a map entry from the effective phandle
58 If a mapping entry for
60 already exists, it is replaced with the new one.
61 The function always returns 0.
63 .Fn OF_device_from_xref
64 returns a device_t instance associated with the effective phandle
66 If no such mapping exists, the function returns NULL.
68 .Fn OF_xref_from_device
69 returns the effective phandle associated with the device
71 If no such mapping exists, the function returns 0.
75 acmephy_attach(device_t dev)
79 /* PHY node is referenced from eth device, register it */
80 node = ofw_bus_get_node(dev);
81 OF_device_register_xref(OF_xref_from_node(node), dev);
90 This manual page was written by
91 .An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org .