summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-03-21 19:10:02 +0100
committerSimon Glass <sjg@chromium.org>2019-04-11 20:10:50 -0600
commitc9222a08b3f7d1b0f7a72301db99dc54e09a3d10 (patch)
tree565c097a10f12f78672725e373eb10433c067e78 /include
parent8153d53b9340e652f78efbf99979d951ba853458 (diff)
fdtdec: Implement fdtdec_add_reserved_memory()
This function can be used to add subnodes in the /reserved-memory node. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'include')
-rw-r--r--include/fdtdec.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/fdtdec.h b/include/fdtdec.h
index ba7f873b89e..9bd6a70587a 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1032,6 +1032,54 @@ int fdtdec_setup_memory_banksize(void);
int fdtdec_set_phandle(void *blob, int node, uint32_t phandle);
/**
+ * fdtdec_add_reserved_memory() - add or find a reserved-memory node
+ *
+ * If a reserved-memory node already exists for the given carveout, a phandle
+ * for that node will be returned. Otherwise a new node will be created and a
+ * phandle corresponding to it will be returned.
+ *
+ * See Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
+ * for details on how to use reserved memory regions.
+ *
+ * As an example, consider the following code snippet:
+ *
+ * struct fdt_memory fb = {
+ * .start = 0x92cb3000,
+ * .end = 0x934b2fff,
+ * };
+ * uint32_t phandle;
+ *
+ * fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, &phandle);
+ *
+ * This results in the following subnode being added to the top-level
+ * /reserved-memory node:
+ *
+ * reserved-memory {
+ * #address-cells = <0x00000002>;
+ * #size-cells = <0x00000002>;
+ * ranges;
+ *
+ * framebuffer@92cb3000 {
+ * reg = <0x00000000 0x92cb3000 0x00000000 0x00800000>;
+ * phandle = <0x0000004d>;
+ * };
+ * };
+ *
+ * If the top-level /reserved-memory node does not exist, it will be created.
+ * The phandle returned from the function call can be used to reference this
+ * reserved memory region from other nodes.
+ *
+ * @param blob FDT blob
+ * @param basename base name of the node to create
+ * @param carveout information about the carveout region
+ * @param phandlep return location for the phandle of the carveout region
+ * @return 0 on success or a negative error code on failure
+ */
+int fdtdec_add_reserved_memory(void *blob, const char *basename,
+ const struct fdt_memory *carveout,
+ uint32_t *phandlep);
+
+/**
* Set up the device tree ready for use
*/
int fdtdec_setup(void);