]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
cros_ec: Add a function for reading a flash map entry
authorSimon Glass <sjg@chromium.org>
Thu, 27 Feb 2014 20:26:01 +0000 (13:26 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 18 Mar 2014 02:05:46 +0000 (20:05 -0600)
A flash map describes the layout of flash memory in terms of offsets and
sizes for each region. Add a function to read a flash map entry from the
device tree.

Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
include/fdtdec.h
lib/fdtdec.c

index 19bab7944817bfb382a0423126f2eaf9bcde8fe7..aa695df3173d843a9964fa53029685dbbfea63ac 100644 (file)
@@ -530,4 +530,22 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
  */
 int fdtdec_decode_region(const void *blob, int node,
                const char *prop_name, void **ptrp, size_t *size);
+
+/* A flash map entry, containing an offset and length */
+struct fmap_entry {
+       uint32_t offset;
+       uint32_t length;
+};
+
+/**
+ * Read a flash entry from the fdt
+ *
+ * @param blob         FDT blob
+ * @param node         Offset of node to read
+ * @param name         Name of node being read
+ * @param entry                Place to put offset and size of this node
+ * @return 0 if ok, -ve on error
+ */
+int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
+                          struct fmap_entry *entry);
 #endif
index 1fecab3fbc3090717db105c5e7415fd235327ab4..c54d97b893998f97eb71186a5fd84a4a47a414a8 100644 (file)
@@ -617,3 +617,27 @@ int fdtdec_decode_region(const void *blob, int node,
        debug("%s: size=%zx\n", __func__, *size);
        return 0;
 }
+
+/**
+ * Read a flash entry from the fdt
+ *
+ * @param blob         FDT blob
+ * @param node         Offset of node to read
+ * @param name         Name of node being read
+ * @param entry                Place to put offset and size of this node
+ * @return 0 if ok, -ve on error
+ */
+int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
+                          struct fmap_entry *entry)
+{
+       u32 reg[2];
+
+       if (fdtdec_get_int_array(blob, node, "reg", reg, 2)) {
+               debug("Node '%s' has bad/missing 'reg' property\n", name);
+               return -FDT_ERR_NOTFOUND;
+       }
+       entry->offset = reg[0];
+       entry->length = reg[1];
+
+       return 0;
+}