summaryrefslogtreecommitdiff
path: root/include/dm/read.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-06-12 06:21:31 -0600
committerSimon Glass <sjg@chromium.org>2017-07-11 10:08:20 -0600
commit878d68c0c357ff62120d5783d950f34ecd1065d9 (patch)
treeb10e1929ab5e2fefa1f786db8c3ce1df089f35a4 /include/dm/read.h
parentf7d6fcf7aead384ea39bc7aba581e912c3759eaa (diff)
dm: core: Add functions to obtain node's address/size cells
The of_n_addr_cells() and of_n_size_cells() functions are useful for getting the size of addresses in a node, but in a few places U-Boot needs to obtain the actual property value for a node without walking up the stack. Add functions for this and just the existing code to use it. Add a comment to the existing ofnode functions which do not do the right thing with a flat tree. This fixes a problem reading PCI addresses. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
Diffstat (limited to 'include/dm/read.h')
-rw-r--r--include/dm/read.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/dm/read.h b/include/dm/read.h
index cea1c16a00..6dd1634675 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -231,6 +231,26 @@ int dev_read_addr_cells(struct udevice *dev);
int dev_read_size_cells(struct udevice *dev);
/**
+ * dev_read_addr_cells() - Get the address cells property in a node
+ *
+ * This function matches fdt_address_cells().
+ *
+ * @dev: devioe to check
+ * @return number of address cells this node uses
+ */
+int dev_read_simple_addr_cells(struct udevice *dev);
+
+/**
+ * dev_read_size_cells() - Get the size cells property in a node
+ *
+ * This function matches fdt_size_cells().
+ *
+ * @dev: devioe to check
+ * @return number of size cells this node uses
+ */
+int dev_read_simple_size_cells(struct udevice *dev);
+
+/**
* dev_read_phandle() - Get the phandle from a device
*
* @dev: device to check
@@ -398,11 +418,23 @@ static inline int dev_read_phandle_with_args(struct udevice *dev,
static inline int dev_read_addr_cells(struct udevice *dev)
{
+ /* NOTE: this call should walk up the parent stack */
return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
}
static inline int dev_read_size_cells(struct udevice *dev)
{
+ /* NOTE: this call should walk up the parent stack */
+ return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
+}
+
+static inline int dev_read_simple_addr_cells(struct udevice *dev)
+{
+ return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
+}
+
+static inline int dev_read_simple_size_cells(struct udevice *dev)
+{
return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
}