OF_NODE_FROM_XREF(9) FreeBSD Kernel Developer's Manual OF_NODE_FROM_XREF(9)

NAME

OF_node_from_xref, OF_xref_from_nodeconvert between kernel phandle and effective phandle

SYNOPSIS

#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
phandle_t
OF_node_from_xref(phandle_t xref);
phandle_t
OF_xref_from_node(phandle_t node);

DESCRIPTION

Some OpenFirmware implementations (FDT, IBM) have a concept of effective phandle or xrefs. They are used to cross-reference device tree nodes. For instance, framebuffer controller may refer to GPIO controller and pin that controls the backlight. For such implementations, phandle used by the kernel to identify node does not match the value of cell property that points to the referred node. Otherwise, effective phandle is equal to the kernel phandle.
OF_node_from_xref() returns kernel phandle for the effective phandle xref. If one cannot be found or OpenFirmware implementation does not support effective phandles, the function returns input value.
OF_xref_from_xref() returns effective phandle for the kernel phandle xref. If one cannot be found or OpenFirmware implementation does not support effective phandles, the function returns input value.

EXAMPLES

    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;

SEE ALSO

OF_device_from_xref(9) OF_device_register_xref(9)

AUTHORS

This manual page was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>.
February 25, 2018 FreeBSD 12.0-CURRENT