diff mbox

[U-Boot,v2,06/11] fdt: Enhance flashmap function to deal with region properties

Message ID 1414112337-22735-6-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Oct. 24, 2014, 12:58 a.m. UTC
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>
---

Changes in v2: None

 include/fdtdec.h | 16 ++++++++++++++++
 lib/fdtdec.c     |  8 ++++++++
 2 files changed, 24 insertions(+)

Comments

Tom Rini Oct. 24, 2014, 6:08 p.m. UTC | #1
On Thu, Oct 23, 2014 at 06:58:52PM -0600, Simon Glass wrote:

> 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>
Simon Glass Nov. 21, 2014, 3:25 a.m. UTC | #2
On 24 October 2014 19:08, Tom Rini <trini@ti.com> wrote:
> On Thu, Oct 23, 2014 at 06:58:52PM -0600, Simon Glass wrote:
>
>> 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>

Applied to u-boot-fdt.
diff mbox

Patch

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 3915fe0..9d9627f 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -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 */
 };
 
 /**
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4b5e9cd..0b16534 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -705,6 +705,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)) {
@@ -713,6 +714,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;
 }