1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2017 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
10 #include <dm/ofnode.h>
12 enum fmap_compress_t {
23 /* A flash map entry, containing an offset and length */
27 uint32_t used; /* Number of bytes used in region */
28 enum fmap_compress_t compress_algo; /* Compression type */
29 enum fmap_hash_t hash_algo; /* Hash algorithm */
30 const uint8_t *hash; /* Hash value */
31 int hash_size; /* Hash size */
35 * Read a flash entry from the fdt
37 * @param node Reference to node to read
38 * @param entry Place to put offset and size of this node
39 * @return 0 if ok, -ve on error
41 int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry);
44 * ofnode_decode_region() - Decode a memory region from a node
46 * Look up a property in a node which contains a memory region address and
47 * size. Then return a pointer to this address.
49 * The property must hold one address with a length. This is only tested on
52 * @param node ofnode to examine
53 * @param prop_name name of property to find
54 * @param basep Returns base address of region
55 * @param size Returns size of region
56 * @return 0 if ok, -1 on error (property not found)
58 int ofnode_decode_region(ofnode node, const char *prop_name, fdt_addr_t *basep,
62 * ofnode_decode_memory_region()- Decode a named region within a memory bank
64 * This function handles selection of a memory region. The region is
65 * specified as an offset/size within a particular type of memory.
67 * The properties used are:
69 * <mem_type>-memory<suffix> for the name of the memory bank
70 * <mem_type>-offset<suffix> for the offset in that bank
72 * The property value must have an offset and a size. The function checks
73 * that the region is entirely within the memory bank.5
75 * @param node ofnode containing the properties (-1 for /config)
76 * @param mem_type Type of memory to use, which is a name, such as
77 * "u-boot" or "kernel".
78 * @param suffix String to append to the memory/offset
80 * @param basep Returns base of region
81 * @param sizep Returns size of region
82 * @return 0 if OK, -ive on error
84 int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,
85 const char *suffix, fdt_addr_t *basep,