2 * Copyright (c) 2017 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <dm/of_access.h>
11 #include <dm/of_extra.h>
12 #include <dm/ofnode.h>
14 int of_read_fmap_entry(ofnode node, const char *name,
15 struct fmap_entry *entry)
20 if (ofnode_read_u32_array(node, "reg", reg, 2)) {
21 debug("Node '%s' has bad/missing 'reg' property\n", name);
22 return -FDT_ERR_NOTFOUND;
24 entry->offset = reg[0];
25 entry->length = reg[1];
26 entry->used = ofnode_read_s32_default(node, "used", entry->length);
27 prop = ofnode_read_string(node, "compress");
28 entry->compress_algo = prop && !strcmp(prop, "lzo") ?
29 FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE;
30 prop = ofnode_read_string(node, "hash");
32 entry->hash_size = strlen(prop);
33 entry->hash_algo = prop ? FMAP_HASH_SHA256 : FMAP_HASH_NONE;
34 entry->hash = (uint8_t *)prop;