]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fdt: Enhance flashmap function to deal with region properties
authorSimon Glass <sjg@chromium.org>
Fri, 24 Oct 2014 00:58:52 +0000 (18:58 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 21 Nov 2014 03:43:17 +0000 (04:43 +0100)
Flash regions can optionally be compressed or hashed. Add the ability to
read this information from the flashmap.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Tom Rini <trini@ti.com>
include/fdtdec.h
lib/fdtdec.c

index 099930e7eefaf8e68fe09141ae2c503b732972c5..1a931e845993b73cbb19ad854473ded376f83db9 100644 (file)
@@ -602,10 +602,26 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
                         fdt_addr_t *basep, fdt_size_t *sizep);
 
+enum fmap_compress_t {
+       FMAP_COMPRESS_NONE,
+       FMAP_COMPRESS_LZO,
+};
+
+enum fmap_hash_t {
+       FMAP_HASH_NONE,
+       FMAP_HASH_SHA1,
+       FMAP_HASH_SHA256,
+};
+
 /* A flash map entry, containing an offset and length */
 struct fmap_entry {
        uint32_t offset;
        uint32_t length;
+       uint32_t used;                  /* Number of bytes used in region */
+       enum fmap_compress_t compress_algo;     /* Compression type */
+       enum fmap_hash_t hash_algo;             /* Hash algorithm */
+       const uint8_t *hash;                    /* Hash value */
+       int hash_size;                          /* Hash size */
 };
 
 /**
index 749f66ecc25f1eaf96ba348a4ded45243d2838d6..4dbd6aee853b8b03ec157d7189882e4f664074e7 100644 (file)
@@ -703,6 +703,7 @@ int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
 int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
                           struct fmap_entry *entry)
 {
+       const char *prop;
        u32 reg[2];
 
        if (fdtdec_get_int_array(blob, node, "reg", reg, 2)) {
@@ -711,6 +712,13 @@ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
        }
        entry->offset = reg[0];
        entry->length = reg[1];
+       entry->used = fdtdec_get_int(blob, node, "used", entry->length);
+       prop = fdt_getprop(blob, node, "compress", NULL);
+       entry->compress_algo = prop && !strcmp(prop, "lzo") ?
+               FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE;
+       prop = fdt_getprop(blob, node, "hash", &entry->hash_size);
+       entry->hash_algo = prop ? FMAP_HASH_SHA256 : FMAP_HASH_NONE;
+       entry->hash = (uint8_t *)prop;
 
        return 0;
 }