diff options
author | Tom Rini <trini@ti.com> | 2014-10-23 06:51:46 -0400 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-10-23 06:51:46 -0400 |
commit | 21109577635a871d038cfd53dd75e264d0e636bf (patch) | |
tree | 52794ad871923cc6bb1944c3f3a9dde5a5365be9 /include/fdtdec.h | |
parent | 68e80fdda1336068f40915388bbdacfd2b75233a (diff) | |
parent | 2f3760428ff3c4d5d1a087d016da5943921f0980 (diff) | |
download | u-boot-imx-21109577635a871d038cfd53dd75e264d0e636bf.zip u-boot-imx-21109577635a871d038cfd53dd75e264d0e636bf.tar.gz u-boot-imx-21109577635a871d038cfd53dd75e264d0e636bf.tar.bz2 |
Merge git://git.denx.de/u-boot-fdt
Diffstat (limited to 'include/fdtdec.h')
-rw-r--r-- | include/fdtdec.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/fdtdec.h b/include/fdtdec.h index 2590d30..99cb353 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -40,6 +40,27 @@ struct fdt_memory { fdt_addr_t end; }; +/* + * Information about a resource. start is the first address of the resource + * and end is the last address (inclusive). The length of the resource will + * be equal to: end - start + 1. + */ +struct fdt_resource { + fdt_addr_t start; + fdt_addr_t end; +}; + +/** + * Compute the size of a resource. + * + * @param res the resource to operate on + * @return the size of the resource + */ +static inline fdt_size_t fdt_resource_size(const struct fdt_resource *res) +{ + return res->end - res->start + 1; +} + /** * Compat types that we know about and for which we might have drivers. * Each is named COMPAT_<dir>_<filename> where <dir> is the directory @@ -597,4 +618,46 @@ struct fmap_entry { */ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name, struct fmap_entry *entry); + +/** + * Obtain an indexed resource from a device property. + * + * @param fdt FDT blob + * @param node node to examine + * @param property name of the property to parse + * @param index index of the resource to retrieve + * @param res returns the resource + * @return 0 if ok, negative on error + */ +int fdt_get_resource(const void *fdt, int node, const char *property, + unsigned int index, struct fdt_resource *res); + +/** + * Obtain a named resource from a device property. + * + * Look up the index of the name in a list of strings and return the resource + * at that index. + * + * @param fdt FDT blob + * @param node node to examine + * @param property name of the property to parse + * @param prop_names name of the property containing the list of names + * @param name the name of the entry to look up + * @param res returns the resource + */ +int fdt_get_named_resource(const void *fdt, int node, const char *property, + const char *prop_names, const char *name, + struct fdt_resource *res); + +/** + * Look at the reg property of a device node that represents a PCI device + * and parse the bus, device and function number from it. + * + * @param fdt FDT blob + * @param node node to examine + * @param bdf returns bus, device, function triplet + * @return 0 if ok, negative on error + */ +int fdtdec_pci_get_bdf(const void *fdt, int node, int *bdf); + #endif |