docbook_devicetree_html_160620_0121.tgz 0000660 0001750 0001750 00002210000 12731723674 017617 0 ustar frowand frowand devicetree.html 0000660 0001750 0001750 00000000063 12731723565 013755 0 ustar frowand frowand devicetree
devicetree/API---of-add-property.html 0000660 0001750 0001750 00000006051 12731723565 017535 0 ustar frowand frowand
__of_add_property — add a property to a node without lock operations
int __of_add_property ( | struct device_node * np, |
struct property * prop) ; |
__of_node_dup — Duplicate or create an empty device tree node
struct device_node * __of_node_dup ( | const struct device_node * np, |
const char * fmt, | |
...) ; |
np
NULL or node to copy
fmt
Format string for new full name of the node @...: varargs for fmt
...
variable arguments
__of_prop_dup — Copy a property into a new dynamic property
struct property * __of_prop_dup ( | const struct property * prop, |
gfp_t allocflags) ; |
Copy prop
into a new property. Memory is allocated for all objects
associated with the new property; the new property does not
contain any
pointers to the contents of old property.
The typical value for allocflags
is GFP_KERNEL.
The new property's OF_DYNAMIC flag is set so dynamic properties can be identified.
__reserved_mem_init_node — call region specific reserved memory init code
int __reserved_mem_init_node ( | struct reserved_mem * rmem) ; |
__unflatten_device_tree — Create expanded device tree (EDT)
void * __unflatten_device_tree ( | const void * blob, |
struct device_node * dad, | |
struct device_node ** mynodes, | |
void *(*dt_alloc)
( u64 size, u64 align) ) ; |
blob
Pointer to flattened device tree (FDT)
dad
NULL or pointer to device tree node to attach new tree to
mynodes
Pointer used to return the expanded device tree (EDT)
dt_alloc
Pointer to a memory allocator that provides a virtual address
Create an expanded device tree (EDT) from the flattened device tree (FDT)
blob
. The “name” and “type” fields of the nodes will be populated so the
normal device-tree walking functions can be used.
If dad
is NULL, the path of the root of the EDT will “/”.
If dad
is not NULL that is probably an error. This usage is deprecated.
The newly created tree will be grafted onto node dad
. See notes about
dad
in unflatten_dt_nodes
for more details.
arch_match_cpu_phys_id — Check match the given logical CPU and physical id
bool arch_match_cpu_phys_id ( | int cpu, |
u64 phys_id) ; |
early_init_dt_check_for_initrd — Decode initrd location from flat tree
void early_init_dt_check_for_initrd ( | unsigned long node) ; |
fdt_init_reserved_mem — allocate and init all saved reserved memory regions
void fdt_init_reserved_mem ( | void) ; |
irq_of_parse_and_map — Parse and map an interrupt into linux virq space
unsigned int irq_of_parse_and_map ( | struct device_node * dev, |
int index) ; |
dev
Device node of the device whose interrupt is to be mapped
index
Zero-based index of the irq
This function is a wrapper that chains of_irq_parse_one
and
irq_create_of_mapping
to make things easier to callers.
of_add_property — add a property to a node
int of_add_property ( | struct device_node * np, |
struct property * prop) ; |
of_address_to_resource — Translate device tree address and return as resource
int of_address_to_resource ( | struct device_node * dev, |
int index, | |
struct resource * r) ; |
dev
Devicetree node
index
Index into the node addresses array
r
Pointer used to return the resource
Get the “reg” or “assigned-adresses” property of node dev
, as apppropriate
for the bus type of the parent of dev
. Use index
to select the element of
the property to translate.
Translate the address from node dev
into a CPU physical address.
r
->start and r
->end are the translated address.
r
->flags pertain to the address from node dev
, not the translated address.
r
->name is from the “reg-names” property of node dev
, if available, else
it is the full name of node dev
.
Note that if your address is a PIO address, the conversion will fail if
the physical address can't be internally converted to an IO token with
pci_address_to_pio
, that is because it's either called too early or it
can't be matched to any host bridge IO space.
of_alias_get_highest_id — get highest alias id for the given stem
int of_alias_get_highest_id ( | const char * stem) ; |
of_alias_get_id — get alias id for the given device_node
int of_alias_get_id ( | struct device_node * np, |
const char * stem) ; |
of_alias_scan — scan all properties of the 'aliases' node
void of_alias_scan ( | void * (*dt_alloc)
( u64 size, u64 align) ) ; |
of_attach_node — Insert node into the expanded device tree
int of_attach_node ( | struct device_node * np) ; |
of_build_overlay_info — Build an overlay info array
int of_build_overlay_info ( | struct of_overlay * ov, |
struct device_node * tree) ; |
Helper function that given a tree containing overlay information,
allocates and builds an overlay info array containing it, ready
for use by of_overlay_apply
.
of_changeset_action — Add a changeset entry to the changeset
int of_changeset_action ( | struct of_changeset * ocs, |
unsigned long action, | |
struct device_node * np, | |
struct property * prop) ; |
ocs
Pointer to changeset
action
Action to perform
np
Pointer to node
prop
Pointer to property
of_changeset_apply — Apply a changeset
int of_changeset_apply ( | struct of_changeset * ocs) ; |
Process each of the changeset actions then process each of the changeset notifiers for the associated actions.
Any side-effects of live tree state changes are applied here on success, like creation/destruction of devices and side-effects like creation of sysfs properties and directories.
On an error from any of the changeset actions the previously applied changeset entries are reverted. There is no check for notifier errors.
of_changeset_destroy — Destroy a changeset
void of_changeset_destroy ( | struct of_changeset * ocs) ; |
of_changeset_init — Initialize a changeset structure
void of_changeset_init ( | struct of_changeset * ocs) ; |
of_changeset_revert — Revert an applied changeset
int of_changeset_revert ( | struct of_changeset * ocs) ; |
of_console_check — add name to preferred console list if node is DT stdout
bool of_console_check ( | struct device_node * dn, |
char * name, | |
int index) ; |
dn
Pointer to node
name
Name to use for preferred console without index
index
Index to use for preferred console
of_count_phandle_with_args — find the number of phandles in a property
int of_count_phandle_with_args ( | const struct device_node * np, |
const char * list_name, | |
const char * cells_name) ; |
np
Pointer to node that contains the phandle list
list_name
Name of property in node np that contains the phandle list
cells_name
Name of property in target node that contains phandle's argument count
It is a typical pattern to encode a list of phandle and variable arguments into a single property. The number of arguments is encoded by a property in the phandle-target node. For example, a gpios property would contain a list of GPIO specifiers consisting of a phandle and 1 or more arguments. The number of arguments are determined by the #gpio-cells property in the node pointed to by the phandle.
of_detach_node — Remove node from the expanded device tree
int of_detach_node ( | struct device_node * np) ; |
Remove np
from the expanded device tree. Remove information about the
node from sysfs. Set the state of np
to OF_DETACHED.
of_node_put
will be called on np
. If the refcount goes to zero, the
memory associated with np
is freed.
After all of the above completes, the reconfig chain will be called with action OF_RECONFIG_DETACH_NODE.
The caller must hold a reference to np
.
This function should not be called for a node that is detached.
of_device_alloc — Allocate and initialize a platform device
struct platform_device * of_device_alloc ( | struct device_node * np, |
const char * bus_id, | |
struct device * parent) ; |
np
Pointer to device node to assign to device
bus_id
NULL or name to assign to the device
parent
Parent device
of_device_is_available — check if a device is available for use
bool of_device_is_available ( | const struct device_node * device) ; |
of_device_is_big_endian — check if a device has BE registers
bool of_device_is_big_endian ( | const struct device_node * device) ; |
Check if the node device
has big endian registers.
Callers would normally use ioread32be/iowrite32be if
of_device_is_big_endian
== true, or readl/writel otherwise.
of_device_is_compatible — check string matches device's “compatible” property
int of_device_is_compatible ( | const struct device_node * device, |
const char * compat) ; |
device
Pointer to node to be checked
compat
Required compatible string, NULL or "" for any match
Checks if the given compat
string matches one of the strings in
thr “compatible” property found in device
.
The return score is weighted for the most specific compatible value to get the highest score. This assumes that the ordering of strings in the “compatible” is from the most specific to the least specific, as specified in the bindings standards.
Note that the score is the opposite of of_fdt_is_compatible
and
of_fdt_match
, which report smaller scores as more compatible.
of_device_uevent — Add devicetree (OF) information to uevent
void of_device_uevent ( | struct device * dev, |
struct kobj_uevent_env * env) ; |
of_dma_configure — Setup DMA configuration
void of_dma_configure ( | struct device * dev, |
struct device_node * np) ; |
of_dma_get_range — Get DMA range info
int of_dma_get_range ( | struct device_node * np, |
u64 * dma_addr, | |
u64 * paddr, | |
u64 * size) ; |
np
Device node to get DMA range info
dma_addr
Pointer used to return initial DMA address of DMA range
paddr
Pointer used to return initial CPU address of DMA range
size
Pointer used to return size of DMA range
of_dma_is_coherent — Check if device is coherent
bool of_dma_is_coherent ( | struct device_node * np) ; |
of_fdt_is_big_endian — Check if node needs BE MMIO accesses
bool of_fdt_is_big_endian ( | const void * blob, |
unsigned long node) ; |
of_fdt_is_compatible — Check if node matches a compatible value
int of_fdt_is_compatible ( | const void * blob, |
unsigned long node, | |
const char * compat) ; |
blob
Pointer to device tree blob (flattened device tree)
node
Node offset in blob
compat
Pointer to compatible string
Note that the score is the opposite of of_device_is_compatible
, which
reports larger scores as more compatible.
of_fdt_match — Check if node matches a list of compatible values
int of_fdt_match ( | const void * blob, |
unsigned long node, | |
const char *const * compat) ; |
blob
Device tree blob (flattened device tree)
node
Node offset in blob
compat
NULL terminated list of pointers to compatible strings
Note that the score is the opposite of of_device_is_compatible
, which
reports larger scores as more compatible.
of_fdt_unflatten_tree — Create expanded device tree (EDT)
void * of_fdt_unflatten_tree ( | const unsigned long * blob, |
struct device_node * dad, | |
struct device_node ** mynodes) ; |
blob
Pointer to flattened device tree (FDT)
dad
NULL or pointer to device tree node to attach new tree to
mynodes
Pointer used to return the expanded device tree (EDT)
Create an expanded device tree (EDT) from the flattened device tree (FDT)
blob
. The “name” and “type” fields of the nodes will be populated so the
normal device-tree walking functions can be used.
If dad
is NULL, the path of the root of the EDT will “/”.
If dad
is not NULL that is probably an error. This usage is deprecated.
The newly created tree will be grafted onto node dad
. See notes about
dad
in unflatten_dt_nodes
for more details.
of_fill_overlay_info — Fill an overlay info structure
int of_fill_overlay_info ( | struct of_overlay * ov, |
struct device_node * info_node, | |
struct of_overlay_info * ovinfo) ; |
ov
Overlay to fill
info_node
Pointer to device node containing the overlay
ovinfo
Pointer to the overlay info structure to fill
Fill an overlay info structure with the overlay information from a device node. This device node must have a target property which contains a phandle of the overlay target node, and an __overlay__ child node which has the overlay contents. Both ovinfo->target & ovinfo->overlay have their references taken.
of_find_all_nodes — get next node in global list
struct device_node * of_find_all_nodes ( | struct device_node * prev) ; |
A node pointer if found, with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_compatible_node — find a node based on type and compatible
struct device_node * of_find_compatible_node ( | struct device_node * from, |
const char * type, | |
const char * compatible) ; |
from
Pointer to node to start searching from or NULL for the entire device tree.
type
The type string to match “device_type” or NULL to ignore
compatible
The string to match to one of the tokens in the device “compatible” list.
Search the device tree for a node whose “compatible” property contains
a match for compatible
and whose “device-type” property contains a
value matching type
.
From will not be searched, the search will begin with the next node in search order. Typical use is to pass what the previous call returned.
The order of the device tree traversal is kernel version specific.
of_node_put
will be called on from
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_device_by_node — Find the platform_device associated with a node
struct platform_device * of_find_device_by_node ( | struct device_node * np) ; |
of_find_matching_node_and_match — find node based on match table
struct device_node * of_find_matching_node_and_match ( | struct device_node * from, |
const struct of_device_id * matches, | |
const struct of_device_id ** match) ; |
from
Pointer to node to start searching from or NULL for the entire device tree.
matches
Array of device match structures to search for
match
If not NULL, pointer used to return the element of matches which is the best match.
Search the device tree for a node that matches an entry in the matches
array. Each element of the matches
array may specify any or all of
compatible, type, or name. If name, type, or compatible in an element
is not specified, it must be a string of length zero.
Set match to point to the element of matches
that provides the best match.
The first string in the node's compatible property is the best match. Matching type is next best, followed by matching name. This results in the following priority order for matching
1. first string in the “compatible” property list && type && name
2. first string in the “compatible” property list && type
3. first string in the “compatible” property list && name
4. first string in the “compatible” property list
5. second string in the “compatible” property list && type && name
6. second string in the “compatible” property list && type
7. second string in the “compatible” property list && name
8. second string in the “compatible” property list
and so on up through the final string in the “compatible” property list. If the ordering of strings in the “compatible” is from the most specific to the least specific, as specified in the bindings standards, then the most specific compatible string is the best match.
If there is no match in the “compatible” property list, the priority order for matching is
1. type && name
2. type
3. name
From will not be searched, the search will begin with the next node in search order. Typical use is to pass what the previous call returned.
The order of the device tree traversal is kernel version specific.
of_node_put
will be called on from
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_next_cache_node — find node's subsidiary cache
struct device_node * of_find_next_cache_node ( | const struct device_node * np) ; |
Find node referenced by phandle in property 'l2-cache' or
'next-level-cache'. If phandle not found and type of np
is 'cpu'
then find child node of np
named 'cache'.
Caller should hold a reference to np
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_node_by_name — find a node by its “name” property
struct device_node * of_find_node_by_name ( | struct device_node * from, |
const char * name) ; |
from
Pointer to node to start searching from or NULL for the entire device tree.
name
The name string to match against
Search the device tree for a node whose “name” property contains a value
matching name
.
from
will not be searched, the search will begin with the next node in
search order. Typical use is to pass what the previous call returned.
The order of the device tree traversal is kernel version specific.
of_node_put
will be called on from
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_node_by_phandle — find a node given a phandle
struct device_node * of_find_node_by_phandle ( | phandle handle) ; |
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_node_by_type — find a node by its “device_type” property
struct device_node * of_find_node_by_type ( | struct device_node * from, |
const char * type) ; |
from
Pointer to node to start searching from or NULL for the entire device tree.
type
The type string to match against
Search the device tree for a node whose “device-type” property contains a
value matching type
.
from
will not be searched, the search will begin with the next node in
search order. Typical use is to pass what the previous call returned.
The order of the device tree traversal is kernel version specific.
of_node_put
will be called on from
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_node_opts_by_path — find a node matching a full OF path
struct device_node * of_find_node_opts_by_path ( | const char * path, |
const char ** opts) ; |
path
Either the full path to match, or if the path does not start with '/', a path beginning with an alias.
opts
If not NULL, pointer into which to store the start of the options string.
Find the deepest (rightmost) node in path
.
If the path
does not start with '/' then the first component of the path
is the name of a property in the “/aliases” node whose value is a path.
That value is substituted into path
in place of the property name before
finding the deepest node in path
.
If path
includes a ':' separator then the bytes following the ':' are the
option string.
Valid forms for path
/foo/bar Full path
foo Valid alias
foo/bar Valid alias + relative path
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_find_node_with_property — find a node with a property with the given name
struct device_node * of_find_node_with_property ( | struct device_node * from, |
const char * prop_name) ; |
from
Pointer to node to start searching from or NULL for the entire device tree.
prop_name
The name of the property to look for
Search the device tree for a node that contains a property with the name
prop_name
.
From will not be searched, the search will begin with the next node in search order. Typical use is to pass what the previous call returned.
The order of the device tree traversal is kernel version specific.
of_node_put
will be called on from
.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_flat_dt_match_machine — Iterate match tables to find matching machine
const void * of_flat_dt_match_machine ( | const void * default_match, |
const void * (*get_next_compat)
( const char * const**) ) ; |
of_flat_dt_translate_address — translate DT addr into CPU phys addr
u64 of_flat_dt_translate_address ( | unsigned long node) ; |
Translate an address from the device-tree into a CPU physical address. This walks up the tree and applies the various bus mappings on the way.
Note - We consider that crossing any level with #size-cells == 0 to mean that translation is impossible (that is we are not dealing with a value that can be mapped to a cpu physical address). This is not really specified that way, but this is traditionally the way IBM at least do things
of_free_overlay_info — Free an overlay info array
int of_free_overlay_info ( | struct of_overlay * ov) ; |
of_get_child_by_name — find the child node by name for a given parent
struct device_node * of_get_child_by_name ( | const struct device_node * node, |
const char * name) ; |
Pointer to child node if found, with refcount incremented, use
of_node_put
on it when done. NULL if node
is not found.
of_get_cpu_node — get device node associated with the given logical CPU
struct device_node * of_get_cpu_node ( | int cpu, |
unsigned int * thread) ; |
cpu
Logical cpu index for which node is required
thread
If not NULL, local thread number within the physical core is returned
Retrieve the device node for the given logical CPU index. It should be used to initialize the of_node in the cpu device. Once of_node in the cpu device is populated, all the further references can use that instead.
CPU logical to physical index mapping is architecture specific and is built before booting secondary cores. This function uses arch_match_cpu_phys_id which can be overridden by architecture specific implementation.
A node pointer if found, with refcount incremented,
use of_node_put
on it when done. NULL if node is not found.
of_get_mac_address — Get best MAC address
const void * of_get_mac_address ( | struct device_node * np) ; |
Search the device tree for the best MAC address to use. The value of property “mac-address” is checked first, because that is supposed to contain to “most recent” MAC address. If that isn't set, then the value of property “local-mac-address” is checked next, because that is the default address. If that isn't set, then the value of the obsolete property “address” is checked, just in case we're using an old device tree.
Note that the “address” property is supposed to contain a virtual address of the register set, but some DTS files have redefined that property to be the MAC address.
All-zero MAC addresses are rejected, because those could be properties that exist in the device tree, but were not set by U-Boot. For example, the DTS could define “mac-address” and “local-mac-address”, with zero MAC addresses. Some older U-Boots only initialized “local-mac-address”. In this case, the real MAC is in “local-mac-address”, and “mac-address” exists but is all zeros.
of_get_next_available_child — find the next available child node
struct device_node * of_get_next_available_child ( | const struct device_node * node, |
struct device_node * prev) ; |
node
Pointer to parent node
prev
Pointer to previous child of parent node, or NULL to get first
This function is like of_get_next_child
, except that it
skips any disabled nodes (i.e. status is any value other than “okay” or
“ok”).
of_node_put
will be called on prev
.
Pointer to next available child node if found, with refcount
incremented, use of_node_put
on it when done. NULL if node
is not found.
of_get_next_child — find next child node
struct device_node * of_get_next_child ( | const struct device_node * node, |
struct device_node * prev) ; |
node
Pointer to parent node
prev
Pointer to previous child of parent node, or NULL to get first
Pointer to next child node if found, with refcount incremented, use
of_node_put
on it when done. NULL if node
is not found.
of_get_next_parent — iterate to a node's parent
struct device_node * of_get_next_parent ( | struct device_node * node) ; |
Find the parent node of node.
This is like of_get_parent
except that it drops the
refcount on the passed node, making it suitable for iterating
up the tree.
Pointer to next parent node pointer if found, with refcount
incremented, use of_node_put
on it when done. NULL if node
is not found.
of_get_parent — get a node's parent
struct device_node * of_get_parent ( | const struct device_node * node) ; |
Pointer to parent node if found, with refcount incremented, use
of_node_put
on it when done. NULL if node
is not found.
of_get_pci_domain_nr — Get PCI host bridge domain number
int of_get_pci_domain_nr ( | struct device_node * node) ; |
of_get_phy_mode — Get phy mode for given device_node
int of_get_phy_mode ( | struct device_node * np) ; |
of_graph_get_endpoint_by_regs — get endpoint node of specific identifiers
struct device_node * of_graph_get_endpoint_by_regs ( | const struct device_node * parent, |
int port_reg, | |
int reg) ; |
parent
Pointer to parent node
port_reg
Identifier (value of reg property) of the parent port node
reg
Identifier (value of reg property) of the endpoint node
Find an 'endpoint' node pointer which is identified by reg
and is the
child of a port node identified by port_reg
. reg
and port_reg
are
ignored when they are -1.
See of_graph_get_next_endpoint
for more information about the expected
form of the parent
node and the parent
port node.
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
An 'endpoint' node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_graph_get_next_endpoint — get next endpoint node
struct device_node * of_graph_get_next_endpoint ( | const struct device_node * parent, |
struct device_node * prev) ; |
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
If prev
is NULL then the port node is parent
/ports/port if that exists
else parent
/port if that exists. If prev
is not NULL then the port node
is the parent of prev
.
If prev
is NULL then the next endpoint node is the first child of the
port node.
If prev
is not NULL then the next endpoint node is the next child of the
port node, following prev
. If there is not a next child in the current
port node then the port node becomes the next sibling node of port, with
the node name of “port”, and the next endpoint is the first child of
the new port node.
of_node_put
will be called on prev
.
An 'endpoint' node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_graph_get_port_by_id — get pointer to the port node matching a given id
struct device_node * of_graph_get_port_by_id ( | struct device_node * parent, |
u32 id) ; |
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
If parent
contains a node named 'ports' then that node is searched else
parent
is searched. Search for child node named 'port' that contains a
'reg' property whose value matches id
.
A 'port' node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_graph_get_remote_port_parent — get remote port's ancestor device node
struct device_node * of_graph_get_remote_port_parent ( | const struct device_node * node) ; |
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
Find the device node that contains the remote endpoint's ancestor “ports” node or “port” node if “ports” does not exist.
First find the endpoint node referred to by the phandle in the
'remote-endpoint' property contained in node
. Then walk up the tree from
the endpoint node to find an ancestor node. The ancestor node is three
levels above the endpoint node if the endpoint node's grandparent is
named 'ports' else two levels. The ancestor node is the “parent” node
that is returned.
A node pointer if found, with refcount incremented,
use of_node_put
on it when done. NULL if node
is not found.
of_graph_get_remote_port — get remote port node
struct device_node * of_graph_get_remote_port ( | const struct device_node * node) ; |
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
First find the endpoint node referred to by the phandle in the
'remote-endpoint' property contained in node
. Then find the parent of
the endpoint node. The parent node is returned.
A node pointer if found, with refcount incremented,
use of_node_put
on it when done. NULL if node
is not found.
of_graph_parse_endpoint — parse common endpoint node properties
int of_graph_parse_endpoint ( | const struct device_node * node, |
struct of_endpoint * endpoint) ; |
This function is used in association with common bindings for video receiver and transmitter interfaces. For more information see Documentation/devicetree/bindings/media/video-interfaces.txt.
The endpoint properties are returned in endpoint
. endpoint
->local_node
is node
, endpoint
->port is the u32 value of the parent node 'reg'
property, endpoint
->id is the u32 value of the node
'reg' property.
The caller should hold a reference to node
.
of_iomap — Map the memory mapped IO for a given device_node
void __iomem * of_iomap ( | struct device_node * np, |
int index) ; |
ioremap
the translated address from node np
. The address translated
is from the “reg” or “assigned-adresses” property of node np
, as
apppropriate for the bus type of the parent of np
. Use index
to select
the element of the property to translate and map.
See of_address_to_resource
for more information on address translation.
of_irq_count — Count the number of IRQs a node uses
int of_irq_count ( | struct device_node * dev) ; |
of_irq_find_parent — Given a device node, find its interrupt parent node
struct device_node * of_irq_find_parent ( | struct device_node * child) ; |
Walk up the tree from child
to find a node containing property
“#interrupt-cells”. Each step of the walk goes to the node referenced by
the phandle in property “interrupt-parent” if it exists, otherwise the
parent of the node. The node containing property “#interrupt-cells” is
the interrupt parent node.
The path of the walk may be short-circuited if no “interrupt-parent” property exists and (of_irq_workarounds & OF_IMAP_NO_PHANDLE).
of_irq_get_byname — Decode a node's IRQ and return it as a Linux irq number
int of_irq_get_byname ( | struct device_node * dev, |
const char * name) ; |
of_irq_get — Parse and map a node's IRQ into linux virq space
int of_irq_get ( | struct device_node * dev, |
int index) ; |
of_irq_init — Scan and initialize matching interrupt controllers in DT
void of_irq_init ( | const struct of_device_id * matches) ; |
This function scans the device tree for matching interrupt controller nodes, and calls their initialization functions in order with parents first.
matches
[]->name, matches
[]->type, and/or matches
[]->compatible determine
whether an interrupt controller node matches.
matches
[]->data contains the initialization function. The functions
are of the form
int (struct device_node *device, struct device_node *interrupt_parent);
A node is an interrupt controller node if it contains the property “interrupt-controller”.
of_irq_parse_and_map_pci — Decode a PCI irq from the device tree and map to a virq
int of_irq_parse_and_map_pci ( | const struct pci_dev * dev, |
u8 slot, | |
u8 pin) ; |
dev
Pointer to PCI device needing an irq
slot
PCI slot number; passed when used as map_irq callback. Unused
pin
PCI irq pin number; passed when used as map_irq callback. Unused
of_irq_parse_one — Resolve an interrupt for a device
int of_irq_parse_one ( | struct device_node * device, |
int index, | |
struct of_phandle_args * out_irq) ; |
device
Pointer to node of device whose interrupt is to be resolved
index
Zero-based index of the irq
out_irq
Pointer used to return the interrupt specifier
This function resolves an interrupt for a node by walking the interrupt tree, finding which interrupt controller node it is attached to, and returning the interrupt specifier that can be used to retrieve a Linux IRQ number.
If the node device
contains the “#interrupt-extended” property, index
is
used to select an entry from the property and that entry is resolved,
starting the tree walk at the node referenced by the phandle in that entry.
Otherwise index
is used to select an entry from the “interrupts” property
and the values in that entry are used for matches while walking the
interrupt tree.
In either case, the value of the “reg” property in node device
is used
as the address to for matches while walking the interrupt tree.
See of_irq_parse_raw
for details on how an interrupt is resolved.
On success the final translated interrupt specifier is returned in out_irq
.
of_irq_parse_pci — Resolve the interrupt for a PCI device
int of_irq_parse_pci ( | const struct pci_dev * pdev, |
struct of_phandle_args * out_irq) ; |
pdev
Pointer to device whose interrupt is to be resolved
out_irq
Pointer used to return zzz
Resolve the PCI interrupt for a given PCI device. If a device-node exists for a given pci_dev, it will use normal OF tree walking. If not, it will implement standard swizzling and walk up the PCI tree until an device-node is found, at which point it will finish resolving using the OF tree walking.
On success the final translated interrupt specifier is returned in out_irq
.
of_irq_parse_raw — Low level interrupt tree parsing
int of_irq_parse_raw ( | const __be32 * addr, |
struct of_phandle_args * out_irq) ; |
addr
If not NULL, an array of address values to be matched
out_irq
Pointer to an input/output structuren
This function is a low-level interrupt tree walking function. It can be used to do a partial walk with synthetized reg and interrupts properties, for example when resolving PCI interrupts when no device node exist for the parent. It takes an interrupt specifier structure as input, walks the tree looking for any interrupt-map properties, translates the specifier for each map, and then returns the translated map.
Walk up the interrupt parent path (see of_irq_find_parent
) to find an
interrupt parent containing property “interrupt-map”. Match an
“interrupt-map” entry (masked by the “interrupt-map-mask” from the same
node). On match, the new parent in the walk is the node referenced by the
phandle in the matched “interrupt-map” entry and the values to match are
updated with the values matched entry.
The walk continues until a node containing property “interrupt-controller” is reached.
The number of elements of addr
is determined by property “#address-cells”.
“#address-cells” is often zero.
== out_irq
input fields
out_irq
->np - Pointer to devicetree node to start the walk.
out_irq
->args[] - “#interrupt-cells” values to be matched in the
interrupt-map.
out_irq
->args_count - The number of input values in out_irq
->args[]. Must
be same as the value of property “#interrupt-cells” in node out_irq
->np,
or found in a node walking up the tree.
The values to match are constructed from the values of addr
, followed by
the values from out_irq
->args[]. If addr
is NULL, and “#address-cells” is
greater than 0 the values of addr
to match are 0.
== out_irq
output fields
out_irq
->np - pointer to final node found to contain property “interrupt-map”
out_irq
->args[] - The interrupt values to be found in an “interrupt-map”
property.
out_irq
->args_count - Number of elements of out_irq
->args[].
out_irq
can be used to call irq_create_of_mapping
.
On success the final translated interrupt specifier is returned in out_irq
.
of_irq_to_resource_table — Fill in resource table with node's IRQ info
int of_irq_to_resource_table ( | struct device_node * dev, |
struct resource * res, | |
int nr_irqs) ; |
dev
Pointer to device tree node
res
Pointer to array used to return resource table
nr_irqs
Maximum number of IRQs to return in res
of_irq_to_resource — Decode a node's IRQ and return it as a resource
int of_irq_to_resource ( | struct device_node * dev, |
int index, | |
struct resource * r) ; |
dev
Pointer to node of device whose interrupt is to be resolved
index
Zero-based index of the irq
r
Pointer used to return result into
of_machine_is_compatible — test root of device tree for given compatible value
int of_machine_is_compatible ( | const char * compat) ; |
of_match_device — Check if a struct device matches an of_device_id list
const struct of_device_id * of_match_device ( | const struct of_device_id * matches, |
const struct device * dev) ; |
matches
Array of device match structures to match against
dev
The of device structure to match against
Used by a driver to check whether a platform_device is in its list of supported devices.
Get the best match in matches
array for dev
. Each element of the matches
array may specify any or all of compatible, type, or name. If name, type,
or compatible in an element is not specified, it must be a string of length
zero.
The first string in the node's compatible property is the best match. Matching type is next best, followed by matching name. This results in the following priority order for matching
1. first string in the “compatible” property list && type && name
2. first string in the “compatible” property list && type
3. first string in the “compatible” property list && name
4. first string in the “compatible” property list
5. second string in the “compatible” property list && type && name
6. second string in the “compatible” property list && type
7. second string in the “compatible” property list && name
8. second string in the “compatible” property list
and so on up through the final string in the “compatible” property list. If the ordering of strings in the “compatible” is from the most specific to the least specific, as specified in the bindings standards, then the most specific compatible string is the best match.
If there is no match in the “compatible” property list, the priority order for matching is
1. type && name
2. type
3. name
of_match_node — check if a device_node has a matching of_match structure
const struct of_device_id * of_match_node ( | const struct of_device_id * matches, |
const struct device_node * node) ; |
Get the best match in matches
array for node
. Each element of the matches
array may specify any or all of compatible, type, or name. If name, type,
or compatible in an element is not specified, it must be a string of length
zero.
The first string in the node's compatible property is the best match. Matching type is next best, followed by matching name. This results in the following priority order for matching
1. first string in the “compatible” property list && type && name
2. first string in the “compatible” property list && type
3. first string in the “compatible” property list && name
4. first string in the “compatible” property list
5. second string in the “compatible” property list && type && name
6. second string in the “compatible” property list && type
7. second string in the “compatible” property list && name
8. second string in the “compatible” property list
and so on up through the final string in the “compatible” property list. If the ordering of strings in the “compatible” is from the most specific to the least specific, as specified in the bindings standards, then the most specific compatible string is the best match.
If there is no match in the “compatible” property list, the priority order for matching is
1. type && name
2. type
3. name
of_mdiobus_register — Register mii_bus and create PHYs from the device tree
int of_mdiobus_register ( | struct mii_bus * mdio, |
struct device_node * np) ; |
of_modalias_node — lookup appropriate modalias for a device node
int of_modalias_node ( | struct device_node * node, |
char * modalias, | |
int len) ; |
node
Pointer to node containing compatible property
modalias
Points to a char * used to return the modalias string
len
Length of modalias
of_msi_configure — Set the msi_domain field of a device
void of_msi_configure ( | struct device * dev, |
struct device_node * np) ; |
of_msi_get_domain — Use msi-parent to find the relevant MSI domain
struct irq_domain * of_msi_get_domain ( | struct device * dev, |
struct device_node * np, | |
enum irq_domain_bus_token token) ; |
dev
Pointer to device for which the domain is requested
np
Device node for dev
token
Bus type for this domain
of_msi_map_get_device_domain — Use msi-map to find the relevant MSI domain
struct irq_domain * of_msi_map_get_device_domain ( | struct device * dev, |
u32 rid) ; |
of_msi_map_rid — Map a MSI requester ID for a device.
u32 of_msi_map_rid ( | struct device * dev, |
struct device_node * msi_np, | |
u32 rid_in) ; |
dev
Pointer to device for which the mapping is to be done
msi_np
NULL or pointer to device node of the expected msi controller
rid_in
Unmapped MSI requester ID for the device
Walk up the device hierarchy, looking for a device whose devicetree node
contains an “msi-map” property. If found and an element of msi-map matches,
apply the mapping specified by the rid-base in the matching element to
rid_in
.
rid_in
may be masked by property “msi-map-mask”, contained in the node that
contains property “msi_map”.
A match occurs if (1) rid_in
, optionally masked by “msi-map-mask”, is in
the range of rid_base..(rid_base + length), and (2) if msi_np
is not NULL,
it has the same value as the dereferenced msi-controller phandle
Note that the tree walk is for “struct device *”, not “struct device_node *”. In other words, not walking up the devicetree tree.
See binding pci/pci-msi.txt for more information about requestor ID and properties “msi-map” and “msi-map-mask”.
of_node_get — Increment refcount of a node
struct device_node * of_node_get ( | struct device_node * node) ; |
of_node_put — Decrement refcount of a node
void of_node_put ( | struct device_node * node) ; |
of_node_release — Release a dynamically allocated node
void of_node_release ( | struct kobject * kobj) ; |
of_overlay_apply —
Apply count
overlays pointed at by ovinfo_tab
int of_overlay_apply ( | struct of_overlay * ov) ; |
of_overlay_create — Create and apply an overlay
int of_overlay_create ( | struct device_node * tree) ; |
of_overlay_destroy_all — Remove all overlays from the system
int of_overlay_destroy_all ( | void) ; |
of_parse_phandle_with_args — find a node pointed to by phandle in a list
int of_parse_phandle_with_args ( | const struct device_node * np, |
const char * list_name, | |
const char * cells_name, | |
int index, | |
struct of_phandle_args * out_args) ; |
np
Pointer to node that contains the phandle list
list_name
Name of property that contains the phandle list
cells_name
Name of property in target node that contains phandle's argument count
index
Index into the phandle list
out_args
If not NULL, pointer used to return the device_node pointer and the phandle arguments.
Resolve a phandle to a device node pointer.
The phandle is an element of the property list_name
in node np
.
Index specifies which element of property list_name
contains the desired
phandle. index
is zero-based. The size of each element of the list is
not constant (see cells_name).
For each phandle in the list, the target device_node will be searched
for the property cells_name
, to determine how many arguments follow the
phandle in the list.
The device_node pointer will be returned in out_args->np. The associated phandle arguments will be returned in out_args->args[].
The caller is responsible to call of_node_put
on the returned out_args->np
pointer when done.
Example
'phandle1: node1 {
#list-cells = <2>;
}'
'phandle2: node2 {
#list-cells = <1>;
}'
'node3 {
list = <phandle1 1 2 phandle2 3>;
}'
To get the 'node2' device_node pointer you may call this: of_parse_phandle_with_args(node3, “list”, “#list-cells”, 1, args);
of_parse_phandle_with_fixed_args — find a node pointed by phandle in a list
int of_parse_phandle_with_fixed_args ( | const struct device_node * np, |
const char * list_name, | |
int cell_count, | |
int index, | |
struct of_phandle_args * out_args) ; |
np
Pointer to node that contains the phandle list
list_name
Name of property in node np that contains the phandle list
cell_count
Number of argument cells following the phandle
index
Index into the phandle list
out_args
If not NULL, pointer used to return the device_node pointer and the phandle arguments.
Resolve a phandle to a device node pointer.
The phandle is an element of the property list_name
in node np
.
Index specifies which element of property list_name
contains the desired
phandle. Index is zero-based. The size of each element of the list is
constant, cell_count
specifies how many arguments follow each phandle.
The device_node pointer will be returned in out_args
->np.
The phandle arguments will be returned in out_args
->args[].
The caller is responsible to call of_node_put
on the returned out_args
->np
pointer when done.
Example
'phandle1: node1 { }'
'phandle2: node2 { }'
'node3 { list = <phandle1 0 2 phandle2 2 3>; }'
To get a device_node of the `node2' node you may call this: of_parse_phandle_with_fixed_args(node3, “list”, 2, 1, args);
of_parse_phandle — find a node pointed by phandle in a list
struct device_node * of_parse_phandle ( | const struct device_node * np, |
const char * phandle_name, | |
int index) ; |
np
Pointer to node that contains the phandle list
phandle_name
Name of property that contains the phandle list
index
Index into the phandle list
Resolve a phandle to a device node pointer.
The phandle is an element of the property phandle_name
in node np
. The
property list contains only phandles; it does not contain any arguments.
Index specifies which element of property handle_name_name contains the desired phandle. Index is zero-based.
A node pointer with refcount incremented, use
of_node_put
on it when done. NULL if node is not found.
of_pci_check_probe_only — Set PCI probe only mode from “linux,pci-probe-only”
void of_pci_check_probe_only ( | void) ; |
of_pci_get_devfn — Get device and function numbers for a device node
int of_pci_get_devfn ( | struct device_node * np) ; |
of_pci_get_host_bridge_resources — Parse PCI host bridge resources
int of_pci_get_host_bridge_resources ( | struct device_node * dev, |
unsigned char busno, | |
unsigned char bus_max, | |
struct list_head * resources, | |
resource_size_t * io_base) ; |
dev
Pointer to device node of the host bridge
busno
Bus number associated with the bridge root bus
bus_max
Maximum number of buses for this bridge
resources
List where the range of resources will be added after parsing
io_base
If not NULL, pointer used to return the start of the I/O range
It is the caller's job to free the resources
list.
Parse the “bus-range” property of a PCI host bridge device
node and setup the resource mapping based on its content.
If the “bus-range” property is not found then busno
and bus_max
are
used to define the resource.
Returns the physical address for the start of the I/O range in io_base
.
of_pci_parse_bus_range — Parse the bus-range property of a PCI device
int of_pci_parse_bus_range ( | struct device_node * node, |
struct resource * res) ; |
of_phy_attach — Attach to a PHY without starting the state machine
struct phy_device * of_phy_attach ( | struct net_device * dev, |
struct device_node * phy_np, | |
u32 flags, | |
phy_interface_t iface) ; |
of_phy_connect — Connect to the phy described in the device tree
struct phy_device * of_phy_connect ( | struct net_device * dev, |
struct device_node * phy_np, | |
void (*hndlr)
( struct net_device *) , | |
u32 flags, | |
phy_interface_t iface) ; |
of_phy_find_device — Give a PHY node, find the phy_device
struct phy_device * of_phy_find_device ( | struct device_node * phy_np) ; |
of_platform_bus_probe — Probe the device-tree for platform buses
int of_platform_bus_probe ( | struct device_node * root, |
const struct of_device_id * matches, | |
struct device * parent) ; |
root
Pointer to parent of the first level to probe
matches
Pointer to match table for bus nodes
parent
Pointer to parent to hook devices from, NULL for toplevel
If root
is NULL, then root
is the root of the tree.
If root
has a match in matches
, create root
and it's children.
Otherwise, for each child of root
that has a match in matches
, create
that child and it's children.
Note that children of the provided root are not instantiated as devices unless the specified root itself matches the bus list and is not NULL.
of_platform_depopulate — Remove devices populated from device tree
void of_platform_depopulate ( | struct device * parent) ; |
Complementary to of_platform_populate
, this function removes children
of the given device (and, recursively, their children) that have been
created from their respective device tree nodes (and only those,
leaving others - eg. manually created - unharmed).
of_platform_device_create — Alloc, initialize and register a platform device
struct platform_device * of_platform_device_create ( | struct device_node * np, |
const char * bus_id, | |
struct device * parent) ; |
np
Pointer to node to create device for
bus_id
NULL or name to assign to the device
parent
Linux device model parent device.
of_platform_populate — Populate platform_devices from device tree data
int of_platform_populate ( | struct device_node * root, |
const struct of_device_id * matches, | |
const struct of_dev_auxdata * lookup, | |
struct device * parent) ; |
root
Pointer to parent of the first level to probe
matches
Pointer to match table for child nodes
lookup
NULL or pointer to auxdata that contains compatible match tables
parent
Pointer to parent to hook devices from, NULL for toplevel
If root
is NULL, then root
is the root of the tree.
Similar to of_platform_bus_probe
, this function walks the device tree
and creates devices from nodes. It differs in that it follows the modern
convention of requiring all device nodes to have a 'compatible' property,
and it is suitable for creating devices which are children of the root
node (of_platform_bus_probe will only create children of the root which
are selected by the matches
argument).
New board support should be using this function instead of
of_platform_bus_probe
.
of_property_count_elems_of_size — count the number of elements in a property
int of_property_count_elems_of_size ( | const struct device_node * np, |
const char * propname, | |
int elem_size) ; |
np
Pointer to node containing the property
propname
Name of the property to be searched
elem_size
Size of the individual element
of_property_match_string — find string in a list and return index
int of_property_match_string ( | const struct device_node * np, |
const char * propname, | |
const char * string) ; |
np
Pointer to node containing the string list property
propname
String list property name
string
Pointer to string to search for in string list
of_property_read_string_helper — internal use only, do not call directly
int of_property_read_string_helper ( | const struct device_node * np, |
const char * propname, | |
const char ** out_strs, | |
size_t sz, | |
int skip) ; |
of_property_read_string — read a string from a property
int of_property_read_string ( | const struct device_node * np, |
const char * propname, | |
const char ** out_string) ; |
np
Pointer to node containing the property
propname
Name of the property to be searched
out_string
Pointer used to return the string
of_property_read_u16_array — find and read an array of u16 from a property
int of_property_read_u16_array ( | const struct device_node * np, |
const char * propname, | |
u16 * out_values, | |
size_t sz) ; |
of_property_read_u32_array — read an array of 32 bit integers from a property
int of_property_read_u32_array ( | const struct device_node * np, |
const char * propname, | |
u32 * out_values, | |
size_t sz) ; |
of_property_read_u32_index — find and read a u32 from a multi-value property
int of_property_read_u32_index ( | const struct device_node * np, |
const char * propname, | |
u32 index, | |
u32 * out_value) ; |
of_property_read_u64_array — read an array of 64 bit integers from a property
int of_property_read_u64_array ( | const struct device_node * np, |
const char * propname, | |
u64 * out_values, | |
size_t sz) ; |
of_property_read_u64 — read a 64 bit integer from a property
int of_property_read_u64 ( | const struct device_node * np, |
const char * propname, | |
u64 * out_value) ; |
of_property_read_u8_array — find and read an array of u8 from a property
int of_property_read_u8_array ( | const struct device_node * np, |
const char * propname, | |
u8 * out_values, | |
size_t sz) ; |
of_remove_property — remove a property from a node
int of_remove_property ( | struct device_node * np, |
struct property * prop) ; |
of_reserved_mem_device_init — assign reserved memory region to given device
int of_reserved_mem_device_init ( | struct device * dev) ; |
of_reserved_mem_device_release — release reserved memory device structures
void of_reserved_mem_device_release ( | struct device * dev) ; |
of_resolve_phandles — Resolve the given node against the live tree.
int of_resolve_phandles ( | struct device_node * resolve) ; |
Perform dynamic Device Tree resolution against the live tree to the given node to resolve. This depends on the live tree having a __symbols__ node, and the resolve node the __fixups__ & __local_fixups__ nodes (if needed). The result of the operation is a resolve node whose contents are fit to be inserted or operate upon the live tree.
0
on success, else -ENOENT
on failure to find a node or property,
-ERANGE
on overflow, -EINVAL
on parsing error or non-existent property;
node “/__symbols__” does not exist; zzz, -EILSEQ
if a string is not
null-terminated within the length of the property data, -ENODATA
if a
property does not have a value, -ENOMEM
on memory allocation error.
struct of_overlay_info — Holds info for a single overlay
struct of_overlay_info { struct device_node * target; struct device_node * overlay; };
struct of_overlay — Holds a complete overlay transaction
struct of_overlay { int id; struct list_head node; int count; struct of_overlay_info * ovinfo_tab; struct of_changeset cset; };
unflatten_dt_nodes — Create expanded device tree (EDT)
int unflatten_dt_nodes ( | const void * blob, |
void * mem, | |
struct device_node * dad, | |
struct device_node ** nodepp) ; |
blob
Pointer to flattened device tree (FDT)
mem
NULL or pointer to memory chunk for memory allocations
dad
NULL or pointer to device tree node to attach new tree to
nodepp
Pointer used to return the root of the EDT
If mem
is NULL calculates required size of mem
for a subsequent call to
unflatten_dt_nodes
.
If mem
is not NULL create an expanded device tree (EDT) from the flattened
device tree (FDT) blob
. Any memory allocations to create the EDT will use
memory from mem
. The “name” and “type” fields of the nodes will be
populated so the normal device-tree walking functions can be used.
If dad
is NULL, the path of the root of the EDT will “/”.
If dad
is not NULL that is probably an error. This usage is deprecated.
The newly created tree will be grafted onto node dad
.
If dad
is not NULL and the FDT version is 0x10 or later the fullname of the
root of the EDT will be the fullname of dad
+ “/” + the name of the first
node in blob
. This is most likely not what you want, because the name of
the first node in blob
is "". The fullname of children of the root of the
EDT will include the fullname of the root node of the EDT, and thus the
fullname of dad
.
If dad
is not NULL and the FDT version is before 0x10 the fullname of the
root of the EDT will be the name of the first node in blob
. The fullname
of children of the root of the EDT will not include the fullname of dad
.
Copyright © 2016 Frank Rowand
This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details see the file COPYING in the source distribution of Linux.
Table of Contents
Functions that are EXPORT_SYMBOL(), EXPORT_SYMBOL_GPL() or EXPORT_SYMBOL_GPL_FUTURE().
count
overlays pointed at by ovinfo_tab
Private symbols used by OF support code. Functions that are not EXPORT_SYMBOL(), EXPORT_SYMBOL_GPL() or EXPORT_SYMBOL_GPL_FUTURE().
libfdt contains functions that are used by the Linux kernel and by user space program. Binary .dtb blobs created by the dtc compiler are in the Flattened Device Tree format. An FDT formatted device tree may also be found on the target system at /sys/firmware/fdt if the proper config options are enabled.